瀏覽代碼

Merge pull request #3899 from Herschel/swf9-uint-shift

[swf9] Fix UInt shift behavior
Nicolas Cannasse 10 年之前
父節點
當前提交
8580926dea
共有 2 個文件被更改,包括 9 次插入1 次删除
  1. 6 1
      genswf9.ml
  2. 3 0
      tests/unit/src/unit/issues/Issue2736.hx

+ 6 - 1
genswf9.ml

@@ -1633,10 +1633,15 @@ and gen_binop ctx retval op e1 e2 t p =
 		gen_expr ctx true e2;
 		write_op op;
 		setvar ctx wacc (if retval then Some (classify ctx e1.etype) else None)
-	| OpAdd | OpMult | OpDiv | OpSub | OpAnd | OpOr | OpXor | OpShl | OpShr | OpUShr | OpMod ->
+	| OpAdd | OpMult | OpDiv | OpSub | OpAnd | OpOr | OpXor | OpMod ->
 		gen_expr ctx true e1;
 		gen_expr ctx true e2;
 		write_op op
+	| OpShl | OpShr	| OpUShr ->
+		gen_expr ctx true e1;
+		gen_expr ctx true e2;
+		write_op op;
+		coerce ctx (classify ctx e1.etype)
 	| OpEq ->
 		gen_eq()
 	| OpNotEq ->

+ 3 - 0
tests/unit/src/unit/issues/Issue2736.hx

@@ -22,6 +22,9 @@ class Issue2736 extends Test {
         t( a > 1.0 ); t( a >= 1.0 );
         f( a < -1.0 ); f( a <= 1.0 );
 
+        // Shift behavior
+        eq( '${a >> 1}', "3397483648" );
+
         /* These are currently broken but should be fixed in the future:
 		 * Currently we don't allow UInt vs Int comparisons.
          * trace(a == -1794967296);