26
26
27
27
module E = Js_exp_make
28
28
29
- let splice_fn_apply fn args =
29
+ let splice_apply fn args =
30
30
E. runtime_call Js_runtime_modules. caml_splice_call " spliceApply"
31
31
[ fn; E. array Immutable args ]
32
32
33
- let splice_obj_fn_apply obj name args =
33
+ let splice_new_apply fn args =
34
+ E. runtime_call Js_runtime_modules. caml_splice_call " spliceNewApply"
35
+ [ fn; E. array Immutable args ]
36
+
37
+ let splice_obj_apply obj name args =
34
38
E. runtime_call Js_runtime_modules. caml_splice_call " spliceObjApply"
35
39
[ obj; E. str name; E. array Immutable args ]
36
40
@@ -253,7 +257,7 @@ let translate_ffi (cxt : Lam_compile_context.t) arg_types
253
257
if splice then
254
258
let args, eff, dynamic = assemble_args_has_splice arg_types args in
255
259
add_eff eff
256
- (if dynamic then splice_fn_apply fn args
260
+ (if dynamic then splice_apply fn args
257
261
else E. call ~info: { arity = Full ; call_info = Call_na } fn args)
258
262
else
259
263
let args, eff = assemble_args_no_splice arg_types args in
@@ -265,13 +269,13 @@ let translate_ffi (cxt : Lam_compile_context.t) arg_types
265
269
let args, eff, dynamic = assemble_args_has_splice arg_types args in
266
270
(* TODO: fix in rest calling convention *)
267
271
add_eff eff
268
- (if dynamic then splice_fn_apply fn args
272
+ (if dynamic then splice_apply fn args
269
273
else E. call ~info: { arity = Full ; call_info = Call_na } fn args)
270
274
else
271
275
let args, eff = assemble_args_no_splice arg_types args in
272
276
(* TODO: fix in rest calling convention *)
273
277
add_eff eff (E. call ~info: { arity = Full ; call_info = Call_na } fn args)
274
- | Js_new { external_module_name = module_name ; name = fn ; scopes } ->
278
+ | Js_new { external_module_name = module_name ; name = fn ; splice; scopes } ->
275
279
(* handle [@@new]*)
276
280
(* This has some side effect, it will
277
281
mark its identifier (If it has) as an object,
@@ -281,15 +285,25 @@ let translate_ffi (cxt : Lam_compile_context.t) arg_types
281
285
TODO: we should propagate this property
282
286
as much as we can(in alias table)
283
287
*)
284
- let args, eff = assemble_args_no_splice arg_types args in
285
- let fn = translate_scoped_module_val module_name fn scopes in
286
- add_eff eff
287
- ((match cxt.continuation with
288
+ let mark () =
289
+ match cxt.continuation with
288
290
| Declare (_ , id ) | Assign id ->
289
291
(* Format.fprintf Format.err_formatter "%a@."Ident.print id; *)
290
292
Ext_ident. make_js_object id
291
- | EffectCall _ | NeedValue _ -> () );
292
- E. new_ fn args)
293
+ | EffectCall _ | NeedValue _ -> ()
294
+ in
295
+ if splice then
296
+ let args, eff, dynamic = assemble_args_has_splice arg_types args in
297
+ let fn = translate_scoped_module_val module_name fn scopes in
298
+ add_eff eff
299
+ (mark () ;
300
+ if dynamic then splice_new_apply fn args
301
+ else E. new_ fn args)
302
+ else
303
+ let args, eff = assemble_args_no_splice arg_types args in
304
+ let fn = translate_scoped_module_val module_name fn scopes in
305
+ add_eff eff
306
+ (mark () ; E. new_ fn args)
293
307
| Js_send { splice; name; js_send_scopes } -> (
294
308
match args with
295
309
| self :: args ->
@@ -300,7 +314,7 @@ let translate_ffi (cxt : Lam_compile_context.t) arg_types
300
314
let args, eff, dynamic = assemble_args_has_splice arg_types args in
301
315
add_eff eff
302
316
(let self = translate_scoped_access js_send_scopes self in
303
- if dynamic then splice_obj_fn_apply self name args
317
+ if dynamic then splice_obj_apply self name args
304
318
else
305
319
E. call
306
320
~info: { arity = Full ; call_info = Call_na }
0 commit comments