case DUP: stack.push(stack.peek()); break;
case NEWSCOPE: scope = new JSScope(scope); break;
case OLDSCOPE: scope = scope.getParentScope(); break;
- case ASSERT: if (!JS.toBoolean(stack.pop())) throw je("ibex.assertion.failed" /*FEATURE: line number*/); break;
+ case ASSERT:
+ if (JS.checkAssertions && !JS.toBoolean(stack.pop()))
+ throw je("ibex.assertion.failed" /*FEATURE: line number*/); break;
case BITNOT: stack.push(JS.N(~JS.toLong(stack.pop()))); break;
case BANG: stack.push(JS.B(!JS.toBoolean(stack.pop()))); break;
case NEWFUNCTION: stack.push(((JSFunction)arg)._cloneWithNewParentScope(scope)); break;
throw je("tried to assign \"" + (val==null?"(null)":val.toString()) + "\" to the null key");
Trap t = null;
- if (target instanceof Trap.TrapScope && key.equals("cascade")) {
- Trap.TrapScope ts = (Trap.TrapScope)target;
- t = ts.t.next;
- ts.cascadeHappened = true;
+ if (target instanceof JSScope && key.equals("cascade")) {
+ Trap.TrapScope ts = null;
+ JSScope p = (JSScope)target; // search the scope-path for the trap
+ if (target instanceof Trap.TrapScope) {
+ ts = (Trap.TrapScope)target;
+ }
+ else {
+ while (ts == null && p.getParentScope() != null) {
+ p = p.getParentScope();
+ if (p instanceof Trap.TrapScope) {
+ ts = (Trap.TrapScope)p;
+ }
+ }
+ }
+ t = ts.t.next;
+ ts.cascadeHappened = true;
while (t != null && t.f.numFormalArgs == 0) t = t.next;
if (t == null) { target = ts.t.trapee; key = ts.t.name; }
} else {
t = ((JS)target).getTrap(key);
}
-
while (t != null && t.f.numFormalArgs == 0) t = t.next; // find the first write trap
- if (t != null) {
- stack.push(new CallMarker(this));
- JSArray args = new JSArray();
- args.addElement(val);
- stack.push(args);
- }
}
if (t != null) {
+ stack.push(new CallMarker(this));
+ JSArray args = new JSArray();
+ args.addElement(val);
+ stack.push(args);
f = t.f;
scope = new Trap.TrapScope(f.parentScope, t, val);
pc = -1;
} else {
t = ((JS)o).getTrap(v);
}
-
while (t != null && t.f.numFormalArgs != 0) t = t.next; // get first read trap
- if (t != null) {
- stack.push(new CallMarker(this));
- JSArray args = new JSArray();
- stack.push(args);
- }
}
if (t != null) {
+ stack.push(new CallMarker(this));
+ JSArray args = new JSArray();
+ stack.push(args);
f = t.f;
scope = new Trap.TrapScope(f.parentScope, t, null);
((Trap.TrapScope)scope).cascadeHappened = true;
}
case THROW:
- throw new JSExn(stack.pop());
+ throw new JSExn(stack.pop(), stack, f, pc, scope);
+ /* FIXME
case MAKE_GRAMMAR: {
final Grammar r = (Grammar)arg;
final JSScope final_scope = scope;
stack.push(r2);
break;
}
-
+ */
case ADD_TRAP: case DEL_TRAP: {
Object val = stack.pop();
Object key = stack.pop();
}
} catch(JSExn e) {
- if(f.op[pc] != FINALLY_DONE) e.addBacktrace(f.sourceName,f.line[pc]);
while(stack.size() > 0) {
Object o = stack.pop();
if (o instanceof CatchMarker || o instanceof TryMarker) {
pc = ((TryMarker)o).finallyLoc - 1;
continue OUTER;
}
- } else if(o instanceof CallMarker) {
- CallMarker cm = (CallMarker) o;
- if(cm.f == null)
- e.addBacktrace("<java>",0); // This might not even be worth mentioning
- else
- e.addBacktrace(cm.f.sourceName,cm.f.line[cm.pc-1]);
}
}
throw e;
static Object getFromPrimitive(Object o, Object key) throws JSExn {
boolean returnJS = false;
if (o instanceof Boolean) {
- throw new JSExn("cannot call methods on Booleans");
+ throw new JSExn("Booleans do not have properties");
} else if (o instanceof Number) {
if (key.equals("toPrecision") || key.equals("toExponential") || key.equals("toFixed"))
returnJS = true;