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

Method eval

src/bsh/BSHTryStatement.java:40–186  ·  view source on GitHub ↗
( CallStack callstack, Interpreter interpreter)

Source from the content-addressed store, hash-verified

38 }
39
40 public Object eval( CallStack callstack, Interpreter interpreter)
41 throws EvalError
42 {
43 BSHBlock tryBlock = ((BSHBlock)jjtGetChild(0));
44
45 List<BSHFormalParameter> catchParams = new ArrayList<BSHFormalParameter>();
46 List<BSHBlock> catchBlocks = new ArrayList<BSHBlock>();
47
48 int nchild = jjtGetNumChildren();
49 Node node = null;
50 int i=1;
51 while((i < nchild) && ((node = jjtGetChild(i++)) instanceof BSHFormalParameter))
52 {
53 catchParams.add((BSHFormalParameter)node);
54 catchBlocks.add((BSHBlock)jjtGetChild(i++));
55 node = null;
56 }
57 // finally block
58 BSHBlock finallyBlock = null;
59 if(node != null)
60 finallyBlock = (BSHBlock)node;
61
62// Why both of these?
63
64 TargetError target = null;
65 Throwable thrown = null;
66 Object ret = null;
67
68 /*
69 Evaluate the contents of the try { } block and catch any resulting
70 TargetErrors generated by the script.
71 We save the callstack depth and if an exception is thrown we pop
72 back to that depth before contiuing. The exception short circuited
73 any intervening method context pops.
74
75 Note: we the stack info... what do we do with it? append
76 to exception message?
77 */
78 int callstackDepth = callstack.depth();
79 try {
80 ret = tryBlock.eval(callstack, interpreter);
81 }
82 catch( TargetError e ) {
83 target = e;
84 String stackInfo = "Bsh Stack: ";
85 while ( callstack.depth() > callstackDepth )
86 stackInfo += "\t" + callstack.pop() +"\n";
87 }
88
89 // unwrap the target error
90 if ( target != null )
91 thrown = target.getTarget();
92
93
94 // If we have an exception, find a catch
95 try {
96 if (thrown != null)
97 {

Callers

nothing calls this directly

Calls 15

evalMethod · 0.95
getTargetMethod · 0.95
evalMethod · 0.95
castObjectMethod · 0.95
setBlockVariableMethod · 0.95
depthMethod · 0.80
popMethod · 0.80
getStrictJavaMethod · 0.80
topMethod · 0.80
swapMethod · 0.80
jjtGetChildMethod · 0.65
jjtGetNumChildrenMethod · 0.65

Tested by

no test coverage detected