MCPcopy Index your code
hub / github.com/beanshell/beanshell / eval

Method eval

src/bsh/Interpreter.java:627–738  ·  view source on GitHub ↗
( 
		Reader in, NameSpace nameSpace, String sourceFileInfo
			/*, CallStack callstack */ )

Source from the content-addressed store, hash-verified

625 */
626
627 public Object eval(
628 Reader in, NameSpace nameSpace, String sourceFileInfo
629 /*, CallStack callstack */ )
630 throws EvalError
631 {
632 Object retVal = null;
633 if ( Interpreter.DEBUG ) debug("eval: nameSpace = "+nameSpace);
634
635 /*
636 Create non-interactive local interpreter for this namespace
637 with source from the input stream and out/err same as
638 this interpreter.
639 */
640 Interpreter localInterpreter =
641 new Interpreter(
642 in, out, err, false, nameSpace, this, sourceFileInfo );
643
644 CallStack callstack = new CallStack( nameSpace );
645
646 SimpleNode node = null;
647 boolean eof = false;
648 while(!eof)
649 {
650 try
651 {
652 eof = localInterpreter.Line();
653 if (localInterpreter.get_jjtree().nodeArity() > 0)
654 {
655 if( node != null )
656 node.lastToken.next = null; // prevent OutOfMemoryError
657
658 node = (SimpleNode)localInterpreter.get_jjtree().rootNode();
659 // quick filter for when we're running as a compiler only
660 if ( getSaveClasses()
661 && !(node instanceof BSHClassDeclaration)
662 && !(node instanceof BSHImportDeclaration )
663 && !(node instanceof BSHPackageDeclaration )
664 )
665 continue;
666
667 // nodes remember from where they were sourced
668 node.setSourceFile( sourceFileInfo );
669
670 if ( TRACE )
671 println( "// " +node.getText() );
672
673 retVal = node.eval( callstack, localInterpreter );
674
675 // sanity check during development
676 if ( callstack.depth() > 1 )
677 throw new InterpreterError(
678 "Callstack growing: "+callstack);
679
680 if ( retVal instanceof ReturnControl ) {
681 retVal = ((ReturnControl)retVal).value;
682 break; // non-interactive, return control now
683 }
684

Callers 15

evalSourceMethod · 0.95
xPrintTargetErrorMethod · 0.95
runMethod · 0.95
sourceMethod · 0.95
getBshPromptMethod · 0.95
getBshVersionMethod · 0.95
evalScriptMethod · 0.95
accessibility_issue_aMethod · 0.95
accessibility_issue_bMethod · 0.95
createCallableMethod · 0.95

Calls 15

debugMethod · 0.95
LineMethod · 0.95
get_jjtreeMethod · 0.95
getSaveClassesMethod · 0.95
setSourceFileMethod · 0.95
printlnMethod · 0.95
getTextMethod · 0.95
evalMethod · 0.95
depthMethod · 0.95
errorMethod · 0.95
clearMethod · 0.95
pushMethod · 0.95