org.millscript.millscript.expr
Class ArithExpr

java.lang.Object
  extended by org.millscript.millscript.expr.Expr<A>
      extended by org.millscript.millscript.expr.BinaryOpExpr<BinaryOpAction>
          extended by org.millscript.millscript.expr.ArithExpr
All Implemented Interfaces:
OneResult

public final class ArithExpr
extends BinaryOpExpr<BinaryOpAction>

This class implements an arithmetic expression. This expression always returns one result.

See Also:
IntegerTools

Constructor Summary
ArithExpr(java.lang.String s, Expr<?> a, Expr<?> b)
          Creates a new arithmetic expression for the specified symbol and left and right hand side expressions.
 
Method Summary
static Expr make(java.lang.String s, Expr a, Expr b)
          Returns an expression for the specified arithmetic expression.
 BinaryOpAction newAction(Action a, Action b)
          Compiles this expression into an action.
 
Methods inherited from class org.millscript.millscript.expr.BinaryOpExpr
compileIt, resolve
 
Methods inherited from class org.millscript.millscript.expr.Expr
arity, compile, isIntegerExpr, resolveList, setLineNumber, setOrigin, show, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArithExpr

public ArithExpr(java.lang.String s,
                 Expr<?> a,
                 Expr<?> b)
Creates a new arithmetic expression for the specified symbol and left and right hand side expressions.

Parameters:
s - the arithmetic symbol to make an expression for
a - the left hand side expression, which should return a single result
b - the right hand side expression, which should return a single result
Method Detail

make

public static Expr make(java.lang.String s,
                        Expr a,
                        Expr b)
Returns an expression for the specified arithmetic expression. The arithmetic expression is composed of a symbol and left and right hand side expressions. This method provides some compile-time optimisation, as it avoids creating additional unnecessary objects in the expression tree. If the specified left and right hand side expressions are for constant integers, the specified operation is performed and a new constant expression returned.

Parameters:
s - the arithmetic symbol to make an expression for
a - the left hand side expression, which should return a single result
b - the right hand side expression, which should return a single result
Returns:
a ConstantExpr if the left and right hand side are constant integers, otherwise an anonymous Action for the specified symbol

newAction

public BinaryOpAction newAction(Action a,
                                Action b)
Description copied from class: BinaryOpExpr
Compiles this expression into an action. This is method performs the expression specific compilation, but does not need to handle the left and right hand side expression compilation.

Specified by:
newAction in class BinaryOpExpr<BinaryOpAction>
Parameters:
a - the compiled left hand side expression
b - the compiled right hand side expression
Returns:
the Action for this expression
See Also:
BinaryOpExpr.newAction(org.millscript.millscript.action.Action, org.millscript.millscript.action.Action)


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.