Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Apr 20, 2023
1 parent fbadd84 commit ad1fa13
Show file tree
Hide file tree
Showing 13 changed files with 716 additions and 558 deletions.
1 change: 0 additions & 1 deletion compiler/lib/generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,6 @@ let throw_statement ctx cx k loc =
]

let is_int = function
| J.ENum n -> J.Num.is_int n
| J.EBin ((J.Bor | J.Lsr), _, _) -> true
| _ -> false

Expand Down
2 changes: 1 addition & 1 deletion compiler/tests-compiler/effects_toplevel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ let%expect_test "test-compiler/lib-effects/test1.ml" =
_d_,
function(_e_){
var _f_ = i + 1 | 0;
if(5 !== i) return caml_cps_exact_call1(_c_, _f_);
if(! Object.is(5, i)) return caml_cps_exact_call1(_c_, _f_);
caml_callback(g, [0]);
var Test = [0];
runtime.caml_register_global(2, Test, "Test");
Expand Down
14 changes: 7 additions & 7 deletions compiler/tests-compiler/gh1007.ml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ let () = M.myfun M.x
next = x$0[1],
rev_sort =
function(n, l){
if(2 === n){
if(Object.is(2, n)){
if(l){
var match = l[2];
if(match){
Expand All @@ -179,7 +179,7 @@ let () = M.myfun M.x
}
}
}
else if(3 === n && l){
else if(Object.is(3, n) && l){
var _d_ = l[2];
if(_d_){
var match$2 = _d_[2];
Expand Down Expand Up @@ -241,7 +241,7 @@ let () = M.myfun M.x
},
sort =
function(n, l){
if(2 === n){
if(Object.is(2, n)){
if(l){
var match = l[2];
if(match){
Expand All @@ -257,7 +257,7 @@ let () = M.myfun M.x
}
}
}
else if(3 === n && l){
else if(Object.is(3, n) && l){
var _b_ = l[2];
if(_b_){
var match$2 = _b_[2];
Expand Down Expand Up @@ -394,7 +394,7 @@ let () = M.run ()
};
even(i);
var _a_ = i + 1 | 0;
if(4 === i) return 0;
if(Object.is(4, i)) return 0;
var i = _a_;
}
}
Expand Down Expand Up @@ -496,7 +496,7 @@ let () = M.run ()
even = closures$0[1];
even(i);
var _e_ = i + 1 | 0;
if(4 !== i){var i = _e_; continue;}
if(! Object.is(4, i)){var i = _e_; continue;}
var
_c_ = caml_call1(Stdlib_List[9], delayed[1]),
_d_ = function(f){return caml_call1(f, 0);};
Expand Down Expand Up @@ -620,7 +620,7 @@ let () = M.run ()
for(;;){
if(759635106 > param$0[1]){var f = param$0[2], param$0 = f(0); continue;}
var _g_ = i + 1 | 0;
if(4 !== i){var i = _g_; continue a;}
if(! Object.is(4, i)){var i = _g_; continue a;}
var
_e_ = caml_call1(Stdlib_List[9], delayed[1]),
_f_ = function(f){return caml_call1(f, 0);};
Expand Down
4 changes: 2 additions & 2 deletions compiler/tests-compiler/gh1320.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ let () = myfun ()
function(i){
function g(x){return app(f, x);}
function f(x){
return 0 === x ? 1 : runtime.caml_mul(i, app(g, x - 1 | 0));
return Object.is(0, x) ? 1 : runtime.caml_mul(i, app(g, x - 1 | 0));
}
var block = [0, g, f];
return block;
Expand All @@ -61,7 +61,7 @@ let () = myfun ()
_b_ = g(i);
caml_call2(Stdlib_Printf[3], _a_, _b_);
var _c_ = i + 1 | 0;
if(4 === i) return 0;
if(Object.is(4, i)) return 0;
var i = _c_;
}
}
Expand Down
169 changes: 86 additions & 83 deletions compiler/tests-compiler/gh747.ml
Original file line number Diff line number Diff line change
Expand Up @@ -316,86 +316,89 @@ end
91: function format_backtrace_slot(pos, slot){
92: function info(is_raise){
93: /*<<test.ml:46:4>>*/ return is_raise
94: ? 0 === pos ? cst_Raised_at : cst_Re_raised_at
95: : 0 === pos ? cst_Raised_by_primitive_operat : cst_Called_from;
96: /*<<test.ml:49:75>>*/ }
97: /*<<test.ml:51:2>>*/ if(0 === slot[0]){
98: /*<<test.ml:59:14>>*/ var
99: _h_ = slot[5],
100: _i_ = slot[4],
101: _j_ = slot[3],
102: _k_ = slot[6] ? cst_inlined : cst,
103: _l_ = slot[2],
104: _m_ = slot[7],
105: /*<<test.ml:59:14>>*/ _n_ = info(slot[1]);
106: /*<<test.ml:58:6>>*/ return [0,
107: /*<<test.ml:58:11>>*/ caml_call8
108: (Stdlib_Printf[4], _a_, _n_, _m_, _l_, _k_, _j_, _i_, _h_)];
109: }
110: if(slot[1]) /*<<test.ml:54:50>>*/ return 0;
111: /*<<test.ml:56:51>>*/ /*<<test.ml:56:51>>*/ var _o_ = info(0);
112: /*<<test.ml:56:8>>*/ return [0,
113: /*<<test.ml:56:13>>*/ caml_call2(Stdlib_Printf[4], _b_, _o_)];
114: /*<<test.ml:61:52>>*/ }
115: function print_exception_backtrace(outchan, backtrace){
116: /*<<test.ml:64:2>>*/ if(! backtrace)
117: /*<<test.ml:66:6>>*/ return /*<<test.ml:66:6>>*/ caml_call2
118: (Stdlib_Printf[1], outchan, _d_);
119: var a = backtrace[1], _f_ = a.length - 1 - 1 | 0, _e_ = 0;
120: if(_f_ >= 0){
121: var i = _e_;
122: for(;;){
123: /*<<test.ml:70:14>>*/ /*<<test.ml:70:14>>*/ var
124: match = format_backtrace_slot(i, runtime.caml_check_bound(a, i)[1 + i]);
125: if(match){
126: var str = match[1];
127: /*<<test.ml:72:24>>*/ /*<<test.ml:72:24>>*/ caml_call3
128: (Stdlib_Printf[1], outchan, _c_, str);
129: }
130: /*<<test.ml:69:6>>*/ /*<<test.ml:69:6>>*/ var _g_ = i + 1 | 0;
131: if(! Object.is(_f_, i)){var i = _g_; continue;}
132: break;
133: }
134: }
135: return 0;
136: /*<<test.ml:73:10>>*/ }
137: function compare(left, right, e1, e2){
138: /*<<test.ml:77:35>>*/ if(0 === e1[0]){
139: var v1 = e1[1];
140: if(0 !== e2[0]) /*<<test.ml:80:23>>*/ return -1;
141: var v2 = e2[1];
142: /*<<test.ml:78:24>>*/ return /*<<test.ml:78:24>>*/ caml_call2
143: (left, v1, v2);
144: }
145: var v1$0 = e1[1];
146: if(0 === e2[0]) /*<<test.ml:81:23>>*/ return 1;
147: var v2$0 = e2[1];
148: /*<<test.ml:79:26>>*/ return /*<<test.ml:79:26>>*/ caml_call2
149: (right, v1$0, v2$0);
150: /*<<test.ml:81:24>>*/ }
151: /*<<test.ml:75:16>>*/ var
152: /*<<test.ml:75:16>>*/ Either = [0, compare],
153: Test =
154: [0,
155: executable_name,
156: os_type,
157: backend_type,
158: big_endian,
159: word_size,
160: int_size,
161: unix,
162: win32,
163: cygwin,
164: max_array_length,
165: max_floatarray_length,
166: max_string_length,
167: Unhandled,
168: format_backtrace_slot,
169: print_exception_backtrace,
170: Either];
171: runtime.caml_register_global(12, Test, "Test");
172: return;
173: /*<<?>>*/ }
174: (globalThis));
175:
176: //# sourceMappingURL=test.map |}]
94: ? Object.is(0, pos) ? cst_Raised_at : cst_Re_raised_at
95: : Object.is
96: (0, pos)
97: ? cst_Raised_by_primitive_operat
98: : cst_Called_from;
99: /*<<test.ml:49:75>>*/ }
100: /*<<test.ml:51:2>>*/ if(0 === slot[0]){
101: /*<<test.ml:59:14>>*/ var
102: _h_ = slot[5],
103: _i_ = slot[4],
104: _j_ = slot[3],
105: _k_ = slot[6] ? cst_inlined : cst,
106: _l_ = slot[2],
107: _m_ = slot[7],
108: /*<<test.ml:59:14>>*/ _n_ = info(slot[1]);
109: /*<<test.ml:58:6>>*/ return [0,
110: /*<<test.ml:58:11>>*/ caml_call8
111: (Stdlib_Printf[4], _a_, _n_, _m_, _l_, _k_, _j_, _i_, _h_)];
112: }
113: if(slot[1]) /*<<test.ml:54:50>>*/ return 0;
114: /*<<test.ml:56:51>>*/ /*<<test.ml:56:51>>*/ var _o_ = info(0);
115: /*<<test.ml:56:8>>*/ return [0,
116: /*<<test.ml:56:13>>*/ caml_call2(Stdlib_Printf[4], _b_, _o_)];
117: /*<<test.ml:61:52>>*/ }
118: function print_exception_backtrace(outchan, backtrace){
119: /*<<test.ml:64:2>>*/ if(! backtrace)
120: /*<<test.ml:66:6>>*/ return /*<<test.ml:66:6>>*/ caml_call2
121: (Stdlib_Printf[1], outchan, _d_);
122: var a = backtrace[1], _f_ = a.length - 1 - 1 | 0, _e_ = 0;
123: if(_f_ >= 0){
124: var i = _e_;
125: for(;;){
126: /*<<test.ml:70:14>>*/ /*<<test.ml:70:14>>*/ var
127: match = format_backtrace_slot(i, runtime.caml_check_bound(a, i)[1 + i]);
128: if(match){
129: var str = match[1];
130: /*<<test.ml:72:24>>*/ /*<<test.ml:72:24>>*/ caml_call3
131: (Stdlib_Printf[1], outchan, _c_, str);
132: }
133: /*<<test.ml:69:6>>*/ /*<<test.ml:69:6>>*/ var _g_ = i + 1 | 0;
134: if(! Object.is(_f_, i)){var i = _g_; continue;}
135: break;
136: }
137: }
138: return 0;
139: /*<<test.ml:73:10>>*/ }
140: function compare(left, right, e1, e2){
141: /*<<test.ml:77:35>>*/ if(0 === e1[0]){
142: var v1 = e1[1];
143: if(0 !== e2[0]) /*<<test.ml:80:23>>*/ return -1;
144: var v2 = e2[1];
145: /*<<test.ml:78:24>>*/ return /*<<test.ml:78:24>>*/ caml_call2
146: (left, v1, v2);
147: }
148: var v1$0 = e1[1];
149: if(0 === e2[0]) /*<<test.ml:81:23>>*/ return 1;
150: var v2$0 = e2[1];
151: /*<<test.ml:79:26>>*/ return /*<<test.ml:79:26>>*/ caml_call2
152: (right, v1$0, v2$0);
153: /*<<test.ml:81:24>>*/ }
154: /*<<test.ml:75:16>>*/ var
155: /*<<test.ml:75:16>>*/ Either = [0, compare],
156: Test =
157: [0,
158: executable_name,
159: os_type,
160: backend_type,
161: big_endian,
162: word_size,
163: int_size,
164: unix,
165: win32,
166: cygwin,
167: max_array_length,
168: max_floatarray_length,
169: max_string_length,
170: Unhandled,
171: format_backtrace_slot,
172: print_exception_backtrace,
173: Either];
174: runtime.caml_register_global(12, Test, "Test");
175: return;
176: /*<<?>>*/ }
177: (globalThis));
178:
179: //# sourceMappingURL=test.map |}]
6 changes: 3 additions & 3 deletions compiler/tests-compiler/lazy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ let%expect_test "static eval of string get" =
[%expect
{|
function do_the_lazy_rec(n){
if(0 === n) return 0;
if(Object.is(0, n)) return 0;
var _b_ = do_the_lazy_rec(n - 1 | 0), _c_ = runtime.caml_obj_tag(lz);
if(250 === _c_)
if(Object.is(250, _c_))
var _d_ = lz[1];
else{
var switch$0 = 0;
if(246 !== _c_ && 244 !== _c_){var _d_ = lz; switch$0 = 1;}
if(! Object.is(246, _c_) && ! Object.is(244, _c_)){var _d_ = lz; switch$0 = 1;}
if(! switch$0) var _d_ = caml_call1(CamlinternalLazy[2], lz);
}
return [0, _d_, _b_];
Expand Down
Loading

0 comments on commit ad1fa13

Please sign in to comment.