Skip to content

Commit 5dea80d

Browse files
committed
snapshot
1 parent 059fc19 commit 5dea80d

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

Diff for: lib/js/caml_format.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -771,29 +771,20 @@ function caml_format_float(fmt, x) {
771771
}
772772

773773
var float_of_string = function (s,exn){
774-
{
774+
775775
var res = +s;
776776
if ((s.length > 0) && (res === res))
777777
return res;
778778
s = s.replace(/_/g, "");
779779
res = +s;
780780
if (((s.length > 0) && (res === res)) || /^[+-]?nan$/i.test(s)) {
781781
return res;
782-
}
783-
;
784-
if (/^ *0x[0-9a-f_]+p[+-]?[0-9_]+/i.test(s)) {
785-
var pidx = s.indexOf('p');
786-
pidx = (pidx == -1) ? s.indexOf('P') : pidx;
787-
var exp = +s.substring(pidx + 1);
788-
res = +s.substring(0, pidx);
789-
return res * Math.pow(2, exp);
790-
}
782+
};
791783
if (/^\+?inf(inity)?$/i.test(s))
792784
return Infinity;
793785
if (/^-inf(inity)?$/i.test(s))
794786
return -Infinity;
795787
throw exn;
796-
}
797788

798789
};
799790

Diff for: lib/whole_compiler.ml

+20-17
Original file line numberDiff line numberDiff line change
@@ -82976,7 +82976,7 @@ module Js_number : sig
8297682976
type t = float
8297782977

8297882978

82979-
val to_string : t -> string
82979+
(* val to_string : t -> string *)
8298082980

8298182981

8298282982
val caml_float_literal_to_js_string : string -> string
@@ -83057,18 +83057,20 @@ let to_string v =
8305783057
else Printf.sprintf "%.18g" v
8305883058

8305983059

83060+
let rec is_hex_format_aux (v : string) cur =
83061+
if v.[cur] = '-' || v.[cur]= '+' then
83062+
is_hex_format_ox v (cur + 1)
83063+
else is_hex_format_ox v cur
83064+
and is_hex_format_ox v cur =
83065+
v.[cur] = '0' &&
83066+
(v.[cur + 1] = 'x' || v.[cur + 1] = 'X')
83067+
83068+
let is_hex_format (v : string) =
83069+
try is_hex_format_aux v 0 with _ -> false
8306083070

83061-
let caml_float_literal_to_js_string v =
83071+
83072+
let caml_float_literal_to_js_string (v : string) : string =
8306283073
let len = String.length v in
83063-
if len >= 2 &&
83064-
v.[0] = '0' &&
83065-
(v.[1] = 'x' || v.[1] = 'X') then
83066-
assert false
83067-
(* TODO: catchup when upgraded to 4.3
83068-
it does not make sense too much since js dos not
83069-
support it natively
83070-
*)
83071-
else
8307283074

8307383075
let rec aux buf i =
8307483076
if i >= len then buf
@@ -83762,11 +83764,11 @@ and expression_desc cxt (level:int) f x : cxt =
8376283764
| Number v ->
8376383765
let s =
8376483766
match v with
83765-
| Float {f = v} ->
83766-
Js_number.caml_float_literal_to_js_string v
83767+
| Float {f} ->
83768+
Js_number.caml_float_literal_to_js_string f
8376783769
(* attach string here for float constant folding?*)
83768-
| Int { i = v; _}
83769-
-> Int32.to_string v (* check , js convention with ocaml lexical convention *)
83770+
| Int { i; _}
83771+
-> Int32.to_string i (* check , js convention with ocaml lexical convention *)
8377083772
| Uint i
8377183773
-> Format.asprintf "%lu" i
8377283774
| Nint i -> Nativeint.to_string i in
@@ -83776,7 +83778,8 @@ and expression_desc cxt (level:int) f x : cxt =
8377683778
else level = 15 (* Parenthesize as well when followed by a dot. *)
8377783779
&& s.[0] <> 'I' (* Infinity *)
8377883780
&& s.[0] <> 'N' (* NaN *) in
83779-
let action = fun _ -> P.string f s in
83781+
let action =
83782+
fun _ -> P.string f s in
8378083783
(
8378183784
if need_paren
8378283785
then P.paren f action
@@ -95390,7 +95393,7 @@ let translate loc (prim_name : string)
9539095393

9539195394
end
9539295395
| "caml_format_float"
95393-
95396+
9539495397
| "caml_nativeint_format"
9539595398
| "caml_int32_format"
9539695399
| "caml_float_of_string"

0 commit comments

Comments
 (0)