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.rule.conditions;
12:
13: import de.uka.ilkd.key.java.Services;
14: import de.uka.ilkd.key.logic.Term;
15: import de.uka.ilkd.key.logic.op.ProgramMethod;
16: import de.uka.ilkd.key.logic.op.SVSubstitute;
17: import de.uka.ilkd.key.logic.op.SchemaVariable;
18: import de.uka.ilkd.key.rule.VariableConditionAdapter;
19: import de.uka.ilkd.key.rule.inst.SVInstantiations;
20:
21: public class TestQuery extends VariableConditionAdapter {
22:
23: private SchemaVariable sv;
24:
25: public TestQuery(SchemaVariable sv) {
26: this .sv = sv;
27: }
28:
29: public SchemaVariable schemaVariable() {
30: return sv;
31: }
32:
33: public boolean check(SchemaVariable var,
34: SVSubstitute instCandidate, SVInstantiations instMap,
35: Services services) {
36: if (var != schemaVariable()) {
37: return true; // not responsible
38: }
39: if (!(instCandidate instanceof Term)) {
40: return false;
41: }
42: return checkTerm((Term) instCandidate);
43: }
44:
45: private boolean checkTerm(Term t) {
46: return t.op() instanceof ProgramMethod;
47: }
48:
49: public String toString() {
50: return "\\isQuery(" + schemaVariable() + ")";
51: }
52:
53: public boolean equals(Object o) {
54: if (!(o instanceof TestQuery)) {
55: return false;
56: }
57: TestQuery tq = (TestQuery) o;
58: return (tq.schemaVariable() == schemaVariable());
59: }
60:
61: public int hashCode() {
62: int result = 17;
63: result = 37 * result + schemaVariable().hashCode();
64: return result;
65: }
66:
67: }
|