From 329f291cd9c8d7e6667a1f568bc81fac5a3c6951 Mon Sep 17 00:00:00 2001 From: Konstantin Olkhovskiy Date: Sun, 1 Nov 2020 12:08:01 +0300 Subject: [PATCH] Specialize caml_float_of_int --- compiler/lib/generate.ml | 2 +- compiler/lib/javascript_from_rehp.re | 1 + compiler/lib/php_from_rehp.re | 3 +++ compiler/lib/rehp.re | 1 + compiler/lib/rehp.rei | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/lib/generate.ml b/compiler/lib/generate.ml index 5118bdd5..1e7d61fb 100644 --- a/compiler/lib/generate.ml +++ b/compiler/lib/generate.ml @@ -1031,7 +1031,6 @@ let _ = ; "caml_int64_to_int", "caml_int64_to_int32" ; "caml_int64_of_nativeint", "caml_int64_of_int32" ; "caml_int64_to_nativeint", "caml_int64_to_int32" - ; "caml_float_of_int", "%identity" ; "caml_array_get_float", "caml_array_get" ; "caml_floatarray_get", "caml_array_get" ; "caml_array_get_addr", "caml_array_get" @@ -1331,6 +1330,7 @@ let _ = ); register_un_prim "caml_obj_dup" `Mutable (fun cx loc -> J.ECopy (cx, loc)); register_un_prim "caml_int_of_float" `Pure (fun cx _loc -> (J.EUn (J.FloatToInt, cx))); + register_un_prim "caml_float_of_int" `Pure (fun cx _loc -> (J.EUn (J.IntToFloat, cx))); register_un_math_prim "caml_abs_float" "abs"; register_un_math_prim "caml_acos_float" "acos"; register_un_math_prim "caml_asin_float" "asin"; diff --git a/compiler/lib/javascript_from_rehp.re b/compiler/lib/javascript_from_rehp.re index 547d6694..2a53df6c 100644 --- a/compiler/lib/javascript_from_rehp.re +++ b/compiler/lib/javascript_from_rehp.re @@ -33,6 +33,7 @@ and from_unop = (unop, jsExpr) => | ToBool | FloatToInt | ToInt => Expand.toInt(jsExpr) + | IntToFloat => jsExpr | IntToString => Expand.intToString(jsExpr) | FloatNeg | Neg => EUn(Javascript.Neg, jsExpr) diff --git a/compiler/lib/php_from_rehp.re b/compiler/lib/php_from_rehp.re index 00a5368f..2c117b9c 100644 --- a/compiler/lib/php_from_rehp.re +++ b/compiler/lib/php_from_rehp.re @@ -553,6 +553,9 @@ and unopFromRehp = (input, unop, rehpExpr) => | ToInt => let (outMapped, exprMapped) = expression(input, rehpExpr); (outMapped, EUn(ToInt, exprMapped)); + | IntToFloat => + let (outMapped, exprMapped) = expression(input, rehpExpr); + (outMapped, exprMapped); | IntToString => let (outMapped, exprMapped) = expression(input, rehpExpr); (outMapped, EUn(IntToString, exprMapped)); diff --git a/compiler/lib/rehp.re b/compiler/lib/rehp.re index ad9f4352..48624b69 100644 --- a/compiler/lib/rehp.re +++ b/compiler/lib/rehp.re @@ -119,6 +119,7 @@ and unop = | ToBool | IntToString | FloatToInt + | IntToFloat | Void /* Only for stubs */ | Delete /* Only for stubs */ | Bnot diff --git a/compiler/lib/rehp.rei b/compiler/lib/rehp.rei index 70561ebb..c2a869b3 100644 --- a/compiler/lib/rehp.rei +++ b/compiler/lib/rehp.rei @@ -75,6 +75,7 @@ and unop = | ToBool | IntToString | FloatToInt + | IntToFloat | Void | Delete | Bnot