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

Method eval

src/bsh/BSHCastExpression.java:43–62  ·  view source on GitHub ↗

@return the result of the cast.

(
		CallStack callstack, Interpreter interpreter )

Source from the content-addressed store, hash-verified

41 @return the result of the cast.
42 */
43 public Object eval(
44 CallStack callstack, Interpreter interpreter ) throws EvalError
45 {
46 NameSpace namespace = callstack.top();
47 Class toType = ((BSHType)jjtGetChild(0)).getType(
48 callstack, interpreter );
49 SimpleNode expression = (SimpleNode)jjtGetChild(1);
50
51 // evaluate the expression
52 Object fromValue = expression.eval(callstack, interpreter);
53 Class fromType = fromValue.getClass();
54
55 // TODO: need to add isJavaCastable() test for strictJava
56 // (as opposed to isJavaAssignable())
57 try {
58 return Types.castObject( fromValue, toType, Types.CAST );
59 } catch ( UtilEvalError e ) {
60 throw e.toEvalError( this, callstack );
61 }
62 }
63
64}

Callers

nothing calls this directly

Calls 7

evalMethod · 0.95
castObjectMethod · 0.95
topMethod · 0.80
getClassMethod · 0.80
jjtGetChildMethod · 0.65
getTypeMethod · 0.45
toEvalErrorMethod · 0.45

Tested by

no test coverage detected