Skip to content

Commit 8dbd65e

Browse files
committed
print bs-external in different modes for debugging
1 parent 627f27f commit 8dbd65e

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

jscomp/syntax/external_ffi_types.ml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,26 @@ let bs_external_length = String.length bs_external
249249
let to_string (t : t) =
250250
bs_external ^ Marshal.to_string t []
251251

252-
253-
(* TODO: better error message when version mismatch *)
254-
let from_string s : t =
252+
let is_bs_primitive s =
255253
let s_len = String.length s in
256-
if s_len >= bs_prefix_length &&
254+
s_len >= bs_prefix_length &&
257255
String.unsafe_get s 0 = 'B' &&
258256
String.unsafe_get s 1 = 'S' &&
259-
String.unsafe_get s 2 = ':' then
257+
String.unsafe_get s 2 = ':'
258+
259+
260+
let () = Oprint.map_primitive_name :=
261+
#if BS_RELEASE_BUILD then
262+
(fun s ->
263+
if is_bs_primitive s then "BS:external"
264+
else s )
265+
#else
266+
(fun s -> String.escaped s)
267+
#end
268+
269+
(* TODO: better error message when version mismatch *)
270+
let from_string s : t =
271+
if is_bs_primitive s then
260272
Marshal.from_string s bs_external_length
261273
else Ffi_normal
262274

0 commit comments

Comments
 (0)