@@ -78,7 +78,7 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
78
78
| Pis_not_none -> Js_of_lam_option. is_not_none (Ext_list. singleton_exn args)
79
79
| Pcreate_extension s -> E. make_exception s
80
80
| Pwrap_exn ->
81
- E. runtime_call Js_runtime_modules . exceptions
81
+ E. runtime_call Primitive_modules . exceptions
82
82
" internalToException" args
83
83
| Praw_js_code { code; code_info } -> E. raw_js_code code_info code
84
84
(* FIXME: save one allocation
@@ -96,22 +96,22 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
96
96
| [ e ] -> (
97
97
match e.expression_desc with
98
98
| Var _ | Undefined _ | Null -> Js_of_lam_option. null_to_opt e
99
- | _ -> E. runtime_call Js_runtime_modules .option " fromNull" args)
99
+ | _ -> E. runtime_call Primitive_modules .option " fromNull" args)
100
100
| _ -> assert false )
101
101
| Pundefined_to_opt -> (
102
102
match args with
103
103
| [ e ] -> (
104
104
match e.expression_desc with
105
105
| Var _ | Undefined _ | Null -> Js_of_lam_option. undef_to_opt e
106
106
| _ ->
107
- E. runtime_call Js_runtime_modules .option " fromUndefined" args)
107
+ E. runtime_call Primitive_modules .option " fromUndefined" args)
108
108
| _ -> assert false )
109
109
| Pnull_undefined_to_opt -> (
110
110
match args with
111
111
| [ e ] -> (
112
112
match e.expression_desc with
113
113
| Var _ | Undefined _ | Null -> Js_of_lam_option. null_undef_to_opt e
114
- | _ -> E. runtime_call Js_runtime_modules .option " fromNullable" args
114
+ | _ -> E. runtime_call Primitive_modules .option " fromNullable" args
115
115
)
116
116
| _ -> assert false )
117
117
(* Compile %import: The module argument for dynamic import is represented as a path,
@@ -150,8 +150,8 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
150
150
assert false (* already handled by {!Lam_compile} *)
151
151
| Pstringadd -> (
152
152
match args with [ a; b ] -> E. string_append a b | _ -> assert false )
153
- | Pinit_mod -> E. runtime_call Js_runtime_modules . module_ " init_mod" args
154
- | Pupdate_mod -> E. runtime_call Js_runtime_modules . module_ " update_mod" args
153
+ | Pinit_mod -> E. runtime_call Primitive_modules . module_ " init_mod" args
154
+ | Pupdate_mod -> E. runtime_call Primitive_modules . module_ " update_mod" args
155
155
| Psome -> (
156
156
let arg = Ext_list. singleton_exn args in
157
157
match arg.expression_desc with
@@ -301,7 +301,7 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
301
301
| Pstringlength -> E. string_length (Ext_list. singleton_exn args)
302
302
| Pstringrefs | Pstringrefu -> (
303
303
match args with
304
- | [ e; e1 ] -> E. runtime_call Js_runtime_modules .string " getChar" args
304
+ | [ e; e1 ] -> E. runtime_call Primitive_modules .string " getChar" args
305
305
| _ -> assert false )
306
306
(* polymorphic operations *)
307
307
| Pobjcomp cmp -> (
@@ -316,23 +316,23 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
316
316
E. neq_null_undefined_boolean e1 e2
317
317
| [ e1; e2 ] ->
318
318
Location. prerr_warning loc Warnings. Bs_polymorphic_comparison ;
319
- E. runtime_call Js_runtime_modules . object_
319
+ E. runtime_call Primitive_modules . object_
320
320
(Lam_compile_util. runtime_of_comp cmp) args
321
321
| _ -> assert false )
322
322
| Pobjorder -> (
323
323
Location. prerr_warning loc Warnings. Bs_polymorphic_comparison ;
324
324
match args with
325
- | [ a; b ] -> E. runtime_call Js_runtime_modules . object_ " compare" args
325
+ | [ a; b ] -> E. runtime_call Primitive_modules . object_ " compare" args
326
326
| _ -> assert false )
327
327
| Pobjmin -> (
328
328
Location. prerr_warning loc Warnings. Bs_polymorphic_comparison ;
329
329
match args with
330
- | [ a; b ] -> E. runtime_call Js_runtime_modules . object_ " min" args
330
+ | [ a; b ] -> E. runtime_call Primitive_modules . object_ " min" args
331
331
| _ -> assert false )
332
332
| Pobjmax -> (
333
333
Location. prerr_warning loc Warnings. Bs_polymorphic_comparison ;
334
334
match args with
335
- | [ a; b ] -> E. runtime_call Js_runtime_modules . object_ " max" args
335
+ | [ a; b ] -> E. runtime_call Primitive_modules . object_ " max" args
336
336
| _ -> assert false )
337
337
| Pobjtag -> (
338
338
(* Note that in ocaml, [int] has tag [1000] and [string] has tag [252]
@@ -344,7 +344,7 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
344
344
| [ { expression_desc = Bool a }; { expression_desc = Bool b } ] ->
345
345
let c = compare (a : bool ) b in
346
346
E. int (if c = 0 then 0l else if c > 0 then 1l else - 1l )
347
- | [ a; b ] -> E. runtime_call Js_runtime_modules .bool " compare" args
347
+ | [ a; b ] -> E. runtime_call Primitive_modules .bool " compare" args
348
348
| _ -> assert false )
349
349
| Pboolmin -> (
350
350
match args with
@@ -353,88 +353,88 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
353
353
Js_analyzer. is_okay_to_duplicate a
354
354
&& Js_analyzer. is_okay_to_duplicate b
355
355
then E. econd (E. js_comp Clt a b) a b
356
- else E. runtime_call Js_runtime_modules .bool " min" args
357
- | [ a; b ] -> E. runtime_call Js_runtime_modules .bool " min" args
356
+ else E. runtime_call Primitive_modules .bool " min" args
357
+ | [ a; b ] -> E. runtime_call Primitive_modules .bool " min" args
358
358
| _ -> assert false )
359
359
| Pboolmax -> (
360
360
match args with
361
361
| [ { expression_desc = Bool _ } as a; { expression_desc = Bool _ } as b ]
362
362
when Js_analyzer. is_okay_to_duplicate a && Js_analyzer. is_okay_to_duplicate b ->
363
363
E. econd (E. js_comp Cgt a b) a b
364
- | [ a; b ] -> E. runtime_call Js_runtime_modules .bool " max" args
364
+ | [ a; b ] -> E. runtime_call Primitive_modules .bool " max" args
365
365
| _ -> assert false )
366
366
| Pintorder -> (
367
367
match args with
368
- | [ a; b ] -> E. runtime_call Js_runtime_modules .int " compare" args
368
+ | [ a; b ] -> E. runtime_call Primitive_modules .int " compare" args
369
369
| _ -> assert false )
370
370
| Pintmin -> (
371
371
match args with
372
372
| [ { expression_desc = Number (Int _) } as a; { expression_desc = Number (Int _) } as b ]
373
373
when Js_analyzer. is_okay_to_duplicate a && Js_analyzer. is_okay_to_duplicate b ->
374
374
E. econd (E. js_comp Clt a b) a b
375
- | [ a; b ] -> E. runtime_call Js_runtime_modules .int " min" args
375
+ | [ a; b ] -> E. runtime_call Primitive_modules .int " min" args
376
376
| _ -> assert false )
377
377
| Pintmax -> (
378
378
match args with
379
379
| [ { expression_desc = Number (Int _) } as a; { expression_desc = Number (Int _) } as b ]
380
380
when Js_analyzer. is_okay_to_duplicate a && Js_analyzer. is_okay_to_duplicate b ->
381
381
E. econd (E. js_comp Cgt a b) a b
382
- | [ a; b ] -> E. runtime_call Js_runtime_modules .int " max" args
382
+ | [ a; b ] -> E. runtime_call Primitive_modules .int " max" args
383
383
| _ -> assert false )
384
384
| Pfloatorder -> (
385
385
match args with
386
386
| [ a; b ] as args ->
387
- E. runtime_call Js_runtime_modules .float " compare" args
387
+ E. runtime_call Primitive_modules .float " compare" args
388
388
| _ -> assert false )
389
389
| Pfloatmin -> (
390
390
match args with
391
391
| [ { expression_desc = Number (Float _) } as a; { expression_desc = Number (Float _) } as b ]
392
392
when Js_analyzer. is_okay_to_duplicate a && Js_analyzer. is_okay_to_duplicate b ->
393
393
E. econd (E. js_comp Clt a b) a b
394
- | [ a; b ] -> E. runtime_call Js_runtime_modules .float " min" args
394
+ | [ a; b ] -> E. runtime_call Primitive_modules .float " min" args
395
395
| _ -> assert false )
396
396
| Pfloatmax -> (
397
397
match args with
398
398
| [ { expression_desc = Number (Float _) } as a; { expression_desc = Number (Float _) } as b ]
399
399
when Js_analyzer. is_okay_to_duplicate a && Js_analyzer. is_okay_to_duplicate b ->
400
400
E. econd (E. js_comp Cgt a b) a b
401
- | [ a; b ] -> E. runtime_call Js_runtime_modules .float " max" args
401
+ | [ a; b ] -> E. runtime_call Primitive_modules .float " max" args
402
402
| _ -> assert false )
403
403
| Pbigintorder -> (
404
404
match args with
405
- | [ a; b ] -> E. runtime_call Js_runtime_modules . bigint " compare" args
405
+ | [ a; b ] -> E. runtime_call Primitive_modules . bigint " compare" args
406
406
| _ -> assert false )
407
407
| Pbigintmin -> (
408
408
match args with
409
409
| [ { expression_desc = Number (BigInt _) } as a; { expression_desc = Number (BigInt _) } as b ]
410
410
when Js_analyzer. is_okay_to_duplicate a && Js_analyzer. is_okay_to_duplicate b ->
411
411
E. econd (E. js_comp Clt a b) a b
412
- | [ a; b ] -> E. runtime_call Js_runtime_modules . bigint " min" args
412
+ | [ a; b ] -> E. runtime_call Primitive_modules . bigint " min" args
413
413
| _ -> assert false )
414
414
| Pbigintmax -> (
415
415
match args with
416
416
| [ { expression_desc = Number (Float _) } as a; { expression_desc = Number (Float _) } as b ]
417
417
when Js_analyzer. is_okay_to_duplicate a && Js_analyzer. is_okay_to_duplicate b ->
418
418
E. econd (E. js_comp Cgt a b) a b
419
- | [ a; b ] -> E. runtime_call Js_runtime_modules . bigint " max" args
419
+ | [ a; b ] -> E. runtime_call Primitive_modules . bigint " max" args
420
420
| _ -> assert false )
421
421
| Pstringorder -> (
422
422
match args with
423
- | [ a; b ] -> E. runtime_call Js_runtime_modules .string " compare" args
423
+ | [ a; b ] -> E. runtime_call Primitive_modules .string " compare" args
424
424
| _ -> assert false )
425
425
| Pstringmin -> (
426
426
match args with
427
427
| [ { expression_desc = Str _ } as a; { expression_desc = Str _ } as b ]
428
428
when Js_analyzer. is_okay_to_duplicate a && Js_analyzer. is_okay_to_duplicate b ->
429
429
E. econd (E. js_comp Clt a b) a b
430
- | [a; b] -> E. runtime_call Js_runtime_modules .string " min" args
430
+ | [a; b] -> E. runtime_call Primitive_modules .string " min" args
431
431
| _ -> assert false )
432
432
| Pstringmax -> (
433
433
match args with
434
434
| [ { expression_desc = Str _ } as a; { expression_desc = Str _ } as b ]
435
435
when Js_analyzer. is_okay_to_duplicate a && Js_analyzer. is_okay_to_duplicate b ->
436
436
E. econd (E. js_comp Cgt a b) a b
437
- | [a; b] -> E. runtime_call Js_runtime_modules .string " max" args
437
+ | [a; b] -> E. runtime_call Primitive_modules .string " max" args
438
438
| _ -> assert false )
439
439
(* only when Lapply -> expand = true*)
440
440
| Praise -> assert false (* handled before here *)
@@ -452,8 +452,8 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
452
452
match args with
453
453
| [ e; e1 ] -> Js_of_lam_array. ref_array e e1 (* Todo: Constant Folding *)
454
454
| _ -> assert false )
455
- | Parrayrefs -> E. runtime_call Js_runtime_modules .array " get" args
456
- | Parraysets -> E. runtime_call Js_runtime_modules .array " set" args
455
+ | Parrayrefs -> E. runtime_call Primitive_modules .array " get" args
456
+ | Parraysets -> E. runtime_call Primitive_modules .array " set" args
457
457
| Pmakearray -> Js_of_lam_array. make_array Mutable args
458
458
| Pmakelist ->
459
459
Js_of_lam_block. make_block
@@ -497,19 +497,19 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
497
497
| _ -> assert false )
498
498
| Phash -> (
499
499
match args with
500
- | [ e1; e2; e3; e4 ] -> E. runtime_call Js_runtime_modules . hash " hash" args
500
+ | [ e1; e2; e3; e4 ] -> E. runtime_call Primitive_modules . hash " hash" args
501
501
| _ -> assert false )
502
502
| Phash_mixint -> (
503
503
match args with
504
- | [ e1; e2 ] -> E. runtime_call Js_runtime_modules . hash " hash_mix_int" args
504
+ | [ e1; e2 ] -> E. runtime_call Primitive_modules . hash " hash_mix_int" args
505
505
| _ -> assert false )
506
506
| Phash_mixstring -> (
507
507
match args with
508
- | [ e1; e2 ] -> E. runtime_call Js_runtime_modules . hash " hash_mix_string" args
508
+ | [ e1; e2 ] -> E. runtime_call Primitive_modules . hash " hash_mix_string" args
509
509
| _ -> assert false )
510
510
| Phash_finalmix -> (
511
511
match args with
512
- | [ e1 ] -> E. runtime_call Js_runtime_modules . hash " hash_final_mix" args
512
+ | [ e1 ] -> E. runtime_call Primitive_modules . hash " hash_final_mix" args
513
513
| _ -> assert false )
514
514
| Plazyforce
515
515
(* FIXME: we don't inline lazy force or at least
0 commit comments