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

Method eval

src/bsh/BSHMethodInvocation.java:47–93  ·  view source on GitHub ↗

Evaluate the method invocation with the specified callstack and interpreter

( CallStack callstack, Interpreter interpreter )

Source from the content-addressed store, hash-verified

45 interpreter
46 */
47 public Object eval( CallStack callstack, Interpreter interpreter )
48 throws EvalError
49 {
50 NameSpace namespace = callstack.top();
51 BSHAmbiguousName nameNode = getNameNode();
52
53 // Do not evaluate methods this() or super() in class instance space
54 // (i.e. inside a constructor)
55 if ( namespace.getParent() != null && namespace.getParent().isClass
56 && ( nameNode.text.equals("super") || nameNode.text.equals("this") )
57 )
58 return Primitive.VOID;
59
60 Name name = nameNode.getName(namespace);
61 Object[] args = getArgsNode().getArguments(callstack, interpreter);
62
63// This try/catch block is replicated is BSHPrimarySuffix... need to
64// factor out common functionality...
65// Move to Reflect?
66 try {
67 return name.invokeMethod( interpreter, args, callstack, this);
68 } catch ( ReflectError e ) {
69 throw new EvalError(
70 "Error in method invocation: " + e.getMessage(),
71 this, callstack, e );
72 } catch ( InvocationTargetException e )
73 {
74 String msg = "Method Invocation "+name;
75 Throwable te = e.getTargetException();
76
77 /*
78 Try to squeltch the native code stack trace if the exception
79 was caused by a reflective call back into the bsh interpreter
80 (e.g. eval() or source()
81 */
82 boolean isNative = true;
83 if ( te instanceof EvalError )
84 if ( te instanceof TargetError )
85 isNative = ((TargetError)te).inNativeCode();
86 else
87 isNative = false;
88
89 throw new TargetError( msg, te, this, callstack, isNative );
90 } catch ( UtilEvalError e ) {
91 throw e.toEvalError( this, callstack );
92 }
93 }
94}
95

Callers

nothing calls this directly

Calls 11

getNameNodeMethod · 0.95
getParentMethod · 0.95
getNameMethod · 0.95
getArgsNodeMethod · 0.95
invokeMethodMethod · 0.95
topMethod · 0.80
getArgumentsMethod · 0.80
inNativeCodeMethod · 0.80
equalsMethod · 0.45
getMessageMethod · 0.45
toEvalErrorMethod · 0.45

Tested by

no test coverage detected