forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs_record_iter.ml
229 lines (198 loc) · 7.17 KB
/
js_record_iter.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
(* Copyright (C) 2015- Hongbo Zhang, Authors of ReScript
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition to the permissions granted to you by the LGPL, you may combine
* or link a "work that uses the Library" with a publicly distributed version
* of this file to produce a combined library or application, then distribute
* that combined work under the terms of your choosing, with no requirement
* to comply with the obligations normally placed on you by section 4 of the
* LGPL version 3 (or the corresponding section of a later version of the LGPL
* should you choose to use a later version).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
open J
let unknown _ _ = ()
let[@inline] option sub self v =
match v with None -> () | Some v -> sub self v
let rec list sub self x =
match x with
| [] -> ()
| x :: xs ->
sub self x;
list sub self xs
type iter = {
ident : ident fn;
module_id : module_id fn;
vident : vident fn;
exception_ident : exception_ident fn;
for_ident : for_ident fn;
expression : expression fn;
statement : statement fn;
variable_declaration : variable_declaration fn;
block : block fn;
program : program fn;
}
and 'a fn = iter -> 'a -> unit
let label : label fn = unknown
let ident : ident fn = unknown
let module_id : module_id fn =
fun _self { id = _x0; kind = _x1 } -> _self.ident _self _x0
let required_modules : required_modules fn =
fun _self arg -> list _self.module_id _self arg
let vident : vident fn =
fun _self -> function
| Id _x0 -> _self.ident _self _x0
| Qualified (_x0, _x1) -> _self.module_id _self _x0
let exception_ident : exception_ident fn =
fun _self arg -> _self.ident _self arg
let for_ident : for_ident fn = fun _self arg -> _self.ident _self arg
let for_direction : for_direction fn = unknown
let property_map : property_map fn =
fun _self arg ->
list (fun _self (_x0, _x1) -> _self.expression _self _x1) _self arg
let length_object : length_object fn = unknown
let expression_desc : expression_desc fn =
fun _self -> function
| Length (_x0, _x1) ->
_self.expression _self _x0;
length_object _self _x1
| Is_null_or_undefined _x0 -> _self.expression _self _x0
| String_append (_x0, _x1) ->
_self.expression _self _x0;
_self.expression _self _x1
| Bool _ -> ()
| Typeof _x0 -> _self.expression _self _x0
| Js_not _x0 -> _self.expression _self _x0
| Seq (_x0, _x1) ->
_self.expression _self _x0;
_self.expression _self _x1
| Cond (_x0, _x1, _x2) ->
_self.expression _self _x0;
_self.expression _self _x1;
_self.expression _self _x2
| Bin (_x0, _x1, _x2) ->
_self.expression _self _x1;
_self.expression _self _x2
| FlatCall (_x0, _x1) ->
_self.expression _self _x0;
_self.expression _self _x1
| Call (_x0, _x1, _x2) ->
_self.expression _self _x0;
list _self.expression _self _x1
| String_index (_x0, _x1) ->
_self.expression _self _x0;
_self.expression _self _x1
| Array_index (_x0, _x1) ->
_self.expression _self _x0;
_self.expression _self _x1
| Static_index (_x0, _x1, _x2) -> _self.expression _self _x0
| New (_x0, _x1) ->
_self.expression _self _x0;
option (fun _self arg -> list _self.expression _self arg) _self _x1
| Var _x0 -> _self.vident _self _x0
| Fun {params; body} ->
list _self.ident _self params;
_self.block _self body
| Str _ -> ()
| Raw_js_code _ -> ()
| Array (_x0, _x1) -> list _self.expression _self _x0
| Optional_block (_x0, _x1) -> _self.expression _self _x0
| Caml_block (_x0, _x1, _x2, _x3) ->
list _self.expression _self _x0;
_self.expression _self _x2
| Caml_block_tag _x0 -> _self.expression _self _x0
| Number _ -> ()
| Object _x0 -> property_map _self _x0
| Undefined -> ()
| Null -> ()
| Await _x0 -> _self.expression _self _x0
let for_ident_expression : for_ident_expression fn =
fun _self arg -> _self.expression _self arg
let finish_ident_expression : finish_ident_expression fn =
fun _self arg -> _self.expression _self arg
let case_clause : case_clause fn =
fun _self { switch_body = _x0; should_break = _x1; comment = _x2 } ->
_self.block _self _x0
let string_clause : string_clause fn =
fun _self (_x0, _x1) -> case_clause _self _x1
let int_clause : int_clause fn = fun _self (_x0, _x1) -> case_clause _self _x1
let statement_desc : statement_desc fn =
fun _self -> function
| Block _x0 -> _self.block _self _x0
| Variable _x0 -> _self.variable_declaration _self _x0
| Exp _x0 -> _self.expression _self _x0
| If (_x0, _x1, _x2) ->
_self.expression _self _x0;
_self.block _self _x1;
_self.block _self _x2
| While (_x0, _x1, _x2, _x3) ->
option label _self _x0;
_self.expression _self _x1;
_self.block _self _x2
| ForRange (_x0, _x1, _x2, _x3, _x4, _x5) ->
option for_ident_expression _self _x0;
finish_ident_expression _self _x1;
_self.for_ident _self _x2;
for_direction _self _x3;
_self.block _self _x4
| Continue _x0 -> label _self _x0
| Break -> ()
| Return _x0 -> _self.expression _self _x0
| Int_switch (_x0, _x1, _x2) ->
_self.expression _self _x0;
list int_clause _self _x1;
option _self.block _self _x2
| String_switch (_x0, _x1, _x2) ->
_self.expression _self _x0;
list string_clause _self _x1;
option _self.block _self _x2
| Throw _x0 -> _self.expression _self _x0
| Try (_x0, _x1, _x2) ->
_self.block _self _x0;
option
(fun _self (_x0, _x1) ->
_self.exception_ident _self _x0;
_self.block _self _x1)
_self _x1;
option _self.block _self _x2
| Debugger -> ()
let expression : expression fn =
fun _self { expression_desc = _x0; comment = _x1 } -> expression_desc _self _x0
let statement : statement fn =
fun _self { statement_desc = _x0; comment = _x1 } -> statement_desc _self _x0
let variable_declaration : variable_declaration fn =
fun _self { ident = _x0; value = _x1; property = _x2; ident_info = _x3 } ->
_self.ident _self _x0;
option _self.expression _self _x1
let block : block fn = fun _self arg -> list _self.statement _self arg
let program : program fn =
fun _self { block = _x0; exports = _x1; export_set = _x2 } ->
_self.block _self _x0
let deps_program : deps_program fn =
fun _self { program = _x0; modules = _x1; side_effect = _x2 } ->
_self.program _self _x0;
required_modules _self _x1
let super : iter =
{
ident;
module_id;
vident;
exception_ident;
for_ident;
expression;
statement;
variable_declaration;
block;
program;
}