@@ -76,7 +76,7 @@ let rec apply_with_arity_aux (fn : J.expression)
7676let apply_with_arity ~arity fn args =
7777 apply_with_arity_aux fn arity args (List. length args)
7878
79- let method_cache_id = ref 1 (* TODO: move to js runtime for re-entrant *)
79+
8080
8181let change_tail_type_in_try
8282 (x : Lam_compile_context.tail_type )
@@ -1145,71 +1145,6 @@ and compile_trywith lam id catch (lambda_cxt : Lam_compile_context.t) =
11451145 mutable initializers: (obj -> unit) list }
11461146 ]}
11471147*)
1148- and compile_send (meth_kind : Lam_compat.meth_kind )
1149- (met : Lam.t )
1150- (obj : Lam.t ) (args : Lam.t list )
1151- (lambda_cxt : Lam_compile_context.t ) =
1152- let new_cxt = {lambda_cxt with continuation = NeedValue Not_tail } in
1153- match Ext_list. split_map (met :: obj :: args) (fun x ->
1154- match x with
1155- | Lprim {primitive = Pccall {prim_name ; _}; args = [] }
1156- (* nullary external call*)
1157- ->
1158- [] , E. var (Ext_ident. create_js prim_name)
1159- | _ ->
1160- match compile_lambda new_cxt x with
1161- | {value = None } -> assert false
1162- | {block; value = Some b } -> block, b
1163- ) with
1164- | _ , ([] | [_]) -> assert false
1165- | (args_code, label::nobj::args)
1166- ->
1167- let cont3 nobj k =
1168- match Js_ast_util. named_expression nobj with
1169- | None ->
1170- let cont =
1171- Js_output. output_of_block_and_expression
1172- lambda_cxt.continuation (List. concat args_code)
1173- in
1174- cont (k nobj)
1175- | Some (obj_code , v ) ->
1176- let cont2 obj_code v =
1177- Js_output. output_of_block_and_expression
1178- lambda_cxt.continuation
1179- ( Ext_list. concat_append args_code [obj_code]) v in
1180- let cobj = E. var v in
1181- cont2 obj_code (k cobj) in
1182- match meth_kind with
1183- | Self ->
1184- (* TODO: horrible hack -- fixed later -- CHECK*)
1185- cont3 nobj (fun aobj -> E. call ~info: Js_call_info. dummy
1186- (Js_of_lam_array. ref_array
1187- (E. array_index_by_int aobj 0l ) label )
1188- (aobj :: args))
1189- (* [E.small_int 1] is because we use array,
1190- when we change the runtime represenation, it needs to be adapted
1191- *)
1192-
1193- | Cached | Public None
1194- (* TODO: check -- 1. js object propagate 2. js object create *)
1195- ->
1196- let get = E. runtime_ref Js_runtime_modules. oo " caml_get_public_method" in
1197- let cache = ! method_cache_id in
1198- let () = incr method_cache_id in
1199- cont3 nobj (fun obj' ->
1200- E. call ~info: Js_call_info. dummy
1201- (E. call ~info: Js_call_info. dummy get
1202- [obj'; label; E. small_int cache]) (obj'::args)
1203- ) (* avoid duplicated compuattion *)
1204-
1205-
1206- | Public (Some name ) ->
1207- let cache = ! method_cache_id in
1208- incr method_cache_id ;
1209- cont3 nobj
1210- (fun aobj -> E. public_method_call name aobj label
1211- (Int32. of_int cache) args )
1212-
12131148
12141149and compile_ifthenelse
12151150 (predicate : Lam.t )
@@ -1661,5 +1596,3 @@ and compile_lambda
16611596 compile_assign id lambda lambda_cxt
16621597 | Ltrywith (lam ,id , catch ) -> (* generate documentation *)
16631598 compile_trywith lam id catch lambda_cxt
1664- | Lsend (meth_kind ,met , obj , args ,_loc ) ->
1665- compile_send meth_kind met obj args lambda_cxt
0 commit comments