Source file class_pre_es6.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
open Common
open Cst_js
module V = Visitor_js
module E = Entity_code
let extract_complete_name_of_info ast =
let in_class = ref (None: string option) in
let in_statics = ref false in
let in_members = ref false in
let (h: (Cst_js.tok, Entity_code.entity_kind * string) Hashtbl.t) =
Hashtbl.create 101 in
let v = V.mk_visitor { V.default_visitor with
V.kstmt = (fun (k, _) st ->
match st with
| VarsDecl(_i_1, [Left (VarClassic { v_name = (class_name, info_class); v_type = _;
v_init = Some((_i_3, (Object(_body_object))))})], _scopt) ->
Hashtbl.add h info_class
(E.Class, spf "Misc.%s" class_name);
Common.save_excursion in_class (Some class_name) (fun () ->
Common.save_excursion in_members true (fun () ->
k st
))
| VarsDecl(_i_1, [Left(VarClassic { v_name = (class_name, info_class); v_type = _;
v_init = Some((_i_3,
(Apply(
(Paren((_i_4, (Function(_body_func)), _i_11))),
(_i_13, [], _i_14)))))})], _scopt) ->
Hashtbl.add h info_class
(E.Class, spf "Misc.%s" class_name);
Common.save_excursion in_class (Some class_name) (fun () ->
Common.save_excursion in_members true (fun () ->
k st
))
| _ -> k st
);
V.kexpr = (fun (k, _) e ->
match e with
| Assign(
(Period((V((class_name, info_class))), _i_3, ("prototype", _i_4))),
(A_eq, _i_6),
(Object(_body_object))) ->
Hashtbl.add h info_class
(E.Class, spf "Prototype.%s" class_name);
Common.save_excursion in_class (Some class_name) (fun () ->
Common.save_excursion in_members true (fun () ->
k e
))
| Assign(
(V((class_name, info_class))),
(A_eq, _i_56),
(Object(_body_object))) ->
Hashtbl.add h info_class
(E.Class, spf "Misc.%s" class_name);
Common.save_excursion in_class (Some class_name) (fun () ->
Common.save_excursion in_members true (fun () ->
k e
))
| Apply(
(Period((V(("JX", _i_1))), _i_3, ("install", _i_4))),
(_i_6,
(Left((L(String((class_name, info_class)))))::Right(_i_9)::_rest_args),
_i_13)) ->
Hashtbl.add h info_class
(E.Class, spf "JX.%s" class_name);
Common.save_excursion in_class (Some (spf "JX.%s" class_name))(fun()->
k e
)
| Apply(
(Period((V(("JX", _i_1))), _i_3, ("copy", _i_4))),
(_i_6,
[Left((Period((V((class_name, info_class))),_i_9,
("prototype", _i_10))));
Right(_i_12);
Left((Object(_object_body)))], _i_16)) ->
Hashtbl.add h info_class
(E.Class, spf "JX.%s" class_name);
Common.save_excursion in_class (Some class_name) (fun () ->
Common.save_excursion in_statics true (fun () ->
k e
))
| Apply(
(Period((V((class_name, info_class))), _i_3, ("mixin", _i_4))),
(_i_6,
[Left((L(String((mixin_name, _info_mixin))))); Right(_i_9);
Left((Object(_body_object)))], _i_13)) ->
Hashtbl.add h info_class
(E.Class, spf "%s<%s" class_name mixin_name);
Common.save_excursion in_class (Some class_name) (fun () ->
Common.save_excursion in_statics true (fun () ->
k e
))
| Apply(
(Period((V(("FB", _i_1))), _i_3, ("subclass", _i_4))),
(_i_6,
[Left((L(String((class_name, info_class))))); Right(_i_9);
Left((L(String((_parent_class, _i_10))))); Right(_i_12);
Left((Object(_body_object)))], _i_16)) ->
Hashtbl.add h info_class
(E.Class, spf "%s" class_name);
Common.save_excursion in_class (Some class_name) (fun () ->
Common.save_excursion in_statics true (fun () ->
k e
))
| Apply(
(Period((V(("FB", _i_19))), _i_21, ("provide", _i_22))),
(_i_24,
[Left((L(String((class_name, info_class))))); Right(_i_27);
Left((Object(_body_object)))], _i_31)) ->
Hashtbl.add h info_class
(E.Class, spf "%s" class_name);
Common.save_excursion in_class (Some class_name) (fun () ->
Common.save_excursion in_statics true (fun () ->
k e
))
| Apply(
(V(("copy_properties", _i_16))),
(_i_18,
[Left((V((class_name, info_class)))); Right(_i_21);
Left((Object(_body_object)))], _i_25)) ->
Hashtbl.add h info_class
(E.Class, spf "Copy_properties.%s" class_name);
Common.save_excursion in_class (Some class_name) (fun () ->
Common.save_excursion in_statics true (fun () ->
k e
))
| Apply(
(V(("copy_properties", info_class))),
(_i_3,
[Left((Period((V((class_name, _i_4))), _i_6, ("prototype", _i_7))));
Right(_i_9);
Left((Object(_body_object)))], _i_13)) ->
Hashtbl.add h info_class
(E.Class, spf "Copy_properties.%s" class_name);
Common.save_excursion in_class (Some class_name) (fun () ->
Common.save_excursion in_statics true (fun () ->
k e
))
| _ -> k e
);
V.kprop = (fun (k, _) e ->
match e with
| P_field (PN_String(("statics", _i_20)), _i_21, _body) ->
Common.save_excursion in_statics true (fun () -> k e)
| P_field (PN_String(("members", _i_20)), _i_21, _body) ->
Common.save_excursion in_members true (fun () -> k e)
| P_field (PN_String((method_name, info_method_name)), _i_40, (Function(_))) ->
let fullname =
(match !in_class, !in_statics, !in_members with
| Some classname, true, false ->
spf "%s::%s" classname method_name
| Some classname, false, true ->
spf "%s->%s" classname method_name
| Some _classname, true, true ->
pr2 ("WEIRD: both statics and members at " ^
Parse_info.string_of_info info_method_name);
""
| Some classname, false, false ->
(match method_name with
| "initialize" | "construct" ->
spf "%s::%s" classname method_name
| _ ->
pr2 ("WEIRD: in class but no statics or members at " ^
Parse_info.string_of_info info_method_name);
""
)
| None, true, _
| None, _, true
->
pr2 ("WEIRD: no class but statics or members at " ^
Parse_info.string_of_info info_method_name);
""
| None, _, _ ->
let raw_str = Parse_info.str_of_info info_method_name in
if raw_str =~ "^[']"
then ()
else begin
end;
""
)
in
Hashtbl.add h info_method_name (E.Method, fullname)
| _ -> k e
);
}
in
v (Program ast);
h