- Object exn = t.pop();
- while(t.size() > 0) {
- Object o = t.pop();
- if (o instanceof CatchMarker || o instanceof TryMarker) {
- boolean inCatch = o instanceof CatchMarker;
- if(inCatch) {
- o = t.pop();
- if(((TryMarker)o).finallyLoc < 0) continue; // no finally block, keep going
- }
- if(!inCatch && ((TryMarker)o).catchLoc >= 0) {
- // run the catch block, this will implicitly run the finally block, if it exists
- t.push(o);
- t.push(catchMarker);
- t.push((exn instanceof JS.Exn) ? ((JS.Exn)exn).getObject() : exn);
- s = ((TryMarker)o).scope;
- pc = ((TryMarker)o).catchLoc - 1;
- continue OUTER;
- } else {
- t.push(exn);
- t.push(new FinallyData(THROW));
- s = ((TryMarker)o).scope;
- pc = ((TryMarker)o).finallyLoc - 1;
- continue OUTER;
- }
- }
- // no handler found within this func
- if(o instanceof CallMarker) {
- if(exn instanceof JS.Exn)
- throw (JS.Exn)exn;
- else
- throw new JS.Exn(exn);
- }
- }
- throw new Error("error: THROW invoked but couldn't find a Try or Call Marker!");