FIXME triage and formatting cleanups
[org.ibex.js.git] / src / org / ibex / js / Interpreter.java
index e20e630..77da0ab 100644 (file)
@@ -248,10 +248,10 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                 TrapMarker tm = (TrapMarker) o;
                 JS key = tm.t.key();
                 JS target = tm.t.target();
-                if(tm.t.isWriteTrap() != write) throw new JSExn("tried to do a " + (write?"write":"read") + " cascade in a " + (write?"read":"write") + " trap");
+                if(tm.t.isWriteTrap() != write)
+                    throw new JSExn("tried to do a "+(write?"write":"read") + " cascade in a " + (write?"read":"write") + " trap");
                 JS.Trap t = write ? tm.t.nextWrite() : tm.t.nextRead();
-                // FIXME: Doesn't handle multiple levels of clone's (probably can just make this a while loop)
-                if(t == null && target instanceof JS.Clone) {
+                while (t == null && target instanceof JS.Clone) {
                     target = ((JS.Clone)target).clonee;
                     t = target.getTrap(key);
                     if(t != null) t = write ? t.write() : t.read();
@@ -344,10 +344,9 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
             }
             
             case CALL: case CALLMETHOD: {
-                // FIXME: can a lot of simple cases in Parser be
-                // reduced so creating a new JS[] is not necessary?
                 JS[] jsargs;
                 if (arg instanceof JSNumber.I) {
+                    // FIXME: we should be able to recycle JS[]'s here
                     jsargs = new JS[((JSNumber.I)arg).toInt()];
                     for (int i=0; i < jsargs.length; i++) jsargs[i] = (JS)stack.pop();
                 } else jsargs = (JS[])arg;
@@ -390,35 +389,12 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
             case THROW:
                 throw new JSExn((JS)stack.pop(), this);
 
-                /* FIXME GRAMMAR
-            case MAKE_GRAMMAR: {
-                final Grammar r = (Grammar)arg;
-                final JSScope final_scope = scope;
-                Grammar r2 = new Grammar() {
-                        public int match(String s, int start, Map v, JSScope scope) throws JSExn {
-                            return r.match(s, start, v, final_scope);
-                        }
-                        public int matchAndWrite(String s, int start, Map v, JSScope scope, String key) throws JSExn {
-                            return r.matchAndWrite(s, start, v, final_scope, key);
-                        }
-                        public Object call(Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
-                            Map v = new Map();
-                            r.matchAndWrite((String)a0, 0, v, final_scope, "foo");
-                            return v.get("foo");
-                        }
-                    };
-                Object obj = stack.pop();
-                if (obj != null && obj instanceof Grammar) r2 = new Grammar.Alternative((Grammar)obj, r2);
-                stack.push(r2);
-                break;
-            }
-                */
             case ADD_TRAP: case DEL_TRAP: {
                 JS val = (JS)stack.pop();
                 JS key = (JS)stack.pop();
                 JS js = (JS)stack.peek();
                 // A trap addition/removal
-                if(!(val instanceof JSFunction)) throw new JSExn("tried to add/remove a non-function trap"); // FIXME
+                if(!(val instanceof JSFunction)) throw new JSExn("tried to add/remove a non-function trap");
                 if(op == ADD_TRAP) js.addTrap(key, val);
                 else js.delTrap(key, val);
                 break;
@@ -558,7 +534,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
     void setupTrap(JS.Trap t, JS val, CallMarker cm) throws JSExn {
         stack.push(cm);
         stack.push(new TrapArgs(t, val));
-        f = (JSFunction)t.function(); // FIXME
+        f = (JSFunction)t.function();
         scope = f.parentScope;
         pc = 0;
     }