View Javadoc

1   // GenConstant.java, created Jun 29, 2004 2:57:29 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.Attribute;
9   import net.sf.bddbddb.Relation;
10  import net.sf.bddbddb.ir.Operation;
11  import net.sf.bddbddb.ir.OperationVisitor;
12  
13  /***
14   * GenConstant
15   * 
16   * @author jwhaley
17   * @version $Id: GenConstant.java 328 2004-10-16 02:45:30Z joewhaley $
18   */
19  public class GenConstant extends Operation {
20      Relation r0;
21      Attribute a;
22      long value;
23  
24      /***
25       * @param r0
26       * @param a
27       * @param value
28       */
29      public GenConstant(Relation r0, Attribute a, long value) {
30          super();
31          this.r0 = r0;
32          this.a = a;
33          this.value = value;
34      }
35  
36      /*
37       * (non-Javadoc)
38       * 
39       * @see java.lang.Object#toString()
40       */
41      public String toString() {
42          return r0.toString() + " = " + getExpressionString();
43      }
44  
45      /*
46       * (non-Javadoc)
47       * 
48       * @see net.sf.bddbddb.ir.Operation#getExpressionString()
49       */
50      public String getExpressionString() {
51          return "const(" + a.toString() + "=" + value + ")";
52      }
53  
54      /*
55       * (non-Javadoc)
56       * 
57       * @see net.sf.bddbddb.ir.Operation#visit(net.sf.bddbddb.ir.HighLevelOperationVisitor)
58       */
59      public Object visit(OperationVisitor i) {
60          return i.visit(this);
61      }
62  
63      /*
64       * (non-Javadoc)
65       * 
66       * @see net.sf.bddbddb.ir.Operation#getDest()
67       */
68      public Relation getRelationDest() {
69          return r0;
70      }
71  
72      /*
73       * (non-Javadoc)
74       * 
75       * @see net.sf.bddbddb.ir.Operation#getSrcs()
76       */
77      public List getSrcs() {
78          return Collections.EMPTY_LIST;
79      }
80  
81      /***
82       * @return  the value of this constant
83       */
84      public long getValue() {
85          return value;
86      }
87  
88      /***
89       * @return  the attribute of this constant
90       */
91      public Attribute getAttribute() {
92          return a;
93      }
94  
95      /* (non-Javadoc)
96       * @see net.sf.bddbddb.ir.Operation#copy()
97       */
98      public Operation copy() {
99          return new GenConstant(r0, a, value);
100     }
101 
102     /*
103      * (non-Javadoc)
104      * 
105      * @see net.sf.bddbddb.ir.Operation#replaceSrc(net.sf.bddbddb.Relation,
106      *      net.sf.bddbddb.Relation)
107      */
108     public void replaceSrc(Relation r_old, Relation r_new) {
109     }
110 
111     /*
112      * (non-Javadoc)
113      * 
114      * @see net.sf.bddbddb.ir.Operation#setRelationDest(net.sf.bddbddb.Relation)
115      */
116     public void setRelationDest(Relation r0) {
117         this.r0 = r0;
118     }
119 }