1
2
3
4 package net.sf.bddbddb.ir.highlevel;
5
6 import java.util.Collections;
7 import java.util.List;
8 import net.sf.bddbddb.Relation;
9 import net.sf.bddbddb.ir.Operation;
10
11 /***
12 * Copy
13 *
14 * @author jwhaley
15 * @version $Id: Copy.java 445 2005-02-21 02:32:50Z cs343 $
16 */
17 public class Copy extends HighLevelOperation {
18 Relation r0, r1;
19
20 /***
21 * @param r0
22 * @param r1
23 */
24 public Copy(Relation r0, Relation r1) {
25 super();
26 this.r0 = r0;
27 this.r1 = r1;
28 }
29
30
31
32
33
34
35 public Object visit(HighLevelOperationVisitor i) {
36 return i.visit(this);
37 }
38
39
40
41
42
43
44 public String toString() {
45 return (TRACE_VERBOSE ? r0.verboseToString() : r0.toString()) + " = " + getExpressionString();
46 }
47
48
49
50
51 public String getExpressionString() {
52 return "copy(" + (TRACE_VERBOSE ? r1.verboseToString() : r1.toString()) + ")";
53 }
54
55
56
57
58
59
60 public Relation getRelationDest() {
61 return r0;
62 }
63
64
65
66
67
68
69 public List getSrcs() {
70 return Collections.singletonList(r1);
71 }
72
73 /***
74 * @return Returns the source relation.
75 */
76 public Relation getSrc() {
77 return r1;
78 }
79
80 public Operation copy() {
81 return new Copy(r0, r1);
82 }
83
84
85
86
87
88
89
90 public void replaceSrc(Relation r_old, Relation r_new) {
91 if (r1 == r_old) r1 = r_new;
92 }
93
94
95
96
97
98
99 public void setRelationDest(Relation r0) {
100 this.r0 = r0;
101 }
102 }