public boolean evaluateNodeLogical(final ASTNode node) { if (node instanceof FunctionNode) { return evaluateFunctionLogical((FunctionNode) node); } if (node instanceof SymbolNode) { BooleanVariable v = fBooleanVariables.get(node.toString()); if (v != null) { return v.getValue(); } Boolean boole = SYMBOL_BOOLEAN_MAP.get(node.toString()); if (boole != null) { return boole.booleanValue(); } } throw new ArithmeticMathException( "EvalDouble#evaluateNodeLogical(ASTNode) not possible for: " + node.toString()); }
throw new ArithmeticMathException("EvalDouble#evaluate(ASTNode) not possible for: " + node.toString());
@Override public double evaluate(DoubleEvaluator engine, FunctionNode function) { if (function.size() != 3) { throw new ArithmeticMathException( "SetFunction#evaluate(DoubleEvaluator,FunctionNode) needs 2 arguments: " + function.toString()); } if (!(function.getNode(1) instanceof SymbolNode)) { throw new ArithmeticMathException( "SetFunction#evaluate(DoubleEvaluator,FunctionNode) symbol required on the left hand side: " + function.toString()); } String variableName = ((SymbolNode) function.getNode(1)).getString(); double result = engine.evaluateNode(function.getNode(2)); IDoubleValue dv = engine.getVariable(variableName); if (dv == null) { dv = new DoubleVariable(result); } else { dv.setValue(result); } engine.defineVariable(variableName, dv); return result; } }
public boolean evaluateFunctionLogical(final FunctionNode functionNode) { if (functionNode.size() > 0 && functionNode.getNode(0) instanceof SymbolNode) { String symbol = functionNode.getNode(0).toString(); if (functionNode.size() == 2) { Object obj = FUNCTION_BOOLEAN_MAP.get(symbol); if (obj instanceof IBooleanBoolean1Function) { return ((IBooleanBoolean1Function) obj).evaluate(evaluateNodeLogical(functionNode.getNode(1))); } } else if (functionNode.size() == 3) { Object obj = FUNCTION_BOOLEAN_MAP.get(symbol); if (obj instanceof IBooleanDouble2Function) { return ((IBooleanDouble2Function) obj).evaluate(evaluateNode(functionNode.getNode(1)), evaluateNode(functionNode.getNode(2))); } else if (obj instanceof IBooleanBoolean2Function) { return ((IBooleanBoolean2Function) obj).evaluate(evaluateNodeLogical(functionNode.getNode(1)), evaluateNodeLogical(functionNode.getNode(2))); } // } else { // Object obj = FUNCTION_BOOLEAN_MAP.get(symbol); // if (obj instanceof IBooleanDoubleFunction) { // return ((IBooleanDoubleFunction) obj).evaluate(this, // functionNode); // } } } throw new ArithmeticMathException( "EvalDouble#evaluateFunctionLogical(FunctionNode) not possible for: " + functionNode.toString()); }
throw new ArithmeticMathException( "EvalDouble#evaluateFunction(FunctionNode) not possible for: " + functionNode.toString());
throw new ArithmeticMathException("EvalDouble#evaluate(ASTNode) not possible for: " + node.toString());