Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion std/hl/I64.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,22 @@

package hl;

@:coreType @:notNull @:runtimeValue abstract I64 from Int {
import haxe.Int64;

@:coreType @:notNull @:runtimeValue abstract I64 {
/** The greatest representable I64 value. */
static public var MAX(get,never):I64;
@:hlNative("std", "num_i64_max") static function get_MAX():I64
return 0;

/** The smallest representable I64 value. */
static public var MIN(get,never):I64;
@:hlNative("std", "num_i64_min") static function get_MIN():I64
return 0;

@:hlNative("std", "num_i64_of_int")
@:from public static function ofInt(i:Int):I64
return cast 0;

/**
Destructively cast to Int
Expand All @@ -37,4 +52,48 @@ package hl;
return toInt();
}

/**
Parse the given string value to I64.
**/
@:hlNative("std", "num_i64_of_string")
static public function ofString(s:String):I64;

/**
Convert `haxe.Int64` to `hl.uv.I64`
**/
@:from static public function ofInt64(hx:Int64):I64 {
return ((hx.high:I64) << 32) | (hx.low:I64);
}

/**
Convert to `haxe.Int64`
**/
@:to public function toInt64():Int64 {
return Int64.make((this >> 32).toInt(), this.toInt());
}

/**
Integer division.
**/
@:hlNative("std", "num_i64_div")
public function div(i:I64):I64
return 0;

@:op(A + B) @:hlNative("std", "num_i64_add") function add(u:I64):I64 return 0;
@:op(A - B) @:hlNative("std", "num_i64_sub") function sub(u:I64):I64 return 0;
@:op(A * B) @:hlNative("std", "num_i64_mul") function mul(u:I64):I64 return 0;
@:op(A % B) @:hlNative("std", "num_i64_mod") function mod(u:I64):I64 return 0;
@:op(A & B) @:hlNative("std", "num_i64_logand") function logand(u:I64):I64 return 0;
@:op(A | B) @:hlNative("std", "num_i64_logor") function logor(u:I64):I64 return 0;
@:op(A ^ B) @:hlNative("std", "num_i64_logxor") function logxor(u:I64):I64 return 0;
@:op(A << B) @:hlNative("std", "num_i64_shift_left") function shift_left(i:Int):I64 return 0;
@:op(A >> B) @:hlNative("std", "num_i64_shift_right") function shift_right(i:Int):I64 return 0;
@:op(~A) @:hlNative("std", "num_i64_lognot") function lognot():I64 return 0;

@:op(A != B) static function ne(a:I64, b:I64):Bool return !eq(a, b);
@:op(A == B) @:hlNAtive("std", "num_i64_eq") static function eq(a:I64, b:I64):Bool return false;
@:op(A < B) @:hlNAtive("std", "num_i64_lt") static function lt(a:I64, b:I64):Bool return false;
@:op(A > B) @:hlNAtive("std", "num_i64_gt") static function gt(a:I64, b:I64):Bool return false;
@:op(A <= B) @:hlNAtive("std", "num_i64_lte") static function lte(a:I64, b:I64):Bool return false;
@:op(A >= B) @:hlNAtive("std", "num_i64_gte") static function gte(a:I64, b:I64):Bool return false;
}