public String getErrorText() { if ( node != null ) return node.getText() ; else return "<unknown error>"; }
/** Gets the invocation text. * @return the invocation text */ public String getInvocationText() { final SimpleNode node = this.getNode(); if (node != null) return node.getText(); else return "<invoked from Java code>"; }
/** Helper method for testing equals on two primitive or boxable objects. yuck: factor this out into Primitive.java */ private boolean primitiveEquals( Object switchVal, Object targetVal, CallStack callstack, SimpleNode switchExp ) throws EvalError { if (targetVal == Primitive.VOID) return false; if ( switchVal instanceof Primitive || targetVal instanceof Primitive ) try { // binaryOperation can return Primitive or wrapper type Object result = Operators.binaryOperation( switchVal, targetVal, ParserConstants.EQ ); result = Primitive.unwrap( result ); return result.equals( Boolean.TRUE ); } catch ( UtilEvalError e ) { throw e.toEvalError( "Switch value: "+switchExp.getText()+": ", this, callstack ); } else return switchVal.equals( targetVal ); } }
/** Print the error with line number and stack trace. */ public String getMessage() { String trace; if ( node != null ) trace = " : at Line: "+ node.getLineNumber() + " : in file: "+ node.getSourceFile() + " : "+node.getText(); else // Users should not normally see this. trace = ": <at unknown location>"; if ( callstack != null ) trace = trace +"\n" + getScriptStackTrace(); return getRawMessage() + trace; }
} catch (EvalError e) { if (node.getText().trim().length() == 1 && e.getCause() instanceof ClassNotFoundException) baseType = Object.class;
if ( args[i] == Primitive.VOID ) throw new EvalError( "Undefined argument: " + ((SimpleNode)jjtGetChild(i)).getText(), this, callstack );
public List bshParse(String sourceFileInfo, Reader in) throws ParseException { List parsedLineNodes = new LinkedList(); Parser parser = new Parser(in); boolean eof = false; while(!eof) { try { eof = parser.Line(); if (parser.jjtree.nodeArity() > 0) { SimpleNode node = (SimpleNode) parser.jjtree.rootNode(); // nodes remember from where they were sourced node.setSourceFile(sourceFileInfo); parsedLineNodes.add(node); if (Debug.verboseOn()) Debug.logVerbose("// " + node.getText()); } } catch (ParseException e) { // add the source file info and throw again e.setErrorSourceFile(sourceFileInfo); Debug.logError(e); throw e; } finally { parser.jjtree.reset(); } } return parsedLineNodes; }
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; }
node.dump(">"); if ( TRACE ) println( "// " +node.getText() );
println( "// " +node.getText() );