/** Re-throw as an eval error, prefixing msg to the message and specifying the node. If a node already exists the addNode is ignored. @see #setNode( bsh.SimpleNode ) <p> @param msg may be null for no additional message. */ public EvalError toEvalError( String msg, SimpleNode node, CallStack callstack ) { if ( Interpreter.DEBUG.get() ) printStackTrace(); if ( msg == null ) msg = ""; else msg += ": "; return new EvalError( msg + this.getMessage(), node, callstack, this ); }
/** Re-throw as an eval error, prefixing msg to the message and specifying the node. If a node already exists the addNode is ignored. @see #setNode(bsh.ast.SimpleNode) <p> @param msg may be null for no additional message. */ public EvalError toEvalError( String msg, SimpleNode node, CallStack callstack ) { if ( Interpreter.DEBUG ) printStackTrace(); if ( msg == null ) msg = ""; else msg = msg + ": "; return new EvalError( msg+getMessage(), node, callstack, this ); }
public Object eval(CallStack callstack, Interpreter interpreter) throws EvalError { renderTypeNode(); this.type = evalType(callstack, interpreter); if (!AutoCloseable.class.isAssignableFrom(this.getType())) throw new EvalError("The resource type "+ this.type.getName() +" does not implement java.lang.AutoCloseable.", this, callstack); this.name = this.getDeclarators()[0].name; // we let BSHTypedVariableDeclaration do the heavy lifting super.eval(callstack, interpreter); try { this.varThis = callstack.top().getVariableImpl(this.getName(), true); } catch (UtilEvalError e) { throw e.toEvalError("Unable to evaluate the try-with-resource " + this.getName() + ". With message:" + e.getMessage(), this, callstack); } return Primitive.VOID; }
throw new UtilEvalError( "LHS evaluation: " + e.getMessage() );
} catch (final UtilEvalError e) { throw new UtilEvalError( "Variable assignment: " + name + ": " + e.getMessage(), e);
} catch ( UtilEvalError e ) { throw new UtilEvalError( "Variable assignment: " + name + ": " + e.getMessage());
throw new UtilEvalError( "LHS evaluation: " + e.getMessage(), e);
/** Unassign the variable name. Name should evaluate to a variable. */ public void unset( String name ) throws EvalError { /* We jump through some hoops here to handle arbitrary cases like unset("bsh.foo"); */ CallStack callstack = new CallStack(); try { LHS lhs = globalNameSpace.getNameResolver( name ).toLHS( callstack, this ); if ( lhs.type != LHS.VARIABLE ) throw new EvalError("Can't unset, not a variable: "+name, SimpleNode.JAVACODE, new CallStack()); lhs.nameSpace.unsetVariable( name ); } catch ( UtilEvalError e ) { throw new EvalError( e.getMessage(), SimpleNode.JAVACODE, new CallStack(), e); } }
/** Unassign the variable name. Name should evaluate to a variable. */ public void unset( String name ) throws EvalError { /* We jump through some hoops here to handle arbitrary cases like unset("bsh.foo"); */ CallStack callstack = new CallStack(); try { LHS lhs = globalNameSpace.getNameResolver( name ).toLHS( new BshEvaluatingVisitor(callstack, this) ); if ( lhs.type != LHS.VARIABLE ) throw new EvalError("Can't unset, not a variable: "+name, SimpleNode.JAVACODE, new CallStack() ); //lhs.assign( null, false ); lhs.nameSpace.unsetVariable( name ); } catch ( UtilEvalError e ) { throw new EvalError( e.getMessage(), SimpleNode.JAVACODE, new CallStack() ); } }
+ "`"+paramNames[k]+"'" + " for method: " + name + " : " + e.getMessage(), callerInfo, callstack ); throw e.toEvalError( "Incorrect type returned from method: " + name + e.getMessage(), node, callstack );
initializers = Types.castObject(initializers, originalBaseType, Types.CAST); } catch (UtilEvalError e) { throw new EvalError(e.getMessage(), this, callstack, e);
+ "`"+paramNames[i]+"'" + " for method: " + name + " : " + e.getMessage(), callerInfo, visitor.getCallstack() ); throw e.toEvalError( "Incorrect type returned from method: " + name + e.getMessage(), node, visitor.getCallstack() );