yarp 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -1
- data/README.md +4 -3
- data/config.yml +332 -52
- data/docs/configuration.md +1 -0
- data/docs/ruby_api.md +2 -0
- data/docs/serialization.md +1 -1
- data/docs/testing.md +2 -2
- data/ext/yarp/api_node.c +703 -136
- data/ext/yarp/extension.c +73 -24
- data/ext/yarp/extension.h +2 -2
- data/include/yarp/ast.h +331 -137
- data/include/yarp/node.h +10 -0
- data/include/yarp/unescape.h +4 -2
- data/include/yarp/util/yp_newline_list.h +3 -0
- data/include/yarp/version.h +2 -2
- data/include/yarp.h +10 -0
- data/lib/yarp/desugar_visitor.rb +267 -0
- data/lib/yarp/ffi.rb +27 -1
- data/lib/yarp/lex_compat.rb +93 -25
- data/lib/yarp/mutation_visitor.rb +683 -0
- data/lib/yarp/node.rb +3042 -508
- data/lib/yarp/serialize.rb +198 -126
- data/lib/yarp.rb +48 -2
- data/src/node.c +421 -185
- data/src/prettyprint.c +262 -80
- data/src/serialize.c +410 -270
- data/src/token_type.c +2 -2
- data/src/unescape.c +69 -51
- data/src/util/yp_newline_list.c +10 -0
- data/src/yarp.c +1208 -458
- data/yarp.gemspec +3 -1
- metadata +4 -2
data/src/serialize.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/******************************************************************************/
|
2
|
-
/* This file is generated by the
|
3
|
-
/* modified manually. See
|
2
|
+
/* This file is generated by the templates/template.rb script and should not */
|
3
|
+
/* be modified manually. See */
|
4
4
|
/* templates/src/serialize.c.erb */
|
5
5
|
/* if you are looking to modify the */
|
6
6
|
/* template */
|
@@ -22,7 +22,7 @@ yp_sizet_to_u32(size_t value) {
|
|
22
22
|
}
|
23
23
|
|
24
24
|
static void
|
25
|
-
|
25
|
+
yp_serialize_location(yp_parser_t *parser, yp_location_t *location, yp_buffer_t *buffer) {
|
26
26
|
assert(location->start);
|
27
27
|
assert(location->end);
|
28
28
|
assert(location->start <= location->end);
|
@@ -31,37 +31,58 @@ serialize_location(yp_parser_t *parser, yp_location_t *location, yp_buffer_t *bu
|
|
31
31
|
yp_buffer_append_u32(buffer, yp_ptrdifft_to_u32(location->end - location->start));
|
32
32
|
}
|
33
33
|
|
34
|
+
static void
|
35
|
+
yp_serialize_string(yp_parser_t *parser, yp_string_t *string, yp_buffer_t *buffer) {
|
36
|
+
switch (string->type) {
|
37
|
+
case YP_STRING_SHARED: {
|
38
|
+
yp_buffer_append_u8(buffer, 1);
|
39
|
+
yp_buffer_append_u32(buffer, yp_ptrdifft_to_u32(yp_string_source(string) - parser->start));
|
40
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(yp_string_length(string)));
|
41
|
+
break;
|
42
|
+
}
|
43
|
+
case YP_STRING_OWNED:
|
44
|
+
case YP_STRING_CONSTANT: {
|
45
|
+
uint32_t length = yp_sizet_to_u32(yp_string_length(string));
|
46
|
+
yp_buffer_append_u8(buffer, 2);
|
47
|
+
yp_buffer_append_u32(buffer, length);
|
48
|
+
yp_buffer_append_str(buffer, yp_string_source(string), length);
|
49
|
+
break;
|
50
|
+
}
|
51
|
+
case YP_STRING_MAPPED:
|
52
|
+
assert(false && "Cannot serialize mapped strings.");
|
53
|
+
break;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
34
57
|
void
|
35
58
|
yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
36
59
|
yp_buffer_append_u8(buffer, (uint8_t) YP_NODE_TYPE(node));
|
37
60
|
|
38
61
|
size_t offset = buffer->length;
|
39
62
|
|
40
|
-
|
63
|
+
yp_serialize_location(parser, &node->location, buffer);
|
41
64
|
|
42
65
|
switch (YP_NODE_TYPE(node)) {
|
66
|
+
// We do not need to serialize a ScopeNode ever as
|
67
|
+
// it is not part of the AST
|
68
|
+
case YP_NODE_SCOPE_NODE:
|
69
|
+
return;
|
43
70
|
case YP_NODE_ALIAS_NODE: {
|
44
71
|
yp_serialize_node(parser, (yp_node_t *)((yp_alias_node_t *)node)->new_name, buffer);
|
45
72
|
yp_serialize_node(parser, (yp_node_t *)((yp_alias_node_t *)node)->old_name, buffer);
|
46
|
-
|
73
|
+
yp_serialize_location(parser, &((yp_alias_node_t *)node)->keyword_loc, buffer);
|
47
74
|
break;
|
48
75
|
}
|
49
76
|
case YP_NODE_ALTERNATION_PATTERN_NODE: {
|
50
77
|
yp_serialize_node(parser, (yp_node_t *)((yp_alternation_pattern_node_t *)node)->left, buffer);
|
51
78
|
yp_serialize_node(parser, (yp_node_t *)((yp_alternation_pattern_node_t *)node)->right, buffer);
|
52
|
-
|
79
|
+
yp_serialize_location(parser, &((yp_alternation_pattern_node_t *)node)->operator_loc, buffer);
|
53
80
|
break;
|
54
81
|
}
|
55
82
|
case YP_NODE_AND_NODE: {
|
56
83
|
yp_serialize_node(parser, (yp_node_t *)((yp_and_node_t *)node)->left, buffer);
|
57
84
|
yp_serialize_node(parser, (yp_node_t *)((yp_and_node_t *)node)->right, buffer);
|
58
|
-
|
59
|
-
break;
|
60
|
-
}
|
61
|
-
case YP_NODE_AND_WRITE_NODE: {
|
62
|
-
yp_serialize_node(parser, (yp_node_t *)((yp_and_write_node_t *)node)->target, buffer);
|
63
|
-
yp_serialize_node(parser, (yp_node_t *)((yp_and_write_node_t *)node)->value, buffer);
|
64
|
-
serialize_location(parser, &((yp_and_write_node_t *)node)->operator_loc, buffer);
|
85
|
+
yp_serialize_location(parser, &((yp_and_node_t *)node)->operator_loc, buffer);
|
65
86
|
break;
|
66
87
|
}
|
67
88
|
case YP_NODE_ARGUMENTS_NODE: {
|
@@ -82,13 +103,13 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
82
103
|
yp_buffer_append_u8(buffer, 0);
|
83
104
|
} else {
|
84
105
|
yp_buffer_append_u8(buffer, 1);
|
85
|
-
|
106
|
+
yp_serialize_location(parser, &((yp_array_node_t *)node)->opening_loc, buffer);
|
86
107
|
}
|
87
108
|
if (((yp_array_node_t *)node)->closing_loc.start == NULL) {
|
88
109
|
yp_buffer_append_u8(buffer, 0);
|
89
110
|
} else {
|
90
111
|
yp_buffer_append_u8(buffer, 1);
|
91
|
-
|
112
|
+
yp_serialize_location(parser, &((yp_array_node_t *)node)->closing_loc, buffer);
|
92
113
|
}
|
93
114
|
break;
|
94
115
|
}
|
@@ -117,13 +138,13 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
117
138
|
yp_buffer_append_u8(buffer, 0);
|
118
139
|
} else {
|
119
140
|
yp_buffer_append_u8(buffer, 1);
|
120
|
-
|
141
|
+
yp_serialize_location(parser, &((yp_array_pattern_node_t *)node)->opening_loc, buffer);
|
121
142
|
}
|
122
143
|
if (((yp_array_pattern_node_t *)node)->closing_loc.start == NULL) {
|
123
144
|
yp_buffer_append_u8(buffer, 0);
|
124
145
|
} else {
|
125
146
|
yp_buffer_append_u8(buffer, 1);
|
126
|
-
|
147
|
+
yp_serialize_location(parser, &((yp_array_pattern_node_t *)node)->closing_loc, buffer);
|
127
148
|
}
|
128
149
|
break;
|
129
150
|
}
|
@@ -138,7 +159,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
138
159
|
yp_buffer_append_u8(buffer, 0);
|
139
160
|
} else {
|
140
161
|
yp_buffer_append_u8(buffer, 1);
|
141
|
-
|
162
|
+
yp_serialize_location(parser, &((yp_assoc_node_t *)node)->operator_loc, buffer);
|
142
163
|
}
|
143
164
|
break;
|
144
165
|
}
|
@@ -148,7 +169,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
148
169
|
} else {
|
149
170
|
yp_serialize_node(parser, (yp_node_t *)((yp_assoc_splat_node_t *)node)->value, buffer);
|
150
171
|
}
|
151
|
-
|
172
|
+
yp_serialize_location(parser, &((yp_assoc_splat_node_t *)node)->operator_loc, buffer);
|
152
173
|
break;
|
153
174
|
}
|
154
175
|
case YP_NODE_BACK_REFERENCE_READ_NODE: {
|
@@ -159,7 +180,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
159
180
|
yp_buffer_append_u8(buffer, 0);
|
160
181
|
} else {
|
161
182
|
yp_buffer_append_u8(buffer, 1);
|
162
|
-
|
183
|
+
yp_serialize_location(parser, &((yp_begin_node_t *)node)->begin_keyword_loc, buffer);
|
163
184
|
}
|
164
185
|
if (((yp_begin_node_t *)node)->statements == NULL) {
|
165
186
|
yp_buffer_append_u8(buffer, 0);
|
@@ -185,7 +206,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
185
206
|
yp_buffer_append_u8(buffer, 0);
|
186
207
|
} else {
|
187
208
|
yp_buffer_append_u8(buffer, 1);
|
188
|
-
|
209
|
+
yp_serialize_location(parser, &((yp_begin_node_t *)node)->end_keyword_loc, buffer);
|
189
210
|
}
|
190
211
|
break;
|
191
212
|
}
|
@@ -195,7 +216,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
195
216
|
} else {
|
196
217
|
yp_serialize_node(parser, (yp_node_t *)((yp_block_argument_node_t *)node)->expression, buffer);
|
197
218
|
}
|
198
|
-
|
219
|
+
yp_serialize_location(parser, &((yp_block_argument_node_t *)node)->operator_loc, buffer);
|
199
220
|
break;
|
200
221
|
}
|
201
222
|
case YP_NODE_BLOCK_NODE: {
|
@@ -214,8 +235,8 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
214
235
|
} else {
|
215
236
|
yp_serialize_node(parser, (yp_node_t *)((yp_block_node_t *)node)->body, buffer);
|
216
237
|
}
|
217
|
-
|
218
|
-
|
238
|
+
yp_serialize_location(parser, &((yp_block_node_t *)node)->opening_loc, buffer);
|
239
|
+
yp_serialize_location(parser, &((yp_block_node_t *)node)->closing_loc, buffer);
|
219
240
|
break;
|
220
241
|
}
|
221
242
|
case YP_NODE_BLOCK_PARAMETER_NODE: {
|
@@ -223,9 +244,9 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
223
244
|
yp_buffer_append_u8(buffer, 0);
|
224
245
|
} else {
|
225
246
|
yp_buffer_append_u8(buffer, 1);
|
226
|
-
|
247
|
+
yp_serialize_location(parser, &((yp_block_parameter_node_t *)node)->name_loc, buffer);
|
227
248
|
}
|
228
|
-
|
249
|
+
yp_serialize_location(parser, &((yp_block_parameter_node_t *)node)->operator_loc, buffer);
|
229
250
|
break;
|
230
251
|
}
|
231
252
|
case YP_NODE_BLOCK_PARAMETERS_NODE: {
|
@@ -237,19 +258,19 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
237
258
|
uint32_t locals_size = yp_sizet_to_u32(((yp_block_parameters_node_t *)node)->locals.size);
|
238
259
|
yp_buffer_append_u32(buffer, locals_size);
|
239
260
|
for (uint32_t index = 0; index < locals_size; index++) {
|
240
|
-
|
261
|
+
yp_serialize_location(parser, &((yp_block_parameters_node_t *)node)->locals.locations[index], buffer);
|
241
262
|
}
|
242
263
|
if (((yp_block_parameters_node_t *)node)->opening_loc.start == NULL) {
|
243
264
|
yp_buffer_append_u8(buffer, 0);
|
244
265
|
} else {
|
245
266
|
yp_buffer_append_u8(buffer, 1);
|
246
|
-
|
267
|
+
yp_serialize_location(parser, &((yp_block_parameters_node_t *)node)->opening_loc, buffer);
|
247
268
|
}
|
248
269
|
if (((yp_block_parameters_node_t *)node)->closing_loc.start == NULL) {
|
249
270
|
yp_buffer_append_u8(buffer, 0);
|
250
271
|
} else {
|
251
272
|
yp_buffer_append_u8(buffer, 1);
|
252
|
-
|
273
|
+
yp_serialize_location(parser, &((yp_block_parameters_node_t *)node)->closing_loc, buffer);
|
253
274
|
}
|
254
275
|
break;
|
255
276
|
}
|
@@ -259,7 +280,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
259
280
|
} else {
|
260
281
|
yp_serialize_node(parser, (yp_node_t *)((yp_break_node_t *)node)->arguments, buffer);
|
261
282
|
}
|
262
|
-
|
283
|
+
yp_serialize_location(parser, &((yp_break_node_t *)node)->keyword_loc, buffer);
|
263
284
|
break;
|
264
285
|
}
|
265
286
|
case YP_NODE_CALL_NODE: {
|
@@ -272,19 +293,19 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
272
293
|
yp_buffer_append_u8(buffer, 0);
|
273
294
|
} else {
|
274
295
|
yp_buffer_append_u8(buffer, 1);
|
275
|
-
|
296
|
+
yp_serialize_location(parser, &((yp_call_node_t *)node)->operator_loc, buffer);
|
276
297
|
}
|
277
298
|
if (((yp_call_node_t *)node)->message_loc.start == NULL) {
|
278
299
|
yp_buffer_append_u8(buffer, 0);
|
279
300
|
} else {
|
280
301
|
yp_buffer_append_u8(buffer, 1);
|
281
|
-
|
302
|
+
yp_serialize_location(parser, &((yp_call_node_t *)node)->message_loc, buffer);
|
282
303
|
}
|
283
304
|
if (((yp_call_node_t *)node)->opening_loc.start == NULL) {
|
284
305
|
yp_buffer_append_u8(buffer, 0);
|
285
306
|
} else {
|
286
307
|
yp_buffer_append_u8(buffer, 1);
|
287
|
-
|
308
|
+
yp_serialize_location(parser, &((yp_call_node_t *)node)->opening_loc, buffer);
|
288
309
|
}
|
289
310
|
if (((yp_call_node_t *)node)->arguments == NULL) {
|
290
311
|
yp_buffer_append_u8(buffer, 0);
|
@@ -295,7 +316,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
295
316
|
yp_buffer_append_u8(buffer, 0);
|
296
317
|
} else {
|
297
318
|
yp_buffer_append_u8(buffer, 1);
|
298
|
-
|
319
|
+
yp_serialize_location(parser, &((yp_call_node_t *)node)->closing_loc, buffer);
|
299
320
|
}
|
300
321
|
if (((yp_call_node_t *)node)->block == NULL) {
|
301
322
|
yp_buffer_append_u8(buffer, 0);
|
@@ -303,26 +324,24 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
303
324
|
yp_serialize_node(parser, (yp_node_t *)((yp_call_node_t *)node)->block, buffer);
|
304
325
|
}
|
305
326
|
yp_buffer_append_u32(buffer, node->flags >> 1);
|
306
|
-
|
307
|
-
yp_buffer_append_u32(buffer, name_length);
|
308
|
-
yp_buffer_append_str(buffer, yp_string_source(&((yp_call_node_t *)node)->name), name_length);
|
327
|
+
yp_serialize_string(parser, &((yp_call_node_t *)node)->name, buffer);
|
309
328
|
break;
|
310
329
|
}
|
311
330
|
case YP_NODE_CALL_OPERATOR_AND_WRITE_NODE: {
|
312
331
|
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_and_write_node_t *)node)->target, buffer);
|
313
|
-
|
332
|
+
yp_serialize_location(parser, &((yp_call_operator_and_write_node_t *)node)->operator_loc, buffer);
|
314
333
|
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_and_write_node_t *)node)->value, buffer);
|
315
334
|
break;
|
316
335
|
}
|
317
336
|
case YP_NODE_CALL_OPERATOR_OR_WRITE_NODE: {
|
318
337
|
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_or_write_node_t *)node)->target, buffer);
|
319
338
|
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_or_write_node_t *)node)->value, buffer);
|
320
|
-
|
339
|
+
yp_serialize_location(parser, &((yp_call_operator_or_write_node_t *)node)->operator_loc, buffer);
|
321
340
|
break;
|
322
341
|
}
|
323
342
|
case YP_NODE_CALL_OPERATOR_WRITE_NODE: {
|
324
343
|
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_write_node_t *)node)->target, buffer);
|
325
|
-
|
344
|
+
yp_serialize_location(parser, &((yp_call_operator_write_node_t *)node)->operator_loc, buffer);
|
326
345
|
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_write_node_t *)node)->value, buffer);
|
327
346
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_call_operator_write_node_t *)node)->operator_id));
|
328
347
|
break;
|
@@ -330,7 +349,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
330
349
|
case YP_NODE_CAPTURE_PATTERN_NODE: {
|
331
350
|
yp_serialize_node(parser, (yp_node_t *)((yp_capture_pattern_node_t *)node)->value, buffer);
|
332
351
|
yp_serialize_node(parser, (yp_node_t *)((yp_capture_pattern_node_t *)node)->target, buffer);
|
333
|
-
|
352
|
+
yp_serialize_location(parser, &((yp_capture_pattern_node_t *)node)->operator_loc, buffer);
|
334
353
|
break;
|
335
354
|
}
|
336
355
|
case YP_NODE_CASE_NODE: {
|
@@ -349,8 +368,8 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
349
368
|
} else {
|
350
369
|
yp_serialize_node(parser, (yp_node_t *)((yp_case_node_t *)node)->consequent, buffer);
|
351
370
|
}
|
352
|
-
|
353
|
-
|
371
|
+
yp_serialize_location(parser, &((yp_case_node_t *)node)->case_keyword_loc, buffer);
|
372
|
+
yp_serialize_location(parser, &((yp_case_node_t *)node)->end_keyword_loc, buffer);
|
354
373
|
break;
|
355
374
|
}
|
356
375
|
case YP_NODE_CLASS_NODE: {
|
@@ -359,13 +378,13 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
359
378
|
for (uint32_t index = 0; index < locals_size; index++) {
|
360
379
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_node_t *)node)->locals.ids[index]));
|
361
380
|
}
|
362
|
-
|
381
|
+
yp_serialize_location(parser, &((yp_class_node_t *)node)->class_keyword_loc, buffer);
|
363
382
|
yp_serialize_node(parser, (yp_node_t *)((yp_class_node_t *)node)->constant_path, buffer);
|
364
383
|
if (((yp_class_node_t *)node)->inheritance_operator_loc.start == NULL) {
|
365
384
|
yp_buffer_append_u8(buffer, 0);
|
366
385
|
} else {
|
367
386
|
yp_buffer_append_u8(buffer, 1);
|
368
|
-
|
387
|
+
yp_serialize_location(parser, &((yp_class_node_t *)node)->inheritance_operator_loc, buffer);
|
369
388
|
}
|
370
389
|
if (((yp_class_node_t *)node)->superclass == NULL) {
|
371
390
|
yp_buffer_append_u8(buffer, 0);
|
@@ -377,14 +396,37 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
377
396
|
} else {
|
378
397
|
yp_serialize_node(parser, (yp_node_t *)((yp_class_node_t *)node)->body, buffer);
|
379
398
|
}
|
380
|
-
|
399
|
+
yp_serialize_location(parser, &((yp_class_node_t *)node)->end_keyword_loc, buffer);
|
400
|
+
yp_serialize_string(parser, &((yp_class_node_t *)node)->name, buffer);
|
401
|
+
break;
|
402
|
+
}
|
403
|
+
case YP_NODE_CLASS_VARIABLE_AND_WRITE_NODE: {
|
404
|
+
yp_serialize_location(parser, &((yp_class_variable_and_write_node_t *)node)->name_loc, buffer);
|
405
|
+
yp_serialize_location(parser, &((yp_class_variable_and_write_node_t *)node)->operator_loc, buffer);
|
406
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_and_write_node_t *)node)->value, buffer);
|
407
|
+
break;
|
408
|
+
}
|
409
|
+
case YP_NODE_CLASS_VARIABLE_OPERATOR_WRITE_NODE: {
|
410
|
+
yp_serialize_location(parser, &((yp_class_variable_operator_write_node_t *)node)->name_loc, buffer);
|
411
|
+
yp_serialize_location(parser, &((yp_class_variable_operator_write_node_t *)node)->operator_loc, buffer);
|
412
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_operator_write_node_t *)node)->value, buffer);
|
413
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_variable_operator_write_node_t *)node)->operator));
|
414
|
+
break;
|
415
|
+
}
|
416
|
+
case YP_NODE_CLASS_VARIABLE_OR_WRITE_NODE: {
|
417
|
+
yp_serialize_location(parser, &((yp_class_variable_or_write_node_t *)node)->name_loc, buffer);
|
418
|
+
yp_serialize_location(parser, &((yp_class_variable_or_write_node_t *)node)->operator_loc, buffer);
|
419
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_or_write_node_t *)node)->value, buffer);
|
381
420
|
break;
|
382
421
|
}
|
383
422
|
case YP_NODE_CLASS_VARIABLE_READ_NODE: {
|
384
423
|
break;
|
385
424
|
}
|
425
|
+
case YP_NODE_CLASS_VARIABLE_TARGET_NODE: {
|
426
|
+
break;
|
427
|
+
}
|
386
428
|
case YP_NODE_CLASS_VARIABLE_WRITE_NODE: {
|
387
|
-
|
429
|
+
yp_serialize_location(parser, &((yp_class_variable_write_node_t *)node)->name_loc, buffer);
|
388
430
|
if (((yp_class_variable_write_node_t *)node)->value == NULL) {
|
389
431
|
yp_buffer_append_u8(buffer, 0);
|
390
432
|
} else {
|
@@ -394,10 +436,35 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
394
436
|
yp_buffer_append_u8(buffer, 0);
|
395
437
|
} else {
|
396
438
|
yp_buffer_append_u8(buffer, 1);
|
397
|
-
|
439
|
+
yp_serialize_location(parser, &((yp_class_variable_write_node_t *)node)->operator_loc, buffer);
|
398
440
|
}
|
399
441
|
break;
|
400
442
|
}
|
443
|
+
case YP_NODE_CONSTANT_AND_WRITE_NODE: {
|
444
|
+
yp_serialize_location(parser, &((yp_constant_and_write_node_t *)node)->name_loc, buffer);
|
445
|
+
yp_serialize_location(parser, &((yp_constant_and_write_node_t *)node)->operator_loc, buffer);
|
446
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_and_write_node_t *)node)->value, buffer);
|
447
|
+
break;
|
448
|
+
}
|
449
|
+
case YP_NODE_CONSTANT_OPERATOR_WRITE_NODE: {
|
450
|
+
yp_serialize_location(parser, &((yp_constant_operator_write_node_t *)node)->name_loc, buffer);
|
451
|
+
yp_serialize_location(parser, &((yp_constant_operator_write_node_t *)node)->operator_loc, buffer);
|
452
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_operator_write_node_t *)node)->value, buffer);
|
453
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_operator_write_node_t *)node)->operator));
|
454
|
+
break;
|
455
|
+
}
|
456
|
+
case YP_NODE_CONSTANT_OR_WRITE_NODE: {
|
457
|
+
yp_serialize_location(parser, &((yp_constant_or_write_node_t *)node)->name_loc, buffer);
|
458
|
+
yp_serialize_location(parser, &((yp_constant_or_write_node_t *)node)->operator_loc, buffer);
|
459
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_or_write_node_t *)node)->value, buffer);
|
460
|
+
break;
|
461
|
+
}
|
462
|
+
case YP_NODE_CONSTANT_PATH_AND_WRITE_NODE: {
|
463
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_and_write_node_t *)node)->target, buffer);
|
464
|
+
yp_serialize_location(parser, &((yp_constant_path_and_write_node_t *)node)->operator_loc, buffer);
|
465
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_and_write_node_t *)node)->value, buffer);
|
466
|
+
break;
|
467
|
+
}
|
401
468
|
case YP_NODE_CONSTANT_PATH_NODE: {
|
402
469
|
if (((yp_constant_path_node_t *)node)->parent == NULL) {
|
403
470
|
yp_buffer_append_u8(buffer, 0);
|
@@ -405,40 +472,48 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
405
472
|
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_node_t *)node)->parent, buffer);
|
406
473
|
}
|
407
474
|
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_node_t *)node)->child, buffer);
|
408
|
-
|
475
|
+
yp_serialize_location(parser, &((yp_constant_path_node_t *)node)->delimiter_loc, buffer);
|
409
476
|
break;
|
410
477
|
}
|
411
|
-
case
|
412
|
-
yp_serialize_node(parser, (yp_node_t *)((
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
478
|
+
case YP_NODE_CONSTANT_PATH_OPERATOR_WRITE_NODE: {
|
479
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_operator_write_node_t *)node)->target, buffer);
|
480
|
+
yp_serialize_location(parser, &((yp_constant_path_operator_write_node_t *)node)->operator_loc, buffer);
|
481
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_operator_write_node_t *)node)->value, buffer);
|
482
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_path_operator_write_node_t *)node)->operator));
|
483
|
+
break;
|
484
|
+
}
|
485
|
+
case YP_NODE_CONSTANT_PATH_OR_WRITE_NODE: {
|
486
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_or_write_node_t *)node)->target, buffer);
|
487
|
+
yp_serialize_location(parser, &((yp_constant_path_or_write_node_t *)node)->operator_loc, buffer);
|
488
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_or_write_node_t *)node)->value, buffer);
|
489
|
+
break;
|
490
|
+
}
|
491
|
+
case YP_NODE_CONSTANT_PATH_TARGET_NODE: {
|
492
|
+
if (((yp_constant_path_target_node_t *)node)->parent == NULL) {
|
420
493
|
yp_buffer_append_u8(buffer, 0);
|
421
494
|
} else {
|
422
|
-
yp_serialize_node(parser, (yp_node_t *)((
|
495
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_target_node_t *)node)->parent, buffer);
|
423
496
|
}
|
497
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_target_node_t *)node)->child, buffer);
|
498
|
+
yp_serialize_location(parser, &((yp_constant_path_target_node_t *)node)->delimiter_loc, buffer);
|
499
|
+
break;
|
500
|
+
}
|
501
|
+
case YP_NODE_CONSTANT_PATH_WRITE_NODE: {
|
502
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_write_node_t *)node)->target, buffer);
|
503
|
+
yp_serialize_location(parser, &((yp_constant_path_write_node_t *)node)->operator_loc, buffer);
|
504
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_write_node_t *)node)->value, buffer);
|
424
505
|
break;
|
425
506
|
}
|
426
507
|
case YP_NODE_CONSTANT_READ_NODE: {
|
427
508
|
break;
|
428
509
|
}
|
510
|
+
case YP_NODE_CONSTANT_TARGET_NODE: {
|
511
|
+
break;
|
512
|
+
}
|
429
513
|
case YP_NODE_CONSTANT_WRITE_NODE: {
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
} else {
|
434
|
-
yp_serialize_node(parser, (yp_node_t *)((yp_constant_write_node_t *)node)->value, buffer);
|
435
|
-
}
|
436
|
-
if (((yp_constant_write_node_t *)node)->operator_loc.start == NULL) {
|
437
|
-
yp_buffer_append_u8(buffer, 0);
|
438
|
-
} else {
|
439
|
-
yp_buffer_append_u8(buffer, 1);
|
440
|
-
serialize_location(parser, &((yp_constant_write_node_t *)node)->operator_loc, buffer);
|
441
|
-
}
|
514
|
+
yp_serialize_location(parser, &((yp_constant_write_node_t *)node)->name_loc, buffer);
|
515
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_write_node_t *)node)->value, buffer);
|
516
|
+
yp_serialize_location(parser, &((yp_constant_write_node_t *)node)->operator_loc, buffer);
|
442
517
|
break;
|
443
518
|
}
|
444
519
|
case YP_NODE_DEF_NODE: {
|
@@ -446,7 +521,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
446
521
|
// encoding of location u32s make us need to save this offset.
|
447
522
|
size_t length_offset = buffer->length;
|
448
523
|
yp_buffer_append_str(buffer, "\0\0\0\0", 4); /* consume 4 bytes, updated below */
|
449
|
-
|
524
|
+
yp_serialize_location(parser, &((yp_def_node_t *)node)->name_loc, buffer);
|
450
525
|
if (((yp_def_node_t *)node)->receiver == NULL) {
|
451
526
|
yp_buffer_append_u8(buffer, 0);
|
452
527
|
} else {
|
@@ -467,36 +542,36 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
467
542
|
for (uint32_t index = 0; index < locals_size; index++) {
|
468
543
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_def_node_t *)node)->locals.ids[index]));
|
469
544
|
}
|
470
|
-
|
545
|
+
yp_serialize_location(parser, &((yp_def_node_t *)node)->def_keyword_loc, buffer);
|
471
546
|
if (((yp_def_node_t *)node)->operator_loc.start == NULL) {
|
472
547
|
yp_buffer_append_u8(buffer, 0);
|
473
548
|
} else {
|
474
549
|
yp_buffer_append_u8(buffer, 1);
|
475
|
-
|
550
|
+
yp_serialize_location(parser, &((yp_def_node_t *)node)->operator_loc, buffer);
|
476
551
|
}
|
477
552
|
if (((yp_def_node_t *)node)->lparen_loc.start == NULL) {
|
478
553
|
yp_buffer_append_u8(buffer, 0);
|
479
554
|
} else {
|
480
555
|
yp_buffer_append_u8(buffer, 1);
|
481
|
-
|
556
|
+
yp_serialize_location(parser, &((yp_def_node_t *)node)->lparen_loc, buffer);
|
482
557
|
}
|
483
558
|
if (((yp_def_node_t *)node)->rparen_loc.start == NULL) {
|
484
559
|
yp_buffer_append_u8(buffer, 0);
|
485
560
|
} else {
|
486
561
|
yp_buffer_append_u8(buffer, 1);
|
487
|
-
|
562
|
+
yp_serialize_location(parser, &((yp_def_node_t *)node)->rparen_loc, buffer);
|
488
563
|
}
|
489
564
|
if (((yp_def_node_t *)node)->equal_loc.start == NULL) {
|
490
565
|
yp_buffer_append_u8(buffer, 0);
|
491
566
|
} else {
|
492
567
|
yp_buffer_append_u8(buffer, 1);
|
493
|
-
|
568
|
+
yp_serialize_location(parser, &((yp_def_node_t *)node)->equal_loc, buffer);
|
494
569
|
}
|
495
570
|
if (((yp_def_node_t *)node)->end_keyword_loc.start == NULL) {
|
496
571
|
yp_buffer_append_u8(buffer, 0);
|
497
572
|
} else {
|
498
573
|
yp_buffer_append_u8(buffer, 1);
|
499
|
-
|
574
|
+
yp_serialize_location(parser, &((yp_def_node_t *)node)->end_keyword_loc, buffer);
|
500
575
|
}
|
501
576
|
// serialize length
|
502
577
|
uint32_t length = yp_sizet_to_u32(buffer->length - offset - sizeof(uint32_t));
|
@@ -508,20 +583,20 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
508
583
|
yp_buffer_append_u8(buffer, 0);
|
509
584
|
} else {
|
510
585
|
yp_buffer_append_u8(buffer, 1);
|
511
|
-
|
586
|
+
yp_serialize_location(parser, &((yp_defined_node_t *)node)->lparen_loc, buffer);
|
512
587
|
}
|
513
588
|
yp_serialize_node(parser, (yp_node_t *)((yp_defined_node_t *)node)->value, buffer);
|
514
589
|
if (((yp_defined_node_t *)node)->rparen_loc.start == NULL) {
|
515
590
|
yp_buffer_append_u8(buffer, 0);
|
516
591
|
} else {
|
517
592
|
yp_buffer_append_u8(buffer, 1);
|
518
|
-
|
593
|
+
yp_serialize_location(parser, &((yp_defined_node_t *)node)->rparen_loc, buffer);
|
519
594
|
}
|
520
|
-
|
595
|
+
yp_serialize_location(parser, &((yp_defined_node_t *)node)->keyword_loc, buffer);
|
521
596
|
break;
|
522
597
|
}
|
523
598
|
case YP_NODE_ELSE_NODE: {
|
524
|
-
|
599
|
+
yp_serialize_location(parser, &((yp_else_node_t *)node)->else_keyword_loc, buffer);
|
525
600
|
if (((yp_else_node_t *)node)->statements == NULL) {
|
526
601
|
yp_buffer_append_u8(buffer, 0);
|
527
602
|
} else {
|
@@ -531,33 +606,33 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
531
606
|
yp_buffer_append_u8(buffer, 0);
|
532
607
|
} else {
|
533
608
|
yp_buffer_append_u8(buffer, 1);
|
534
|
-
|
609
|
+
yp_serialize_location(parser, &((yp_else_node_t *)node)->end_keyword_loc, buffer);
|
535
610
|
}
|
536
611
|
break;
|
537
612
|
}
|
538
613
|
case YP_NODE_EMBEDDED_STATEMENTS_NODE: {
|
539
|
-
|
614
|
+
yp_serialize_location(parser, &((yp_embedded_statements_node_t *)node)->opening_loc, buffer);
|
540
615
|
if (((yp_embedded_statements_node_t *)node)->statements == NULL) {
|
541
616
|
yp_buffer_append_u8(buffer, 0);
|
542
617
|
} else {
|
543
618
|
yp_serialize_node(parser, (yp_node_t *)((yp_embedded_statements_node_t *)node)->statements, buffer);
|
544
619
|
}
|
545
|
-
|
620
|
+
yp_serialize_location(parser, &((yp_embedded_statements_node_t *)node)->closing_loc, buffer);
|
546
621
|
break;
|
547
622
|
}
|
548
623
|
case YP_NODE_EMBEDDED_VARIABLE_NODE: {
|
549
|
-
|
624
|
+
yp_serialize_location(parser, &((yp_embedded_variable_node_t *)node)->operator_loc, buffer);
|
550
625
|
yp_serialize_node(parser, (yp_node_t *)((yp_embedded_variable_node_t *)node)->variable, buffer);
|
551
626
|
break;
|
552
627
|
}
|
553
628
|
case YP_NODE_ENSURE_NODE: {
|
554
|
-
|
629
|
+
yp_serialize_location(parser, &((yp_ensure_node_t *)node)->ensure_keyword_loc, buffer);
|
555
630
|
if (((yp_ensure_node_t *)node)->statements == NULL) {
|
556
631
|
yp_buffer_append_u8(buffer, 0);
|
557
632
|
} else {
|
558
633
|
yp_serialize_node(parser, (yp_node_t *)((yp_ensure_node_t *)node)->statements, buffer);
|
559
634
|
}
|
560
|
-
|
635
|
+
yp_serialize_location(parser, &((yp_ensure_node_t *)node)->end_keyword_loc, buffer);
|
561
636
|
break;
|
562
637
|
}
|
563
638
|
case YP_NODE_FALSE_NODE: {
|
@@ -580,13 +655,13 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
580
655
|
yp_buffer_append_u8(buffer, 0);
|
581
656
|
} else {
|
582
657
|
yp_buffer_append_u8(buffer, 1);
|
583
|
-
|
658
|
+
yp_serialize_location(parser, &((yp_find_pattern_node_t *)node)->opening_loc, buffer);
|
584
659
|
}
|
585
660
|
if (((yp_find_pattern_node_t *)node)->closing_loc.start == NULL) {
|
586
661
|
yp_buffer_append_u8(buffer, 0);
|
587
662
|
} else {
|
588
663
|
yp_buffer_append_u8(buffer, 1);
|
589
|
-
|
664
|
+
yp_serialize_location(parser, &((yp_find_pattern_node_t *)node)->closing_loc, buffer);
|
590
665
|
}
|
591
666
|
break;
|
592
667
|
}
|
@@ -601,7 +676,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
601
676
|
} else {
|
602
677
|
yp_serialize_node(parser, (yp_node_t *)((yp_flip_flop_node_t *)node)->right, buffer);
|
603
678
|
}
|
604
|
-
|
679
|
+
yp_serialize_location(parser, &((yp_flip_flop_node_t *)node)->operator_loc, buffer);
|
605
680
|
yp_buffer_append_u32(buffer, node->flags >> 1);
|
606
681
|
break;
|
607
682
|
}
|
@@ -616,15 +691,15 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
616
691
|
} else {
|
617
692
|
yp_serialize_node(parser, (yp_node_t *)((yp_for_node_t *)node)->statements, buffer);
|
618
693
|
}
|
619
|
-
|
620
|
-
|
694
|
+
yp_serialize_location(parser, &((yp_for_node_t *)node)->for_keyword_loc, buffer);
|
695
|
+
yp_serialize_location(parser, &((yp_for_node_t *)node)->in_keyword_loc, buffer);
|
621
696
|
if (((yp_for_node_t *)node)->do_keyword_loc.start == NULL) {
|
622
697
|
yp_buffer_append_u8(buffer, 0);
|
623
698
|
} else {
|
624
699
|
yp_buffer_append_u8(buffer, 1);
|
625
|
-
|
700
|
+
yp_serialize_location(parser, &((yp_for_node_t *)node)->do_keyword_loc, buffer);
|
626
701
|
}
|
627
|
-
|
702
|
+
yp_serialize_location(parser, &((yp_for_node_t *)node)->end_keyword_loc, buffer);
|
628
703
|
break;
|
629
704
|
}
|
630
705
|
case YP_NODE_FORWARDING_ARGUMENTS_NODE: {
|
@@ -641,32 +716,45 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
641
716
|
}
|
642
717
|
break;
|
643
718
|
}
|
719
|
+
case YP_NODE_GLOBAL_VARIABLE_AND_WRITE_NODE: {
|
720
|
+
yp_serialize_location(parser, &((yp_global_variable_and_write_node_t *)node)->name_loc, buffer);
|
721
|
+
yp_serialize_location(parser, &((yp_global_variable_and_write_node_t *)node)->operator_loc, buffer);
|
722
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_and_write_node_t *)node)->value, buffer);
|
723
|
+
break;
|
724
|
+
}
|
725
|
+
case YP_NODE_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE: {
|
726
|
+
yp_serialize_location(parser, &((yp_global_variable_operator_write_node_t *)node)->name_loc, buffer);
|
727
|
+
yp_serialize_location(parser, &((yp_global_variable_operator_write_node_t *)node)->operator_loc, buffer);
|
728
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_operator_write_node_t *)node)->value, buffer);
|
729
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_global_variable_operator_write_node_t *)node)->operator));
|
730
|
+
break;
|
731
|
+
}
|
732
|
+
case YP_NODE_GLOBAL_VARIABLE_OR_WRITE_NODE: {
|
733
|
+
yp_serialize_location(parser, &((yp_global_variable_or_write_node_t *)node)->name_loc, buffer);
|
734
|
+
yp_serialize_location(parser, &((yp_global_variable_or_write_node_t *)node)->operator_loc, buffer);
|
735
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_or_write_node_t *)node)->value, buffer);
|
736
|
+
break;
|
737
|
+
}
|
644
738
|
case YP_NODE_GLOBAL_VARIABLE_READ_NODE: {
|
645
739
|
break;
|
646
740
|
}
|
741
|
+
case YP_NODE_GLOBAL_VARIABLE_TARGET_NODE: {
|
742
|
+
break;
|
743
|
+
}
|
647
744
|
case YP_NODE_GLOBAL_VARIABLE_WRITE_NODE: {
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
} else {
|
652
|
-
yp_buffer_append_u8(buffer, 1);
|
653
|
-
serialize_location(parser, &((yp_global_variable_write_node_t *)node)->operator_loc, buffer);
|
654
|
-
}
|
655
|
-
if (((yp_global_variable_write_node_t *)node)->value == NULL) {
|
656
|
-
yp_buffer_append_u8(buffer, 0);
|
657
|
-
} else {
|
658
|
-
yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_write_node_t *)node)->value, buffer);
|
659
|
-
}
|
745
|
+
yp_serialize_location(parser, &((yp_global_variable_write_node_t *)node)->name_loc, buffer);
|
746
|
+
yp_serialize_location(parser, &((yp_global_variable_write_node_t *)node)->operator_loc, buffer);
|
747
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_write_node_t *)node)->value, buffer);
|
660
748
|
break;
|
661
749
|
}
|
662
750
|
case YP_NODE_HASH_NODE: {
|
663
|
-
|
751
|
+
yp_serialize_location(parser, &((yp_hash_node_t *)node)->opening_loc, buffer);
|
664
752
|
uint32_t elements_size = yp_sizet_to_u32(((yp_hash_node_t *)node)->elements.size);
|
665
753
|
yp_buffer_append_u32(buffer, elements_size);
|
666
754
|
for (uint32_t index = 0; index < elements_size; index++) {
|
667
755
|
yp_serialize_node(parser, (yp_node_t *) ((yp_hash_node_t *)node)->elements.nodes[index], buffer);
|
668
756
|
}
|
669
|
-
|
757
|
+
yp_serialize_location(parser, &((yp_hash_node_t *)node)->closing_loc, buffer);
|
670
758
|
break;
|
671
759
|
}
|
672
760
|
case YP_NODE_HASH_PATTERN_NODE: {
|
@@ -689,13 +777,13 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
689
777
|
yp_buffer_append_u8(buffer, 0);
|
690
778
|
} else {
|
691
779
|
yp_buffer_append_u8(buffer, 1);
|
692
|
-
|
780
|
+
yp_serialize_location(parser, &((yp_hash_pattern_node_t *)node)->opening_loc, buffer);
|
693
781
|
}
|
694
782
|
if (((yp_hash_pattern_node_t *)node)->closing_loc.start == NULL) {
|
695
783
|
yp_buffer_append_u8(buffer, 0);
|
696
784
|
} else {
|
697
785
|
yp_buffer_append_u8(buffer, 1);
|
698
|
-
|
786
|
+
yp_serialize_location(parser, &((yp_hash_pattern_node_t *)node)->closing_loc, buffer);
|
699
787
|
}
|
700
788
|
break;
|
701
789
|
}
|
@@ -704,7 +792,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
704
792
|
yp_buffer_append_u8(buffer, 0);
|
705
793
|
} else {
|
706
794
|
yp_buffer_append_u8(buffer, 1);
|
707
|
-
|
795
|
+
yp_serialize_location(parser, &((yp_if_node_t *)node)->if_keyword_loc, buffer);
|
708
796
|
}
|
709
797
|
yp_serialize_node(parser, (yp_node_t *)((yp_if_node_t *)node)->predicate, buffer);
|
710
798
|
if (((yp_if_node_t *)node)->statements == NULL) {
|
@@ -721,7 +809,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
721
809
|
yp_buffer_append_u8(buffer, 0);
|
722
810
|
} else {
|
723
811
|
yp_buffer_append_u8(buffer, 1);
|
724
|
-
|
812
|
+
yp_serialize_location(parser, &((yp_if_node_t *)node)->end_keyword_loc, buffer);
|
725
813
|
}
|
726
814
|
break;
|
727
815
|
}
|
@@ -736,44 +824,57 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
736
824
|
} else {
|
737
825
|
yp_serialize_node(parser, (yp_node_t *)((yp_in_node_t *)node)->statements, buffer);
|
738
826
|
}
|
739
|
-
|
827
|
+
yp_serialize_location(parser, &((yp_in_node_t *)node)->in_loc, buffer);
|
740
828
|
if (((yp_in_node_t *)node)->then_loc.start == NULL) {
|
741
829
|
yp_buffer_append_u8(buffer, 0);
|
742
830
|
} else {
|
743
831
|
yp_buffer_append_u8(buffer, 1);
|
744
|
-
|
832
|
+
yp_serialize_location(parser, &((yp_in_node_t *)node)->then_loc, buffer);
|
745
833
|
}
|
746
834
|
break;
|
747
835
|
}
|
836
|
+
case YP_NODE_INSTANCE_VARIABLE_AND_WRITE_NODE: {
|
837
|
+
yp_serialize_location(parser, &((yp_instance_variable_and_write_node_t *)node)->name_loc, buffer);
|
838
|
+
yp_serialize_location(parser, &((yp_instance_variable_and_write_node_t *)node)->operator_loc, buffer);
|
839
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_and_write_node_t *)node)->value, buffer);
|
840
|
+
break;
|
841
|
+
}
|
842
|
+
case YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE: {
|
843
|
+
yp_serialize_location(parser, &((yp_instance_variable_operator_write_node_t *)node)->name_loc, buffer);
|
844
|
+
yp_serialize_location(parser, &((yp_instance_variable_operator_write_node_t *)node)->operator_loc, buffer);
|
845
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_operator_write_node_t *)node)->value, buffer);
|
846
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_instance_variable_operator_write_node_t *)node)->operator));
|
847
|
+
break;
|
848
|
+
}
|
849
|
+
case YP_NODE_INSTANCE_VARIABLE_OR_WRITE_NODE: {
|
850
|
+
yp_serialize_location(parser, &((yp_instance_variable_or_write_node_t *)node)->name_loc, buffer);
|
851
|
+
yp_serialize_location(parser, &((yp_instance_variable_or_write_node_t *)node)->operator_loc, buffer);
|
852
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_or_write_node_t *)node)->value, buffer);
|
853
|
+
break;
|
854
|
+
}
|
748
855
|
case YP_NODE_INSTANCE_VARIABLE_READ_NODE: {
|
749
856
|
break;
|
750
857
|
}
|
858
|
+
case YP_NODE_INSTANCE_VARIABLE_TARGET_NODE: {
|
859
|
+
break;
|
860
|
+
}
|
751
861
|
case YP_NODE_INSTANCE_VARIABLE_WRITE_NODE: {
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
} else {
|
756
|
-
yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_write_node_t *)node)->value, buffer);
|
757
|
-
}
|
758
|
-
if (((yp_instance_variable_write_node_t *)node)->operator_loc.start == NULL) {
|
759
|
-
yp_buffer_append_u8(buffer, 0);
|
760
|
-
} else {
|
761
|
-
yp_buffer_append_u8(buffer, 1);
|
762
|
-
serialize_location(parser, &((yp_instance_variable_write_node_t *)node)->operator_loc, buffer);
|
763
|
-
}
|
862
|
+
yp_serialize_location(parser, &((yp_instance_variable_write_node_t *)node)->name_loc, buffer);
|
863
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_write_node_t *)node)->value, buffer);
|
864
|
+
yp_serialize_location(parser, &((yp_instance_variable_write_node_t *)node)->operator_loc, buffer);
|
764
865
|
break;
|
765
866
|
}
|
766
867
|
case YP_NODE_INTEGER_NODE: {
|
767
868
|
break;
|
768
869
|
}
|
769
870
|
case YP_NODE_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
|
770
|
-
|
871
|
+
yp_serialize_location(parser, &((yp_interpolated_regular_expression_node_t *)node)->opening_loc, buffer);
|
771
872
|
uint32_t parts_size = yp_sizet_to_u32(((yp_interpolated_regular_expression_node_t *)node)->parts.size);
|
772
873
|
yp_buffer_append_u32(buffer, parts_size);
|
773
874
|
for (uint32_t index = 0; index < parts_size; index++) {
|
774
875
|
yp_serialize_node(parser, (yp_node_t *) ((yp_interpolated_regular_expression_node_t *)node)->parts.nodes[index], buffer);
|
775
876
|
}
|
776
|
-
|
877
|
+
yp_serialize_location(parser, &((yp_interpolated_regular_expression_node_t *)node)->closing_loc, buffer);
|
777
878
|
yp_buffer_append_u32(buffer, node->flags >> 1);
|
778
879
|
break;
|
779
880
|
}
|
@@ -782,7 +883,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
782
883
|
yp_buffer_append_u8(buffer, 0);
|
783
884
|
} else {
|
784
885
|
yp_buffer_append_u8(buffer, 1);
|
785
|
-
|
886
|
+
yp_serialize_location(parser, &((yp_interpolated_string_node_t *)node)->opening_loc, buffer);
|
786
887
|
}
|
787
888
|
uint32_t parts_size = yp_sizet_to_u32(((yp_interpolated_string_node_t *)node)->parts.size);
|
788
889
|
yp_buffer_append_u32(buffer, parts_size);
|
@@ -793,7 +894,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
793
894
|
yp_buffer_append_u8(buffer, 0);
|
794
895
|
} else {
|
795
896
|
yp_buffer_append_u8(buffer, 1);
|
796
|
-
|
897
|
+
yp_serialize_location(parser, &((yp_interpolated_string_node_t *)node)->closing_loc, buffer);
|
797
898
|
}
|
798
899
|
break;
|
799
900
|
}
|
@@ -802,7 +903,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
802
903
|
yp_buffer_append_u8(buffer, 0);
|
803
904
|
} else {
|
804
905
|
yp_buffer_append_u8(buffer, 1);
|
805
|
-
|
906
|
+
yp_serialize_location(parser, &((yp_interpolated_symbol_node_t *)node)->opening_loc, buffer);
|
806
907
|
}
|
807
908
|
uint32_t parts_size = yp_sizet_to_u32(((yp_interpolated_symbol_node_t *)node)->parts.size);
|
808
909
|
yp_buffer_append_u32(buffer, parts_size);
|
@@ -813,18 +914,18 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
813
914
|
yp_buffer_append_u8(buffer, 0);
|
814
915
|
} else {
|
815
916
|
yp_buffer_append_u8(buffer, 1);
|
816
|
-
|
917
|
+
yp_serialize_location(parser, &((yp_interpolated_symbol_node_t *)node)->closing_loc, buffer);
|
817
918
|
}
|
818
919
|
break;
|
819
920
|
}
|
820
921
|
case YP_NODE_INTERPOLATED_X_STRING_NODE: {
|
821
|
-
|
922
|
+
yp_serialize_location(parser, &((yp_interpolated_x_string_node_t *)node)->opening_loc, buffer);
|
822
923
|
uint32_t parts_size = yp_sizet_to_u32(((yp_interpolated_x_string_node_t *)node)->parts.size);
|
823
924
|
yp_buffer_append_u32(buffer, parts_size);
|
824
925
|
for (uint32_t index = 0; index < parts_size; index++) {
|
825
926
|
yp_serialize_node(parser, (yp_node_t *) ((yp_interpolated_x_string_node_t *)node)->parts.nodes[index], buffer);
|
826
927
|
}
|
827
|
-
|
928
|
+
yp_serialize_location(parser, &((yp_interpolated_x_string_node_t *)node)->closing_loc, buffer);
|
828
929
|
break;
|
829
930
|
}
|
830
931
|
case YP_NODE_KEYWORD_HASH_NODE: {
|
@@ -836,7 +937,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
836
937
|
break;
|
837
938
|
}
|
838
939
|
case YP_NODE_KEYWORD_PARAMETER_NODE: {
|
839
|
-
|
940
|
+
yp_serialize_location(parser, &((yp_keyword_parameter_node_t *)node)->name_loc, buffer);
|
840
941
|
if (((yp_keyword_parameter_node_t *)node)->value == NULL) {
|
841
942
|
yp_buffer_append_u8(buffer, 0);
|
842
943
|
} else {
|
@@ -845,12 +946,12 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
845
946
|
break;
|
846
947
|
}
|
847
948
|
case YP_NODE_KEYWORD_REST_PARAMETER_NODE: {
|
848
|
-
|
949
|
+
yp_serialize_location(parser, &((yp_keyword_rest_parameter_node_t *)node)->operator_loc, buffer);
|
849
950
|
if (((yp_keyword_rest_parameter_node_t *)node)->name_loc.start == NULL) {
|
850
951
|
yp_buffer_append_u8(buffer, 0);
|
851
952
|
} else {
|
852
953
|
yp_buffer_append_u8(buffer, 1);
|
853
|
-
|
954
|
+
yp_serialize_location(parser, &((yp_keyword_rest_parameter_node_t *)node)->name_loc, buffer);
|
854
955
|
}
|
855
956
|
break;
|
856
957
|
}
|
@@ -860,7 +961,9 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
860
961
|
for (uint32_t index = 0; index < locals_size; index++) {
|
861
962
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_lambda_node_t *)node)->locals.ids[index]));
|
862
963
|
}
|
863
|
-
|
964
|
+
yp_serialize_location(parser, &((yp_lambda_node_t *)node)->operator_loc, buffer);
|
965
|
+
yp_serialize_location(parser, &((yp_lambda_node_t *)node)->opening_loc, buffer);
|
966
|
+
yp_serialize_location(parser, &((yp_lambda_node_t *)node)->closing_loc, buffer);
|
864
967
|
if (((yp_lambda_node_t *)node)->parameters == NULL) {
|
865
968
|
yp_buffer_append_u8(buffer, 0);
|
866
969
|
} else {
|
@@ -873,38 +976,59 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
873
976
|
}
|
874
977
|
break;
|
875
978
|
}
|
979
|
+
case YP_NODE_LOCAL_VARIABLE_AND_WRITE_NODE: {
|
980
|
+
yp_serialize_location(parser, &((yp_local_variable_and_write_node_t *)node)->name_loc, buffer);
|
981
|
+
yp_serialize_location(parser, &((yp_local_variable_and_write_node_t *)node)->operator_loc, buffer);
|
982
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_and_write_node_t *)node)->value, buffer);
|
983
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_and_write_node_t *)node)->constant_id));
|
984
|
+
yp_buffer_append_u32(buffer, ((yp_local_variable_and_write_node_t *)node)->depth);
|
985
|
+
break;
|
986
|
+
}
|
987
|
+
case YP_NODE_LOCAL_VARIABLE_OPERATOR_WRITE_NODE: {
|
988
|
+
yp_serialize_location(parser, &((yp_local_variable_operator_write_node_t *)node)->name_loc, buffer);
|
989
|
+
yp_serialize_location(parser, &((yp_local_variable_operator_write_node_t *)node)->operator_loc, buffer);
|
990
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_operator_write_node_t *)node)->value, buffer);
|
991
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_operator_write_node_t *)node)->constant_id));
|
992
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_operator_write_node_t *)node)->operator_id));
|
993
|
+
yp_buffer_append_u32(buffer, ((yp_local_variable_operator_write_node_t *)node)->depth);
|
994
|
+
break;
|
995
|
+
}
|
996
|
+
case YP_NODE_LOCAL_VARIABLE_OR_WRITE_NODE: {
|
997
|
+
yp_serialize_location(parser, &((yp_local_variable_or_write_node_t *)node)->name_loc, buffer);
|
998
|
+
yp_serialize_location(parser, &((yp_local_variable_or_write_node_t *)node)->operator_loc, buffer);
|
999
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_or_write_node_t *)node)->value, buffer);
|
1000
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_or_write_node_t *)node)->constant_id));
|
1001
|
+
yp_buffer_append_u32(buffer, ((yp_local_variable_or_write_node_t *)node)->depth);
|
1002
|
+
break;
|
1003
|
+
}
|
876
1004
|
case YP_NODE_LOCAL_VARIABLE_READ_NODE: {
|
877
1005
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_read_node_t *)node)->constant_id));
|
878
1006
|
yp_buffer_append_u32(buffer, ((yp_local_variable_read_node_t *)node)->depth);
|
879
1007
|
break;
|
880
1008
|
}
|
1009
|
+
case YP_NODE_LOCAL_VARIABLE_TARGET_NODE: {
|
1010
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_target_node_t *)node)->constant_id));
|
1011
|
+
yp_buffer_append_u32(buffer, ((yp_local_variable_target_node_t *)node)->depth);
|
1012
|
+
break;
|
1013
|
+
}
|
881
1014
|
case YP_NODE_LOCAL_VARIABLE_WRITE_NODE: {
|
882
1015
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_write_node_t *)node)->constant_id));
|
883
1016
|
yp_buffer_append_u32(buffer, ((yp_local_variable_write_node_t *)node)->depth);
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_write_node_t *)node)->value, buffer);
|
888
|
-
}
|
889
|
-
serialize_location(parser, &((yp_local_variable_write_node_t *)node)->name_loc, buffer);
|
890
|
-
if (((yp_local_variable_write_node_t *)node)->operator_loc.start == NULL) {
|
891
|
-
yp_buffer_append_u8(buffer, 0);
|
892
|
-
} else {
|
893
|
-
yp_buffer_append_u8(buffer, 1);
|
894
|
-
serialize_location(parser, &((yp_local_variable_write_node_t *)node)->operator_loc, buffer);
|
895
|
-
}
|
1017
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_write_node_t *)node)->value, buffer);
|
1018
|
+
yp_serialize_location(parser, &((yp_local_variable_write_node_t *)node)->name_loc, buffer);
|
1019
|
+
yp_serialize_location(parser, &((yp_local_variable_write_node_t *)node)->operator_loc, buffer);
|
896
1020
|
break;
|
897
1021
|
}
|
898
1022
|
case YP_NODE_MATCH_PREDICATE_NODE: {
|
899
1023
|
yp_serialize_node(parser, (yp_node_t *)((yp_match_predicate_node_t *)node)->value, buffer);
|
900
1024
|
yp_serialize_node(parser, (yp_node_t *)((yp_match_predicate_node_t *)node)->pattern, buffer);
|
901
|
-
|
1025
|
+
yp_serialize_location(parser, &((yp_match_predicate_node_t *)node)->operator_loc, buffer);
|
902
1026
|
break;
|
903
1027
|
}
|
904
1028
|
case YP_NODE_MATCH_REQUIRED_NODE: {
|
905
1029
|
yp_serialize_node(parser, (yp_node_t *)((yp_match_required_node_t *)node)->value, buffer);
|
906
1030
|
yp_serialize_node(parser, (yp_node_t *)((yp_match_required_node_t *)node)->pattern, buffer);
|
907
|
-
|
1031
|
+
yp_serialize_location(parser, &((yp_match_required_node_t *)node)->operator_loc, buffer);
|
908
1032
|
break;
|
909
1033
|
}
|
910
1034
|
case YP_NODE_MISSING_NODE: {
|
@@ -916,14 +1040,15 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
916
1040
|
for (uint32_t index = 0; index < locals_size; index++) {
|
917
1041
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_module_node_t *)node)->locals.ids[index]));
|
918
1042
|
}
|
919
|
-
|
1043
|
+
yp_serialize_location(parser, &((yp_module_node_t *)node)->module_keyword_loc, buffer);
|
920
1044
|
yp_serialize_node(parser, (yp_node_t *)((yp_module_node_t *)node)->constant_path, buffer);
|
921
1045
|
if (((yp_module_node_t *)node)->body == NULL) {
|
922
1046
|
yp_buffer_append_u8(buffer, 0);
|
923
1047
|
} else {
|
924
1048
|
yp_serialize_node(parser, (yp_node_t *)((yp_module_node_t *)node)->body, buffer);
|
925
1049
|
}
|
926
|
-
|
1050
|
+
yp_serialize_location(parser, &((yp_module_node_t *)node)->end_keyword_loc, buffer);
|
1051
|
+
yp_serialize_string(parser, &((yp_module_node_t *)node)->name, buffer);
|
927
1052
|
break;
|
928
1053
|
}
|
929
1054
|
case YP_NODE_MULTI_WRITE_NODE: {
|
@@ -936,7 +1061,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
936
1061
|
yp_buffer_append_u8(buffer, 0);
|
937
1062
|
} else {
|
938
1063
|
yp_buffer_append_u8(buffer, 1);
|
939
|
-
|
1064
|
+
yp_serialize_location(parser, &((yp_multi_write_node_t *)node)->operator_loc, buffer);
|
940
1065
|
}
|
941
1066
|
if (((yp_multi_write_node_t *)node)->value == NULL) {
|
942
1067
|
yp_buffer_append_u8(buffer, 0);
|
@@ -947,13 +1072,13 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
947
1072
|
yp_buffer_append_u8(buffer, 0);
|
948
1073
|
} else {
|
949
1074
|
yp_buffer_append_u8(buffer, 1);
|
950
|
-
|
1075
|
+
yp_serialize_location(parser, &((yp_multi_write_node_t *)node)->lparen_loc, buffer);
|
951
1076
|
}
|
952
1077
|
if (((yp_multi_write_node_t *)node)->rparen_loc.start == NULL) {
|
953
1078
|
yp_buffer_append_u8(buffer, 0);
|
954
1079
|
} else {
|
955
1080
|
yp_buffer_append_u8(buffer, 1);
|
956
|
-
|
1081
|
+
yp_serialize_location(parser, &((yp_multi_write_node_t *)node)->rparen_loc, buffer);
|
957
1082
|
}
|
958
1083
|
break;
|
959
1084
|
}
|
@@ -963,44 +1088,31 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
963
1088
|
} else {
|
964
1089
|
yp_serialize_node(parser, (yp_node_t *)((yp_next_node_t *)node)->arguments, buffer);
|
965
1090
|
}
|
966
|
-
|
1091
|
+
yp_serialize_location(parser, &((yp_next_node_t *)node)->keyword_loc, buffer);
|
967
1092
|
break;
|
968
1093
|
}
|
969
1094
|
case YP_NODE_NIL_NODE: {
|
970
1095
|
break;
|
971
1096
|
}
|
972
1097
|
case YP_NODE_NO_KEYWORDS_PARAMETER_NODE: {
|
973
|
-
|
974
|
-
|
1098
|
+
yp_serialize_location(parser, &((yp_no_keywords_parameter_node_t *)node)->operator_loc, buffer);
|
1099
|
+
yp_serialize_location(parser, &((yp_no_keywords_parameter_node_t *)node)->keyword_loc, buffer);
|
975
1100
|
break;
|
976
1101
|
}
|
977
1102
|
case YP_NODE_NUMBERED_REFERENCE_READ_NODE: {
|
978
1103
|
break;
|
979
1104
|
}
|
980
|
-
case YP_NODE_OPERATOR_WRITE_NODE: {
|
981
|
-
yp_serialize_node(parser, (yp_node_t *)((yp_operator_write_node_t *)node)->target, buffer);
|
982
|
-
serialize_location(parser, &((yp_operator_write_node_t *)node)->operator_loc, buffer);
|
983
|
-
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_operator_write_node_t *)node)->operator));
|
984
|
-
yp_serialize_node(parser, (yp_node_t *)((yp_operator_write_node_t *)node)->value, buffer);
|
985
|
-
break;
|
986
|
-
}
|
987
1105
|
case YP_NODE_OPTIONAL_PARAMETER_NODE: {
|
988
1106
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_optional_parameter_node_t *)node)->constant_id));
|
989
|
-
|
990
|
-
|
1107
|
+
yp_serialize_location(parser, &((yp_optional_parameter_node_t *)node)->name_loc, buffer);
|
1108
|
+
yp_serialize_location(parser, &((yp_optional_parameter_node_t *)node)->operator_loc, buffer);
|
991
1109
|
yp_serialize_node(parser, (yp_node_t *)((yp_optional_parameter_node_t *)node)->value, buffer);
|
992
1110
|
break;
|
993
1111
|
}
|
994
1112
|
case YP_NODE_OR_NODE: {
|
995
1113
|
yp_serialize_node(parser, (yp_node_t *)((yp_or_node_t *)node)->left, buffer);
|
996
1114
|
yp_serialize_node(parser, (yp_node_t *)((yp_or_node_t *)node)->right, buffer);
|
997
|
-
|
998
|
-
break;
|
999
|
-
}
|
1000
|
-
case YP_NODE_OR_WRITE_NODE: {
|
1001
|
-
yp_serialize_node(parser, (yp_node_t *)((yp_or_write_node_t *)node)->target, buffer);
|
1002
|
-
yp_serialize_node(parser, (yp_node_t *)((yp_or_write_node_t *)node)->value, buffer);
|
1003
|
-
serialize_location(parser, &((yp_or_write_node_t *)node)->operator_loc, buffer);
|
1115
|
+
yp_serialize_location(parser, &((yp_or_node_t *)node)->operator_loc, buffer);
|
1004
1116
|
break;
|
1005
1117
|
}
|
1006
1118
|
case YP_NODE_PARAMETERS_NODE: {
|
@@ -1047,20 +1159,20 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1047
1159
|
} else {
|
1048
1160
|
yp_serialize_node(parser, (yp_node_t *)((yp_parentheses_node_t *)node)->body, buffer);
|
1049
1161
|
}
|
1050
|
-
|
1051
|
-
|
1162
|
+
yp_serialize_location(parser, &((yp_parentheses_node_t *)node)->opening_loc, buffer);
|
1163
|
+
yp_serialize_location(parser, &((yp_parentheses_node_t *)node)->closing_loc, buffer);
|
1052
1164
|
break;
|
1053
1165
|
}
|
1054
1166
|
case YP_NODE_PINNED_EXPRESSION_NODE: {
|
1055
1167
|
yp_serialize_node(parser, (yp_node_t *)((yp_pinned_expression_node_t *)node)->expression, buffer);
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1168
|
+
yp_serialize_location(parser, &((yp_pinned_expression_node_t *)node)->operator_loc, buffer);
|
1169
|
+
yp_serialize_location(parser, &((yp_pinned_expression_node_t *)node)->lparen_loc, buffer);
|
1170
|
+
yp_serialize_location(parser, &((yp_pinned_expression_node_t *)node)->rparen_loc, buffer);
|
1059
1171
|
break;
|
1060
1172
|
}
|
1061
1173
|
case YP_NODE_PINNED_VARIABLE_NODE: {
|
1062
1174
|
yp_serialize_node(parser, (yp_node_t *)((yp_pinned_variable_node_t *)node)->variable, buffer);
|
1063
|
-
|
1175
|
+
yp_serialize_location(parser, &((yp_pinned_variable_node_t *)node)->operator_loc, buffer);
|
1064
1176
|
break;
|
1065
1177
|
}
|
1066
1178
|
case YP_NODE_POST_EXECUTION_NODE: {
|
@@ -1069,9 +1181,9 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1069
1181
|
} else {
|
1070
1182
|
yp_serialize_node(parser, (yp_node_t *)((yp_post_execution_node_t *)node)->statements, buffer);
|
1071
1183
|
}
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1184
|
+
yp_serialize_location(parser, &((yp_post_execution_node_t *)node)->keyword_loc, buffer);
|
1185
|
+
yp_serialize_location(parser, &((yp_post_execution_node_t *)node)->opening_loc, buffer);
|
1186
|
+
yp_serialize_location(parser, &((yp_post_execution_node_t *)node)->closing_loc, buffer);
|
1075
1187
|
break;
|
1076
1188
|
}
|
1077
1189
|
case YP_NODE_PRE_EXECUTION_NODE: {
|
@@ -1080,9 +1192,9 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1080
1192
|
} else {
|
1081
1193
|
yp_serialize_node(parser, (yp_node_t *)((yp_pre_execution_node_t *)node)->statements, buffer);
|
1082
1194
|
}
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1195
|
+
yp_serialize_location(parser, &((yp_pre_execution_node_t *)node)->keyword_loc, buffer);
|
1196
|
+
yp_serialize_location(parser, &((yp_pre_execution_node_t *)node)->opening_loc, buffer);
|
1197
|
+
yp_serialize_location(parser, &((yp_pre_execution_node_t *)node)->closing_loc, buffer);
|
1086
1198
|
break;
|
1087
1199
|
}
|
1088
1200
|
case YP_NODE_PROGRAM_NODE: {
|
@@ -1105,7 +1217,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1105
1217
|
} else {
|
1106
1218
|
yp_serialize_node(parser, (yp_node_t *)((yp_range_node_t *)node)->right, buffer);
|
1107
1219
|
}
|
1108
|
-
|
1220
|
+
yp_serialize_location(parser, &((yp_range_node_t *)node)->operator_loc, buffer);
|
1109
1221
|
yp_buffer_append_u32(buffer, node->flags >> 1);
|
1110
1222
|
break;
|
1111
1223
|
}
|
@@ -1117,12 +1229,10 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1117
1229
|
break;
|
1118
1230
|
}
|
1119
1231
|
case YP_NODE_REGULAR_EXPRESSION_NODE: {
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
yp_buffer_append_u32(buffer, unescaped_length);
|
1125
|
-
yp_buffer_append_str(buffer, yp_string_source(&((yp_regular_expression_node_t *)node)->unescaped), unescaped_length);
|
1232
|
+
yp_serialize_location(parser, &((yp_regular_expression_node_t *)node)->opening_loc, buffer);
|
1233
|
+
yp_serialize_location(parser, &((yp_regular_expression_node_t *)node)->content_loc, buffer);
|
1234
|
+
yp_serialize_location(parser, &((yp_regular_expression_node_t *)node)->closing_loc, buffer);
|
1235
|
+
yp_serialize_string(parser, &((yp_regular_expression_node_t *)node)->unescaped, buffer);
|
1126
1236
|
yp_buffer_append_u32(buffer, node->flags >> 1);
|
1127
1237
|
break;
|
1128
1238
|
}
|
@@ -1132,8 +1242,8 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1132
1242
|
for (uint32_t index = 0; index < parameters_size; index++) {
|
1133
1243
|
yp_serialize_node(parser, (yp_node_t *) ((yp_required_destructured_parameter_node_t *)node)->parameters.nodes[index], buffer);
|
1134
1244
|
}
|
1135
|
-
|
1136
|
-
|
1245
|
+
yp_serialize_location(parser, &((yp_required_destructured_parameter_node_t *)node)->opening_loc, buffer);
|
1246
|
+
yp_serialize_location(parser, &((yp_required_destructured_parameter_node_t *)node)->closing_loc, buffer);
|
1137
1247
|
break;
|
1138
1248
|
}
|
1139
1249
|
case YP_NODE_REQUIRED_PARAMETER_NODE: {
|
@@ -1142,12 +1252,12 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1142
1252
|
}
|
1143
1253
|
case YP_NODE_RESCUE_MODIFIER_NODE: {
|
1144
1254
|
yp_serialize_node(parser, (yp_node_t *)((yp_rescue_modifier_node_t *)node)->expression, buffer);
|
1145
|
-
|
1255
|
+
yp_serialize_location(parser, &((yp_rescue_modifier_node_t *)node)->keyword_loc, buffer);
|
1146
1256
|
yp_serialize_node(parser, (yp_node_t *)((yp_rescue_modifier_node_t *)node)->rescue_expression, buffer);
|
1147
1257
|
break;
|
1148
1258
|
}
|
1149
1259
|
case YP_NODE_RESCUE_NODE: {
|
1150
|
-
|
1260
|
+
yp_serialize_location(parser, &((yp_rescue_node_t *)node)->keyword_loc, buffer);
|
1151
1261
|
uint32_t exceptions_size = yp_sizet_to_u32(((yp_rescue_node_t *)node)->exceptions.size);
|
1152
1262
|
yp_buffer_append_u32(buffer, exceptions_size);
|
1153
1263
|
for (uint32_t index = 0; index < exceptions_size; index++) {
|
@@ -1157,7 +1267,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1157
1267
|
yp_buffer_append_u8(buffer, 0);
|
1158
1268
|
} else {
|
1159
1269
|
yp_buffer_append_u8(buffer, 1);
|
1160
|
-
|
1270
|
+
yp_serialize_location(parser, &((yp_rescue_node_t *)node)->operator_loc, buffer);
|
1161
1271
|
}
|
1162
1272
|
if (((yp_rescue_node_t *)node)->reference == NULL) {
|
1163
1273
|
yp_buffer_append_u8(buffer, 0);
|
@@ -1177,12 +1287,12 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1177
1287
|
break;
|
1178
1288
|
}
|
1179
1289
|
case YP_NODE_REST_PARAMETER_NODE: {
|
1180
|
-
|
1290
|
+
yp_serialize_location(parser, &((yp_rest_parameter_node_t *)node)->operator_loc, buffer);
|
1181
1291
|
if (((yp_rest_parameter_node_t *)node)->name_loc.start == NULL) {
|
1182
1292
|
yp_buffer_append_u8(buffer, 0);
|
1183
1293
|
} else {
|
1184
1294
|
yp_buffer_append_u8(buffer, 1);
|
1185
|
-
|
1295
|
+
yp_serialize_location(parser, &((yp_rest_parameter_node_t *)node)->name_loc, buffer);
|
1186
1296
|
}
|
1187
1297
|
break;
|
1188
1298
|
}
|
@@ -1190,7 +1300,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1190
1300
|
break;
|
1191
1301
|
}
|
1192
1302
|
case YP_NODE_RETURN_NODE: {
|
1193
|
-
|
1303
|
+
yp_serialize_location(parser, &((yp_return_node_t *)node)->keyword_loc, buffer);
|
1194
1304
|
if (((yp_return_node_t *)node)->arguments == NULL) {
|
1195
1305
|
yp_buffer_append_u8(buffer, 0);
|
1196
1306
|
} else {
|
@@ -1207,31 +1317,29 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1207
1317
|
for (uint32_t index = 0; index < locals_size; index++) {
|
1208
1318
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_singleton_class_node_t *)node)->locals.ids[index]));
|
1209
1319
|
}
|
1210
|
-
|
1211
|
-
|
1320
|
+
yp_serialize_location(parser, &((yp_singleton_class_node_t *)node)->class_keyword_loc, buffer);
|
1321
|
+
yp_serialize_location(parser, &((yp_singleton_class_node_t *)node)->operator_loc, buffer);
|
1212
1322
|
yp_serialize_node(parser, (yp_node_t *)((yp_singleton_class_node_t *)node)->expression, buffer);
|
1213
1323
|
if (((yp_singleton_class_node_t *)node)->body == NULL) {
|
1214
1324
|
yp_buffer_append_u8(buffer, 0);
|
1215
1325
|
} else {
|
1216
1326
|
yp_serialize_node(parser, (yp_node_t *)((yp_singleton_class_node_t *)node)->body, buffer);
|
1217
1327
|
}
|
1218
|
-
|
1328
|
+
yp_serialize_location(parser, &((yp_singleton_class_node_t *)node)->end_keyword_loc, buffer);
|
1219
1329
|
break;
|
1220
1330
|
}
|
1221
1331
|
case YP_NODE_SOURCE_ENCODING_NODE: {
|
1222
1332
|
break;
|
1223
1333
|
}
|
1224
1334
|
case YP_NODE_SOURCE_FILE_NODE: {
|
1225
|
-
|
1226
|
-
yp_buffer_append_u32(buffer, filepath_length);
|
1227
|
-
yp_buffer_append_str(buffer, yp_string_source(&((yp_source_file_node_t *)node)->filepath), filepath_length);
|
1335
|
+
yp_serialize_string(parser, &((yp_source_file_node_t *)node)->filepath, buffer);
|
1228
1336
|
break;
|
1229
1337
|
}
|
1230
1338
|
case YP_NODE_SOURCE_LINE_NODE: {
|
1231
1339
|
break;
|
1232
1340
|
}
|
1233
1341
|
case YP_NODE_SPLAT_NODE: {
|
1234
|
-
|
1342
|
+
yp_serialize_location(parser, &((yp_splat_node_t *)node)->operator_loc, buffer);
|
1235
1343
|
if (((yp_splat_node_t *)node)->expression == NULL) {
|
1236
1344
|
yp_buffer_append_u8(buffer, 0);
|
1237
1345
|
} else {
|
@@ -1257,27 +1365,25 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1257
1365
|
yp_buffer_append_u8(buffer, 0);
|
1258
1366
|
} else {
|
1259
1367
|
yp_buffer_append_u8(buffer, 1);
|
1260
|
-
|
1368
|
+
yp_serialize_location(parser, &((yp_string_node_t *)node)->opening_loc, buffer);
|
1261
1369
|
}
|
1262
|
-
|
1370
|
+
yp_serialize_location(parser, &((yp_string_node_t *)node)->content_loc, buffer);
|
1263
1371
|
if (((yp_string_node_t *)node)->closing_loc.start == NULL) {
|
1264
1372
|
yp_buffer_append_u8(buffer, 0);
|
1265
1373
|
} else {
|
1266
1374
|
yp_buffer_append_u8(buffer, 1);
|
1267
|
-
|
1375
|
+
yp_serialize_location(parser, &((yp_string_node_t *)node)->closing_loc, buffer);
|
1268
1376
|
}
|
1269
|
-
|
1270
|
-
yp_buffer_append_u32(buffer, unescaped_length);
|
1271
|
-
yp_buffer_append_str(buffer, yp_string_source(&((yp_string_node_t *)node)->unescaped), unescaped_length);
|
1377
|
+
yp_serialize_string(parser, &((yp_string_node_t *)node)->unescaped, buffer);
|
1272
1378
|
break;
|
1273
1379
|
}
|
1274
1380
|
case YP_NODE_SUPER_NODE: {
|
1275
|
-
|
1381
|
+
yp_serialize_location(parser, &((yp_super_node_t *)node)->keyword_loc, buffer);
|
1276
1382
|
if (((yp_super_node_t *)node)->lparen_loc.start == NULL) {
|
1277
1383
|
yp_buffer_append_u8(buffer, 0);
|
1278
1384
|
} else {
|
1279
1385
|
yp_buffer_append_u8(buffer, 1);
|
1280
|
-
|
1386
|
+
yp_serialize_location(parser, &((yp_super_node_t *)node)->lparen_loc, buffer);
|
1281
1387
|
}
|
1282
1388
|
if (((yp_super_node_t *)node)->arguments == NULL) {
|
1283
1389
|
yp_buffer_append_u8(buffer, 0);
|
@@ -1288,7 +1394,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1288
1394
|
yp_buffer_append_u8(buffer, 0);
|
1289
1395
|
} else {
|
1290
1396
|
yp_buffer_append_u8(buffer, 1);
|
1291
|
-
|
1397
|
+
yp_serialize_location(parser, &((yp_super_node_t *)node)->rparen_loc, buffer);
|
1292
1398
|
}
|
1293
1399
|
if (((yp_super_node_t *)node)->block == NULL) {
|
1294
1400
|
yp_buffer_append_u8(buffer, 0);
|
@@ -1302,18 +1408,21 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1302
1408
|
yp_buffer_append_u8(buffer, 0);
|
1303
1409
|
} else {
|
1304
1410
|
yp_buffer_append_u8(buffer, 1);
|
1305
|
-
|
1411
|
+
yp_serialize_location(parser, &((yp_symbol_node_t *)node)->opening_loc, buffer);
|
1412
|
+
}
|
1413
|
+
if (((yp_symbol_node_t *)node)->value_loc.start == NULL) {
|
1414
|
+
yp_buffer_append_u8(buffer, 0);
|
1415
|
+
} else {
|
1416
|
+
yp_buffer_append_u8(buffer, 1);
|
1417
|
+
yp_serialize_location(parser, &((yp_symbol_node_t *)node)->value_loc, buffer);
|
1306
1418
|
}
|
1307
|
-
serialize_location(parser, &((yp_symbol_node_t *)node)->value_loc, buffer);
|
1308
1419
|
if (((yp_symbol_node_t *)node)->closing_loc.start == NULL) {
|
1309
1420
|
yp_buffer_append_u8(buffer, 0);
|
1310
1421
|
} else {
|
1311
1422
|
yp_buffer_append_u8(buffer, 1);
|
1312
|
-
|
1423
|
+
yp_serialize_location(parser, &((yp_symbol_node_t *)node)->closing_loc, buffer);
|
1313
1424
|
}
|
1314
|
-
|
1315
|
-
yp_buffer_append_u32(buffer, unescaped_length);
|
1316
|
-
yp_buffer_append_str(buffer, yp_string_source(&((yp_symbol_node_t *)node)->unescaped), unescaped_length);
|
1425
|
+
yp_serialize_string(parser, &((yp_symbol_node_t *)node)->unescaped, buffer);
|
1317
1426
|
break;
|
1318
1427
|
}
|
1319
1428
|
case YP_NODE_TRUE_NODE: {
|
@@ -1325,11 +1434,11 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1325
1434
|
for (uint32_t index = 0; index < names_size; index++) {
|
1326
1435
|
yp_serialize_node(parser, (yp_node_t *) ((yp_undef_node_t *)node)->names.nodes[index], buffer);
|
1327
1436
|
}
|
1328
|
-
|
1437
|
+
yp_serialize_location(parser, &((yp_undef_node_t *)node)->keyword_loc, buffer);
|
1329
1438
|
break;
|
1330
1439
|
}
|
1331
1440
|
case YP_NODE_UNLESS_NODE: {
|
1332
|
-
|
1441
|
+
yp_serialize_location(parser, &((yp_unless_node_t *)node)->keyword_loc, buffer);
|
1333
1442
|
yp_serialize_node(parser, (yp_node_t *)((yp_unless_node_t *)node)->predicate, buffer);
|
1334
1443
|
if (((yp_unless_node_t *)node)->statements == NULL) {
|
1335
1444
|
yp_buffer_append_u8(buffer, 0);
|
@@ -1345,12 +1454,18 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1345
1454
|
yp_buffer_append_u8(buffer, 0);
|
1346
1455
|
} else {
|
1347
1456
|
yp_buffer_append_u8(buffer, 1);
|
1348
|
-
|
1457
|
+
yp_serialize_location(parser, &((yp_unless_node_t *)node)->end_keyword_loc, buffer);
|
1349
1458
|
}
|
1350
1459
|
break;
|
1351
1460
|
}
|
1352
1461
|
case YP_NODE_UNTIL_NODE: {
|
1353
|
-
|
1462
|
+
yp_serialize_location(parser, &((yp_until_node_t *)node)->keyword_loc, buffer);
|
1463
|
+
if (((yp_until_node_t *)node)->closing_loc.start == NULL) {
|
1464
|
+
yp_buffer_append_u8(buffer, 0);
|
1465
|
+
} else {
|
1466
|
+
yp_buffer_append_u8(buffer, 1);
|
1467
|
+
yp_serialize_location(parser, &((yp_until_node_t *)node)->closing_loc, buffer);
|
1468
|
+
}
|
1354
1469
|
yp_serialize_node(parser, (yp_node_t *)((yp_until_node_t *)node)->predicate, buffer);
|
1355
1470
|
if (((yp_until_node_t *)node)->statements == NULL) {
|
1356
1471
|
yp_buffer_append_u8(buffer, 0);
|
@@ -1361,7 +1476,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1361
1476
|
break;
|
1362
1477
|
}
|
1363
1478
|
case YP_NODE_WHEN_NODE: {
|
1364
|
-
|
1479
|
+
yp_serialize_location(parser, &((yp_when_node_t *)node)->keyword_loc, buffer);
|
1365
1480
|
uint32_t conditions_size = yp_sizet_to_u32(((yp_when_node_t *)node)->conditions.size);
|
1366
1481
|
yp_buffer_append_u32(buffer, conditions_size);
|
1367
1482
|
for (uint32_t index = 0; index < conditions_size; index++) {
|
@@ -1375,7 +1490,13 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1375
1490
|
break;
|
1376
1491
|
}
|
1377
1492
|
case YP_NODE_WHILE_NODE: {
|
1378
|
-
|
1493
|
+
yp_serialize_location(parser, &((yp_while_node_t *)node)->keyword_loc, buffer);
|
1494
|
+
if (((yp_while_node_t *)node)->closing_loc.start == NULL) {
|
1495
|
+
yp_buffer_append_u8(buffer, 0);
|
1496
|
+
} else {
|
1497
|
+
yp_buffer_append_u8(buffer, 1);
|
1498
|
+
yp_serialize_location(parser, &((yp_while_node_t *)node)->closing_loc, buffer);
|
1499
|
+
}
|
1379
1500
|
yp_serialize_node(parser, (yp_node_t *)((yp_while_node_t *)node)->predicate, buffer);
|
1380
1501
|
if (((yp_while_node_t *)node)->statements == NULL) {
|
1381
1502
|
yp_buffer_append_u8(buffer, 0);
|
@@ -1386,21 +1507,19 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1386
1507
|
break;
|
1387
1508
|
}
|
1388
1509
|
case YP_NODE_X_STRING_NODE: {
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
yp_buffer_append_u32(buffer, unescaped_length);
|
1394
|
-
yp_buffer_append_str(buffer, yp_string_source(&((yp_x_string_node_t *)node)->unescaped), unescaped_length);
|
1510
|
+
yp_serialize_location(parser, &((yp_x_string_node_t *)node)->opening_loc, buffer);
|
1511
|
+
yp_serialize_location(parser, &((yp_x_string_node_t *)node)->content_loc, buffer);
|
1512
|
+
yp_serialize_location(parser, &((yp_x_string_node_t *)node)->closing_loc, buffer);
|
1513
|
+
yp_serialize_string(parser, &((yp_x_string_node_t *)node)->unescaped, buffer);
|
1395
1514
|
break;
|
1396
1515
|
}
|
1397
1516
|
case YP_NODE_YIELD_NODE: {
|
1398
|
-
|
1517
|
+
yp_serialize_location(parser, &((yp_yield_node_t *)node)->keyword_loc, buffer);
|
1399
1518
|
if (((yp_yield_node_t *)node)->lparen_loc.start == NULL) {
|
1400
1519
|
yp_buffer_append_u8(buffer, 0);
|
1401
1520
|
} else {
|
1402
1521
|
yp_buffer_append_u8(buffer, 1);
|
1403
|
-
|
1522
|
+
yp_serialize_location(parser, &((yp_yield_node_t *)node)->lparen_loc, buffer);
|
1404
1523
|
}
|
1405
1524
|
if (((yp_yield_node_t *)node)->arguments == NULL) {
|
1406
1525
|
yp_buffer_append_u8(buffer, 0);
|
@@ -1411,14 +1530,15 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
|
1411
1530
|
yp_buffer_append_u8(buffer, 0);
|
1412
1531
|
} else {
|
1413
1532
|
yp_buffer_append_u8(buffer, 1);
|
1414
|
-
|
1533
|
+
yp_serialize_location(parser, &((yp_yield_node_t *)node)->rparen_loc, buffer);
|
1415
1534
|
}
|
1416
1535
|
break;
|
1417
1536
|
}
|
1418
1537
|
}
|
1419
1538
|
}
|
1420
1539
|
|
1421
|
-
void
|
1540
|
+
static void
|
1541
|
+
yp_serialize_comment(yp_parser_t *parser, yp_comment_t *comment, yp_buffer_t *buffer) {
|
1422
1542
|
// serialize type
|
1423
1543
|
yp_buffer_append_u8(buffer, (uint8_t) comment->type);
|
1424
1544
|
|
@@ -1427,16 +1547,18 @@ void yp_serialize_comment(yp_parser_t *parser, yp_comment_t *comment, yp_buffer_
|
|
1427
1547
|
yp_buffer_append_u32(buffer, yp_ptrdifft_to_u32(comment->end - comment->start));
|
1428
1548
|
}
|
1429
1549
|
|
1430
|
-
void
|
1431
|
-
|
1550
|
+
static void
|
1551
|
+
yp_serialize_comment_list(yp_parser_t *parser, yp_list_t *list, yp_buffer_t *buffer) {
|
1552
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(yp_list_size(list)));
|
1432
1553
|
|
1433
1554
|
yp_comment_t *comment;
|
1434
|
-
for (comment = (yp_comment_t *) list
|
1555
|
+
for (comment = (yp_comment_t *) list->head; comment != NULL; comment = (yp_comment_t *) comment->node.next) {
|
1435
1556
|
yp_serialize_comment(parser, comment, buffer);
|
1436
1557
|
}
|
1437
1558
|
}
|
1438
1559
|
|
1439
|
-
void
|
1560
|
+
static void
|
1561
|
+
yp_serialize_diagnostic(yp_parser_t *parser, yp_diagnostic_t *diagnostic, yp_buffer_t *buffer) {
|
1440
1562
|
// serialize message
|
1441
1563
|
size_t message_length = strlen(diagnostic->message);
|
1442
1564
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(message_length));
|
@@ -1447,31 +1569,30 @@ void yp_serialize_diagnostic(yp_parser_t *parser, yp_diagnostic_t *diagnostic, y
|
|
1447
1569
|
yp_buffer_append_u32(buffer, yp_ptrdifft_to_u32(diagnostic->end - diagnostic->start));
|
1448
1570
|
}
|
1449
1571
|
|
1450
|
-
void
|
1451
|
-
|
1572
|
+
static void
|
1573
|
+
yp_serialize_diagnostic_list(yp_parser_t *parser, yp_list_t *list, yp_buffer_t *buffer) {
|
1574
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(yp_list_size(list)));
|
1452
1575
|
|
1453
1576
|
yp_diagnostic_t *diagnostic;
|
1454
|
-
for (diagnostic = (yp_diagnostic_t *) list
|
1577
|
+
for (diagnostic = (yp_diagnostic_t *) list->head; diagnostic != NULL; diagnostic = (yp_diagnostic_t *) diagnostic->node.next) {
|
1455
1578
|
yp_serialize_diagnostic(parser, diagnostic, buffer);
|
1456
1579
|
}
|
1457
1580
|
}
|
1458
1581
|
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
// First, serialize the encoding of the parser.
|
1463
|
-
size_t encoding_length = strlen(parser->encoding.name);
|
1582
|
+
static void
|
1583
|
+
yp_serialize_encoding(yp_encoding_t *encoding, yp_buffer_t *buffer) {
|
1584
|
+
size_t encoding_length = strlen(encoding->name);
|
1464
1585
|
yp_buffer_append_u32(buffer, yp_sizet_to_u32(encoding_length));
|
1465
|
-
yp_buffer_append_str(buffer,
|
1466
|
-
|
1467
|
-
// Serialize the comments
|
1468
|
-
yp_serialize_comment_list(parser, parser->comment_list, buffer);
|
1469
|
-
|
1470
|
-
// Serialize the errors
|
1471
|
-
yp_serialize_diagnostic_list(parser, parser->error_list, buffer);
|
1586
|
+
yp_buffer_append_str(buffer, encoding->name, encoding_length);
|
1587
|
+
}
|
1472
1588
|
|
1473
|
-
|
1474
|
-
|
1589
|
+
#line 181 "serialize.c.erb"
|
1590
|
+
void
|
1591
|
+
yp_serialize_content(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
1592
|
+
yp_serialize_encoding(&parser->encoding, buffer);
|
1593
|
+
yp_serialize_comment_list(parser, &parser->comment_list, buffer);
|
1594
|
+
yp_serialize_diagnostic_list(parser, &parser->error_list, buffer);
|
1595
|
+
yp_serialize_diagnostic_list(parser, &parser->warning_list, buffer);
|
1475
1596
|
|
1476
1597
|
// Here we're going to leave space for the offset of the constant pool in
|
1477
1598
|
// the buffer.
|
@@ -1535,16 +1656,35 @@ yp_lex_serialize(const char *source, size_t size, const char *filepath, yp_buffe
|
|
1535
1656
|
yp_node_t *node = yp_parse(&parser);
|
1536
1657
|
|
1537
1658
|
// Append 0 to mark end of tokens
|
1538
|
-
|
1659
|
+
yp_buffer_append_u8(buffer, 0);
|
1539
1660
|
|
1540
|
-
|
1541
|
-
yp_serialize_comment_list(&parser, parser.comment_list, buffer);
|
1661
|
+
yp_serialize_encoding(&parser.encoding, buffer);
|
1662
|
+
yp_serialize_comment_list(&parser, &parser.comment_list, buffer);
|
1663
|
+
yp_serialize_diagnostic_list(&parser, &parser.error_list, buffer);
|
1664
|
+
yp_serialize_diagnostic_list(&parser, &parser.warning_list, buffer);
|
1542
1665
|
|
1543
|
-
|
1544
|
-
|
1666
|
+
yp_node_destroy(&parser, node);
|
1667
|
+
yp_parser_free(&parser);
|
1668
|
+
}
|
1669
|
+
|
1670
|
+
// Parse and serialize both the AST and the tokens represented by the given
|
1671
|
+
// source to the given buffer.
|
1672
|
+
YP_EXPORTED_FUNCTION void
|
1673
|
+
yp_parse_lex_serialize(const char *source, size_t size, yp_buffer_t *buffer, const char *metadata) {
|
1674
|
+
yp_parser_t parser;
|
1675
|
+
yp_parser_init(&parser, source, size, NULL);
|
1676
|
+
if (metadata) yp_parser_metadata(&parser, metadata);
|
1677
|
+
|
1678
|
+
yp_lex_callback_t lex_callback = (yp_lex_callback_t) {
|
1679
|
+
.data = (void *) buffer,
|
1680
|
+
.callback = serialize_token,
|
1681
|
+
};
|
1682
|
+
|
1683
|
+
parser.lex_callback = &lex_callback;
|
1684
|
+
yp_node_t *node = yp_parse(&parser);
|
1545
1685
|
|
1546
|
-
|
1547
|
-
|
1686
|
+
yp_buffer_append_u8(buffer, 0);
|
1687
|
+
yp_serialize(&parser, node, buffer);
|
1548
1688
|
|
1549
1689
|
yp_node_destroy(&parser, node);
|
1550
1690
|
yp_parser_free(&parser);
|