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.
This function implements the SpecialEvaluationI interface so that it handles setting the value of a variable.
curNumberOfParameters, numberOfParameters| Constructor and Description |
|---|
If() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkNumberOfParameters(int n)
Checks the number of parameters of the call.
|
Object |
evaluate(Node node,
EvaluatorI pv)
Performs some special evaluation on the node.
|
checkStack, getNumberOfParameters, run, setCurNumberOfParameterspublic boolean checkNumberOfParameters(int n)
checkNumberOfParameters in interface PostfixMathCommandIcheckNumberOfParameters in class PostfixMathCommandn - number of parameters function will be called with.public Object evaluate(Node node, EvaluatorI pv) throws ParseException
CallbackEvaluationIpv.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 CallbackEvaluationInode - The current nodepv - The visitor, can be used evaluate the childrenParseExceptionCopyright © 2018. All rights reserved.