View Javadoc

1   // Copy.java, created Jul 2, 2004 12:28:31 PM 2004 by jwhaley
2   // Copyright (C) 2004 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
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       * (non-Javadoc)
32       * 
33       * @see net.sf.bddbddb.ir.Operation#visit(net.sf.bddbddb.ir.HighLevelOperationVisitor)
34       */
35      public Object visit(HighLevelOperationVisitor i) {
36          return i.visit(this);
37      }
38  
39      /*
40       * (non-Javadoc)
41       * 
42       * @see java.lang.Object#toString()
43       */
44      public String toString() {
45          return (TRACE_VERBOSE ? r0.verboseToString() : r0.toString()) + " = " + getExpressionString();
46      }
47  
48      /* (non-Javadoc)
49       * @see net.sf.bddbddb.ir.Operation#getExpressionString()
50       */
51      public String getExpressionString() {
52          return "copy(" + (TRACE_VERBOSE ? r1.verboseToString() : r1.toString()) + ")";
53      }
54  
55      /*
56       * (non-Javadoc)
57       * 
58       * @see net.sf.bddbddb.ir.Operation#getDest()
59       */
60      public Relation getRelationDest() {
61          return r0;
62      }
63  
64      /*
65       * (non-Javadoc)
66       * 
67       * @see net.sf.bddbddb.ir.Operation#getSrcs()
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       * (non-Javadoc)
86       * 
87       * @see net.sf.bddbddb.ir.Operation#replaceSrc(net.sf.bddbddb.Relation,
88       *      net.sf.bddbddb.Relation)
89       */
90      public void replaceSrc(Relation r_old, Relation r_new) {
91            if (r1 == r_old) r1 = r_new; 
92      }
93  
94      /*
95       * (non-Javadoc)
96       * 
97       * @see net.sf.bddbddb.ir.Operation#setRelationDest(net.sf.bddbddb.Relation)
98       */
99      public void setRelationDest(Relation r0) {
100         this.r0 = r0;
101     }
102 }