org.norecess.citkit.tir.expressions
Class OperatorETIR

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

public class OperatorETIR
extends java.lang.Object
implements IOperatorETIR

The TIR for an operator expression. This covers most types of expressions---comparative, additive, multiplicative, etc. The OperatorETIR.Operator enumerate type supplies values for the possible operators.

Author:
Jeremy D. Frens

Nested Class Summary
static class OperatorETIR.Operator
          Represents an operator like addition or multiplication.
 
Nested classes/interfaces inherited from interface org.norecess.citkit.tir.expressions.IOperatorETIR
IOperatorETIR.IOperator
 
Constructor Summary
OperatorETIR(ExpressionTIR left, IOperatorETIR.IOperator operator, ExpressionTIR right)
          Basic constructor.
OperatorETIR(IPosition position, ExpressionTIR left, IOperatorETIR.IOperator operator, ExpressionTIR right)
          Constructs an operator expression.
 
Method Summary
<T> T
accept(ExpressionTIRVisitor<T> visitor)
          Implements the visitor pattern with ExpressionTIRVisitor.
 boolean equals(java.lang.Object o)
           
 ExpressionTIR getLeft()
          Returns the left expression.
 ExpressionTIR getLeftExpression()
          Returns the left expression.
 IOperatorETIR.IOperator getOperator()
          Returns the operator.
 IPosition getPosition()
          Retrieves the position of the code that generated the TIR.
 ExpressionTIR getRight()
          Returns the right expression.
 ExpressionTIR getRightExpression()
          Returns the right expression.
 HobbesType getType()
          Currently, this method returns the type of the left subtree.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OperatorETIR

public OperatorETIR(IPosition position,
                    ExpressionTIR left,
                    IOperatorETIR.IOperator operator,
                    ExpressionTIR right)
Constructs an operator expression.

Parameters:
position - the position of the operator expression in the source code.
left - the expression to the left of the operator.
operator - the operator (see the constants of this class).
right - the expression to the right of the operator.

OperatorETIR

public OperatorETIR(ExpressionTIR left,
                    IOperatorETIR.IOperator operator,
                    ExpressionTIR right)
Basic constructor.

Parameters:
left - the left subexpression.
operator - the operator.
right - the right subexpression.
Method Detail

getLeftExpression

public ExpressionTIR getLeftExpression()
Returns the left expression.

Returns:
the left expression.

getLeft

public ExpressionTIR getLeft()
Returns the left expression.

Specified by:
getLeft in interface IOperatorETIR
Returns:
the left expression.

getOperator

public IOperatorETIR.IOperator getOperator()
Returns the operator.

Specified by:
getOperator in interface IOperatorETIR
Returns:
the operator.

getRightExpression

public ExpressionTIR getRightExpression()
Returns the right expression.

Returns:
the right expression.

getRight

public ExpressionTIR getRight()
Returns the right expression.

Specified by:
getRight in interface IOperatorETIR
Returns:
the right expression.

getType

public HobbesType getType()
Currently, this method returns the type of the left subtree. This is an error if the right subtree is more general.

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

accept

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

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 code that generated the TIR.

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