- public JSExn(JS js) {
- this.js = js;
- if (Interpreter.current() != null)
- fill(Interpreter.current().stack, Interpreter.current().f, Interpreter.current().pc, Interpreter.current().scope);
- }
- public JSExn(JS js, Interpreter.Stack stack, JSFunction f, int pc, JSScope scope) { this.js = js; fill(stack, f, pc, scope); }
- private void fill(Interpreter.Stack stack, JSFunction f, int pc, JSScope scope) {
- addBacktrace(f.sourceName + ":" + f.line[pc]);
- for(int i=stack.size()-1; i>=0; i--) {
- JS element = stack.elementAt(i);
- if (element instanceof Interpreter.CallMarker) {
- Interpreter.CallMarker cm = (Interpreter.CallMarker)element;
- if(cm.f == null) break;
- String s = cm.f.sourceName + ":" + cm.f.line[cm.pc-1];
- if(cm instanceof Interpreter.TrapMarker)
- s += " (trap on " + JS.debugToString(((Interpreter.TrapMarker)cm).key) + ")";
- addBacktrace(s);
- }
- }
+ public JSExn(JS js) { this(js,null); }
+ public JSExn(JS js, Interpreter cx) { this.js = js; fill(cx); }
+
+ private void fill(Interpreter cx) {
+ if(cx == null) cx = Interpreter.current();
+ if(cx == null) return;
+ addBacktrace(cx.f.sourceName + ":" + cx.f.line[cx.pc]);
+ cx.stack.backtrace(this);