public class If extends PostfixMathCommand implements CallbackEvaluationI
This function performs lazy evaluation so that only posExpr or negExpr will be evaluated. For Complex numbers only the real part is used.
An alternate form if(condExpr, posExpr, negExpr, zeroExpr) is also available. Note most computations are carried out over floating point doubles so testing for zero can be dangerous.
Note most computations are carried out over floating point doubles so testing for zero can be dangerous.
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
falseValue |
curNumberOfParameters, name, NaN, numberOfParameters
Constructor and Description |
---|
If() |
If(java.lang.Object falseValue)
If this constructor is used then a two argument version can be used
if(condExpr, posExpr)
is also available. |
Modifier and Type | Method and Description |
---|---|
boolean |
checkNumberOfParameters(int n)
Checks the number of parameters of the call.
|
java.lang.Object |
evaluate(Node node,
Evaluator pv)
Performs some special evaluation on the node.
|
java.lang.Object |
getFalseValue()
The value returned for false values in the two argument version.
|
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, getName, getNumberOfParameters, run, setCurNumberOfParameters, setName, toString, toString
public If()
public If(java.lang.Object falseValue)
if(condExpr, posExpr)
is also available.falseValue
- the value to return when condExpr is false in the two argument versionpublic boolean checkNumberOfParameters(int n)
checkNumberOfParameters
in interface PostfixMathCommandI
checkNumberOfParameters
in class PostfixMathCommand
n
- number of parameters function will be called with.public java.lang.Object evaluate(Node node, Evaluator pv) throws EvaluationException
CallbackEvaluationI
pv.eval(node.jjtGetChild(i))for each child. The SymbolTable is not passed as an argument. This is because it is better practice to get and set variable values by using node.getVar().setValue() rather that through the SymbolTable with requires a hashtable lookup.
evaluate
in interface CallbackEvaluationI
node
- The current nodepv
- The visitor, can be used evaluate the childrenEvaluationException
- if the calculation cannot be performedEvaluator
public java.lang.Object getFalseValue()
Copyright © 2018 Singular Systems http://www.singularsys.com/jep