View Javadoc

1   // Invert.java, created Jul 1, 2004 11:04:17 PM by joewhaley
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   * Invert
13   * 
14   * @author John Whaley
15   * @version $Id: Invert.java 328 2004-10-16 02:45:30Z joewhaley $
16   */
17  public class Invert extends HighLevelOperation {
18      Relation r0, r1;
19  
20      /***
21       * @param r0
22       * @param r1
23       */
24      public Invert(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 net.sf.bddbddb.ir.Operation#toString()
43       */
44      public String toString() {
45          return r0.toString() + " = " + getExpressionString();
46      }
47  
48      /*
49       * (non-Javadoc)
50       * 
51       * @see net.sf.bddbddb.ir.Operation#getExpressionString()
52       */
53      public String getExpressionString() {
54          return "invert(" + r1.toString() + ")";
55      }
56  
57      /*
58       * (non-Javadoc)
59       * 
60       * @see net.sf.bddbddb.ir.Operation#getDest()
61       */
62      public Relation getRelationDest() {
63          return r0;
64      }
65  
66      /*
67       * (non-Javadoc)
68       * 
69       * @see net.sf.bddbddb.ir.Operation#getSrcs()
70       */
71      public List getSrcs() {
72          return Collections.singletonList(r1);
73      }
74  
75      /***
76       * @return Returns the source relation.
77       */
78      public Relation getSrc() {
79          return r1;
80      }
81  
82      public Operation copy() {
83          return new Invert(r0, r1);
84      }
85  
86      /*
87       * (non-Javadoc)
88       * 
89       * @see net.sf.bddbddb.ir.Operation#replaceSrc(net.sf.bddbddb.Relation,
90       *      net.sf.bddbddb.Relation)
91       */
92      public void replaceSrc(Relation r_old, Relation r_new) {
93          if (r1 == r_old) r1 = r_new;
94      }
95  
96      /*
97       * (non-Javadoc)
98       * 
99       * @see net.sf.bddbddb.ir.Operation#setRelationDest(net.sf.bddbddb.Relation)
100      */
101     public void setRelationDest(Relation r0) {
102         this.r0 = r0;
103     }
104 }