@@ -138,22 +138,22 @@ let default_action ~saturated failaction =
138138 | None -> Complete
139139 | Some x -> if saturated then Complete else Default x
140140
141- let get_const_name i (sw_names : Lambda .switch_names option ) =
141+ let get_const_name i (sw_names : Ast_untagged_variants .switch_names option ) =
142142 match sw_names with None -> None | Some { consts } -> Some consts.(i)
143143
144- let get_block i (sw_names : Lambda .switch_names option ) =
144+ let get_block i (sw_names : Ast_untagged_variants .switch_names option ) =
145145 match sw_names with None -> None | Some { blocks } -> Some blocks.(i)
146146
147- let get_tag_name (sw_names : Lambda .switch_names option ) =
147+ let get_tag_name (sw_names : Ast_untagged_variants .switch_names option ) =
148148 match sw_names with
149149 | None -> Js_dump_lit. tag
150150 | Some { blocks } ->
151- (match Array. find_opt (fun {Lambda . tag_name} -> tag_name <> None ) blocks with
151+ (match Array. find_opt (fun {Ast_untagged_variants . tag_name} -> tag_name <> None ) blocks with
152152 | Some {tag_name = Some s } -> s
153153 | _ -> Js_dump_lit. tag
154154 )
155155
156- let get_block_cases (sw_names : Lambda .switch_names option ) =
156+ let get_block_cases (sw_names : Ast_untagged_variants .switch_names option ) =
157157 let res = ref [] in
158158 (match sw_names with
159159 | None -> res := []
@@ -165,25 +165,25 @@ let get_block_cases (sw_names : Lambda.switch_names option) =
165165 );
166166 ! res
167167
168- let get_literal_cases (sw_names : Lambda .switch_names option ) =
168+ let get_literal_cases (sw_names : Ast_untagged_variants .switch_names option ) =
169169 let res = ref [] in
170170 (match sw_names with
171171 | None -> res := []
172172 | Some { consts } ->
173173 Ext_array. iter consts (function
174- | {literal = Some literal } -> res := literal :: ! res
175- | {name; literal = None } -> res := String name :: ! res
174+ | {literal_type = Some literal } -> res := literal :: ! res
175+ | {name; literal_type = None } -> res := String name :: ! res
176176 )
177177 );
178178 ! res
179179
180180
181- let has_null_undefined_other (sw_names : Lambda .switch_names option ) =
181+ let has_null_undefined_other (sw_names : Ast_untagged_variants .switch_names option ) =
182182 let (null, undefined, other) = (ref false , ref false , ref false ) in
183183 (match sw_names with
184184 | None -> ()
185185 | Some { consts; blocks } ->
186- Ext_array. iter consts (fun x -> match x.literal with
186+ Ext_array. iter consts (fun x -> match x.literal_type with
187187 | Some Undefined -> undefined := true
188188 | Some Null -> null := true
189189 | _ -> other := true );
@@ -500,7 +500,7 @@ and compile_recursive_lets cxt id_args : Js_output.t =
500500
501501and compile_general_cases :
502502 'a .
503- ('a -> Lambda. cstr_name option ) ->
503+ ('a -> Ast_untagged_variants. literal option ) ->
504504 ('a -> J. expression ) ->
505505 ('a option -> J. expression -> 'a option -> J. expression -> J. expression ) ->
506506 Lam_compile_context. t ->
@@ -513,7 +513,7 @@ and compile_general_cases :
513513 ('a * Lam. t ) list ->
514514 default_case ->
515515 J. block =
516- fun (get_cstr_name : _ -> Lambda.cstr_name option ) (make_exp : _ -> J.expression )
516+ fun (get_cstr_name : _ -> Ast_untagged_variants.literal option ) (make_exp : _ -> J.expression )
517517 (eq_exp : 'a option -> J.expression -> 'a option -> J.expression -> J.expression )
518518 (cxt : Lam_compile_context.t )
519519 (switch :
@@ -619,9 +619,9 @@ and compile_general_cases :
619619and use_compile_literal_cases table get_name =
620620 List. fold_right (fun (i , lam ) acc ->
621621 match get_name i, acc with
622- | Some {Lambda. literal = Some literal } , Some string_table ->
622+ | Some {Ast_untagged_variants. literal_type = Some literal } , Some string_table ->
623623 Some ((literal, lam) :: string_table)
624- | Some {name; literal = None } , Some string_table -> Some ((String name, lam) :: string_table)
624+ | Some {name; literal_type = None } , Some string_table -> Some ((String name, lam) :: string_table)
625625 | _ , _ -> None
626626 ) table (Some [] )
627627and compile_cases ?(untagged =false ) cxt (switch_exp : E.t ) table default get_name =
@@ -634,7 +634,7 @@ and compile_cases ?(untagged=false) cxt (switch_exp : E.t) table default get_nam
634634 compile_general_cases get_name
635635 (fun i -> match get_name i with
636636 | None -> E. small_int i
637- | Some {literal = Some (String s )} -> E. str s
637+ | Some {literal_type = Some (String s )} -> E. str s
638638 | Some {name} -> E. str name)
639639 (fun _ x _ y -> E. int_equal x y) cxt
640640 (fun ?default ?declaration e clauses ->
@@ -671,9 +671,9 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch)
671671 let get_block_name i = match get_block i with
672672 | None -> None
673673 | Some ({block_type = Some block_type } as block ) ->
674- Some {block.cstr_name with literal = Some (Block block_type)}
675- | Some ({block_type = None ; cstr_name } ) ->
676- Some cstr_name in
674+ Some {block.literal with literal_type = Some (Block block_type)}
675+ | Some ({block_type = None ; literal } ) ->
676+ Some literal in
677677 let tag_name = get_tag_name sw_names in
678678 let untagged = block_cases <> [] in
679679 let compile_whole (cxt : Lam_compile_context.t ) =
@@ -744,7 +744,7 @@ and compile_untagged_cases cxt switch_exp table default =
744744 let literal = function
745745 | literal -> E. literal literal
746746 in
747- let add_runtime_type_check (literal : Lambda.literal ) x y = match literal with
747+ let add_runtime_type_check (literal : Ast_untagged_variants.literal_type ) x y = match literal with
748748 | Block IntType
749749 | Block StringType
750750 | Block FloatType
@@ -754,14 +754,14 @@ and compile_untagged_cases cxt switch_exp table default =
754754 (* This should not happen because unknown must be the only non-literal case *)
755755 assert false
756756 | Bool _ | Float _ | Int _ | String _ | Null | Undefined -> x in
757- let mk_eq (i : Lambda.literal option ) x j y = match i, j with
757+ let mk_eq (i : Ast_untagged_variants.literal_type option ) x j y = match i, j with
758758 | Some literal , _ -> (* XX *)
759759 add_runtime_type_check literal x y
760760 | _ , Some literal ->
761761 add_runtime_type_check literal y x
762762 | _ -> E. string_equal x y
763763 in
764- let is_array (l , _ ) = l = Lambda .Block Array in
764+ let is_array (l , _ ) = l = Ast_untagged_variants .Block Array in
765765 let body ?default ?declaration e clauses =
766766 let array_clauses = Ext_list. filter clauses is_array in
767767 match array_clauses with
@@ -786,7 +786,7 @@ and compile_stringswitch l cases default (lambda_cxt : Lam_compile_context.t) =
786786 Be careful: we should avoid multiple evaluation of l,
787787 The [gen] can be elimiated when number of [cases] is less than 3
788788 *)
789- let cases = cases |> List. map (fun (s ,l ) -> Lambda .String s, l) in
789+ let cases = cases |> List. map (fun (s ,l ) -> Ast_untagged_variants .String s, l) in
790790 match
791791 compile_lambda { lambda_cxt with continuation = NeedValue Not_tail } l
792792 with
0 commit comments