|
@@ -23,128 +23,130 @@
|
|
|
* DAMAGE.
|
|
|
*/
|
|
|
package haxe;
|
|
|
-
|
|
|
-private typedef NativeInt64 = Int64;
|
|
|
+using haxe.Int64;
|
|
|
+private typedef NativeInt64 = Int;
|
|
|
|
|
|
@:nativegen class Int64
|
|
|
{
|
|
|
- public static inline function make( high : Int32, low : Int32 ) : Int64
|
|
|
+ @:extern private static inline function asNative(i:haxe.Int64):NativeInt64 return untyped i
|
|
|
+ @:extern private static inline function ofNative(i:NativeInt64):haxe.Int64 return untyped i
|
|
|
+ @:extern private static inline function mkNative(i:Dynamic):NativeInt64 return i
|
|
|
+
|
|
|
+ public static inline function make( high : Int32, low : Int32 ) : haxe.Int64
|
|
|
{
|
|
|
- return (cast(high, NativeInt64) << 32 ) | (cast(low, NativeInt64));
|
|
|
+ return ((cast(high, NativeInt64) << 32 ) | (cast(low, NativeInt64))).ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function ofInt( x : Int ) : Int64 {
|
|
|
+ public static inline function ofInt( x : Int ) : haxe.Int64 {
|
|
|
return cast x;
|
|
|
}
|
|
|
|
|
|
- public static inline function ofInt32( x : Int32 ) : Int64 {
|
|
|
+ public static inline function ofInt32( x : Int32 ) : haxe.Int64 {
|
|
|
return cast x;
|
|
|
}
|
|
|
|
|
|
- public static inline function toInt( x : Int64 ) : Int
|
|
|
+ public static inline function toInt( x : haxe.Int64 ) : Int
|
|
|
{
|
|
|
return cast x;
|
|
|
}
|
|
|
|
|
|
- public static inline function getLow( x : Int64 ) : Int32
|
|
|
+ public static inline function getLow( x : haxe.Int64 ) : Int32
|
|
|
{
|
|
|
- return cast x;
|
|
|
+ return cast (x.asNative() & 0xFFFFFFFF.mkNative());
|
|
|
}
|
|
|
|
|
|
- public static inline function getHigh( x : Int64 ) : Int32
|
|
|
+ public static inline function getHigh( x : haxe.Int64 ) : Int32
|
|
|
{
|
|
|
- return cast (cast(x,NativeInt64) >>> 32, Int32);
|
|
|
+ return cast(cast(x,NativeInt64) >>> 32, Int32);
|
|
|
}
|
|
|
|
|
|
- public static inline function add( a : Int64, b : Int64 ) : Int64
|
|
|
+ public static inline function add( a : haxe.Int64, b : haxe.Int64 ) : haxe.Int64
|
|
|
{
|
|
|
- return cast(a, NativeInt64) + cast(b, NativeInt64);
|
|
|
+ return (a.asNative() + b.asNative()).ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function sub( a : Int64, b : Int64 ) : Int64
|
|
|
+ public static inline function sub( a : haxe.Int64, b : haxe.Int64 ) : haxe.Int64
|
|
|
{
|
|
|
- return cast(a, NativeInt64) - cast(b, NativeInt64);
|
|
|
+ return (a.asNative() - b.asNative()).ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function mul( a : Int64, b : Int64 ) : Int64 {
|
|
|
- return cast(a, NativeInt64) * cast(b, NativeInt64);
|
|
|
+ public static inline function mul( a : haxe.Int64, b : haxe.Int64 ) : haxe.Int64 {
|
|
|
+ return (a.asNative() * b.asNative()).ofNative();
|
|
|
}
|
|
|
|
|
|
- static function divMod( modulus : Int64, divisor : Int64 )
|
|
|
+ static function divMod( modulus : haxe.Int64, divisor : haxe.Int64 )
|
|
|
{
|
|
|
- var q:NativeInt64 = cast (cast(modulus, NativeInt64) / cast(divisor, NativeInt64));
|
|
|
- var m:NativeInt64 = cast(modulus, NativeInt64) % cast(divisor, NativeInt64);
|
|
|
+ var q:Int64 = (modulus.asNative() / divisor.asNative()).mkNative().ofNative();
|
|
|
+ var m:Int64 = (modulus.asNative() % divisor.asNative()).mkNative().ofNative();
|
|
|
return { quotient : q, modulus : m };
|
|
|
}
|
|
|
|
|
|
- public static inline function div( a : Int64, b : Int64 ) : Int64 {
|
|
|
- return cast (cast(a, NativeInt64) / cast(b, NativeInt64));
|
|
|
+ public static inline function div( a : haxe.Int64, b : haxe.Int64 ) : haxe.Int64 {
|
|
|
+ return (a.asNative() / b.asNative()).mkNative().ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function mod( a : Int64, b : Int64 ) : Int64 {
|
|
|
- return cast(a, NativeInt64) % cast(b, NativeInt64);
|
|
|
+ public static inline function mod( a : haxe.Int64, b : haxe.Int64 ) : haxe.Int64 {
|
|
|
+ return (a.asNative() % b.asNative()).mkNative().ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function shl( a : Int64, b : Int ) : Int64 {
|
|
|
- return cast(a, NativeInt64) << cast(b, NativeInt64);
|
|
|
+ public static inline function shl( a : haxe.Int64, b : Int ) : haxe.Int64 {
|
|
|
+ return (a.asNative() << b).ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function shr( a : Int64, b : Int ) : Int64 {
|
|
|
- return cast(a, NativeInt64) >> cast(b, NativeInt64);
|
|
|
+ public static inline function shr( a : haxe.Int64, b : Int ) : haxe.Int64 {
|
|
|
+ return (a.asNative() >> b).ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function ushr( a : Int64, b : Int ) : Int64 {
|
|
|
- return cast(a, NativeInt64) >>> b;
|
|
|
+ public static inline function ushr( a : haxe.Int64, b : Int ) : haxe.Int64 {
|
|
|
+ return (a.asNative() >>> b).ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function and( a : Int64, b : Int64 ) : Int64
|
|
|
+ public static inline function and( a : haxe.Int64, b : haxe.Int64 ) : haxe.Int64
|
|
|
{
|
|
|
- return cast(a, NativeInt64) & cast(b, NativeInt64);
|
|
|
+ return (a.asNative() & b.asNative()).ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function or( a : Int64, b : Int64 ) : Int64
|
|
|
+ public static inline function or( a : haxe.Int64, b : haxe.Int64 ) : haxe.Int64
|
|
|
{
|
|
|
- return cast(a, NativeInt64) | cast(b, NativeInt64);
|
|
|
+ return (a.asNative() | b.asNative()).ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function xor( a : Int64, b : Int64 ) : Int64
|
|
|
+ public static inline function xor( a : haxe.Int64, b : haxe.Int64 ) : haxe.Int64
|
|
|
{
|
|
|
- return cast(a, NativeInt64) ^ cast(b, NativeInt64);
|
|
|
+ return (a.asNative() ^ b.asNative()).ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function neg( a : Int64 ) : Int64
|
|
|
+ public static inline function neg( a : haxe.Int64 ) : haxe.Int64
|
|
|
{
|
|
|
- return -cast(a, NativeInt64);
|
|
|
+ return (~a.asNative()).ofNative();
|
|
|
}
|
|
|
|
|
|
- public static inline function isNeg( a : Int64 ) : Bool
|
|
|
+ public static inline function isNeg( a : haxe.Int64 ) : Bool
|
|
|
{
|
|
|
- return cast(a, NativeInt64) < cast(0, NativeInt64);
|
|
|
+ return (a.asNative() < 0.mkNative());
|
|
|
}
|
|
|
|
|
|
- public static inline function isZero( a : Int64 ) : Bool
|
|
|
+ public static inline function isZero( a : haxe.Int64 ) : Bool
|
|
|
{
|
|
|
- return cast(a, NativeInt64) == cast(0, NativeInt64);
|
|
|
+ return (a.asNative() == 0.mkNative());
|
|
|
}
|
|
|
|
|
|
- public static inline function compare( a : Int64, b : Int64 ) : Int
|
|
|
+ public static inline function compare( a : haxe.Int64, b : haxe.Int64 ) : Int
|
|
|
{
|
|
|
- return cast(cast(a, NativeInt64) - cast(b, NativeInt64), Int);
|
|
|
+ return cast (a.asNative() - b.asNative());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
Compare two Int64 in unsigned mode.
|
|
|
**/
|
|
|
- public static function ucompare( a : Int64, b : Int64 ) : Int
|
|
|
+ public static function ucompare( a : haxe.Int64, b : haxe.Int64 ) : Int
|
|
|
{
|
|
|
- var a:NativeInt64 = cast a;
|
|
|
- var b:NativeInt64 = cast b;
|
|
|
- if (a < cast(0, NativeInt64))
|
|
|
- return (b < cast(0, NativeInt64)) ? compare(~a, ~b) : 1;
|
|
|
- return (b < cast(0, NativeInt64)) ? -1 : compare(a, b);
|
|
|
+ if (a.asNative() < 0.mkNative())
|
|
|
+ return (b.asNative() < 0.mkNative()) ? compare( (~a.asNative()).ofNative(), (~b.asNative()).ofNative()) : 1;
|
|
|
+ return (b.asNative() < 0.mkNative()) ? -1 : compare(a, b);
|
|
|
}
|
|
|
|
|
|
- public static inline function toStr( a : Int64 ) : String {
|
|
|
+ public static inline function toStr( a : haxe.Int64 ) : String {
|
|
|
return a + "";
|
|
|
}
|
|
|
}
|