org.norecess.citkit.tir.declarations
Class VariableDTIR

java.lang.Object
  extended by org.norecess.citkit.tir.declarations.VariableDTIR
All Implemented Interfaces:
IVariableDTIR, DeclarationTIR, HobbesTIR

public class VariableDTIR
extends java.lang.Object
implements IVariableDTIR

The TIR for a variable declaration. The name of the variable being declared is specified as a String. The expression used to initialize the variable is an ExpressionTIR. You must provide both of these; if your language does not require an initialization expression, then provide a default initialization expression. Optionally, you can specify a data type for the variable as a NameTTIR.

Author:
Jeremy D. Frens

Constructor Summary
VariableDTIR(IPosition position, ISymbol symbol, INameTTIR type, ExpressionTIR initialization)
          Constructs a variable declaration.
VariableDTIR(ISymbol symbol, ExpressionTIR initialization)
          Constructs a variable declaration without a known type.
VariableDTIR(ISymbol symbol, INameTTIR type, ExpressionTIR initialization)
          Basic constructor.
 
Method Summary
<T> T
accept(DeclarationTIRVisitor<T> visitor)
          Implements the visitor pattern with DeclarationTIRVisitor.
 boolean equals(java.lang.Object obj)
           
 ExpressionTIR getInititialization()
          Returns the initialization expression.
 IPosition getPosition()
          Retrieves the position of the code that generated the TIR.
 ISymbol getSymbol()
          Returns the symbol for the variable.
 INameTTIR getType()
          Returns the type of the variable.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VariableDTIR

public VariableDTIR(IPosition position,
                    ISymbol symbol,
                    INameTTIR type,
                    ExpressionTIR initialization)
Constructs a variable declaration.

Parameters:
position - the position of the variable declaration in the source code.
symbol - the name of the variable.
type - the type of the variable (could be null)
initialization - the initialization of the variable.

VariableDTIR

public VariableDTIR(ISymbol symbol,
                    INameTTIR type,
                    ExpressionTIR initialization)
Basic constructor.

Parameters:
symbol - name of the variable.
type - type of the variable (could be null)
initialization - the initialization expression.

VariableDTIR

public VariableDTIR(ISymbol symbol,
                    ExpressionTIR initialization)
Constructs a variable declaration without a known type.

Parameters:
symbol - the name of the variable.
initialization - the initialization of the variable.
Method Detail

getPosition

public IPosition getPosition()
Description copied from interface: DeclarationTIR
Retrieves the position of the code that generated the TIR.

Specified by:
getPosition in interface DeclarationTIR
Specified by:
getPosition in interface HobbesTIR
Returns:
the position of the code in the source code.

getInititialization

public ExpressionTIR getInititialization()
Returns the initialization expression.

Specified by:
getInititialization in interface IVariableDTIR
Returns:
the initialization expression.

getSymbol

public ISymbol getSymbol()
Description copied from interface: IVariableDTIR
Returns the symbol for the variable.

Specified by:
getSymbol in interface IVariableDTIR
Returns:
the symbol for the variable.

getType

public INameTTIR getType()
Returns the type of the variable.

Specified by:
getType in interface IVariableDTIR
Returns:
the type of the variable.

accept

public <T> T accept(DeclarationTIRVisitor<T> visitor)
Description copied from interface: DeclarationTIR
Implements the visitor pattern with DeclarationTIRVisitor.

Specified by:
accept in interface DeclarationTIR
Parameters:
visitor - the visitor object.
Returns:
the result of visiting the TIR with the visitor.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object