edu.cmu.cs.crystal.tac.model
Class SourceVariable

java.lang.Object
  extended by edu.cmu.cs.crystal.tac.model.Variable
      extended by edu.cmu.cs.crystal.tac.model.SourceVariable

public class SourceVariable
extends Variable

A source variable is a variable in three address code that actually existed in the original Java source code. Most of the variables that appear in three address code are temporary variables that exist solely for the purpose of storing intermediate sub-expression values. However, variables that originally existed in source code are translated as variables of this type. For example, in the following excerpt:
int a = 4+5+3+6+9+2+9;
each of the additions on the right-hand side will be turned into a temporary variable assignment, but the variable 'a' will exist as an instance of this class.

Author:
Kevin Bierhoff

Constructor Summary
SourceVariable(String id, IVariableBinding binding, boolean isLocallyDeclared)
          Creates a new source variable object for a local with the given name and binding.
 
Method Summary
<T> T
dispatch(IVariableVisitor<T> visitor)
           
 boolean equals(Object obj)
           
 IVariableBinding getBinding()
          We can get the original java source binding.
 int hashCode()
           
 boolean isCapturedFromOuterScope()
          Indicates whether this source variable is captured from an outer scope.
 ITypeBinding resolveType()
          null or the type binding of this variable.
 String toString()
           
 
Methods inherited from class edu.cmu.cs.crystal.tac.model.Variable
getSourceString, isUnqualifiedSuper, isUnqualifiedThis
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SourceVariable

public SourceVariable(String id,
                      IVariableBinding binding,
                      boolean isLocallyDeclared)
Creates a new source variable object for a local with the given name and binding.

Parameters:
id -
binding -
isLocallyDeclared - pass true for locally declared variables, including formal parameters, false for variables captured from an outer scope.
Method Detail

getBinding

public IVariableBinding getBinding()
We can get the original java source binding. Note that this method returns an type from the Java AST, not from 3 address code.

Returns:
the binding

isCapturedFromOuterScope

public boolean isCapturedFromOuterScope()
Indicates whether this source variable is captured from an outer scope.

Returns:
true if this source variable is captured from an outer scope, false otherwise.

dispatch

public <T> T dispatch(IVariableVisitor<T> visitor)
Specified by:
dispatch in class Variable

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

resolveType

public ITypeBinding resolveType()
Description copied from class: Variable
null or the type binding of this variable.

Specified by:
resolveType in class Variable
See Also:
Expression.resolveTypeBinding()