Revision: 4827 http://sourceforge.net/p/vexi/code/4827 Author: mkpg2 Date: 2015-11-12 01:29:43 +0000 (Thu, 12 Nov 2015) Log Message: ----------- Fix. Support LABEL on for(var k,v in ... loops.
Modified Paths: -------------- branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Interpreter.java branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/parse/Parser.java branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/general/TestGeneral.java Added Paths: ----------- branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/general/loop.js Modified: branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Interpreter.java =================================================================== --- branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Interpreter.java 2015-11-10 15:52:57 UTC (rev 4826) +++ branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Interpreter.java 2015-11-12 01:29:43 UTC (rev 4827) @@ -264,9 +264,14 @@ case BREAK: case CONTINUE: + boolean nolabel = false; while(!stack.empty()) { Object o = stack.pop(); - if (o instanceof CallMarker) throw je("Tried to '"+(op==BREAK?"break":"continue")+"' when not within a loop"+(op==BREAK?"/switch":"")); + if (o instanceof CallMarker) { + if(nolabel) + throw je("Could not find label '"+arg+"'"); + throw je("Tried to '"+(op==BREAK?"break":"continue")+"' when not within a loop"+(op==BREAK?"/switch":"")); + } if (o instanceof TryMarker) { if(((TryMarker)o).finallyLoc < 0) continue; // no finally block, keep going stack.push(new FinallyData(op, arg)); @@ -288,6 +293,7 @@ else jumpAbs(loopInstructionLocation); continue OUTER; } + nolabel = true; } } throw new Error((op==BREAK?"BREAK":"CONTINUE")+" invoked but couldn't find LoopMarker at " + Modified: branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/parse/Parser.java =================================================================== --- branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/parse/Parser.java 2015-11-10 15:52:57 UTC (rev 4826) +++ branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/parse/Parser.java 2015-11-12 01:29:43 UTC (rev 4827) @@ -1104,7 +1104,9 @@ b.add(parserLine, PUSHKEYS); // o,k b.add(parserLine, LITERAL, string("iterator")); // o,k,"iterator" b.add(parserLine, GET_PRESERVE); // o,k,"iterator",Stub - b.add(parserLine, CALLMETHOD, integer(0)); // o,k,I + b.add(parserLine, CALLMETHOD, integer(0)); // o,k,I + + if (label != null) b.add(parserLine, LABEL, label); int size = b.size; b.add(parserLine, LOOP); // o,k,I,LM,true b.add(parserLine, POP); // o,k,I,LM Modified: branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/general/TestGeneral.java =================================================================== --- branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/general/TestGeneral.java 2015-11-10 15:52:57 UTC (rev 4826) +++ branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/general/TestGeneral.java 2015-11-12 01:29:43 UTC (rev 4827) @@ -16,7 +16,7 @@ public static void main(String[] args) throws Throwable { try{ JSTestSuite jts = new JSTestSuite(TestGeneral.class); - JSTestCase t = jts.createTestCase(jts.getResourceDirs(), "ternary_precedence.js"); + JSTestCase t = jts.createTestCase(jts.getResourceDirs(), "loop.js"); //t.printByteCode(); t.runBare(); }catch(Throwable t){ Added: branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/general/loop.js =================================================================== --- branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/general/loop.js (rev 0) +++ branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/general/loop.js 2015-11-12 01:29:43 UTC (rev 4827) @@ -0,0 +1,9 @@ + +OUTER: for(var i=0; i>10; i++){ + continue OUTER; +} + +OUTER: for(var i,e in ["a"]){ + continue OUTER; +} +return r; \ No newline at end of file Property changes on: branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/general/loop.js ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn