01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.strategy.feature;
12:
13: import de.uka.ilkd.key.logic.PosInOccurrence;
14: import de.uka.ilkd.key.logic.Term;
15: import de.uka.ilkd.key.proof.Goal;
16: import de.uka.ilkd.key.rule.RuleApp;
17: import de.uka.ilkd.key.strategy.RuleAppCost;
18: import de.uka.ilkd.key.strategy.termProjection.ProjectionToTerm;
19: import de.uka.ilkd.key.strategy.termProjection.TermBuffer;
20:
21: /**
22: * Feature for locally binding a <code>TermBuffer</code> to a certain value,
23: * namely to a term that is generated by a <code>ProjectionToTerm</code>.
24: * This is mostly useful to make feature terms more readable, and to avoid
25: * repeated evaluation of projections.
26: */
27: public class LetFeature implements Feature {
28:
29: private final TermBuffer var;
30: private final ProjectionToTerm value;
31: private final Feature body;
32:
33: public static Feature create(TermBuffer var,
34: ProjectionToTerm value, Feature body) {
35: return new LetFeature(var, value, body);
36: }
37:
38: private LetFeature(TermBuffer var, ProjectionToTerm value,
39: Feature body) {
40: this .var = var;
41: this .value = value;
42: this .body = body;
43: }
44:
45: public RuleAppCost compute(RuleApp app, PosInOccurrence pos,
46: Goal goal) {
47: final Term outerVarContent = var.getContent();
48:
49: var.setContent(value.toTerm(app, pos, goal));
50: final RuleAppCost res = body.compute(app, pos, goal);
51:
52: var.setContent(outerVarContent);
53: return res;
54: }
55:
56: }
|