Skip to content

Commit

Permalink
remove the transl_constant function
Browse files Browse the repository at this point in the history
  • Loading branch information
alanechang committed Nov 29, 2023
1 parent a744ed6 commit f5aa651
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
4 changes: 0 additions & 4 deletions ocaml/lambda/lambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions ocaml/lambda/lambda.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions ocaml/lambda/matching.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 )

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion ocaml/lambda/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5aa651

Please sign in to comment.