Skip to content

Commit 9985abe

Browse files
committed
WIP
1 parent 0fbf132 commit 9985abe

File tree

7 files changed

+368
-369
lines changed

7 files changed

+368
-369
lines changed

compiler/lib/js_traverse.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,13 +1707,13 @@ class simpl =
17071707
match e1, e2 with
17081708
| _, ENum n when Num.is_neg n -> EBin (Minus, e1, ENum (Num.neg n))
17091709
| ENum n, _ when Num.is_neg n -> EBin (Minus, e2, ENum (Num.neg n))
1710-
| ENum zero, (ENum _ as x) when is_zero zero -> x
1711-
| (ENum _ as x), ENum zero when is_zero zero -> x
1710+
| ENum zero, (ENum _ as x) when Num.is_zero zero -> x
1711+
| (ENum _ as x), ENum zero when Num.is_zero zero -> x
17121712
| _ -> e)
17131713
| EBin (Minus, e1, e2) -> (
17141714
match e1, e2 with
17151715
| _, ENum n when Num.is_neg n -> EBin (Plus, e1, ENum (Num.neg n))
1716-
| (ENum _ as x), ENum zero when is_zero zero -> x
1716+
| (ENum _ as x), ENum zero when Num.is_zero zero -> x
17171717
| _ -> e)
17181718
| EFun
17191719
(None, (({ generator = false; async = true | false }, _, body, _) as fun_decl))

compiler/tests-compiler/array_access.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ let%expect_test "array_set" =
3333
print_fun_decl program (Some "some_name");
3434
[%expect
3535
{|
36-
function some_name(a, n){runtime.caml_check_bound(a, n)[1 + n] = n; return 1;}
37-
//end |}]
36+
function some_name(a, n){runtime.caml_check_bound(a, n)[n + 1] = n; return 1;}
37+
//end
38+
|}]
3839

3940
let%expect_test "array_set" =
4041
compile_and_run array_set;

compiler/tests-compiler/gh1354.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ with Exit ->
6767
catch(_e_){
6868
var _c_ = caml_wrap_exception(_e_);
6969
if(_c_ !== Stdlib[3]) throw caml_maybe_attach_backtrace(_c_, 0);
70-
caml_call2(Stdlib_Printf[3], _d_, _b_ | 0);
70+
caml_call2(Stdlib_Printf[3], _d_, _b_ + 0 | 0);
7171
var Test = [0];
7272
runtime.caml_register_global(3, Test, "Test");
7373
0;
@@ -148,14 +148,14 @@ with Exit ->
148148
throw caml_maybe_attach_backtrace(Stdlib[3], 1);
149149
}
150150
catch(_k_){
151-
caml_call3(Stdlib_Printf[3], _h_, _g_ | 0, _b_);
151+
caml_call3(Stdlib_Printf[3], _h_, _g_ + 0 | 0, _b_);
152152
throw caml_maybe_attach_backtrace(Stdlib[3], 1);
153153
}
154154
}
155155
catch(_j_){
156156
var _d_ = caml_wrap_exception(_j_);
157157
if(_d_ !== Stdlib[3]) throw caml_maybe_attach_backtrace(_d_, 0);
158-
caml_call3(Stdlib_Printf[3], _e_, _c_ | 0, _b_);
158+
caml_call3(Stdlib_Printf[3], _e_, _c_ + 0 | 0, _b_);
159159
var Test = [0];
160160
runtime.caml_register_global(4, Test, "Test");
161161
0;

compiler/tests-compiler/gh1768.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let () =
5656
Assert_failure = global_data.Assert_failure,
5757
_a_ = [0, caml_string_of_jsbytes("test.ml"), 4, 27],
5858
_b_ = [0, caml_string_of_jsbytes("test.ml"), 8, 2];
59-
function h(x){x[1] = function(x, y){return x + y | 0;};}
59+
function h(x){x[1] = runtime.caml_add;}
6060
function f(param){
6161
return [0,
6262
function(param){
@@ -73,4 +73,5 @@ let () =
7373
return;
7474
}
7575
(globalThis));
76-
//end |}]
76+
//end
77+
|}]

compiler/tests-compiler/gh747.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ end
334334
114: /*<<test.ml:66:6>>*/ return caml_call2(Stdlib_Printf[1], outchan, _d_) /*<<test.ml:73:10>>*/ ;
335335
115: var
336336
116: a = /*<<test.ml:64:2>>*/ backtrace[1],
337-
117: _f_ = /*<<test.ml:69:6>>*/ a.length - 2 | 0,
337+
117: _f_ = /*<<test.ml:69:6>>*/ a.length - 1 - 1 | 0,
338338
118: _e_ = 0;
339339
119: if(_f_ >= 0){
340340
120: var i = _e_;

compiler/tests-compiler/obj.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ let%expect_test "static eval of string get" =
5252
//end
5353
function my_size(x){return x.length - 1;}
5454
//end
55-
function my_field(x, i){return x[1 + i];}
56-
//end
57-
function my_set_field(x, i, o){x[1 + i] = o; return 0;}
55+
not found
56+
function my_set_field(x, i, o){x[i + 1] = o; return 0;}
5857
//end
5958
function my_new_block(x, l){return runtime.caml_obj_block(x + 1 | 0, 3);}
6059
//end
6160
function my_dup(t){return runtime.caml_obj_dup([0, t, 0]);}
62-
//end |}]
61+
//end
62+
|}]

0 commit comments

Comments
 (0)