Browse Source

Fix REPEAT/UNTIL semantic.

Vladislav Folts 10 years ago
parent
commit
d4b0038693
3 changed files with 11 additions and 6 deletions
  1. BIN
      bin/compiled.zip
  2. 9 4
      src/context.js
  3. 2 2
      test/expected/repeat.js

BIN
bin/compiled.zip


+ 9 - 4
src/context.js

@@ -1474,11 +1474,16 @@ exports.Repeat = ChainedContext.extend({
 exports.Until = ChainedContext.extend({
     init: function UntilContext(context){
         ChainedContext.prototype.init.call(this, context);
-        var gen = context.codeGenerator();
-        gen.closeScope(" while (");
+        context.codeGenerator().closeScope(" while (");
+    },
+    codeGenerator: function(){ return nullCodeGenerator; },
+    handleExpression: function(e){
+        handleIfExpression(e);
+        this.parent().codeGenerator().write( op.not(e).code() );
     },
-    handleExpression: handleIfExpression,
-    endParse: function(){this.codeGenerator().write(");\n");}
+    endParse: function(){
+        this.parent().codeGenerator().write(");\n");
+    }
 });
 
 exports.For = ChainedContext.extend({

+ 2 - 2
test/expected/repeat.js

@@ -5,9 +5,9 @@ b1 = true;
 b2 = false;
 do {
 	i1 = 0;
-} while (b1);
+} while (!b1);
 do {
 	i1 = 1;
 	b2 = false;
-} while (b1);
+} while (!b1);
 }();