瀏覽代碼

one more fix in logical expressions and "~"

Vladislav Folts 11 年之前
父節點
當前提交
05cee39dc4
共有 3 個文件被更改,包括 5 次插入1 次删除
  1. 3 1
      src/context.js
  2. 1 0
      test/expected/logical.js
  3. 1 0
      test/input/logical.ob

+ 3 - 1
src/context.js

@@ -923,8 +923,10 @@ exports.Term = ChainedContext.extend({
     endParse: function(){this.parent().handleTerm(this.__expression);},
     handleExpression: function(e){
         promoteExpressionType(this, this.__expression, e);
-        if (this.__logicalNot)
+        if (this.__logicalNot){
             e = op.not(e);
+            this.__logicalNot = false;
+        }
         if (this.__operator)
             e = this.__expression ? this.__operator(this.__expression, e)
                                   : this.__operator(e);

+ 1 - 0
test/expected/logical.js

@@ -8,4 +8,5 @@ b1 = b1 && b2 || !b1;
 b1 = b2 && !b1;
 b1 = b2 || b1;
 b1 = b2 || !!(b1 && b2);
+b1 = !b1 && !b2;
 }();

+ 1 - 0
test/input/logical.ob

@@ -12,4 +12,5 @@ BEGIN
     b1 := b2 & ~b1;
     b1 := b2 OR ~~b1;
     b1 := b2 OR ~(~(b1 & b2));
+    b1 := ~b1 & ~b2;
 END m.