|
@@ -67,7 +67,7 @@ abstract Int32(Int) from Int to Int {
|
|
|
|
|
|
@:op(A - B) public static function floatSub(a:Float, b:Int32):Float;
|
|
@:op(A - B) public static function floatSub(a:Float, b:Int32):Float;
|
|
|
|
|
|
- #if (as3 || js || php || python)
|
|
|
|
|
|
+ #if (as3 || js || php || python || lua)
|
|
|
|
|
|
@:op(A * B) private static function mul(a:Int32, b:Int32):Int32
|
|
@:op(A * B) private static function mul(a:Int32, b:Int32):Int32
|
|
return clamp( (a : Int) * ((b : Int) & 0xFFFF) + clamp( (a : Int) * ((b : Int) >>> 16) << 16 ) );
|
|
return clamp( (a : Int) * ((b : Int) & 0xFFFF) + clamp( (a : Int) * ((b : Int) >>> 16) << 16 ) );
|
|
@@ -133,8 +133,15 @@ abstract Int32(Int) from Int to Int {
|
|
@:op(A & B) private static function and(a:Int32, b:Int32):Int32;
|
|
@:op(A & B) private static function and(a:Int32, b:Int32):Int32;
|
|
@:op(A & B) @:commutative private static function andInt(a:Int32, b:Int):Int32;
|
|
@:op(A & B) @:commutative private static function andInt(a:Int32, b:Int):Int32;
|
|
|
|
|
|
|
|
+#if lua
|
|
|
|
+ @:op(A | B) private static function or(a:Int32, b:Int32):Int32
|
|
|
|
+ return clamp((a:Int) | (b:Int));
|
|
|
|
+ @:op(A | B) @:commutative private static function orInt(a:Int32, b:Int):Int32
|
|
|
|
+ return clamp((a:Int) | (b:Int));
|
|
|
|
+#else
|
|
@:op(A | B) private static function or(a:Int32, b:Int32):Int32;
|
|
@:op(A | B) private static function or(a:Int32, b:Int32):Int32;
|
|
@:op(A | B) @:commutative private static function orInt(a:Int32, b:Int):Int32;
|
|
@:op(A | B) @:commutative private static function orInt(a:Int32, b:Int):Int32;
|
|
|
|
+#end
|
|
|
|
|
|
@:op(A ^ B) private static function xor(a:Int32, b:Int32):Int32;
|
|
@:op(A ^ B) private static function xor(a:Int32, b:Int32):Int32;
|
|
@:op(A ^ B) @:commutative private static function xorInt(a:Int32, b:Int):Int32;
|
|
@:op(A ^ B) @:commutative private static function xorInt(a:Int32, b:Int):Int32;
|
|
@@ -148,7 +155,7 @@ abstract Int32(Int) from Int to Int {
|
|
@:op(A >>> B) private static function ushrInt(a:Int32, b:Int):Int32;
|
|
@:op(A >>> B) private static function ushrInt(a:Int32, b:Int):Int32;
|
|
@:op(A >>> B) private static function intUshr(a:Int, b:Int32):Int32;
|
|
@:op(A >>> B) private static function intUshr(a:Int, b:Int32):Int32;
|
|
|
|
|
|
- #if (php || python)
|
|
|
|
|
|
+ #if (php || python || lua)
|
|
|
|
|
|
// PHP may be 64-bit, so shifts must be clamped
|
|
// PHP may be 64-bit, so shifts must be clamped
|
|
@:op(A << B) private static inline function shl(a:Int32, b:Int32):Int32
|
|
@:op(A << B) private static inline function shl(a:Int32, b:Int32):Int32
|
|
@@ -158,7 +165,7 @@ abstract Int32(Int) from Int to Int {
|
|
return clamp( (a : Int) << b );
|
|
return clamp( (a : Int) << b );
|
|
|
|
|
|
@:op(A << B) private static inline function intShl(a:Int, b:Int32):Int32
|
|
@:op(A << B) private static inline function intShl(a:Int, b:Int32):Int32
|
|
- return clamp( a << (b : Int) );
|
|
|
|
|
|
+ return clamp( a << (b : Int) );
|
|
|
|
|
|
#else
|
|
#else
|
|
|
|
|
|
@@ -184,7 +191,8 @@ abstract Int32(Int) from Int to Int {
|
|
static var extraBits : Int = untyped __php__("PHP_INT_SIZE") * 8 - 32;
|
|
static var extraBits : Int = untyped __php__("PHP_INT_SIZE") * 8 - 32;
|
|
#end
|
|
#end
|
|
|
|
|
|
- static inline function clamp( x : Int ) : Int {
|
|
|
|
|
|
+#if !lua inline #end
|
|
|
|
+ static function clamp( x : Int ) : Int {
|
|
// force to-int conversion on platforms that require it
|
|
// force to-int conversion on platforms that require it
|
|
#if (as3 || js)
|
|
#if (as3 || js)
|
|
return x | 0;
|
|
return x | 0;
|
|
@@ -193,6 +201,8 @@ abstract Int32(Int) from Int to Int {
|
|
return (x << extraBits) >> extraBits;
|
|
return (x << extraBits) >> extraBits;
|
|
#elseif python
|
|
#elseif python
|
|
return python.Syntax.pythonCode("{0} % {1}", (x + python.Syntax.opPow(2, 31)), python.Syntax.opPow(2, 32)) - python.Syntax.opPow(2, 31);
|
|
return python.Syntax.pythonCode("{0} % {1}", (x + python.Syntax.opPow(2, 31)), python.Syntax.opPow(2, 32)) - python.Syntax.opPow(2, 31);
|
|
|
|
+ #elseif lua
|
|
|
|
+ return (x & 2147483647) - (x & cast 2147483648);
|
|
#else
|
|
#else
|
|
return (x);
|
|
return (x);
|
|
#end
|
|
#end
|