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.
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.
|
getNumberOfParameters, run, setCurNumberOfParameters
public boolean checkNumberOfParameters(int n)
checkNumberOfParameters
in interface PostfixMathCommandI
checkNumberOfParameters
in class PostfixMathCommand
n
- number of parameters function will be called with.public Object evaluate(Node node, EvaluatorI pv) throws ParseException
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 childrenParseException
Jas4pp 1.5 © Java Analysis Studio for Particle Physics