Jelajahi Sumber

Fix REPEAT/UNTIL semantic.

Vladislav Folts 10 tahun lalu
induk
melakukan
d4b0038693
3 mengubah file dengan 11 tambahan dan 6 penghapusan
  1. TEMPAT SAMPAH
      bin/compiled.zip
  2. 9 4
      src/context.js
  3. 2 2
      test/expected/repeat.js

TEMPAT SAMPAH
bin/compiled.zip


+ 9 - 4
src/context.js

@@ -1474,11 +1474,16 @@ exports.Repeat = ChainedContext.extend({
 exports.Until = ChainedContext.extend({
 exports.Until = ChainedContext.extend({
     init: function UntilContext(context){
     init: function UntilContext(context){
         ChainedContext.prototype.init.call(this, 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({
 exports.For = ChainedContext.extend({

+ 2 - 2
test/expected/repeat.js

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