| 49 | } |
| 50 | |
| 51 | public static boolean evaluateCondition( |
| 52 | SimpleNode condExp, CallStack callstack, Interpreter interpreter) |
| 53 | throws EvalError |
| 54 | { |
| 55 | Object obj = condExp.eval(callstack, interpreter); |
| 56 | if(obj instanceof Primitive) { |
| 57 | if ( obj == Primitive.VOID ) |
| 58 | throw new EvalError("Condition evaluates to void type", |
| 59 | condExp, callstack ); |
| 60 | obj = ((Primitive)obj).getValue(); |
| 61 | } |
| 62 | |
| 63 | if(obj instanceof Boolean) |
| 64 | return ((Boolean)obj).booleanValue(); |
| 65 | else |
| 66 | throw new EvalError( |
| 67 | "Condition must evaluate to a Boolean or boolean.", |
| 68 | condExp, callstack ); |
| 69 | } |
| 70 | } |