public class Operation extends Object implements Expression
| Constructor and Description |
|---|
Operation(String operation,
Expression left,
Expression right)
Creates a new operation, with the given operator and the left and right expression.
|
| Modifier and Type | Method and Description |
|---|---|
Expression |
eval(Scope scope,
Generator gen)
If possible the expression is evaluated and a simplified expression is returned.
|
protected double |
evalOperation(Generator gen,
double lVal,
double rVal) |
Expression |
getLeft()
Returns the left side of the operation.
|
String |
getOperation()
Returns the operator of this operation.
|
Expression |
getRight()
Returns the right side of the operation.
|
boolean |
isConstant()
Determines if this expression is constant or if it depends on variables.
|
boolean |
isProtect()
Determines if the operation is guarded by braces and most not be re-ordered by operator precedence.
|
void |
protect()
Marks that this expression is guarded by braces so that operator precedence does not matter.
|
void |
setRight(Expression right)
Sets the right side of the operation.
|
String |
toString() |
public Operation(String operation, Expression left, Expression right)
operation - the operation to useleft - the expression on the left sideright - the expression on the right sidepublic void protect()
public String getOperation()
public boolean isProtect()
public Expression getLeft()
public Expression getRight()
public void setRight(Expression right)
right - the new right side of the operationpublic boolean isConstant()
ExpressionisConstant in interface Expressionpublic Expression eval(Scope scope, Generator gen)
Expressioneval in interface Expressionscope - the scope used to resolve variables.gen - the generator used to evaluate functionsprotected double evalOperation(Generator gen, double lVal, double rVal)
Copyright © 2016. All rights reserved.