X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FForthBlock.java;h=f1f1e0a4d46d3d4943b8b0ea650fcec8ae856b64;hp=43607bed875807d1f8928ebef820084f5facf45e;hb=3734845964723dd29be220bb562c02af2158899d;hpb=c022d9dbbc396b467bcaf005684e4a971ddfcdce diff --git a/src/org/xwt/js/ForthBlock.java b/src/org/xwt/js/ForthBlock.java index 43607be..f1f1e0a 100644 --- a/src/org/xwt/js/ForthBlock.java +++ b/src/org/xwt/js/ForthBlock.java @@ -38,8 +38,15 @@ class ForthBlock implements OpCodes, Tokens { case LITERAL: t.push(arg[i]); break; case OBJECT: t.push(new JS.Obj()); break; case ARRAY: t.push(new JS.Array(JS.toNumber(arg[i]).intValue())); break; - case DECLARE: s.declare((String)t.pop()); break; - case OpCodes.THIS: t.push(s); break; // FIXME: transparents + case DECLARE: { + String st = (String)t.pop(); + if (st.equals("sel")) { + System.out.println("**** SEL!"); + for(int j=0; j<4; j++) System.out.println(op[i+j] + " " + arg[i+j]); + } + s.declare(st); break; + } + case THIS: t.push(s); break; // FIXME: transparents case JT: if (JS.toBoolean(t.pop())) i += JS.toNumber(arg[i]).intValue() - 1; break; case JF: if (!JS.toBoolean(t.pop())) i += JS.toNumber(arg[i]).intValue() - 1; break; case JMP: i += JS.toNumber(arg[i]).intValue() - 1; break; @@ -48,7 +55,7 @@ class ForthBlock implements OpCodes, Tokens { case DUP: t.push(t.peek()); break; case NOP: break; case EXPR: t.push(((ForthBlock)arg[i]).eval(s)); break; - case SCOPE: t.push(((ForthBlock)arg[i]).eval(new JS.Scope(s), t)); break; + case SCOPE: t.push(((ForthBlock)arg[i]).eval(new JS.Scope(s))); break; case ASSERT: if (!JS.toBoolean(t.pop())) throw new EvaluatorException(line, sourceName, "assertion failed"); break; case RETURN: throw new ReturnException(t.pop()); @@ -137,6 +144,7 @@ class ForthBlock implements OpCodes, Tokens { t.push(new JS.Function() { public String toString() { return sourceName + ":" + line; } public String getSourceName() throws JS.Exn { return sourceName; } + public int getLine() throws JS.Exn { return line; } public Object _call(final JS.Array args) throws JS.Exn { Function save = JS.getCurrentFunction(); JS.currentFunction.put(java.lang.Thread.currentThread(), this); @@ -235,13 +243,18 @@ class ForthBlock implements OpCodes, Tokens { } } } if (t.size() != 1) { + for(int i=0; i= 0 ? codeToString[op[i]] : "" + op[i]) + " [" + arg[i] + "]"); + } throw new EvaluatorException(line, sourceName, "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"); + if (o == null) { + throw new EvaluatorException(line, sourceName, "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() {