org.norecess.citkit.tir.expressions
Class VariableETIR

java.lang.Object
  extended by org.norecess.citkit.tir.expressions.VariableETIR
All Implemented Interfaces:
IVariableETIR, ExpressionTIR, HobbesTIR

public class VariableETIR
extends java.lang.Object
implements IVariableETIR

The TIR for a variable (i.e., l-value) expression. There are three possible l-value expressions:

L-value expressions are plugged into an ExpressionTIR with this class.

An interpreter or compiler using ExpressionTIRVisitor to process an ExpressionTIR will also need to implement LValueTIRVisitor to properly process l-value expressions.

Author:
Jeremy D. Frens

Constructor Summary
VariableETIR(IPosition position, LValueTIR lvalue)
          Constructs a variable expression.
VariableETIR(IPosition position, LValueTIR lvalue, HobbesType type)
          Constructs a variable expression.
VariableETIR(LValueTIR lvalue)
          Basic constructor.
VariableETIR(LValueTIR lvalue, HobbesType type)
          Basic constructor.
 
Method Summary
<T> T
accept(ExpressionTIRVisitor<T> visitor)
          Implements the visitor pattern.
 boolean equals(java.lang.Object o)
           
 LValueTIR getLValue()
          Returns the l-value of this variable expression.
 IPosition getPosition()
          Retrieves the position of the text that generated the TIR.
 HobbesType getType()
          Retrieves the type of the expression.
 int hashCode()
           
 void setType(HobbesType type)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VariableETIR

public VariableETIR(IPosition position,
                    LValueTIR lvalue)
Constructs a variable expression.

Parameters:
position - the position of the variable expression in the source code.
lvalue - the l-value expression.

VariableETIR

public VariableETIR(IPosition position,
                    LValueTIR lvalue,
                    HobbesType type)
Constructs a variable expression.

Parameters:
position - the position of the variable expression in the source code.
lvalue - the l-value expression.
type - the type of the expression.

VariableETIR

public VariableETIR(LValueTIR lvalue)
Basic constructor.

Parameters:
lvalue - the l-value expression.

VariableETIR

public VariableETIR(LValueTIR lvalue,
                    HobbesType type)
Basic constructor.

Parameters:
lvalue - the l-value expression.
type - the type of the expression.
Method Detail

getLValue

public LValueTIR getLValue()
Returns the l-value of this variable expression.

Specified by:
getLValue in interface IVariableETIR
Returns:
the l-value of this variable expression.

getType

public HobbesType getType()
Description copied from interface: ExpressionTIR
Retrieves the type of the expression.

Specified by:
getType in interface ExpressionTIR
Returns:
the type of the code.

setType

public void setType(HobbesType type)

accept

public <T> T accept(ExpressionTIRVisitor<T> visitor)
Implements the visitor pattern. Calls ExpressionTIRVisitor.visitVariableETIR(IVariableETIR).

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

equals

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

hashCode

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

toString

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

getPosition

public IPosition getPosition()
Retrieves the position of the text that generated the TIR.

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