1
2
3
4 package net.sf.bddbddb.ir;
5
6 import java.util.Iterator;
7 import java.util.List;
8 import jwutil.io.SystemProperties;
9 import net.sf.bddbddb.Attribute;
10 import net.sf.bddbddb.BDDRelation;
11 import net.sf.bddbddb.IterationElement;
12 import net.sf.bddbddb.Relation;
13 import net.sf.javabdd.BDDDomain;
14
15 /***
16 * Operation
17 *
18 * @author jwhaley
19 * @version $Id: Operation.java 522 2005-04-29 02:34:44Z joewhaley $
20 */
21 public abstract class Operation implements IterationElement {
22 static int opNumber = 0;
23
24 /***
25 * @return the number of operations generated so far
26 */
27 public static int getNumberOfOperations() {
28 return opNumber + 1;
29 }
30
31 /***
32 * Boolean for verbose tracing of operations
33 */
34 public static boolean TRACE_VERBOSE = SystemProperties.getProperty("traceinterpreter", "no").equals("verbose");
35 /***
36 * Unique ID number for this operation.
37 */
38 public final int id;
39
40 /***
41 *
42 */
43 public Operation() {
44 id = ++opNumber;
45 }
46
47 /***
48 * @param i
49 * @return the result of the visit
50 */
51 public abstract Object visit(OperationVisitor i);
52
53
54
55
56
57
58 public abstract String toString();
59
60 /***
61 * @return the destination relation of this operation, or null
62 */
63 public abstract Relation getRelationDest();
64
65 /***
66 * @param r0
67 */
68 public abstract void setRelationDest(Relation r0);
69
70 /***
71 * @return the source relation of this operation
72 */
73 public abstract List
74
75 /***
76 * @param r_old
77 * @param r_new
78 */
79 public abstract void replaceSrc(Relation r_old, Relation r_new);
80
81 /***
82 * @return the expression in string form
83 */
84 public abstract String getExpressionString();
85
86 public abstract Operation copy();
87
88 public static String getRenames(BDDRelation r1, BDDRelation r2) {
89 StringBuffer sb = new StringBuffer();
90 for (Iterator i = r1.getAttributes().iterator(); i.hasNext();) {
91 Attribute a = (Attribute) i.next();
92 BDDDomain d1 = r1.getBDDDomain(a);
93 BDDDomain d2 = r2.getBDDDomain(a);
94 if (d2 == null || d1 == d2) continue;
95 sb.append("," + d1 + "->" + d2);
96 }
97 return sb.toString();
98 }
99 }