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: package de.uka.ilkd.key.unittest.simplify.ast;
09:
10: import de.uka.ilkd.key.util.*;
11:
12: public class Term {
13:
14: protected ExtList subs;
15: private String op;
16:
17: public Term(String op, ExtList subs) {
18: this .subs = subs;
19: this .op = op;
20: }
21:
22: public Term(String op) {
23: this (op, new ExtList());
24: }
25:
26: public int arity() {
27: return subs.size();
28: }
29:
30: public Term sub(int i) {
31: return (Term) subs.get(i);
32: }
33:
34: public void setSub(int i, Term t) {
35: // subs.remove(i);
36: subs.add(i, t);
37: }
38:
39: public void addSub(Term t) {
40: subs.add(t);
41: }
42:
43: public void remove(Term t) {
44: subs.remove(t);
45: }
46:
47: public String toSimplify() {
48: String result = "(" + op;
49: for (int i = 0; i < arity(); i++) {
50: result += " " + sub(i).toSimplify();
51: }
52: result += ")";
53: return result;
54: }
55:
56: public String toString() {
57: return toSimplify();
58: }
59:
60: public String op() {
61: return op;
62: }
63:
64: }
|