X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJSExn.java;h=e01b769cf453f07e1904dfc22f04f180c18052d4;hb=ce791e4058158295bce9cf7b6698c2b565d571d7;hp=8c1362ddf2029825b39b0978c9ab96bfe4c59a42;hpb=b1a58aeb4adfade0697650583ec5801fa6e88d5e;p=org.ibex.core.git diff --git a/src/org/ibex/js/JSExn.java b/src/org/ibex/js/JSExn.java index 8c1362d..e01b769 100644 --- a/src/org/ibex/js/JSExn.java +++ b/src/org/ibex/js/JSExn.java @@ -7,25 +7,27 @@ import java.io.*; /** An exception which can be thrown and caught by JavaScript code */ public class JSExn extends Exception { private Vec backtrace = new Vec(); - private Object js = null; - public JSExn(Object js) { + private JS js = null; + public JSExn(String s) { this(JS.S(s)); } + 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(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) { + 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]); - if (scope != null && scope instanceof Trap.TrapScope) - addBacktrace("trap on property \"" + ((Trap.TrapScope)scope).t.name + "\""); + // FIXME: "trap on property" + /*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); + JS 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 + "\""); + addBacktrace(cm.f.sourceName + ":" + cm.f.line[cm.pc-1]); + /*if (cm.scope != null && cm.scope instanceof Trap.TrapScope) + addBacktrace("trap on property \"" + ((Trap.TrapScope)cm.scope).t.name + "\"");*/ } } } @@ -38,18 +40,16 @@ public class JSExn extends Exception { for(int i=0; i