From f5aa651fa1422bddff7ac4728d5733cbb8c418cc Mon Sep 17 00:00:00 2001 From: alanechang Date: Thu, 23 Nov 2023 11:38:31 -0500 Subject: [PATCH] remove the transl_constant function --- ocaml/lambda/lambda.ml | 4 ---- ocaml/lambda/lambda.mli | 2 -- ocaml/lambda/matching.ml | 19 +++++++++---------- ocaml/lambda/translcore.ml | 2 +- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/ocaml/lambda/lambda.ml b/ocaml/lambda/lambda.ml index 3ca0ecd7c03..ec429e84a9d 100644 --- a/ocaml/lambda/lambda.ml +++ b/ocaml/lambda/lambda.ml @@ -1096,10 +1096,6 @@ let transl_prim mod_name name = | exception Not_found -> fatal_error ("Primitive " ^ name ^ " not found.") -(* Translation of constants *) - -let transl_constant (cst : Typedtree.constant) = Lconst(Const_base cst) - (* Compile a sequence of expressions *) let rec make_sequence fn = function diff --git a/ocaml/lambda/lambda.mli b/ocaml/lambda/lambda.mli index 944eaf2bd52..0f1abc19cf8 100644 --- a/ocaml/lambda/lambda.mli +++ b/ocaml/lambda/lambda.mli @@ -667,8 +667,6 @@ val transl_prim: string -> string -> lambda ]} *) -val transl_constant : Typedtree.constant -> lambda - val free_variables: lambda -> Ident.Set.t val transl_module_path: scoped_location -> Env.t -> Path.t -> lambda diff --git a/ocaml/lambda/matching.ml b/ocaml/lambda/matching.ml index 615855972f9..9af0271b2b5 100644 --- a/ocaml/lambda/matching.ml +++ b/ocaml/lambda/matching.ml @@ -2400,7 +2400,7 @@ let rec do_tests_fail value_kind loc fail tst arg = function | [] -> fail | (c, act) :: rem -> Lifthenelse - ( Lprim (tst, [ arg; c ], loc), + ( Lprim (tst, [ arg; Lconst (Const_base c) ], loc), do_tests_fail value_kind loc fail tst arg rem, act, value_kind ) @@ -2409,16 +2409,15 @@ let rec do_tests_nofail value_kind loc tst arg = function | [ (_, act) ] -> act | (c, act) :: rem -> Lifthenelse - ( Lprim (tst, [ arg; c ], loc), + ( Lprim (tst, [ arg; Lconst (Const_base c) ], loc), do_tests_nofail value_kind loc tst arg rem, act, value_kind ) -let make_test_sequence value_kind loc fail tst lt_tst arg const_lambda_list transl_const = +let make_test_sequence value_kind loc fail tst lt_tst arg const_lambda_list = let const_lambda_list = sort_lambda_list const_lambda_list in let hs, const_lambda_list, fail = share_actions_tree value_kind const_lambda_list fail in - let const_lambda_list = List.map (fun (c, l) -> transl_const c, l) const_lambda_list in let rec make_test_sequence const_lambda_list = if List.length const_lambda_list >= 4 && lt_tst <> Pignore then split_sequence const_lambda_list @@ -2431,7 +2430,7 @@ let make_test_sequence value_kind loc fail tst lt_tst arg const_lambda_list tran rev_split_at (List.length const_lambda_list / 2) const_lambda_list in Lifthenelse - ( Lprim (lt_tst, [ arg; fst (List.hd list2) ], loc), + ( Lprim (lt_tst, [ arg; Lconst (Const_base (fst (List.hd list2))) ], loc), make_test_sequence list1, make_test_sequence list2, value_kind ) in @@ -2867,27 +2866,27 @@ let combine_constant value_kind loc arg cst partial ctx def | Const_float _ -> make_test_sequence value_kind loc fail (Pfloatcomp CFneq) (Pfloatcomp CFlt) arg - const_lambda_list transl_constant + const_lambda_list | Const_unboxed_float _ -> make_test_sequence value_kind loc fail (Punboxed_float_comp CFneq) (Punboxed_float_comp CFlt) - arg const_lambda_list transl_constant + arg const_lambda_list | Const_int32 _ -> make_test_sequence value_kind loc fail (Pbintcomp (Pint32, Cne)) (Pbintcomp (Pint32, Clt)) - arg const_lambda_list transl_constant + arg const_lambda_list | Const_int64 _ -> make_test_sequence value_kind loc fail (Pbintcomp (Pint64, Cne)) (Pbintcomp (Pint64, Clt)) - arg const_lambda_list transl_constant + arg const_lambda_list | Const_nativeint _ -> make_test_sequence value_kind loc fail (Pbintcomp (Pnativeint, Cne)) (Pbintcomp (Pnativeint, Clt)) - arg const_lambda_list transl_constant + arg const_lambda_list in (lambda1, Jumps.union local_jumps total) diff --git a/ocaml/lambda/translcore.ml b/ocaml/lambda/translcore.ml index 4fddea11be7..8b7edf13517 100644 --- a/ocaml/lambda/translcore.ml +++ b/ocaml/lambda/translcore.ml @@ -389,7 +389,7 @@ and transl_exp0 ~in_new_scope ~scopes sort e = | Texp_ident(path, _, desc, kind, _) -> transl_ident (of_location ~scopes e.exp_loc) e.exp_env e.exp_type path desc kind - | Texp_constant cst -> transl_constant cst + | Texp_constant cst -> Lconst (Const_base cst) | Texp_let(rec_flag, pat_expr_list, body) -> let return_layout = layout_exp sort body in transl_let ~scopes ~return_layout rec_flag pat_expr_list