@@ -37,23 +37,14 @@ type uncurry_type_gen =
37
37
Parsetree .core_type ->
38
38
Parsetree .core_type ) cxt
39
39
40
- let uncurry_type_id () =
41
- if Js_config. is_browser () then
42
- Ast_literal.Lid. pervasives_fn
43
- else
44
- Ast_literal.Lid. js_fn
40
+ let uncurry_type_id =
41
+ Ast_literal.Lid. js_fn
45
42
46
- let method_id () =
47
- if Js_config. is_browser () then
48
- Ast_literal.Lid. pervasives_meth
49
- else
50
- Ast_literal.Lid. js_meth
43
+ let method_id =
44
+ Ast_literal.Lid. js_meth
51
45
52
- let method_call_back_id () =
53
- if Js_config. is_browser () then
54
- Ast_literal.Lid. pervasives_meth_callback
55
- else
56
- Ast_literal.Lid. js_meth_callback
46
+ let method_call_back_id =
47
+ Ast_literal.Lid. js_meth_callback
57
48
58
49
let arity_lit = " Arity_"
59
50
@@ -72,14 +63,14 @@ let generic_lift txt loc args result =
72
63
Typ. constr ~loc {txt ; loc} xs
73
64
74
65
let lift_curry_type loc =
75
- generic_lift ( uncurry_type_id () ) loc
66
+ generic_lift uncurry_type_id loc
76
67
77
68
let lift_method_type loc =
78
- generic_lift ( method_id () ) loc
69
+ generic_lift method_id loc
79
70
80
71
let lift_js_method_callback loc
81
72
=
82
- generic_lift ( method_call_back_id () ) loc
73
+ generic_lift method_call_back_id loc
83
74
(* * Note that currently there is no way to consume [Js.meth_callback]
84
75
so it is fine to encode it with a freedom,
85
76
but we need make it better for error message.
@@ -99,24 +90,12 @@ let arrow = Typ.arrow
99
90
100
91
101
92
let js_property loc obj name =
102
- if Js_config. is_browser () then
103
- let downgrade ~loc () =
104
- let var = Typ. var ~loc " a" in
105
- Ast_comb. arrow_no_label ~loc
106
- (Ast_comb. to_js_type loc var) var
107
- in
108
- Ast_external. local_extern_cont loc
109
- ~pval_prim: [Literals. js_unsafe_downgrade]
110
- ~pval_type: (downgrade ~loc () )
111
- ~local_fun_name: " cast"
112
- (fun down -> Exp. send ~loc (Exp. apply ~loc down [" " , obj]) name )
113
- else
114
- Parsetree. Pexp_send
115
- ((Exp. apply ~loc
116
- (Exp. ident ~loc
117
- {loc;
118
- txt = Ldot (Ast_literal.Lid. js_unsafe, Literals. js_unsafe_downgrade)})
119
- [" " ,obj]), name)
93
+ Parsetree. Pexp_send
94
+ ((Exp. apply ~loc
95
+ (Exp. ident ~loc
96
+ {loc;
97
+ txt = Ldot (Ast_literal.Lid. js_unsafe, Literals. js_unsafe_downgrade)})
98
+ [" " ,obj]), name)
120
99
121
100
(* TODO:
122
101
have a final checking for property arities
@@ -144,7 +123,7 @@ let generic_apply kind loc
144
123
0 , cb loc obj, []
145
124
| _ ->
146
125
len, cb loc obj, args in
147
- if not ( Js_config. is_browser () ) && arity < 10 then
126
+ if arity < 10 then
148
127
let txt =
149
128
match kind with
150
129
| `Fn | `PropertyFn ->
@@ -267,7 +246,7 @@ let generic_to_uncurry_exp kind loc (self : Ast_mapper.mapper) pat body
267
246
| _ -> len
268
247
end
269
248
| `Method_callback -> len in
270
- if arity < 10 && not ( Js_config. is_browser () ) then
249
+ if arity < 10 then
271
250
let txt =
272
251
match kind with
273
252
| `Fn ->
@@ -301,17 +280,9 @@ let to_method_callback =
301
280
302
281
let handle_debugger loc payload =
303
282
if Ast_payload. as_empty_structure payload then
304
- if Js_config. is_browser () then
305
- let predef_unit_type = Ast_literal. type_unit ~loc () in
306
- let pval_prim = [Literals. js_debugger] in
307
- Ast_external. create_local_external loc
308
- ~pval_prim
309
- ~pval_type: (arrow " " predef_unit_type predef_unit_type)
310
- [(" " , Ast_literal. val_unit ~loc () )]
311
- else
312
- Parsetree. Pexp_apply
313
- (Exp. ident {txt = Ldot (Ast_literal.Lid. js_unsafe, Literals. js_debugger ); loc},
314
- [" " , Ast_literal. val_unit ~loc () ])
283
+ Parsetree. Pexp_apply
284
+ (Exp. ident {txt = Ldot (Ast_literal.Lid. js_unsafe, Literals. js_debugger ); loc},
285
+ [" " , Ast_literal. val_unit ~loc () ])
315
286
else Location. raise_errorf ~loc " bs.raw can only be applied to a string"
316
287
317
288
@@ -322,16 +293,8 @@ let handle_raw loc payload =
322
293
" bs.raw can only be applied to a string "
323
294
324
295
| Some exp ->
325
- let pval_prim = [Literals. js_pure_expr] in
326
296
let pexp_desc =
327
- if Js_config. is_browser () then
328
- Ast_external. create_local_external loc
329
- ~pval_prim
330
- ~pval_type: (arrow " "
331
- (Ast_literal. type_string ~loc () )
332
- (Ast_literal. type_any ~loc () ) )
333
- [" " ,exp]
334
- else Parsetree. Pexp_apply (
297
+ Parsetree. Pexp_apply (
335
298
Exp. ident {loc;
336
299
txt =
337
300
Ldot (Ast_literal.Lid. js_unsafe,
@@ -350,16 +313,7 @@ let handle_raw_structure loc payload =
350
313
| Some exp
351
314
->
352
315
let pexp_desc =
353
- if Js_config. is_browser () then
354
- let pval_prim = [Literals. js_pure_stmt] in
355
- Ast_external. create_local_external loc
356
- ~pval_prim
357
- ~pval_type: (arrow " "
358
- (Ast_literal. type_string ~loc () )
359
- (Ast_literal. type_any ~loc () ))
360
- [" " ,exp]
361
- else
362
- Parsetree. Pexp_apply (
316
+ Parsetree. Pexp_apply (
363
317
Exp. ident {txt = Ldot (Ast_literal.Lid. js_unsafe, Literals. js_pure_stmt); loc},
364
318
[" " ,exp]) in
365
319
Ast_helper.Str. eval
0 commit comments