File tree Expand file tree Collapse file tree 4 files changed +28
-24
lines changed Expand file tree Collapse file tree 4 files changed +28
-24
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ let js_module_table : Ident.t Hash_string.t = Hash_string.create 31
97
97
98
98
*)
99
99
100
- let [@ inline] convert (c : char ) : string =
100
+ let [@ inline] convert ?(op = false ) (c : char ) : string =
101
101
(match c with
102
102
| '*' -> " $star"
103
103
| '\' ' -> " $p"
@@ -106,7 +106,7 @@ let [@inline] convert (c : char) : string =
106
106
| '<' -> " $less"
107
107
| '=' -> " $eq"
108
108
| '+' -> " $plus"
109
- | '-' -> " $neg"
109
+ | '-' -> if op then " $neg" else " $ "
110
110
| '@' -> " $at"
111
111
| '^' -> " $caret"
112
112
| '/' -> " $slash"
@@ -131,23 +131,24 @@ let [@inline] no_escape (c : char) =
131
131
| 'a' .. 'z' | 'A' .. 'Z'
132
132
| '0' .. '9' | '_' | '$' -> true
133
133
| _ -> false
134
- exception Not_normal_letter
134
+
135
+ exception Not_normal_letter of int
135
136
let name_mangle name =
136
137
let len = String. length name in
137
138
try
138
139
for i = 0 to len - 1 do
139
140
if not (no_escape (String. unsafe_get name i)) then
140
- raise_notrace (Not_normal_letter )
141
+ raise_notrace (Not_normal_letter i )
141
142
done ;
142
143
name (* Normal letter *)
143
144
with
144
- | Not_normal_letter ->
145
+ | Not_normal_letter i ->
145
146
let buffer = Ext_buffer. create len in
146
147
for j = 0 to len - 1 do
147
148
let c = String. unsafe_get name j in
148
149
if no_escape c then Ext_buffer. add_char buffer c
149
150
else
150
- Ext_buffer. add_string buffer (convert c)
151
+ Ext_buffer. add_string buffer (convert ~op: (i = 0 ) c)
151
152
done ; Ext_buffer. contents buffer
152
153
153
154
(* TODO:
Original file line number Diff line number Diff line change @@ -10932,7 +10932,7 @@ let js_module_table : Ident.t Hash_string.t = Hash_string.create 31
10932
10932
10933
10933
*)
10934
10934
10935
- let [@inline] convert (c : char) : string =
10935
+ let [@inline] convert ?(op=false) (c : char) : string =
10936
10936
(match c with
10937
10937
| '*' -> "$star"
10938
10938
| '\'' -> "$p"
@@ -10941,7 +10941,7 @@ let [@inline] convert (c : char) : string =
10941
10941
| '<' -> "$less"
10942
10942
| '=' -> "$eq"
10943
10943
| '+' -> "$plus"
10944
- | '-' -> "$neg"
10944
+ | '-' -> if op then "$neg" else "$ "
10945
10945
| '@' -> "$at"
10946
10946
| '^' -> "$caret"
10947
10947
| '/' -> "$slash"
@@ -10966,23 +10966,24 @@ let [@inline] no_escape (c : char) =
10966
10966
| 'a' .. 'z' | 'A' .. 'Z'
10967
10967
| '0' .. '9' | '_' | '$' -> true
10968
10968
| _ -> false
10969
- exception Not_normal_letter
10969
+
10970
+ exception Not_normal_letter of int
10970
10971
let name_mangle name =
10971
10972
let len = String.length name in
10972
10973
try
10973
10974
for i = 0 to len - 1 do
10974
10975
if not (no_escape (String.unsafe_get name i)) then
10975
- raise_notrace (Not_normal_letter )
10976
+ raise_notrace (Not_normal_letter i )
10976
10977
done;
10977
10978
name (* Normal letter *)
10978
10979
with
10979
- | Not_normal_letter ->
10980
+ | Not_normal_letter i ->
10980
10981
let buffer = Ext_buffer.create len in
10981
10982
for j = 0 to len - 1 do
10982
10983
let c = String.unsafe_get name j in
10983
10984
if no_escape c then Ext_buffer.add_char buffer c
10984
10985
else
10985
- Ext_buffer.add_string buffer (convert c)
10986
+ Ext_buffer.add_string buffer (convert ~op:(i=0) c)
10986
10987
done; Ext_buffer.contents buffer
10987
10988
10988
10989
(* TODO:
Original file line number Diff line number Diff line change @@ -82022,7 +82022,7 @@ let js_module_table : Ident.t Hash_string.t = Hash_string.create 31
82022
82022
82023
82023
*)
82024
82024
82025
- let [@inline] convert (c : char) : string =
82025
+ let [@inline] convert ?(op=false) (c : char) : string =
82026
82026
(match c with
82027
82027
| '*' -> "$star"
82028
82028
| '\'' -> "$p"
@@ -82031,7 +82031,7 @@ let [@inline] convert (c : char) : string =
82031
82031
| '<' -> "$less"
82032
82032
| '=' -> "$eq"
82033
82033
| '+' -> "$plus"
82034
- | '-' -> "$neg"
82034
+ | '-' -> if op then "$neg" else "$ "
82035
82035
| '@' -> "$at"
82036
82036
| '^' -> "$caret"
82037
82037
| '/' -> "$slash"
@@ -82056,23 +82056,24 @@ let [@inline] no_escape (c : char) =
82056
82056
| 'a' .. 'z' | 'A' .. 'Z'
82057
82057
| '0' .. '9' | '_' | '$' -> true
82058
82058
| _ -> false
82059
- exception Not_normal_letter
82059
+
82060
+ exception Not_normal_letter of int
82060
82061
let name_mangle name =
82061
82062
let len = String.length name in
82062
82063
try
82063
82064
for i = 0 to len - 1 do
82064
82065
if not (no_escape (String.unsafe_get name i)) then
82065
- raise_notrace (Not_normal_letter )
82066
+ raise_notrace (Not_normal_letter i )
82066
82067
done;
82067
82068
name (* Normal letter *)
82068
82069
with
82069
- | Not_normal_letter ->
82070
+ | Not_normal_letter i ->
82070
82071
let buffer = Ext_buffer.create len in
82071
82072
for j = 0 to len - 1 do
82072
82073
let c = String.unsafe_get name j in
82073
82074
if no_escape c then Ext_buffer.add_char buffer c
82074
82075
else
82075
- Ext_buffer.add_string buffer (convert c)
82076
+ Ext_buffer.add_string buffer (convert ~op:(i=0) c)
82076
82077
done; Ext_buffer.contents buffer
82077
82078
82078
82079
(* TODO:
Original file line number Diff line number Diff line change @@ -373278,7 +373278,7 @@ let js_module_table : Ident.t Hash_string.t = Hash_string.create 31
373278
373278
373279
373279
*)
373280
373280
373281
- let [@inline] convert (c : char) : string =
373281
+ let [@inline] convert ?(op=false) (c : char) : string =
373282
373282
(match c with
373283
373283
| '*' -> "$star"
373284
373284
| '\'' -> "$p"
@@ -373287,7 +373287,7 @@ let [@inline] convert (c : char) : string =
373287
373287
| '<' -> "$less"
373288
373288
| '=' -> "$eq"
373289
373289
| '+' -> "$plus"
373290
- | '-' -> "$neg"
373290
+ | '-' -> if op then "$neg" else "$ "
373291
373291
| '@' -> "$at"
373292
373292
| '^' -> "$caret"
373293
373293
| '/' -> "$slash"
@@ -373312,23 +373312,24 @@ let [@inline] no_escape (c : char) =
373312
373312
| 'a' .. 'z' | 'A' .. 'Z'
373313
373313
| '0' .. '9' | '_' | '$' -> true
373314
373314
| _ -> false
373315
- exception Not_normal_letter
373315
+
373316
+ exception Not_normal_letter of int
373316
373317
let name_mangle name =
373317
373318
let len = String.length name in
373318
373319
try
373319
373320
for i = 0 to len - 1 do
373320
373321
if not (no_escape (String.unsafe_get name i)) then
373321
- raise_notrace (Not_normal_letter )
373322
+ raise_notrace (Not_normal_letter i )
373322
373323
done;
373323
373324
name (* Normal letter *)
373324
373325
with
373325
- | Not_normal_letter ->
373326
+ | Not_normal_letter i ->
373326
373327
let buffer = Ext_buffer.create len in
373327
373328
for j = 0 to len - 1 do
373328
373329
let c = String.unsafe_get name j in
373329
373330
if no_escape c then Ext_buffer.add_char buffer c
373330
373331
else
373331
- Ext_buffer.add_string buffer (convert c)
373332
+ Ext_buffer.add_string buffer (convert ~op:(i=0) c)
373332
373333
done; Ext_buffer.contents buffer
373333
373334
373334
373335
(* TODO:
You can’t perform that action at this time.
0 commit comments