public Object eval( CallStack callstack, Interpreter interpreter) throws EvalError { if ( isDefault ) return null; // should probably error SimpleNode label = ((SimpleNode)jjtGetChild(0)); return label.eval( callstack, interpreter ); } }
public Object eval( CallStack callstack, Interpreter interpreter) throws EvalError { SimpleNode cond = (SimpleNode)jjtGetChild(0), evalTrue = (SimpleNode)jjtGetChild(1), evalFalse = (SimpleNode)jjtGetChild(2); if ( BSHIfStatement.evaluateCondition( cond, callstack, interpreter ) ) return evalTrue.eval( callstack, interpreter ); else return evalFalse.eval( callstack, interpreter ); }
public Object eval(CallStack callstack, Interpreter interpreter) throws EvalError { int n = jjtGetNumChildren(); for(int i=0; i<n; i++) { SimpleNode node = ((SimpleNode)jjtGetChild(i)); node.eval(callstack, interpreter); } return Primitive.VOID; } }
public Object eval( CallStack callstack, Interpreter interpreter) throws EvalError { for (int i=0; i < jjtGetNumChildren(); i++) ((SimpleNode) jjtGetChild(i)).eval(callstack, interpreter); return Primitive.VOID; }
public static boolean evaluateCondition( SimpleNode condExp, CallStack callstack, Interpreter interpreter) throws EvalError { Object obj = condExp.eval(callstack, interpreter); if ( obj == Primitive.VOID ) throw new EvalError("Condition evaluates to void type", condExp, callstack ); obj = Primitive.unwrap(obj); if( obj instanceof Boolean ) return ((Boolean) obj).booleanValue(); else throw new EvalError( "Condition must evaluate to a Boolean or boolean.", condExp, callstack ); } }
public Object eval(CallStack callstack, Interpreter interpreter) throws EvalError { Object ret = null; if( evaluateCondition( (SimpleNode)jjtGetChild(0), callstack, interpreter ) ) ret = ((SimpleNode)jjtGetChild(1)).eval(callstack, interpreter); else if(jjtGetNumChildren() > 2) ret = ((SimpleNode)jjtGetChild(2)).eval(callstack, interpreter); if(ret instanceof ReturnControl) return ret; else return Primitive.VOID; }
public Object eval( CallStack callstack, Interpreter interpreter) throws EvalError { Object obj = ((SimpleNode) jjtGetChild(0)).eval(callstack, interpreter); if(!(obj instanceof Throwable)) throw new EvalError("Expression in 'throw' must be Throwable type", this, callstack ); // wrap the exception in a TargetException to propagate it up throw new TargetError( (Throwable) obj, this, callstack ); } }
public Object eval(CallStack callstack, Interpreter interpreter) throws EvalError { Object value; if(jjtGetNumChildren() > 0) value = ((SimpleNode)jjtGetChild(0)).eval(callstack, interpreter); else value = Primitive.VOID; return new ReturnControl( kind, value, this ); } }
syncValue = exp.eval(callstack, interpreter);
/** @return the result of the cast. */ public Object eval( CallStack callstack, Interpreter interpreter ) throws EvalError { Class toType = ((BSHType)jjtGetChild(0)).getType( callstack, interpreter ); SimpleNode expression = (SimpleNode)jjtGetChild(1); // evaluate the expression Object fromValue = expression.eval(callstack, interpreter); // TODO: need to add isJavaCastable() test for strictJava // (as opposed to isJavaAssignable()) try { return Types.castObject( fromValue, toType, Types.CAST ); } catch ( UtilEvalError e ) { throw e.toEvalError( this, callstack ); } }
/** */ static int getIndexAux(Object obj, int idx, CallStack callstack, Interpreter interpreter, SimpleNode callerInfo ) throws EvalError { int index; try { Object indexVal = ((SimpleNode) callerInfo.jjtGetChild(idx)).eval( callstack, interpreter ); if ( !(indexVal instanceof Primitive) ) indexVal = Types.castObject( indexVal, Integer.TYPE, Types.ASSIGNMENT ); index = ((Primitive) indexVal).intValue(); } catch( UtilEvalError e ) { Interpreter.debug("doIndex: "+e); throw e.toEvalError( "Arrays may only be indexed by integer types.", callerInfo, callstack ); } return index; }
continue; Object ret = body.eval(callstack, interpreter); if (ret instanceof ReturnControl) { switch (((ReturnControl) ret).kind) {
public Object eval( CallStack callstack, Interpreter interpreter) throws EvalError { SimpleNode node = (SimpleNode)jjtGetChild(0); // If this is a unary increment of decrement (either pre or postfix) // then we need an LHS to which to assign the result. Otherwise // just do the unary operation for the value. try { if ( kind == INCR || kind == DECR ) { LHS lhs = ((BSHPrimaryExpression)node).toLHS( callstack, interpreter ); return lhsUnaryOperation( lhs, interpreter.getStrictJava() ); } else return unaryOperation( node.eval(callstack, interpreter), kind ); } catch ( UtilEvalError e ) { throw e.toEvalError( this, callstack ); } }
for(int i = 0; i < args.length; i++) args[i] = ((SimpleNode)jjtGetChild(i)).eval(callstack, interpreter); if ( args[i] == Primitive.VOID ) throw new EvalError( "Undefined argument: " +
this, callstack ); Object value = ((SimpleNode)jjtGetChild(0)).eval( callstack, interpreter);
/** Helper function to traverse array dimensions to find the common type. * Recursive calling for each element in an array initializer or finds the * common type relative to a value cell. * @param common the current common type * @param node the node to query * @param callstack the evaluation call stack * @param interpreter the evaluation interpreter * @return the common type for all cells * @throws EvalError thrown at node evaluation */ private Class<?> inferCommonType(Class<?> common, Node node, CallStack callstack, Interpreter interpreter ) throws EvalError { // Object is already the most common type and maps are typed LHS.MapEntry if ( Object.class == common || LHS.MapEntry.class == common ) return common; // inspect value elements for common type if ( !(node instanceof BSHArrayInitializer) ) { Object value = ((SimpleNode) node).eval(callstack, interpreter); Class<?> type = Types.getType(value, Primitive.isWrapperType(common)); return Types.getCommonType(common, Types.arrayElementType(type)); } // avoid traversing maps as arrays when nested in array if ( isMapInArray((BSHArrayInitializer) node) ) return Types.getCommonType(common, Map.class); // recurse through nested array initializer nodes int count = node.jjtGetNumChildren(); for ( int i = 0; i < count; i++ ) common = this.inferCommonType(common, node.jjtGetChild(i), callstack, interpreter); return common; }
this.getArrayDims(typeNode), callstack, interpreter); else value = initializer.eval( callstack, interpreter);
this, callstack ); else obj = ((SimpleNode)obj).eval(callstack, interpreter);
Object ot = ((SimpleNode) node).eval(callstack, interpreter);
obj = ((BSHAmbiguousName)obj).toObject(callstack, interpreter); else obj = ((SimpleNode)obj).eval(callstack, interpreter); else if ( obj instanceof LHS )