}
public Object eval(final JS.Scope s, Vec t) throws ControlTransferException {
- for(int i=0; i<size; i++) switch(op[i]) {
+
+ for(int i=0; i<size; i++) {
+ switch(op[i]) {
case LABEL: break;
case LITERAL: t.push(arg[i]); break;
case OBJECT: t.push(new JS.Obj()); break;
Object key = t.pop();
JS target = (JS)t.peek();
if (target == null)
- throw new EvaluatorException(line, sourceName, "tried to put a value to the " + key + " property on the null value");
+ throw new JS.Exn("tried to put a value to the " + key + " property on the null value");
target.put(key, val);
t.push(val);
break;
arguments.setSize(numArgs);
for(int j=numArgs - 1; j >= 0; j--) arguments.setElementAt(t.pop(), j);
JS.Function f = (JS.Function)t.pop();
- if (f == null) throw new JS.Exn(new EvaluatorException(line, sourceName, "attempted to call null"));
+ if (f == null) throw new JS.Exn("attempted to call null");
t.push(f.call(arguments));
break;
}
default: throw new Error("unknown opcode " + op[i]);
} }
}
- System.out.println("returning");
+ }
if (t.size() != 1) throw new Error("eval() terminated with " + t.size() + " elements on the stack; one expected");
return t.pop();
}
public Object doGet(final Object o, final Object v) {
if (o == null)
- throw new EvaluatorException(line, sourceName, "tried to get property \"" + v + "\" from the null value");
+ throw new JS.Exn("tried to get property \"" + v + "\" from the null value");
if (o instanceof String) {
if (v.equals("length")) return new Integer(((String)o).length());
else if (v.equals("substring")) return new JS.Function() {