View Javadoc

1   package joeq.Compiler.Analysis.IPSSA;
2   import joeq.Class.jq_Method;
3   import joeq.Compiler.Quad.Quad;
4   
5   /***
6    * An SSABinding is an assignment of an SSAValue to to an SSADefinition.
7    * @see SSADefinition
8    * @see joeq.Compiler.Analysis.IPSSA.SSAValue
9    * @see joeq.Compiler.Analysis.IPSSA.SSADefinition
10   * @version $Id: SSABinding.java 1709 2004-04-28 08:46:37Z joewhaley $
11   * */
12  public class SSABinding {
13      protected Quad             _quad;
14      protected SSADefinition    _destination;
15      protected SSAValue            _value;
16      
17      public SSABinding(Quad quad, SSADefinition def, SSAValue value) {
18          this._quad          = quad;
19          this._destination     = def;
20          this._value         = value;
21          
22          value.setDestination(def);
23      }
24      
25      public SSABinding(Quad quad, SSALocation loc, SSAValue value, jq_Method method) {
26          this._quad = quad;        
27          this._value = value;
28          
29          SSADefinition def = SSAProcInfo.Helper.create_ssa_definition(loc, quad, method);
30          this._destination = def;
31          
32          if(value != null){
33              value.setDestination(def);
34          }
35      }
36      
37      public void setValue(SSAValue value){
38          this._value = value;
39          _value.setDestination(_destination);
40      }
41      
42      /*** Tests whether the binding has been completed by filling out it RHS */
43      public boolean isComplete(){
44          return _value != null;
45      }
46      
47      public boolean isValid(){
48          return 
49              (_value == null || _destination == _value.getDestination()) &&
50              (_quad == _destination.getQuad());
51      }
52      
53      public SSADefinition getDestination() {return _destination;}
54      public SSAValue getValue() {return _value;}
55      public Quad getQuad() {return _destination.getQuad();}
56  
57      public void accept(SSABindingVisitor vis) {
58          vis.visit(this);        
59      }
60      
61      public String toString(){
62          return _destination.toString() + " = " + (_value == null ? "<incomplete>" : _value.toString());
63      }
64  }