@@ -138,22 +138,22 @@ let default_action ~saturated failaction =
138
138
| None -> Complete
139
139
| Some x -> if saturated then Complete else Default x
140
140
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 ) =
142
142
match sw_names with None -> None | Some { consts } -> Some consts.(i)
143
143
144
- let get_block i (sw_names : Lambda .switch_names option ) =
144
+ let get_block i (sw_names : Ast_untagged_variants .switch_names option ) =
145
145
match sw_names with None -> None | Some { blocks } -> Some blocks.(i)
146
146
147
- let get_tag_name (sw_names : Lambda .switch_names option ) =
147
+ let get_tag_name (sw_names : Ast_untagged_variants .switch_names option ) =
148
148
match sw_names with
149
149
| None -> Js_dump_lit. tag
150
150
| 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
152
152
| Some {tag_name = Some s } -> s
153
153
| _ -> Js_dump_lit. tag
154
154
)
155
155
156
- let get_block_cases (sw_names : Lambda .switch_names option ) =
156
+ let get_block_cases (sw_names : Ast_untagged_variants .switch_names option ) =
157
157
let res = ref [] in
158
158
(match sw_names with
159
159
| None -> res := []
@@ -165,25 +165,25 @@ let get_block_cases (sw_names : Lambda.switch_names option) =
165
165
);
166
166
! res
167
167
168
- let get_literal_cases (sw_names : Lambda .switch_names option ) =
168
+ let get_literal_cases (sw_names : Ast_untagged_variants .switch_names option ) =
169
169
let res = ref [] in
170
170
(match sw_names with
171
171
| None -> res := []
172
172
| Some { consts } ->
173
173
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
176
176
)
177
177
);
178
178
! res
179
179
180
180
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 ) =
182
182
let (null, undefined, other) = (ref false , ref false , ref false ) in
183
183
(match sw_names with
184
184
| None -> ()
185
185
| 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
187
187
| Some Undefined -> undefined := true
188
188
| Some Null -> null := true
189
189
| _ -> other := true );
@@ -500,7 +500,7 @@ and compile_recursive_lets cxt id_args : Js_output.t =
500
500
501
501
and compile_general_cases :
502
502
'a .
503
- ('a -> Lambda. cstr_name option ) ->
503
+ ('a -> Ast_untagged_variants. literal option ) ->
504
504
('a -> J. expression ) ->
505
505
('a option -> J. expression -> 'a option -> J. expression -> J. expression ) ->
506
506
Lam_compile_context. t ->
@@ -513,7 +513,7 @@ and compile_general_cases :
513
513
('a * Lam. t ) list ->
514
514
default_case ->
515
515
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 )
517
517
(eq_exp : 'a option -> J.expression -> 'a option -> J.expression -> J.expression )
518
518
(cxt : Lam_compile_context.t )
519
519
(switch :
@@ -619,9 +619,9 @@ and compile_general_cases :
619
619
and use_compile_literal_cases table get_name =
620
620
List. fold_right (fun (i , lam ) acc ->
621
621
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 ->
623
623
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)
625
625
| _ , _ -> None
626
626
) table (Some [] )
627
627
and 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
634
634
compile_general_cases get_name
635
635
(fun i -> match get_name i with
636
636
| None -> E. small_int i
637
- | Some {literal = Some (String s )} -> E. str s
637
+ | Some {literal_type = Some (String s )} -> E. str s
638
638
| Some {name} -> E. str name)
639
639
(fun _ x _ y -> E. int_equal x y) cxt
640
640
(fun ?default ?declaration e clauses ->
@@ -671,9 +671,9 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch)
671
671
let get_block_name i = match get_block i with
672
672
| None -> None
673
673
| 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
677
677
let tag_name = get_tag_name sw_names in
678
678
let untagged = block_cases <> [] in
679
679
let compile_whole (cxt : Lam_compile_context.t ) =
@@ -744,7 +744,7 @@ and compile_untagged_cases cxt switch_exp table default =
744
744
let literal = function
745
745
| literal -> E. literal literal
746
746
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
748
748
| Block IntType
749
749
| Block StringType
750
750
| Block FloatType
@@ -754,14 +754,14 @@ and compile_untagged_cases cxt switch_exp table default =
754
754
(* This should not happen because unknown must be the only non-literal case *)
755
755
assert false
756
756
| 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
758
758
| Some literal , _ -> (* XX *)
759
759
add_runtime_type_check literal x y
760
760
| _ , Some literal ->
761
761
add_runtime_type_check literal y x
762
762
| _ -> E. string_equal x y
763
763
in
764
- let is_array (l , _ ) = l = Lambda .Block Array in
764
+ let is_array (l , _ ) = l = Ast_untagged_variants .Block Array in
765
765
let body ?default ?declaration e clauses =
766
766
let array_clauses = Ext_list. filter clauses is_array in
767
767
match array_clauses with
@@ -786,7 +786,7 @@ and compile_stringswitch l cases default (lambda_cxt : Lam_compile_context.t) =
786
786
Be careful: we should avoid multiple evaluation of l,
787
787
The [gen] can be elimiated when number of [cases] is less than 3
788
788
*)
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
790
790
match
791
791
compile_lambda { lambda_cxt with continuation = NeedValue Not_tail } l
792
792
with
0 commit comments