123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- /*
- * Copyright (C)2005-2012 Haxe Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
- package haxe;
- using haxe.Int64;
- private typedef __Int64 = java.StdTypes.Int64;
- @:coreApi
- abstract Int64(__Int64) from __Int64 to __Int64
- {
- public static inline function make( high : Int32, low : Int32 ) : Int64
- return new Int64( (cast(high, __Int64) << 32) | (low & untyped __java__('0xffffffffL')) );
- private inline function new(x : __Int64)
- this = x;
- private var val( get, set ) : __Int64;
- inline function get_val() : __Int64 return this;
- inline function set_val( x : __Int64 ) : __Int64 return this = x;
- public inline function copy():Int64
- return new Int64( this );
- @:from public static inline function ofInt( x : Int ) : Int64
- return cast x;
- public static inline function toInt( x : Int64 ) : Int {
- if( x.val < 0x80000000 || x.val > 0x7FFFFFFF )
- throw "Overflow";
- return cast x.val;
- }
- public static inline function getHigh( x : Int64 ) : Int32
- return cast( x.val >> 32 );
- public static inline function getLow( x : Int64 ) : Int32
- return cast( x.val );
- public static inline function isNeg( x : Int64 ) : Bool
- return x.val < 0;
- public static inline function isZero( x : Int64 ) : Bool
- return x.val == 0;
- public static inline function compare( a : Int64, b : Int64 ) : Int
- {
- if( a.val < b.val ) return -1;
- if( a.val > b.val ) return 1;
- return 0;
- }
- public static inline function ucompare( a : Int64, b : Int64 ) : Int {
- if( a.val < 0 )
- return ( b.val < 0 ) ? compare( a, b ) : 1;
- return ( b.val < 0 ) ? -1 : compare( a, b );
- }
- public static inline function toStr( x : Int64 ) : String
- return x.val + "";
- public static inline function divMod( dividend : Int64, divisor : Int64 ) : { quotient : Int64, modulus : Int64 }
- return {quotient:0,modulus:0};//{ quotient: dividend / divisor, modulus: dividend % divisor };
- private inline function toString() : String
- return this + "";
- @:op(-A) public static function neg( x : Int64 ) : Int64
- return -x.val;
- @:op(++A) private inline function preIncrement() : Int64
- return ++this;
- @:op(A++) private inline function postIncrement() : Int64
- return this++;
- @:op(--A) private inline function preDecrement() : Int64
- return --this;
- @:op(A--) private inline function postDecrement() : Int64
- return this--;
-
- @:op(A + B) public static inline function add( a : Int64, b : Int64 ) : Int64
- return a.val + b.val;
- @:op(A + B) @:commutative private static inline function addInt( a : Int64, b : Int ) : Int64
- return a.val + b;
- @:op(A - B) public static inline function sub( a : Int64, b : Int64 ) : Int64
- return a.val - b.val;
- @:op(A - B) private static inline function subInt( a : Int64, b : Int ) : Int64
- return a.val - b;
- @:op(A - B) private static inline function intSub( a : Int, b : Int64 ) : Int64
- return a - b.val;
- @:op(A * B) public static inline function mul( a : Int64, b : Int64 ) : Int64
- return a.val * b.val;
- @:op(A * B) @:commutative private static inline function mulInt( a : Int64, b : Int ) : Int64
- return a.val * b;
- @:op(A / B) public static inline function div( a : Int64, b : Int64 ) : Int64
- return a.val / b.val;
- @:op(A / B) private static inline function divInt( a : Int64, b : Int ) : Int64
- return a.val / b;
- @:op(A / B) private static inline function intDiv( a : Int, b : Int64 ) : Int64
- return a / b.val;
- @:op(A % B) public static inline function mod( a : Int64, b : Int64 ) : Int64
- return a.val % b.val;
- @:op(A % B) private static inline function modInt( a : Int64, b : Int ) : Int64
- return a.val % b;
- @:op(A % B) private static inline function intMod( a : Int, b : Int64 ) : Int64
- return a % b.val;
- @:op(A == B) public static inline function eq( a : Int64, b : Int64 ) : Bool
- return a.val == b.val;
- @:op(A == B) @:commutative private static inline function eqInt( a : Int64, b : Int ) : Bool
- return a.val == b;
- @:op(A != B) public static inline function neq( a : Int64, b : Int64 ) : Bool
- return a.val != b.val;
- @:op(A != B) @:commutative private static inline function neqInt( a : Int64, b : Int ) : Bool
- return a.val != b;
- @:op(A < B) private static inline function lt( a : Int64, b : Int64 ) : Bool
- return a.val < b.val;
- @:op(A < B) private static inline function ltInt( a : Int64, b : Int ) : Bool
- return a.val < b;
- @:op(A < B) private static inline function intLt( a : Int, b : Int64 ) : Bool
- return a < b.val;
- @:op(A <= B) private static inline function lte( a : Int64, b : Int64 ) : Bool
- return a.val <= b.val;
- @:op(A <= B) private static inline function lteInt( a : Int64, b : Int ) : Bool
- return a.val <= b;
- @:op(A <= B) private static inline function intLte( a : Int, b : Int64 ) : Bool
- return a <= b.val;
- @:op(A > B) private static inline function gt( a : Int64, b : Int64 ) : Bool
- return a.val > b.val;
- @:op(A > B) private static inline function gtInt( a : Int64, b : Int ) : Bool
- return a.val > b;
- @:op(A > B) private static inline function intGt( a : Int, b : Int64 ) : Bool
- return a > b.val;
- @:op(A >= B) private static inline function gte( a : Int64, b : Int64 ) : Bool
- return a.val >= b.val;
- @:op(A >= B) private static inline function gteInt( a : Int64, b : Int ) : Bool
- return a.val >= b;
- @:op(A >= B) private static inline function intGte( a : Int, b : Int64 ) : Bool
- return a >= b.val;
- @:op(~A) private static inline function complement( x : Int64 ) : Int64
- return ~x.val;
- @:op(A & B) public static inline function and( a : Int64, b : Int64 ) : Int64
- return a.val & b.val;
- @:op(A | B) public static inline function or( a : Int64, b : Int64 ) : Int64
- return a.val | b.val;
- @:op(A ^ B) public static inline function xor( a : Int64, b : Int64 ) : Int64
- return a.val ^ b.val;
- @:op(A << B) public static inline function shl( a : Int64, b : Int ) : Int64
- return a.val << b;
- @:op(A >> B) public static inline function shr( a : Int64, b : Int ) : Int64
- return a.val >> b;
- @:op(A >>> B) public static inline function ushr( a : Int64, b : Int ) : Int64
- return a.val >>> b;
- }
|