+ public JSExn(Object js) {
+ this.js = js;
+ if (Interpreter.current() != null)
+ fill(Interpreter.current().stack, Interpreter.current().f, Interpreter.current().pc, Interpreter.current().scope);
+ }
+ public JSExn(Object js, Vec stack, JSFunction f, int pc, JSScope scope) { this.js = js; fill(stack, f, pc, scope); }
+ private void fill(Vec stack, JSFunction f, int pc, JSScope scope) {
+ addBacktrace(f.sourceName + ":" + f.line[pc]);
+ if (scope != null && scope instanceof Trap.TrapScope)
+ addBacktrace("trap on property \"" + ((Trap.TrapScope)scope).t.name + "\"");
+ for(int i=stack.size()-1; i>=0; i--) {
+ Object element = stack.elementAt(i);
+ if (element instanceof Interpreter.CallMarker) {
+ Interpreter.CallMarker cm = (Interpreter.CallMarker)element;
+ if (cm.f != null)
+ addBacktrace(cm.f.sourceName + ":" + cm.f.line[cm.pc]);
+ if (cm.scope != null && cm.scope instanceof Trap.TrapScope)
+ addBacktrace("trap on property \"" + ((Trap.TrapScope)cm.scope).t.name + "\"");
+ }
+ }
+ }
+ public void printStackTrace() { printStackTrace(System.err); }
+ public void printStackTrace(PrintWriter pw) {
+ for(int i=0; i<backtrace.size(); i++) pw.println(" at " + (String) backtrace.elementAt(i));
+ super.printStackTrace(pw);
+ }
+ public void printStackTrace(PrintStream ps) {
+ for(int i=0; i<backtrace.size(); i++) ps.println(" at " + (String) backtrace.elementAt(i));
+ super.printStackTrace(ps);
+ }