/** Occasionally we need to freeze the callstack for error reporting purposes, etc. */ public CallStack copy() { CallStack cs = new CallStack(); cs.stack.addAll(this.stack); return cs; } }
public String getScriptStackTrace() { if ( callstack == null ) return "<Unknown>"; String trace = ""; CallStack stack = callstack.copy(); while ( stack.depth() > 0 ) { NameSpace ns = stack.pop(); SimpleNode node = ns.getNode(); if ( ns.isMethod ) { trace = trace + "\nCalled from method: " + ns.getName(); if ( node != null ) trace += " : at Line: "+ node.getLineNumber() + " : in file: "+ node.getSourceFile() + " : "+node.getText(); } } return trace; }
public Object constructWithInterfaceBody( BSHAllocationExpression node, Class type, Object[] args, BSHBlock body ) throws EvalError { NameSpace namespace = callstack.top(); NameSpace local = new NameSpace(namespace, "AnonymousBlock"); callstack.push(local); evalBlock(body, true); callstack.pop(); // statical import fields from the interface so that code inside // can refer to the fields directly (e.g. HEIGHT) local.importStatic( type ); return local.getThis(interpreter).getInterface( type ); }
int callstackDepth = callstack.depth(); try { ret = tryBlock.accept(this); target = e; String stackInfo = "Bsh Stack: "; while ( callstack.depth() > callstackDepth ) stackInfo += "\t" + callstack.pop() +"\n"; NameSpace enclosingNameSpace = callstack.top(); BlockNameSpace cbNameSpace = new BlockNameSpace( enclosingNameSpace ); callstack.swap( cbNameSpace ); try { ret = cb.accept(this); } finally { callstack.swap( enclosingNameSpace );
/** * Register actual context, used by generated class constructor, which calls * {@link #initInstance(GeneratedClass, String, Object[])}. */ static void registerConstructorContext(CallStack callstack, Interpreter interpreter) { if (callstack != null) CONTEXT_NAMESPACE.set(callstack.top()); else CONTEXT_NAMESPACE.remove(); if (interpreter != null) CONTEXT_INTERPRETER.set(interpreter); else CONTEXT_INTERPRETER.remove(); }
public CallStack( NameSpace namespace ) { push( namespace ); }
public EvalError( String s, SimpleNode node, CallStack callstack ) { this.message = s; this.node = node; // freeze the callstack for the stack trace. this.callstack = callstack==null ? null : callstack.copy(); }
obj = callstack.get( ++callstackDepth ).getThis( interpreter );
int callstackDepth = callstack.depth(); try { ret = tryBlock.eval(callstack, interpreter); thrown = e.getTarget(); while ( callstack.depth() > callstackDepth ) callstack.pop(); } finally { NameSpace enclosingNameSpace = callstack.top(); BlockNameSpace cbNameSpace = new BlockNameSpace( enclosingNameSpace ); callstack.swap( cbNameSpace ); try { ret = cb.eval( callstack, interpreter ); } finally { callstack.swap( enclosingNameSpace );
/** * Register actual context, used by generated class constructor, which calls * {@link #initInstance(GeneratedClass, String, Object[])}. */ public static void registerConstructorContext(CallStack callstack, Interpreter interpreter) { if (callstack != null) { CONTEXT_NAMESPACE.set(callstack.top()); } else { CONTEXT_NAMESPACE.remove(); } if (interpreter != null) { CONTEXT_INTERPRETER.set(interpreter); } else { CONTEXT_INTERPRETER.remove(); } }