-
- b.add(parserLine, LITERAL, JS.N(1)); // decrement the length
- b.add(parserLine, SUB);
- b.add(parserLine, DUP);
- b.add(parserLine, LITERAL, JS.ZERO); // see if we've exhausted all the elements
- b.add(parserLine, LT);
- b.add(parserLine, JF, JS.N(2));
- b.add(parserLine, BREAK); // if we have, then BREAK
- b.add(parserLine, GET_PRESERVE); // get the key out of the keys array
- b.add(parserLine, LITERAL, varName);
- b.add(parserLine, PUT); // write it to this[varName]
- parseStatement(b, null); // do some stuff
- b.add(parserLine, CONTINUE); // continue if we fall out the bottom
-
- b.set(size - 1, JS.N(b.size - size + 1)); // BREAK to here
- b.add(parserLine, OLDSCOPE); // restore the scope
-
+
+ b.add(parserLine, PUSHKEYS);
+
+ int size = b.size;
+ b.add(parserLine, LOOP);
+ b.add(parserLine, POP);
+
+ b.add(parserLine,SWAP); // get the keys enumeration object on top
+ b.add(parserLine,DUP);
+ b.add(parserLine,GET,JS.S("hasMoreElements"));
+ int size2 = b.size;
+ b.add(parserLine,JT);
+ b.add(parserLine,SWAP);
+ b.add(parserLine,BREAK);
+ b.set(size2, JS.N(b.size - size2));
+ b.add(parserLine,DUP);
+ b.add(parserLine,GET,JS.S("nextElement"));
+
+ scopePush(b);
+
+ if(hadVar) scopeDeclare(varName);
+ JS varKey = scopeKey(varName);
+
+ if(varKey == null) {
+ b.add(parserLine,GLOBALSCOPE);
+ b.add(parserLine,SWAP);
+ b.add(parserLine, LITERAL, JSString.intern(varName));
+ b.add(parserLine,SWAP);
+ b.add(parserLine,PUT);
+ b.add(parserLine,POP);
+ } else {
+ b.add(parserLine, SCOPEPUT, varKey);
+ }
+ b.add(parserLine,POP); // pop the put'ed value
+ b.add(parserLine,SWAP); // put CallMarker back into place
+
+ parseStatement(b, null);
+
+ scopePop(b);
+ b.add(parserLine, CONTINUE);
+ // jump here on break
+ b.set(size, JS.N(b.size - size));
+
+ b.add(parserLine, POP);