Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Int128 + its numeral literal suffix #11750

Open
wants to merge 100 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
8313293
Update Int64.hx
SomeGuyWhoLovesCoding Aug 22, 2024
7b5d61f
Update Int64Helper.hx
SomeGuyWhoLovesCoding Aug 22, 2024
e276fed
Create Int128.hx
SomeGuyWhoLovesCoding Aug 22, 2024
b6de9a0
Create Int128Helper.hx
SomeGuyWhoLovesCoding Aug 22, 2024
fe445d2
Update Int64Helper.hx
SomeGuyWhoLovesCoding Aug 22, 2024
03e401c
Update Int128.hx
SomeGuyWhoLovesCoding Aug 22, 2024
183fdb6
You don't even need throw checks if the number overflows
SomeGuyWhoLovesCoding Aug 22, 2024
bdfc1d6
Correct the max value
SomeGuyWhoLovesCoding Aug 22, 2024
01aaaa4
About to fix the parseString function
SomeGuyWhoLovesCoding Aug 22, 2024
507a836
Add Int128.ofInt64 overflow check and Int64 versions of the operator …
SomeGuyWhoLovesCoding Aug 22, 2024
d932d09
Update Int64.hx
SomeGuyWhoLovesCoding Aug 22, 2024
19e5360
Update Int64.hx
SomeGuyWhoLovesCoding Aug 22, 2024
738c5f6
Update Int64.hx
SomeGuyWhoLovesCoding Aug 22, 2024
58886f3
Update Int64Helper.hx
SomeGuyWhoLovesCoding Aug 22, 2024
037d3db
Update Int128Helper.hx
SomeGuyWhoLovesCoding Aug 22, 2024
cb40327
Update Int128.hx
SomeGuyWhoLovesCoding Aug 22, 2024
80b2b47
Update Int128.hx
SomeGuyWhoLovesCoding Aug 22, 2024
5fd7471
Update Int64Helper.hx
SomeGuyWhoLovesCoding Aug 22, 2024
685a529
Update Int64.hx
SomeGuyWhoLovesCoding Aug 22, 2024
75b7f71
I'm still tempted to fix that damn Int128 multiplication operator error
SomeGuyWhoLovesCoding Aug 22, 2024
9dcfa3d
Fuck it
SomeGuyWhoLovesCoding Aug 23, 2024
0c0d203
Update Int64Helper.hx
SomeGuyWhoLovesCoding Aug 23, 2024
3692b6e
Update Int128Helper.hx
SomeGuyWhoLovesCoding Aug 23, 2024
913c3db
Update Int128.hx
SomeGuyWhoLovesCoding Aug 24, 2024
5ac18c5
Update Int64.hx
SomeGuyWhoLovesCoding Aug 24, 2024
f2b5c0b
Update Int128.hx
SomeGuyWhoLovesCoding Aug 24, 2024
f32f7f4
Update Int64.hx
SomeGuyWhoLovesCoding Aug 24, 2024
4a21108
Update Int128Helper.hx
SomeGuyWhoLovesCoding Aug 24, 2024
3b9090f
Update Int64Helper.hx
SomeGuyWhoLovesCoding Aug 24, 2024
071aade
Update Int64Helper.hx
SomeGuyWhoLovesCoding Aug 24, 2024
d3d2146
Update Int128Helper.hx
SomeGuyWhoLovesCoding Aug 24, 2024
c6c01ee
Update Int64.hx
SomeGuyWhoLovesCoding Aug 24, 2024
8b36be6
Update Int128.hx
SomeGuyWhoLovesCoding Aug 24, 2024
f0dea72
Update Int128.hx
SomeGuyWhoLovesCoding Aug 24, 2024
5f616d5
Update Int128.hx
SomeGuyWhoLovesCoding Aug 24, 2024
52460de
Update Int64.hx
SomeGuyWhoLovesCoding Aug 24, 2024
0097f7b
Update Int64Helper.hx
SomeGuyWhoLovesCoding Aug 24, 2024
e7a2fb1
Update Int128Helper.hx
SomeGuyWhoLovesCoding Aug 24, 2024
95b5cc1
Update Int64Helper.hx
SomeGuyWhoLovesCoding Aug 24, 2024
a8295e7
Create Int128.hx
SomeGuyWhoLovesCoding Aug 24, 2024
e85821d
Delete tests/unit/src/unit/Int128.hx
SomeGuyWhoLovesCoding Aug 24, 2024
ef86192
Create TestInt128.hx
SomeGuyWhoLovesCoding Aug 24, 2024
47f52ad
Update Int128Helper.hx
SomeGuyWhoLovesCoding Aug 24, 2024
e1b4199
Implement numeric literal suffix for Int128
SomeGuyWhoLovesCoding Aug 25, 2024
8957662
Update reification.ml
SomeGuyWhoLovesCoding Aug 25, 2024
084527b
Update macroApi.ml
SomeGuyWhoLovesCoding Aug 25, 2024
1429f0e
Update typer.ml
SomeGuyWhoLovesCoding Aug 25, 2024
fc2b350
Update typer.ml
SomeGuyWhoLovesCoding Aug 25, 2024
7ba4ccf
Update typer.ml
SomeGuyWhoLovesCoding Aug 25, 2024
93d7d77
Update typer.ml
SomeGuyWhoLovesCoding Aug 25, 2024
71caec4
Update typer.ml
SomeGuyWhoLovesCoding Aug 25, 2024
18f40b3
Update typer.ml
SomeGuyWhoLovesCoding Aug 25, 2024
4841673
Update typer.ml
SomeGuyWhoLovesCoding Aug 25, 2024
9cc7a8f
Update typer.ml
SomeGuyWhoLovesCoding Aug 25, 2024
c90eb0b
Update typer.ml
SomeGuyWhoLovesCoding Aug 25, 2024
e394575
Oops
SomeGuyWhoLovesCoding Aug 25, 2024
40d1169
Add Std.parseInt64 and Std.parseInt128
SomeGuyWhoLovesCoding Aug 25, 2024
a4e98fc
Actually, nah
SomeGuyWhoLovesCoding Aug 25, 2024
9965db8
Update Int64.hx
SomeGuyWhoLovesCoding Sep 2, 2024
3b6c0db
Update Int128Helper.hx
SomeGuyWhoLovesCoding Sep 2, 2024
23120d8
Update Int64Helper.hx
SomeGuyWhoLovesCoding Sep 2, 2024
5802e58
Update Int64Helper.hx
SomeGuyWhoLovesCoding Sep 2, 2024
0f2444c
Update Int128Helper.hx
SomeGuyWhoLovesCoding Sep 2, 2024
01ac650
FUCK I'm sorry about that
SomeGuyWhoLovesCoding Sep 2, 2024
dea16a1
Update Int128.hx
SomeGuyWhoLovesCoding Sep 2, 2024
31960cd
Update Int64.hx
SomeGuyWhoLovesCoding Sep 2, 2024
0b357bc
Update Int128.hx
SomeGuyWhoLovesCoding Sep 2, 2024
bc5006d
Update Int128Helper.hx
SomeGuyWhoLovesCoding Sep 3, 2024
4360564
Update Int128Helper.hx
SomeGuyWhoLovesCoding Sep 3, 2024
be1dbc3
Update Int64Helper.hx
SomeGuyWhoLovesCoding Sep 3, 2024
1bb1838
Update Int64Helper.hx
SomeGuyWhoLovesCoding Sep 3, 2024
86d7230
Update Int128Helper.hx
SomeGuyWhoLovesCoding Sep 3, 2024
89bcc55
Update Int64.hx
SomeGuyWhoLovesCoding Sep 3, 2024
f6ae5db
Update Int128.hx
SomeGuyWhoLovesCoding Sep 3, 2024
06be641
Update Int64.hx
SomeGuyWhoLovesCoding Sep 3, 2024
052021e
Update Int128.hx
SomeGuyWhoLovesCoding Sep 3, 2024
fc5a0d6
Update Int64Helper.hx
SomeGuyWhoLovesCoding Sep 4, 2024
b018ce6
Update Int128Helper.hx
SomeGuyWhoLovesCoding Sep 4, 2024
7d83e82
Update Int64Helper.hx
SomeGuyWhoLovesCoding Sep 4, 2024
d6a5472
Update Int64.hx
SomeGuyWhoLovesCoding Sep 4, 2024
7960ccd
Update Int128.hx
SomeGuyWhoLovesCoding Sep 4, 2024
5fe6742
Fuck I didn't mean to do that
SomeGuyWhoLovesCoding Sep 4, 2024
fd8e3bf
Upgrade `File.getBytes` to have starting position and length.
SomeGuyWhoLovesCoding Sep 9, 2024
b827366
Update File.hx
SomeGuyWhoLovesCoding Sep 9, 2024
c55bf59
Update NativeFile.hx
SomeGuyWhoLovesCoding Sep 9, 2024
1f99fb2
Update File.hx
SomeGuyWhoLovesCoding Sep 9, 2024
e3f55ef
Update NativeFile.hx
SomeGuyWhoLovesCoding Sep 9, 2024
22847ae
Update File.hx
SomeGuyWhoLovesCoding Sep 9, 2024
cbadeec
Update File.hx
SomeGuyWhoLovesCoding Sep 10, 2024
75f80d6
Update File.hx
SomeGuyWhoLovesCoding Sep 10, 2024
1ba2fc6
Update File.hx
SomeGuyWhoLovesCoding Sep 10, 2024
f2473d8
Update File.hx
SomeGuyWhoLovesCoding Sep 10, 2024
ac937d4
Update File.hx
SomeGuyWhoLovesCoding Sep 10, 2024
f4100f8
Update File.hx
SomeGuyWhoLovesCoding Sep 10, 2024
f7bcc10
Update File.hx
SomeGuyWhoLovesCoding Sep 10, 2024
66550f7
Update File.hx
SomeGuyWhoLovesCoding Sep 10, 2024
443b24b
Update File.hx
SomeGuyWhoLovesCoding Sep 10, 2024
d93acf6
Update File.hx
SomeGuyWhoLovesCoding Sep 10, 2024
4c444fe
Update Bytes.hx
SomeGuyWhoLovesCoding Sep 10, 2024
7bc84e1
Update Bytes.hx
SomeGuyWhoLovesCoding Sep 10, 2024
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
2 changes: 1 addition & 1 deletion src/macro/macroApi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ let decode_const c =
| 0, [s;suffix] ->
let decoded_suffix = opt decode_string suffix in
(match decoded_suffix with
| None | Some "i32" | Some "i64" | Some "u32" ->
| None | Some "i32" | Some "i64" | Some "i128" | Some "u32" ->
Int (decode_string s, decoded_suffix)
| Some other ->
raise Invalid_expr)
Expand Down
2 changes: 2 additions & 0 deletions src/syntax/reification.ml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ let reify in_macro =
| EParenthesis (ECheckType (e2, (CTPath({path = {tname="Float";tpackage=[]}}),_)),_) -> expr "EConst" [mk_enum "Constant" "CFloat" [e2] (pos e2)]
| EConst (Int (s, Some "i64")) ->
expr "EConst" [mk_enum "Constant" "CInt" [ (EConst(String (s, SDoubleQuotes)),(pos e1)); (EConst(String ("i64", SDoubleQuotes)),(pos e1)) ] (pos e1)]
| EConst (Int (s, Some "i128")) ->
expr "EConst" [mk_enum "Constant" "CInt" [ (EConst(String (s, SDoubleQuotes)),(pos e1)); (EConst(String ("i128", SDoubleQuotes)),(pos e1)) ] (pos e1)]
| _ ->
(ECall ((efield ((efield ((efield ((EConst (Ident "haxe"),p),"macro"),p),"Context"),p),"makeExpr"),p),[e1; to_enc_pos (pos e1)]),p)
end
Expand Down
19 changes: 19 additions & 0 deletions src/typing/typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,25 @@ and type_expr ?(mode=MGet) ctx (e,p) (with_type:WithType.t) =
let arg_low = EConst (Int (Int32.to_string low, None)), p in
let call = ECall (field, [ arg_high; arg_low ]), p in
type_expr ctx call with_type
| "i128" ->
if String.length s > 34 && String.sub s 0 2 = "0x" then raise_typing_error "Invalid hexadecimal integer" p;

(*
This uses a different method apart from the i64 suffix code.
This is because ocaml doesn't have an Int128 type.
I, SomeGuyWhoLikesCoding, am NOT familiar with the ocaml syntax.
*)

let high = Int64.of_string (String.sub s 2 18) in
let low = Int64.of_string (String.sub s 19 34) in

let ident = EConst (Ident "haxe"), p in
let field = efield ((efield (ident, "Int128"), p), "make"), p in

let arg_high = EConst (Int (Int64.to_string(high), Some "i64")), p in
let arg_low = EConst (Int (Int64.to_string(low), Some "i64")), p in
let call = ECall (field, [ arg_high; arg_low ]), p in
type_expr ctx call with_type
| "u32" ->
let check = ECheckType ((EConst (Int (s, None)), p), (make_ptp_th (mk_type_path ([],"UInt")) p)), p in
type_expr ctx check with_type
Expand Down
Loading