org.millscript.millscript.expr
Class ArithExpr
java.lang.Object
org.millscript.millscript.expr.Expr<A>
org.millscript.millscript.expr.BinaryOpExpr<BinaryOpAction>
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. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 fora - the left hand side expression, which should return a single
resultb - the right hand side expression, which should return a single
result
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 fora - the left hand side expression, which should return a single
resultb - 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 expressionb - 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.