yarp 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +51 -0
- data/LICENSE.md +7 -0
- data/Makefile.in +79 -0
- data/README.md +86 -0
- data/config.h.in +25 -0
- data/config.yml +2147 -0
- data/configure +4487 -0
- data/docs/build_system.md +85 -0
- data/docs/building.md +26 -0
- data/docs/configuration.md +56 -0
- data/docs/design.md +53 -0
- data/docs/encoding.md +116 -0
- data/docs/extension.md +20 -0
- data/docs/fuzzing.md +93 -0
- data/docs/heredocs.md +36 -0
- data/docs/mapping.md +117 -0
- data/docs/ripper.md +36 -0
- data/docs/serialization.md +130 -0
- data/docs/testing.md +55 -0
- data/ext/yarp/api_node.c +3680 -0
- data/ext/yarp/api_pack.c +256 -0
- data/ext/yarp/extconf.rb +131 -0
- data/ext/yarp/extension.c +547 -0
- data/ext/yarp/extension.h +18 -0
- data/include/yarp/ast.h +1412 -0
- data/include/yarp/defines.h +54 -0
- data/include/yarp/diagnostic.h +24 -0
- data/include/yarp/enc/yp_encoding.h +94 -0
- data/include/yarp/node.h +36 -0
- data/include/yarp/pack.h +141 -0
- data/include/yarp/parser.h +389 -0
- data/include/yarp/regexp.h +19 -0
- data/include/yarp/unescape.h +42 -0
- data/include/yarp/util/yp_buffer.h +39 -0
- data/include/yarp/util/yp_char.h +75 -0
- data/include/yarp/util/yp_constant_pool.h +64 -0
- data/include/yarp/util/yp_list.h +67 -0
- data/include/yarp/util/yp_memchr.h +14 -0
- data/include/yarp/util/yp_newline_list.h +54 -0
- data/include/yarp/util/yp_state_stack.h +24 -0
- data/include/yarp/util/yp_string.h +57 -0
- data/include/yarp/util/yp_string_list.h +28 -0
- data/include/yarp/util/yp_strpbrk.h +29 -0
- data/include/yarp/version.h +5 -0
- data/include/yarp.h +69 -0
- data/lib/yarp/lex_compat.rb +759 -0
- data/lib/yarp/node.rb +7428 -0
- data/lib/yarp/pack.rb +185 -0
- data/lib/yarp/ripper_compat.rb +174 -0
- data/lib/yarp/serialize.rb +389 -0
- data/lib/yarp.rb +330 -0
- data/src/diagnostic.c +25 -0
- data/src/enc/yp_big5.c +79 -0
- data/src/enc/yp_euc_jp.c +85 -0
- data/src/enc/yp_gbk.c +88 -0
- data/src/enc/yp_shift_jis.c +83 -0
- data/src/enc/yp_tables.c +509 -0
- data/src/enc/yp_unicode.c +2320 -0
- data/src/enc/yp_windows_31j.c +83 -0
- data/src/node.c +2011 -0
- data/src/pack.c +493 -0
- data/src/prettyprint.c +1782 -0
- data/src/regexp.c +580 -0
- data/src/serialize.c +1576 -0
- data/src/token_type.c +347 -0
- data/src/unescape.c +576 -0
- data/src/util/yp_buffer.c +78 -0
- data/src/util/yp_char.c +229 -0
- data/src/util/yp_constant_pool.c +147 -0
- data/src/util/yp_list.c +50 -0
- data/src/util/yp_memchr.c +31 -0
- data/src/util/yp_newline_list.c +119 -0
- data/src/util/yp_state_stack.c +25 -0
- data/src/util/yp_string.c +207 -0
- data/src/util/yp_string_list.c +32 -0
- data/src/util/yp_strncasecmp.c +20 -0
- data/src/util/yp_strpbrk.c +66 -0
- data/src/yarp.c +13211 -0
- data/yarp.gemspec +100 -0
- metadata +125 -0
data/src/serialize.c
ADDED
@@ -0,0 +1,1576 @@
|
|
1
|
+
/******************************************************************************/
|
2
|
+
/* This file is generated by the bin/template script and should not be */
|
3
|
+
/* modified manually. See */
|
4
|
+
/* templates/src/serialize.c.erb */
|
5
|
+
/* if you are looking to modify the */
|
6
|
+
/* template */
|
7
|
+
/******************************************************************************/
|
8
|
+
#include "yarp/ast.h"
|
9
|
+
#include "yarp/diagnostic.h"
|
10
|
+
#include "yarp/parser.h"
|
11
|
+
#include "yarp/util/yp_buffer.h"
|
12
|
+
|
13
|
+
#include <stdio.h>
|
14
|
+
|
15
|
+
static inline uint32_t
|
16
|
+
yp_ptrdifft_to_u32(ptrdiff_t value) {
|
17
|
+
assert(value >= 0 && ((unsigned long) value) < UINT32_MAX);
|
18
|
+
return (uint32_t) value;
|
19
|
+
}
|
20
|
+
|
21
|
+
static inline uint32_t
|
22
|
+
yp_sizet_to_u32(size_t value) {
|
23
|
+
assert(value < UINT32_MAX);
|
24
|
+
return (uint32_t) value;
|
25
|
+
}
|
26
|
+
|
27
|
+
static void
|
28
|
+
serialize_location(yp_parser_t *parser, yp_location_t *location, yp_buffer_t *buffer) {
|
29
|
+
assert(location->start);
|
30
|
+
assert(location->end);
|
31
|
+
assert(location->start <= location->end);
|
32
|
+
|
33
|
+
yp_buffer_append_u32(buffer, yp_ptrdifft_to_u32(location->start - parser->start));
|
34
|
+
yp_buffer_append_u32(buffer, yp_ptrdifft_to_u32(location->end - location->start));
|
35
|
+
}
|
36
|
+
|
37
|
+
void
|
38
|
+
yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
39
|
+
yp_buffer_append_u8(buffer, (uint8_t) YP_NODE_TYPE(node));
|
40
|
+
|
41
|
+
size_t offset = buffer->length;
|
42
|
+
|
43
|
+
serialize_location(parser, &node->location, buffer);
|
44
|
+
|
45
|
+
switch (YP_NODE_TYPE(node)) {
|
46
|
+
case YP_NODE_ALIAS_NODE: {
|
47
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_alias_node_t *)node)->new_name, buffer);
|
48
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_alias_node_t *)node)->old_name, buffer);
|
49
|
+
serialize_location(parser, &((yp_alias_node_t *)node)->keyword_loc, buffer);
|
50
|
+
break;
|
51
|
+
}
|
52
|
+
case YP_NODE_ALTERNATION_PATTERN_NODE: {
|
53
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_alternation_pattern_node_t *)node)->left, buffer);
|
54
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_alternation_pattern_node_t *)node)->right, buffer);
|
55
|
+
serialize_location(parser, &((yp_alternation_pattern_node_t *)node)->operator_loc, buffer);
|
56
|
+
break;
|
57
|
+
}
|
58
|
+
case YP_NODE_AND_NODE: {
|
59
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_and_node_t *)node)->left, buffer);
|
60
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_and_node_t *)node)->right, buffer);
|
61
|
+
serialize_location(parser, &((yp_and_node_t *)node)->operator_loc, buffer);
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
case YP_NODE_ARGUMENTS_NODE: {
|
65
|
+
uint32_t arguments_size = yp_sizet_to_u32(((yp_arguments_node_t *)node)->arguments.size);
|
66
|
+
yp_buffer_append_u32(buffer, arguments_size);
|
67
|
+
for (uint32_t index = 0; index < arguments_size; index++) {
|
68
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_arguments_node_t *)node)->arguments.nodes[index], buffer);
|
69
|
+
}
|
70
|
+
break;
|
71
|
+
}
|
72
|
+
case YP_NODE_ARRAY_NODE: {
|
73
|
+
uint32_t elements_size = yp_sizet_to_u32(((yp_array_node_t *)node)->elements.size);
|
74
|
+
yp_buffer_append_u32(buffer, elements_size);
|
75
|
+
for (uint32_t index = 0; index < elements_size; index++) {
|
76
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_array_node_t *)node)->elements.nodes[index], buffer);
|
77
|
+
}
|
78
|
+
if (((yp_array_node_t *)node)->opening_loc.start == NULL) {
|
79
|
+
yp_buffer_append_u8(buffer, 0);
|
80
|
+
} else {
|
81
|
+
yp_buffer_append_u8(buffer, 1);
|
82
|
+
serialize_location(parser, &((yp_array_node_t *)node)->opening_loc, buffer);
|
83
|
+
}
|
84
|
+
if (((yp_array_node_t *)node)->closing_loc.start == NULL) {
|
85
|
+
yp_buffer_append_u8(buffer, 0);
|
86
|
+
} else {
|
87
|
+
yp_buffer_append_u8(buffer, 1);
|
88
|
+
serialize_location(parser, &((yp_array_node_t *)node)->closing_loc, buffer);
|
89
|
+
}
|
90
|
+
break;
|
91
|
+
}
|
92
|
+
case YP_NODE_ARRAY_PATTERN_NODE: {
|
93
|
+
if (((yp_array_pattern_node_t *)node)->constant == NULL) {
|
94
|
+
yp_buffer_append_u8(buffer, 0);
|
95
|
+
} else {
|
96
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_array_pattern_node_t *)node)->constant, buffer);
|
97
|
+
}
|
98
|
+
uint32_t requireds_size = yp_sizet_to_u32(((yp_array_pattern_node_t *)node)->requireds.size);
|
99
|
+
yp_buffer_append_u32(buffer, requireds_size);
|
100
|
+
for (uint32_t index = 0; index < requireds_size; index++) {
|
101
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_array_pattern_node_t *)node)->requireds.nodes[index], buffer);
|
102
|
+
}
|
103
|
+
if (((yp_array_pattern_node_t *)node)->rest == NULL) {
|
104
|
+
yp_buffer_append_u8(buffer, 0);
|
105
|
+
} else {
|
106
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_array_pattern_node_t *)node)->rest, buffer);
|
107
|
+
}
|
108
|
+
uint32_t posts_size = yp_sizet_to_u32(((yp_array_pattern_node_t *)node)->posts.size);
|
109
|
+
yp_buffer_append_u32(buffer, posts_size);
|
110
|
+
for (uint32_t index = 0; index < posts_size; index++) {
|
111
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_array_pattern_node_t *)node)->posts.nodes[index], buffer);
|
112
|
+
}
|
113
|
+
if (((yp_array_pattern_node_t *)node)->opening_loc.start == NULL) {
|
114
|
+
yp_buffer_append_u8(buffer, 0);
|
115
|
+
} else {
|
116
|
+
yp_buffer_append_u8(buffer, 1);
|
117
|
+
serialize_location(parser, &((yp_array_pattern_node_t *)node)->opening_loc, buffer);
|
118
|
+
}
|
119
|
+
if (((yp_array_pattern_node_t *)node)->closing_loc.start == NULL) {
|
120
|
+
yp_buffer_append_u8(buffer, 0);
|
121
|
+
} else {
|
122
|
+
yp_buffer_append_u8(buffer, 1);
|
123
|
+
serialize_location(parser, &((yp_array_pattern_node_t *)node)->closing_loc, buffer);
|
124
|
+
}
|
125
|
+
break;
|
126
|
+
}
|
127
|
+
case YP_NODE_ASSOC_NODE: {
|
128
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_assoc_node_t *)node)->key, buffer);
|
129
|
+
if (((yp_assoc_node_t *)node)->value == NULL) {
|
130
|
+
yp_buffer_append_u8(buffer, 0);
|
131
|
+
} else {
|
132
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_assoc_node_t *)node)->value, buffer);
|
133
|
+
}
|
134
|
+
if (((yp_assoc_node_t *)node)->operator_loc.start == NULL) {
|
135
|
+
yp_buffer_append_u8(buffer, 0);
|
136
|
+
} else {
|
137
|
+
yp_buffer_append_u8(buffer, 1);
|
138
|
+
serialize_location(parser, &((yp_assoc_node_t *)node)->operator_loc, buffer);
|
139
|
+
}
|
140
|
+
break;
|
141
|
+
}
|
142
|
+
case YP_NODE_ASSOC_SPLAT_NODE: {
|
143
|
+
if (((yp_assoc_splat_node_t *)node)->value == NULL) {
|
144
|
+
yp_buffer_append_u8(buffer, 0);
|
145
|
+
} else {
|
146
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_assoc_splat_node_t *)node)->value, buffer);
|
147
|
+
}
|
148
|
+
serialize_location(parser, &((yp_assoc_splat_node_t *)node)->operator_loc, buffer);
|
149
|
+
break;
|
150
|
+
}
|
151
|
+
case YP_NODE_BACK_REFERENCE_READ_NODE: {
|
152
|
+
break;
|
153
|
+
}
|
154
|
+
case YP_NODE_BEGIN_NODE: {
|
155
|
+
if (((yp_begin_node_t *)node)->begin_keyword_loc.start == NULL) {
|
156
|
+
yp_buffer_append_u8(buffer, 0);
|
157
|
+
} else {
|
158
|
+
yp_buffer_append_u8(buffer, 1);
|
159
|
+
serialize_location(parser, &((yp_begin_node_t *)node)->begin_keyword_loc, buffer);
|
160
|
+
}
|
161
|
+
if (((yp_begin_node_t *)node)->statements == NULL) {
|
162
|
+
yp_buffer_append_u8(buffer, 0);
|
163
|
+
} else {
|
164
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_begin_node_t *)node)->statements, buffer);
|
165
|
+
}
|
166
|
+
if (((yp_begin_node_t *)node)->rescue_clause == NULL) {
|
167
|
+
yp_buffer_append_u8(buffer, 0);
|
168
|
+
} else {
|
169
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_begin_node_t *)node)->rescue_clause, buffer);
|
170
|
+
}
|
171
|
+
if (((yp_begin_node_t *)node)->else_clause == NULL) {
|
172
|
+
yp_buffer_append_u8(buffer, 0);
|
173
|
+
} else {
|
174
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_begin_node_t *)node)->else_clause, buffer);
|
175
|
+
}
|
176
|
+
if (((yp_begin_node_t *)node)->ensure_clause == NULL) {
|
177
|
+
yp_buffer_append_u8(buffer, 0);
|
178
|
+
} else {
|
179
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_begin_node_t *)node)->ensure_clause, buffer);
|
180
|
+
}
|
181
|
+
if (((yp_begin_node_t *)node)->end_keyword_loc.start == NULL) {
|
182
|
+
yp_buffer_append_u8(buffer, 0);
|
183
|
+
} else {
|
184
|
+
yp_buffer_append_u8(buffer, 1);
|
185
|
+
serialize_location(parser, &((yp_begin_node_t *)node)->end_keyword_loc, buffer);
|
186
|
+
}
|
187
|
+
break;
|
188
|
+
}
|
189
|
+
case YP_NODE_BLOCK_ARGUMENT_NODE: {
|
190
|
+
if (((yp_block_argument_node_t *)node)->expression == NULL) {
|
191
|
+
yp_buffer_append_u8(buffer, 0);
|
192
|
+
} else {
|
193
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_block_argument_node_t *)node)->expression, buffer);
|
194
|
+
}
|
195
|
+
serialize_location(parser, &((yp_block_argument_node_t *)node)->operator_loc, buffer);
|
196
|
+
break;
|
197
|
+
}
|
198
|
+
case YP_NODE_BLOCK_NODE: {
|
199
|
+
uint32_t locals_size = yp_sizet_to_u32(((yp_block_node_t *)node)->locals.size);
|
200
|
+
yp_buffer_append_u32(buffer, locals_size);
|
201
|
+
for (uint32_t index = 0; index < locals_size; index++) {
|
202
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_block_node_t *)node)->locals.ids[index]));
|
203
|
+
}
|
204
|
+
if (((yp_block_node_t *)node)->parameters == NULL) {
|
205
|
+
yp_buffer_append_u8(buffer, 0);
|
206
|
+
} else {
|
207
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_block_node_t *)node)->parameters, buffer);
|
208
|
+
}
|
209
|
+
if (((yp_block_node_t *)node)->statements == NULL) {
|
210
|
+
yp_buffer_append_u8(buffer, 0);
|
211
|
+
} else {
|
212
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_block_node_t *)node)->statements, buffer);
|
213
|
+
}
|
214
|
+
serialize_location(parser, &((yp_block_node_t *)node)->opening_loc, buffer);
|
215
|
+
serialize_location(parser, &((yp_block_node_t *)node)->closing_loc, buffer);
|
216
|
+
break;
|
217
|
+
}
|
218
|
+
case YP_NODE_BLOCK_PARAMETER_NODE: {
|
219
|
+
if (((yp_block_parameter_node_t *)node)->name_loc.start == NULL) {
|
220
|
+
yp_buffer_append_u8(buffer, 0);
|
221
|
+
} else {
|
222
|
+
yp_buffer_append_u8(buffer, 1);
|
223
|
+
serialize_location(parser, &((yp_block_parameter_node_t *)node)->name_loc, buffer);
|
224
|
+
}
|
225
|
+
serialize_location(parser, &((yp_block_parameter_node_t *)node)->operator_loc, buffer);
|
226
|
+
break;
|
227
|
+
}
|
228
|
+
case YP_NODE_BLOCK_PARAMETERS_NODE: {
|
229
|
+
if (((yp_block_parameters_node_t *)node)->parameters == NULL) {
|
230
|
+
yp_buffer_append_u8(buffer, 0);
|
231
|
+
} else {
|
232
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_block_parameters_node_t *)node)->parameters, buffer);
|
233
|
+
}
|
234
|
+
uint32_t locals_size = yp_sizet_to_u32(((yp_block_parameters_node_t *)node)->locals.size);
|
235
|
+
yp_buffer_append_u32(buffer, locals_size);
|
236
|
+
for (uint32_t index = 0; index < locals_size; index++) {
|
237
|
+
serialize_location(parser, &((yp_block_parameters_node_t *)node)->locals.locations[index], buffer);
|
238
|
+
}
|
239
|
+
if (((yp_block_parameters_node_t *)node)->opening_loc.start == NULL) {
|
240
|
+
yp_buffer_append_u8(buffer, 0);
|
241
|
+
} else {
|
242
|
+
yp_buffer_append_u8(buffer, 1);
|
243
|
+
serialize_location(parser, &((yp_block_parameters_node_t *)node)->opening_loc, buffer);
|
244
|
+
}
|
245
|
+
if (((yp_block_parameters_node_t *)node)->closing_loc.start == NULL) {
|
246
|
+
yp_buffer_append_u8(buffer, 0);
|
247
|
+
} else {
|
248
|
+
yp_buffer_append_u8(buffer, 1);
|
249
|
+
serialize_location(parser, &((yp_block_parameters_node_t *)node)->closing_loc, buffer);
|
250
|
+
}
|
251
|
+
break;
|
252
|
+
}
|
253
|
+
case YP_NODE_BREAK_NODE: {
|
254
|
+
if (((yp_break_node_t *)node)->arguments == NULL) {
|
255
|
+
yp_buffer_append_u8(buffer, 0);
|
256
|
+
} else {
|
257
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_break_node_t *)node)->arguments, buffer);
|
258
|
+
}
|
259
|
+
serialize_location(parser, &((yp_break_node_t *)node)->keyword_loc, buffer);
|
260
|
+
break;
|
261
|
+
}
|
262
|
+
case YP_NODE_CALL_NODE: {
|
263
|
+
if (((yp_call_node_t *)node)->receiver == NULL) {
|
264
|
+
yp_buffer_append_u8(buffer, 0);
|
265
|
+
} else {
|
266
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_call_node_t *)node)->receiver, buffer);
|
267
|
+
}
|
268
|
+
if (((yp_call_node_t *)node)->operator_loc.start == NULL) {
|
269
|
+
yp_buffer_append_u8(buffer, 0);
|
270
|
+
} else {
|
271
|
+
yp_buffer_append_u8(buffer, 1);
|
272
|
+
serialize_location(parser, &((yp_call_node_t *)node)->operator_loc, buffer);
|
273
|
+
}
|
274
|
+
if (((yp_call_node_t *)node)->message_loc.start == NULL) {
|
275
|
+
yp_buffer_append_u8(buffer, 0);
|
276
|
+
} else {
|
277
|
+
yp_buffer_append_u8(buffer, 1);
|
278
|
+
serialize_location(parser, &((yp_call_node_t *)node)->message_loc, buffer);
|
279
|
+
}
|
280
|
+
if (((yp_call_node_t *)node)->opening_loc.start == NULL) {
|
281
|
+
yp_buffer_append_u8(buffer, 0);
|
282
|
+
} else {
|
283
|
+
yp_buffer_append_u8(buffer, 1);
|
284
|
+
serialize_location(parser, &((yp_call_node_t *)node)->opening_loc, buffer);
|
285
|
+
}
|
286
|
+
if (((yp_call_node_t *)node)->arguments == NULL) {
|
287
|
+
yp_buffer_append_u8(buffer, 0);
|
288
|
+
} else {
|
289
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_call_node_t *)node)->arguments, buffer);
|
290
|
+
}
|
291
|
+
if (((yp_call_node_t *)node)->closing_loc.start == NULL) {
|
292
|
+
yp_buffer_append_u8(buffer, 0);
|
293
|
+
} else {
|
294
|
+
yp_buffer_append_u8(buffer, 1);
|
295
|
+
serialize_location(parser, &((yp_call_node_t *)node)->closing_loc, buffer);
|
296
|
+
}
|
297
|
+
if (((yp_call_node_t *)node)->block == NULL) {
|
298
|
+
yp_buffer_append_u8(buffer, 0);
|
299
|
+
} else {
|
300
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_call_node_t *)node)->block, buffer);
|
301
|
+
}
|
302
|
+
yp_buffer_append_u32(buffer, ((yp_call_node_t *)node)->flags);
|
303
|
+
uint32_t name_length = yp_sizet_to_u32(yp_string_length(&((yp_call_node_t *)node)->name));
|
304
|
+
yp_buffer_append_u32(buffer, name_length);
|
305
|
+
yp_buffer_append_str(buffer, yp_string_source(&((yp_call_node_t *)node)->name), name_length);
|
306
|
+
break;
|
307
|
+
}
|
308
|
+
case YP_NODE_CALL_OPERATOR_AND_WRITE_NODE: {
|
309
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_and_write_node_t *)node)->target, buffer);
|
310
|
+
serialize_location(parser, &((yp_call_operator_and_write_node_t *)node)->operator_loc, buffer);
|
311
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_and_write_node_t *)node)->value, buffer);
|
312
|
+
break;
|
313
|
+
}
|
314
|
+
case YP_NODE_CALL_OPERATOR_OR_WRITE_NODE: {
|
315
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_or_write_node_t *)node)->target, buffer);
|
316
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_or_write_node_t *)node)->value, buffer);
|
317
|
+
serialize_location(parser, &((yp_call_operator_or_write_node_t *)node)->operator_loc, buffer);
|
318
|
+
break;
|
319
|
+
}
|
320
|
+
case YP_NODE_CALL_OPERATOR_WRITE_NODE: {
|
321
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_write_node_t *)node)->target, buffer);
|
322
|
+
serialize_location(parser, &((yp_call_operator_write_node_t *)node)->operator_loc, buffer);
|
323
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_write_node_t *)node)->value, buffer);
|
324
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_call_operator_write_node_t *)node)->operator_id));
|
325
|
+
break;
|
326
|
+
}
|
327
|
+
case YP_NODE_CAPTURE_PATTERN_NODE: {
|
328
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_capture_pattern_node_t *)node)->value, buffer);
|
329
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_capture_pattern_node_t *)node)->target, buffer);
|
330
|
+
serialize_location(parser, &((yp_capture_pattern_node_t *)node)->operator_loc, buffer);
|
331
|
+
break;
|
332
|
+
}
|
333
|
+
case YP_NODE_CASE_NODE: {
|
334
|
+
if (((yp_case_node_t *)node)->predicate == NULL) {
|
335
|
+
yp_buffer_append_u8(buffer, 0);
|
336
|
+
} else {
|
337
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_case_node_t *)node)->predicate, buffer);
|
338
|
+
}
|
339
|
+
uint32_t conditions_size = yp_sizet_to_u32(((yp_case_node_t *)node)->conditions.size);
|
340
|
+
yp_buffer_append_u32(buffer, conditions_size);
|
341
|
+
for (uint32_t index = 0; index < conditions_size; index++) {
|
342
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_case_node_t *)node)->conditions.nodes[index], buffer);
|
343
|
+
}
|
344
|
+
if (((yp_case_node_t *)node)->consequent == NULL) {
|
345
|
+
yp_buffer_append_u8(buffer, 0);
|
346
|
+
} else {
|
347
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_case_node_t *)node)->consequent, buffer);
|
348
|
+
}
|
349
|
+
serialize_location(parser, &((yp_case_node_t *)node)->case_keyword_loc, buffer);
|
350
|
+
serialize_location(parser, &((yp_case_node_t *)node)->end_keyword_loc, buffer);
|
351
|
+
break;
|
352
|
+
}
|
353
|
+
case YP_NODE_CLASS_NODE: {
|
354
|
+
uint32_t locals_size = yp_sizet_to_u32(((yp_class_node_t *)node)->locals.size);
|
355
|
+
yp_buffer_append_u32(buffer, locals_size);
|
356
|
+
for (uint32_t index = 0; index < locals_size; index++) {
|
357
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_node_t *)node)->locals.ids[index]));
|
358
|
+
}
|
359
|
+
serialize_location(parser, &((yp_class_node_t *)node)->class_keyword_loc, buffer);
|
360
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_class_node_t *)node)->constant_path, buffer);
|
361
|
+
if (((yp_class_node_t *)node)->inheritance_operator_loc.start == NULL) {
|
362
|
+
yp_buffer_append_u8(buffer, 0);
|
363
|
+
} else {
|
364
|
+
yp_buffer_append_u8(buffer, 1);
|
365
|
+
serialize_location(parser, &((yp_class_node_t *)node)->inheritance_operator_loc, buffer);
|
366
|
+
}
|
367
|
+
if (((yp_class_node_t *)node)->superclass == NULL) {
|
368
|
+
yp_buffer_append_u8(buffer, 0);
|
369
|
+
} else {
|
370
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_class_node_t *)node)->superclass, buffer);
|
371
|
+
}
|
372
|
+
if (((yp_class_node_t *)node)->statements == NULL) {
|
373
|
+
yp_buffer_append_u8(buffer, 0);
|
374
|
+
} else {
|
375
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_class_node_t *)node)->statements, buffer);
|
376
|
+
}
|
377
|
+
serialize_location(parser, &((yp_class_node_t *)node)->end_keyword_loc, buffer);
|
378
|
+
break;
|
379
|
+
}
|
380
|
+
case YP_NODE_CLASS_VARIABLE_OPERATOR_AND_WRITE_NODE: {
|
381
|
+
serialize_location(parser, &((yp_class_variable_operator_and_write_node_t *)node)->name_loc, buffer);
|
382
|
+
serialize_location(parser, &((yp_class_variable_operator_and_write_node_t *)node)->operator_loc, buffer);
|
383
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_operator_and_write_node_t *)node)->value, buffer);
|
384
|
+
break;
|
385
|
+
}
|
386
|
+
case YP_NODE_CLASS_VARIABLE_OPERATOR_OR_WRITE_NODE: {
|
387
|
+
serialize_location(parser, &((yp_class_variable_operator_or_write_node_t *)node)->name_loc, buffer);
|
388
|
+
serialize_location(parser, &((yp_class_variable_operator_or_write_node_t *)node)->operator_loc, buffer);
|
389
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_operator_or_write_node_t *)node)->value, buffer);
|
390
|
+
break;
|
391
|
+
}
|
392
|
+
case YP_NODE_CLASS_VARIABLE_OPERATOR_WRITE_NODE: {
|
393
|
+
serialize_location(parser, &((yp_class_variable_operator_write_node_t *)node)->name_loc, buffer);
|
394
|
+
serialize_location(parser, &((yp_class_variable_operator_write_node_t *)node)->operator_loc, buffer);
|
395
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_operator_write_node_t *)node)->value, buffer);
|
396
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_variable_operator_write_node_t *)node)->operator));
|
397
|
+
break;
|
398
|
+
}
|
399
|
+
case YP_NODE_CLASS_VARIABLE_READ_NODE: {
|
400
|
+
break;
|
401
|
+
}
|
402
|
+
case YP_NODE_CLASS_VARIABLE_WRITE_NODE: {
|
403
|
+
serialize_location(parser, &((yp_class_variable_write_node_t *)node)->name_loc, buffer);
|
404
|
+
if (((yp_class_variable_write_node_t *)node)->value == NULL) {
|
405
|
+
yp_buffer_append_u8(buffer, 0);
|
406
|
+
} else {
|
407
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_write_node_t *)node)->value, buffer);
|
408
|
+
}
|
409
|
+
if (((yp_class_variable_write_node_t *)node)->operator_loc.start == NULL) {
|
410
|
+
yp_buffer_append_u8(buffer, 0);
|
411
|
+
} else {
|
412
|
+
yp_buffer_append_u8(buffer, 1);
|
413
|
+
serialize_location(parser, &((yp_class_variable_write_node_t *)node)->operator_loc, buffer);
|
414
|
+
}
|
415
|
+
break;
|
416
|
+
}
|
417
|
+
case YP_NODE_CONSTANT_OPERATOR_AND_WRITE_NODE: {
|
418
|
+
serialize_location(parser, &((yp_constant_operator_and_write_node_t *)node)->name_loc, buffer);
|
419
|
+
serialize_location(parser, &((yp_constant_operator_and_write_node_t *)node)->operator_loc, buffer);
|
420
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_operator_and_write_node_t *)node)->value, buffer);
|
421
|
+
break;
|
422
|
+
}
|
423
|
+
case YP_NODE_CONSTANT_OPERATOR_OR_WRITE_NODE: {
|
424
|
+
serialize_location(parser, &((yp_constant_operator_or_write_node_t *)node)->name_loc, buffer);
|
425
|
+
serialize_location(parser, &((yp_constant_operator_or_write_node_t *)node)->operator_loc, buffer);
|
426
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_operator_or_write_node_t *)node)->value, buffer);
|
427
|
+
break;
|
428
|
+
}
|
429
|
+
case YP_NODE_CONSTANT_OPERATOR_WRITE_NODE: {
|
430
|
+
serialize_location(parser, &((yp_constant_operator_write_node_t *)node)->name_loc, buffer);
|
431
|
+
serialize_location(parser, &((yp_constant_operator_write_node_t *)node)->operator_loc, buffer);
|
432
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_operator_write_node_t *)node)->value, buffer);
|
433
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_operator_write_node_t *)node)->operator));
|
434
|
+
break;
|
435
|
+
}
|
436
|
+
case YP_NODE_CONSTANT_PATH_NODE: {
|
437
|
+
if (((yp_constant_path_node_t *)node)->parent == NULL) {
|
438
|
+
yp_buffer_append_u8(buffer, 0);
|
439
|
+
} else {
|
440
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_node_t *)node)->parent, buffer);
|
441
|
+
}
|
442
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_node_t *)node)->child, buffer);
|
443
|
+
serialize_location(parser, &((yp_constant_path_node_t *)node)->delimiter_loc, buffer);
|
444
|
+
break;
|
445
|
+
}
|
446
|
+
case YP_NODE_CONSTANT_PATH_OPERATOR_AND_WRITE_NODE: {
|
447
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_operator_and_write_node_t *)node)->target, buffer);
|
448
|
+
serialize_location(parser, &((yp_constant_path_operator_and_write_node_t *)node)->operator_loc, buffer);
|
449
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_operator_and_write_node_t *)node)->value, buffer);
|
450
|
+
break;
|
451
|
+
}
|
452
|
+
case YP_NODE_CONSTANT_PATH_OPERATOR_OR_WRITE_NODE: {
|
453
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_operator_or_write_node_t *)node)->target, buffer);
|
454
|
+
serialize_location(parser, &((yp_constant_path_operator_or_write_node_t *)node)->operator_loc, buffer);
|
455
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_operator_or_write_node_t *)node)->value, buffer);
|
456
|
+
break;
|
457
|
+
}
|
458
|
+
case YP_NODE_CONSTANT_PATH_OPERATOR_WRITE_NODE: {
|
459
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_operator_write_node_t *)node)->target, buffer);
|
460
|
+
serialize_location(parser, &((yp_constant_path_operator_write_node_t *)node)->operator_loc, buffer);
|
461
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_operator_write_node_t *)node)->value, buffer);
|
462
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_path_operator_write_node_t *)node)->operator));
|
463
|
+
break;
|
464
|
+
}
|
465
|
+
case YP_NODE_CONSTANT_PATH_WRITE_NODE: {
|
466
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_write_node_t *)node)->target, buffer);
|
467
|
+
if (((yp_constant_path_write_node_t *)node)->operator_loc.start == NULL) {
|
468
|
+
yp_buffer_append_u8(buffer, 0);
|
469
|
+
} else {
|
470
|
+
yp_buffer_append_u8(buffer, 1);
|
471
|
+
serialize_location(parser, &((yp_constant_path_write_node_t *)node)->operator_loc, buffer);
|
472
|
+
}
|
473
|
+
if (((yp_constant_path_write_node_t *)node)->value == NULL) {
|
474
|
+
yp_buffer_append_u8(buffer, 0);
|
475
|
+
} else {
|
476
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_write_node_t *)node)->value, buffer);
|
477
|
+
}
|
478
|
+
break;
|
479
|
+
}
|
480
|
+
case YP_NODE_CONSTANT_READ_NODE: {
|
481
|
+
break;
|
482
|
+
}
|
483
|
+
case YP_NODE_CONSTANT_WRITE_NODE: {
|
484
|
+
serialize_location(parser, &((yp_constant_write_node_t *)node)->name_loc, buffer);
|
485
|
+
if (((yp_constant_write_node_t *)node)->value == NULL) {
|
486
|
+
yp_buffer_append_u8(buffer, 0);
|
487
|
+
} else {
|
488
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_constant_write_node_t *)node)->value, buffer);
|
489
|
+
}
|
490
|
+
if (((yp_constant_write_node_t *)node)->operator_loc.start == NULL) {
|
491
|
+
yp_buffer_append_u8(buffer, 0);
|
492
|
+
} else {
|
493
|
+
yp_buffer_append_u8(buffer, 1);
|
494
|
+
serialize_location(parser, &((yp_constant_write_node_t *)node)->operator_loc, buffer);
|
495
|
+
}
|
496
|
+
break;
|
497
|
+
}
|
498
|
+
case YP_NODE_DEF_NODE: {
|
499
|
+
// serialize length
|
500
|
+
// encoding of location u32s make us need to save this offset.
|
501
|
+
size_t length_offset = buffer->length;
|
502
|
+
yp_buffer_append_str(buffer, "\0\0\0\0", 4); /* consume 4 bytes, updated below */
|
503
|
+
serialize_location(parser, &((yp_def_node_t *)node)->name_loc, buffer);
|
504
|
+
if (((yp_def_node_t *)node)->receiver == NULL) {
|
505
|
+
yp_buffer_append_u8(buffer, 0);
|
506
|
+
} else {
|
507
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_def_node_t *)node)->receiver, buffer);
|
508
|
+
}
|
509
|
+
if (((yp_def_node_t *)node)->parameters == NULL) {
|
510
|
+
yp_buffer_append_u8(buffer, 0);
|
511
|
+
} else {
|
512
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_def_node_t *)node)->parameters, buffer);
|
513
|
+
}
|
514
|
+
if (((yp_def_node_t *)node)->statements == NULL) {
|
515
|
+
yp_buffer_append_u8(buffer, 0);
|
516
|
+
} else {
|
517
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_def_node_t *)node)->statements, buffer);
|
518
|
+
}
|
519
|
+
uint32_t locals_size = yp_sizet_to_u32(((yp_def_node_t *)node)->locals.size);
|
520
|
+
yp_buffer_append_u32(buffer, locals_size);
|
521
|
+
for (uint32_t index = 0; index < locals_size; index++) {
|
522
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_def_node_t *)node)->locals.ids[index]));
|
523
|
+
}
|
524
|
+
serialize_location(parser, &((yp_def_node_t *)node)->def_keyword_loc, buffer);
|
525
|
+
if (((yp_def_node_t *)node)->operator_loc.start == NULL) {
|
526
|
+
yp_buffer_append_u8(buffer, 0);
|
527
|
+
} else {
|
528
|
+
yp_buffer_append_u8(buffer, 1);
|
529
|
+
serialize_location(parser, &((yp_def_node_t *)node)->operator_loc, buffer);
|
530
|
+
}
|
531
|
+
if (((yp_def_node_t *)node)->lparen_loc.start == NULL) {
|
532
|
+
yp_buffer_append_u8(buffer, 0);
|
533
|
+
} else {
|
534
|
+
yp_buffer_append_u8(buffer, 1);
|
535
|
+
serialize_location(parser, &((yp_def_node_t *)node)->lparen_loc, buffer);
|
536
|
+
}
|
537
|
+
if (((yp_def_node_t *)node)->rparen_loc.start == NULL) {
|
538
|
+
yp_buffer_append_u8(buffer, 0);
|
539
|
+
} else {
|
540
|
+
yp_buffer_append_u8(buffer, 1);
|
541
|
+
serialize_location(parser, &((yp_def_node_t *)node)->rparen_loc, buffer);
|
542
|
+
}
|
543
|
+
if (((yp_def_node_t *)node)->equal_loc.start == NULL) {
|
544
|
+
yp_buffer_append_u8(buffer, 0);
|
545
|
+
} else {
|
546
|
+
yp_buffer_append_u8(buffer, 1);
|
547
|
+
serialize_location(parser, &((yp_def_node_t *)node)->equal_loc, buffer);
|
548
|
+
}
|
549
|
+
if (((yp_def_node_t *)node)->end_keyword_loc.start == NULL) {
|
550
|
+
yp_buffer_append_u8(buffer, 0);
|
551
|
+
} else {
|
552
|
+
yp_buffer_append_u8(buffer, 1);
|
553
|
+
serialize_location(parser, &((yp_def_node_t *)node)->end_keyword_loc, buffer);
|
554
|
+
}
|
555
|
+
// serialize length
|
556
|
+
uint32_t length = yp_sizet_to_u32(buffer->length - offset - sizeof(uint32_t));
|
557
|
+
memcpy(buffer->value + length_offset, &length, sizeof(uint32_t));
|
558
|
+
break;
|
559
|
+
}
|
560
|
+
case YP_NODE_DEFINED_NODE: {
|
561
|
+
if (((yp_defined_node_t *)node)->lparen_loc.start == NULL) {
|
562
|
+
yp_buffer_append_u8(buffer, 0);
|
563
|
+
} else {
|
564
|
+
yp_buffer_append_u8(buffer, 1);
|
565
|
+
serialize_location(parser, &((yp_defined_node_t *)node)->lparen_loc, buffer);
|
566
|
+
}
|
567
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_defined_node_t *)node)->value, buffer);
|
568
|
+
if (((yp_defined_node_t *)node)->rparen_loc.start == NULL) {
|
569
|
+
yp_buffer_append_u8(buffer, 0);
|
570
|
+
} else {
|
571
|
+
yp_buffer_append_u8(buffer, 1);
|
572
|
+
serialize_location(parser, &((yp_defined_node_t *)node)->rparen_loc, buffer);
|
573
|
+
}
|
574
|
+
serialize_location(parser, &((yp_defined_node_t *)node)->keyword_loc, buffer);
|
575
|
+
break;
|
576
|
+
}
|
577
|
+
case YP_NODE_ELSE_NODE: {
|
578
|
+
serialize_location(parser, &((yp_else_node_t *)node)->else_keyword_loc, buffer);
|
579
|
+
if (((yp_else_node_t *)node)->statements == NULL) {
|
580
|
+
yp_buffer_append_u8(buffer, 0);
|
581
|
+
} else {
|
582
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_else_node_t *)node)->statements, buffer);
|
583
|
+
}
|
584
|
+
if (((yp_else_node_t *)node)->end_keyword_loc.start == NULL) {
|
585
|
+
yp_buffer_append_u8(buffer, 0);
|
586
|
+
} else {
|
587
|
+
yp_buffer_append_u8(buffer, 1);
|
588
|
+
serialize_location(parser, &((yp_else_node_t *)node)->end_keyword_loc, buffer);
|
589
|
+
}
|
590
|
+
break;
|
591
|
+
}
|
592
|
+
case YP_NODE_EMBEDDED_STATEMENTS_NODE: {
|
593
|
+
serialize_location(parser, &((yp_embedded_statements_node_t *)node)->opening_loc, buffer);
|
594
|
+
if (((yp_embedded_statements_node_t *)node)->statements == NULL) {
|
595
|
+
yp_buffer_append_u8(buffer, 0);
|
596
|
+
} else {
|
597
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_embedded_statements_node_t *)node)->statements, buffer);
|
598
|
+
}
|
599
|
+
serialize_location(parser, &((yp_embedded_statements_node_t *)node)->closing_loc, buffer);
|
600
|
+
break;
|
601
|
+
}
|
602
|
+
case YP_NODE_EMBEDDED_VARIABLE_NODE: {
|
603
|
+
serialize_location(parser, &((yp_embedded_variable_node_t *)node)->operator_loc, buffer);
|
604
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_embedded_variable_node_t *)node)->variable, buffer);
|
605
|
+
break;
|
606
|
+
}
|
607
|
+
case YP_NODE_ENSURE_NODE: {
|
608
|
+
serialize_location(parser, &((yp_ensure_node_t *)node)->ensure_keyword_loc, buffer);
|
609
|
+
if (((yp_ensure_node_t *)node)->statements == NULL) {
|
610
|
+
yp_buffer_append_u8(buffer, 0);
|
611
|
+
} else {
|
612
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_ensure_node_t *)node)->statements, buffer);
|
613
|
+
}
|
614
|
+
serialize_location(parser, &((yp_ensure_node_t *)node)->end_keyword_loc, buffer);
|
615
|
+
break;
|
616
|
+
}
|
617
|
+
case YP_NODE_FALSE_NODE: {
|
618
|
+
break;
|
619
|
+
}
|
620
|
+
case YP_NODE_FIND_PATTERN_NODE: {
|
621
|
+
if (((yp_find_pattern_node_t *)node)->constant == NULL) {
|
622
|
+
yp_buffer_append_u8(buffer, 0);
|
623
|
+
} else {
|
624
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_find_pattern_node_t *)node)->constant, buffer);
|
625
|
+
}
|
626
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_find_pattern_node_t *)node)->left, buffer);
|
627
|
+
uint32_t requireds_size = yp_sizet_to_u32(((yp_find_pattern_node_t *)node)->requireds.size);
|
628
|
+
yp_buffer_append_u32(buffer, requireds_size);
|
629
|
+
for (uint32_t index = 0; index < requireds_size; index++) {
|
630
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_find_pattern_node_t *)node)->requireds.nodes[index], buffer);
|
631
|
+
}
|
632
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_find_pattern_node_t *)node)->right, buffer);
|
633
|
+
if (((yp_find_pattern_node_t *)node)->opening_loc.start == NULL) {
|
634
|
+
yp_buffer_append_u8(buffer, 0);
|
635
|
+
} else {
|
636
|
+
yp_buffer_append_u8(buffer, 1);
|
637
|
+
serialize_location(parser, &((yp_find_pattern_node_t *)node)->opening_loc, buffer);
|
638
|
+
}
|
639
|
+
if (((yp_find_pattern_node_t *)node)->closing_loc.start == NULL) {
|
640
|
+
yp_buffer_append_u8(buffer, 0);
|
641
|
+
} else {
|
642
|
+
yp_buffer_append_u8(buffer, 1);
|
643
|
+
serialize_location(parser, &((yp_find_pattern_node_t *)node)->closing_loc, buffer);
|
644
|
+
}
|
645
|
+
break;
|
646
|
+
}
|
647
|
+
case YP_NODE_FLOAT_NODE: {
|
648
|
+
break;
|
649
|
+
}
|
650
|
+
case YP_NODE_FOR_NODE: {
|
651
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_for_node_t *)node)->index, buffer);
|
652
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_for_node_t *)node)->collection, buffer);
|
653
|
+
if (((yp_for_node_t *)node)->statements == NULL) {
|
654
|
+
yp_buffer_append_u8(buffer, 0);
|
655
|
+
} else {
|
656
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_for_node_t *)node)->statements, buffer);
|
657
|
+
}
|
658
|
+
serialize_location(parser, &((yp_for_node_t *)node)->for_keyword_loc, buffer);
|
659
|
+
serialize_location(parser, &((yp_for_node_t *)node)->in_keyword_loc, buffer);
|
660
|
+
if (((yp_for_node_t *)node)->do_keyword_loc.start == NULL) {
|
661
|
+
yp_buffer_append_u8(buffer, 0);
|
662
|
+
} else {
|
663
|
+
yp_buffer_append_u8(buffer, 1);
|
664
|
+
serialize_location(parser, &((yp_for_node_t *)node)->do_keyword_loc, buffer);
|
665
|
+
}
|
666
|
+
serialize_location(parser, &((yp_for_node_t *)node)->end_keyword_loc, buffer);
|
667
|
+
break;
|
668
|
+
}
|
669
|
+
case YP_NODE_FORWARDING_ARGUMENTS_NODE: {
|
670
|
+
break;
|
671
|
+
}
|
672
|
+
case YP_NODE_FORWARDING_PARAMETER_NODE: {
|
673
|
+
break;
|
674
|
+
}
|
675
|
+
case YP_NODE_FORWARDING_SUPER_NODE: {
|
676
|
+
if (((yp_forwarding_super_node_t *)node)->block == NULL) {
|
677
|
+
yp_buffer_append_u8(buffer, 0);
|
678
|
+
} else {
|
679
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_forwarding_super_node_t *)node)->block, buffer);
|
680
|
+
}
|
681
|
+
break;
|
682
|
+
}
|
683
|
+
case YP_NODE_GLOBAL_VARIABLE_OPERATOR_AND_WRITE_NODE: {
|
684
|
+
serialize_location(parser, &((yp_global_variable_operator_and_write_node_t *)node)->name_loc, buffer);
|
685
|
+
serialize_location(parser, &((yp_global_variable_operator_and_write_node_t *)node)->operator_loc, buffer);
|
686
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_operator_and_write_node_t *)node)->value, buffer);
|
687
|
+
break;
|
688
|
+
}
|
689
|
+
case YP_NODE_GLOBAL_VARIABLE_OPERATOR_OR_WRITE_NODE: {
|
690
|
+
serialize_location(parser, &((yp_global_variable_operator_or_write_node_t *)node)->name_loc, buffer);
|
691
|
+
serialize_location(parser, &((yp_global_variable_operator_or_write_node_t *)node)->operator_loc, buffer);
|
692
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_operator_or_write_node_t *)node)->value, buffer);
|
693
|
+
break;
|
694
|
+
}
|
695
|
+
case YP_NODE_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE: {
|
696
|
+
serialize_location(parser, &((yp_global_variable_operator_write_node_t *)node)->name_loc, buffer);
|
697
|
+
serialize_location(parser, &((yp_global_variable_operator_write_node_t *)node)->operator_loc, buffer);
|
698
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_operator_write_node_t *)node)->value, buffer);
|
699
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_global_variable_operator_write_node_t *)node)->operator));
|
700
|
+
break;
|
701
|
+
}
|
702
|
+
case YP_NODE_GLOBAL_VARIABLE_READ_NODE: {
|
703
|
+
break;
|
704
|
+
}
|
705
|
+
case YP_NODE_GLOBAL_VARIABLE_WRITE_NODE: {
|
706
|
+
serialize_location(parser, &((yp_global_variable_write_node_t *)node)->name_loc, buffer);
|
707
|
+
if (((yp_global_variable_write_node_t *)node)->operator_loc.start == NULL) {
|
708
|
+
yp_buffer_append_u8(buffer, 0);
|
709
|
+
} else {
|
710
|
+
yp_buffer_append_u8(buffer, 1);
|
711
|
+
serialize_location(parser, &((yp_global_variable_write_node_t *)node)->operator_loc, buffer);
|
712
|
+
}
|
713
|
+
if (((yp_global_variable_write_node_t *)node)->value == NULL) {
|
714
|
+
yp_buffer_append_u8(buffer, 0);
|
715
|
+
} else {
|
716
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_write_node_t *)node)->value, buffer);
|
717
|
+
}
|
718
|
+
break;
|
719
|
+
}
|
720
|
+
case YP_NODE_HASH_NODE: {
|
721
|
+
serialize_location(parser, &((yp_hash_node_t *)node)->opening_loc, buffer);
|
722
|
+
uint32_t elements_size = yp_sizet_to_u32(((yp_hash_node_t *)node)->elements.size);
|
723
|
+
yp_buffer_append_u32(buffer, elements_size);
|
724
|
+
for (uint32_t index = 0; index < elements_size; index++) {
|
725
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_hash_node_t *)node)->elements.nodes[index], buffer);
|
726
|
+
}
|
727
|
+
serialize_location(parser, &((yp_hash_node_t *)node)->closing_loc, buffer);
|
728
|
+
break;
|
729
|
+
}
|
730
|
+
case YP_NODE_HASH_PATTERN_NODE: {
|
731
|
+
if (((yp_hash_pattern_node_t *)node)->constant == NULL) {
|
732
|
+
yp_buffer_append_u8(buffer, 0);
|
733
|
+
} else {
|
734
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_hash_pattern_node_t *)node)->constant, buffer);
|
735
|
+
}
|
736
|
+
uint32_t assocs_size = yp_sizet_to_u32(((yp_hash_pattern_node_t *)node)->assocs.size);
|
737
|
+
yp_buffer_append_u32(buffer, assocs_size);
|
738
|
+
for (uint32_t index = 0; index < assocs_size; index++) {
|
739
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_hash_pattern_node_t *)node)->assocs.nodes[index], buffer);
|
740
|
+
}
|
741
|
+
if (((yp_hash_pattern_node_t *)node)->kwrest == NULL) {
|
742
|
+
yp_buffer_append_u8(buffer, 0);
|
743
|
+
} else {
|
744
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_hash_pattern_node_t *)node)->kwrest, buffer);
|
745
|
+
}
|
746
|
+
if (((yp_hash_pattern_node_t *)node)->opening_loc.start == NULL) {
|
747
|
+
yp_buffer_append_u8(buffer, 0);
|
748
|
+
} else {
|
749
|
+
yp_buffer_append_u8(buffer, 1);
|
750
|
+
serialize_location(parser, &((yp_hash_pattern_node_t *)node)->opening_loc, buffer);
|
751
|
+
}
|
752
|
+
if (((yp_hash_pattern_node_t *)node)->closing_loc.start == NULL) {
|
753
|
+
yp_buffer_append_u8(buffer, 0);
|
754
|
+
} else {
|
755
|
+
yp_buffer_append_u8(buffer, 1);
|
756
|
+
serialize_location(parser, &((yp_hash_pattern_node_t *)node)->closing_loc, buffer);
|
757
|
+
}
|
758
|
+
break;
|
759
|
+
}
|
760
|
+
case YP_NODE_IF_NODE: {
|
761
|
+
if (((yp_if_node_t *)node)->if_keyword_loc.start == NULL) {
|
762
|
+
yp_buffer_append_u8(buffer, 0);
|
763
|
+
} else {
|
764
|
+
yp_buffer_append_u8(buffer, 1);
|
765
|
+
serialize_location(parser, &((yp_if_node_t *)node)->if_keyword_loc, buffer);
|
766
|
+
}
|
767
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_if_node_t *)node)->predicate, buffer);
|
768
|
+
if (((yp_if_node_t *)node)->statements == NULL) {
|
769
|
+
yp_buffer_append_u8(buffer, 0);
|
770
|
+
} else {
|
771
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_if_node_t *)node)->statements, buffer);
|
772
|
+
}
|
773
|
+
if (((yp_if_node_t *)node)->consequent == NULL) {
|
774
|
+
yp_buffer_append_u8(buffer, 0);
|
775
|
+
} else {
|
776
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_if_node_t *)node)->consequent, buffer);
|
777
|
+
}
|
778
|
+
if (((yp_if_node_t *)node)->end_keyword_loc.start == NULL) {
|
779
|
+
yp_buffer_append_u8(buffer, 0);
|
780
|
+
} else {
|
781
|
+
yp_buffer_append_u8(buffer, 1);
|
782
|
+
serialize_location(parser, &((yp_if_node_t *)node)->end_keyword_loc, buffer);
|
783
|
+
}
|
784
|
+
break;
|
785
|
+
}
|
786
|
+
case YP_NODE_IMAGINARY_NODE: {
|
787
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_imaginary_node_t *)node)->numeric, buffer);
|
788
|
+
break;
|
789
|
+
}
|
790
|
+
case YP_NODE_IN_NODE: {
|
791
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_in_node_t *)node)->pattern, buffer);
|
792
|
+
if (((yp_in_node_t *)node)->statements == NULL) {
|
793
|
+
yp_buffer_append_u8(buffer, 0);
|
794
|
+
} else {
|
795
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_in_node_t *)node)->statements, buffer);
|
796
|
+
}
|
797
|
+
serialize_location(parser, &((yp_in_node_t *)node)->in_loc, buffer);
|
798
|
+
if (((yp_in_node_t *)node)->then_loc.start == NULL) {
|
799
|
+
yp_buffer_append_u8(buffer, 0);
|
800
|
+
} else {
|
801
|
+
yp_buffer_append_u8(buffer, 1);
|
802
|
+
serialize_location(parser, &((yp_in_node_t *)node)->then_loc, buffer);
|
803
|
+
}
|
804
|
+
break;
|
805
|
+
}
|
806
|
+
case YP_NODE_INSTANCE_VARIABLE_OPERATOR_AND_WRITE_NODE: {
|
807
|
+
serialize_location(parser, &((yp_instance_variable_operator_and_write_node_t *)node)->name_loc, buffer);
|
808
|
+
serialize_location(parser, &((yp_instance_variable_operator_and_write_node_t *)node)->operator_loc, buffer);
|
809
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_operator_and_write_node_t *)node)->value, buffer);
|
810
|
+
break;
|
811
|
+
}
|
812
|
+
case YP_NODE_INSTANCE_VARIABLE_OPERATOR_OR_WRITE_NODE: {
|
813
|
+
serialize_location(parser, &((yp_instance_variable_operator_or_write_node_t *)node)->name_loc, buffer);
|
814
|
+
serialize_location(parser, &((yp_instance_variable_operator_or_write_node_t *)node)->operator_loc, buffer);
|
815
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_operator_or_write_node_t *)node)->value, buffer);
|
816
|
+
break;
|
817
|
+
}
|
818
|
+
case YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE: {
|
819
|
+
serialize_location(parser, &((yp_instance_variable_operator_write_node_t *)node)->name_loc, buffer);
|
820
|
+
serialize_location(parser, &((yp_instance_variable_operator_write_node_t *)node)->operator_loc, buffer);
|
821
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_operator_write_node_t *)node)->value, buffer);
|
822
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_instance_variable_operator_write_node_t *)node)->operator));
|
823
|
+
break;
|
824
|
+
}
|
825
|
+
case YP_NODE_INSTANCE_VARIABLE_READ_NODE: {
|
826
|
+
break;
|
827
|
+
}
|
828
|
+
case YP_NODE_INSTANCE_VARIABLE_WRITE_NODE: {
|
829
|
+
serialize_location(parser, &((yp_instance_variable_write_node_t *)node)->name_loc, buffer);
|
830
|
+
if (((yp_instance_variable_write_node_t *)node)->value == NULL) {
|
831
|
+
yp_buffer_append_u8(buffer, 0);
|
832
|
+
} else {
|
833
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_write_node_t *)node)->value, buffer);
|
834
|
+
}
|
835
|
+
if (((yp_instance_variable_write_node_t *)node)->operator_loc.start == NULL) {
|
836
|
+
yp_buffer_append_u8(buffer, 0);
|
837
|
+
} else {
|
838
|
+
yp_buffer_append_u8(buffer, 1);
|
839
|
+
serialize_location(parser, &((yp_instance_variable_write_node_t *)node)->operator_loc, buffer);
|
840
|
+
}
|
841
|
+
break;
|
842
|
+
}
|
843
|
+
case YP_NODE_INTEGER_NODE: {
|
844
|
+
break;
|
845
|
+
}
|
846
|
+
case YP_NODE_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
|
847
|
+
serialize_location(parser, &((yp_interpolated_regular_expression_node_t *)node)->opening_loc, buffer);
|
848
|
+
uint32_t parts_size = yp_sizet_to_u32(((yp_interpolated_regular_expression_node_t *)node)->parts.size);
|
849
|
+
yp_buffer_append_u32(buffer, parts_size);
|
850
|
+
for (uint32_t index = 0; index < parts_size; index++) {
|
851
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_interpolated_regular_expression_node_t *)node)->parts.nodes[index], buffer);
|
852
|
+
}
|
853
|
+
serialize_location(parser, &((yp_interpolated_regular_expression_node_t *)node)->closing_loc, buffer);
|
854
|
+
yp_buffer_append_u32(buffer, ((yp_interpolated_regular_expression_node_t *)node)->flags);
|
855
|
+
break;
|
856
|
+
}
|
857
|
+
case YP_NODE_INTERPOLATED_STRING_NODE: {
|
858
|
+
if (((yp_interpolated_string_node_t *)node)->opening_loc.start == NULL) {
|
859
|
+
yp_buffer_append_u8(buffer, 0);
|
860
|
+
} else {
|
861
|
+
yp_buffer_append_u8(buffer, 1);
|
862
|
+
serialize_location(parser, &((yp_interpolated_string_node_t *)node)->opening_loc, buffer);
|
863
|
+
}
|
864
|
+
uint32_t parts_size = yp_sizet_to_u32(((yp_interpolated_string_node_t *)node)->parts.size);
|
865
|
+
yp_buffer_append_u32(buffer, parts_size);
|
866
|
+
for (uint32_t index = 0; index < parts_size; index++) {
|
867
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_interpolated_string_node_t *)node)->parts.nodes[index], buffer);
|
868
|
+
}
|
869
|
+
if (((yp_interpolated_string_node_t *)node)->closing_loc.start == NULL) {
|
870
|
+
yp_buffer_append_u8(buffer, 0);
|
871
|
+
} else {
|
872
|
+
yp_buffer_append_u8(buffer, 1);
|
873
|
+
serialize_location(parser, &((yp_interpolated_string_node_t *)node)->closing_loc, buffer);
|
874
|
+
}
|
875
|
+
break;
|
876
|
+
}
|
877
|
+
case YP_NODE_INTERPOLATED_SYMBOL_NODE: {
|
878
|
+
if (((yp_interpolated_symbol_node_t *)node)->opening_loc.start == NULL) {
|
879
|
+
yp_buffer_append_u8(buffer, 0);
|
880
|
+
} else {
|
881
|
+
yp_buffer_append_u8(buffer, 1);
|
882
|
+
serialize_location(parser, &((yp_interpolated_symbol_node_t *)node)->opening_loc, buffer);
|
883
|
+
}
|
884
|
+
uint32_t parts_size = yp_sizet_to_u32(((yp_interpolated_symbol_node_t *)node)->parts.size);
|
885
|
+
yp_buffer_append_u32(buffer, parts_size);
|
886
|
+
for (uint32_t index = 0; index < parts_size; index++) {
|
887
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_interpolated_symbol_node_t *)node)->parts.nodes[index], buffer);
|
888
|
+
}
|
889
|
+
if (((yp_interpolated_symbol_node_t *)node)->closing_loc.start == NULL) {
|
890
|
+
yp_buffer_append_u8(buffer, 0);
|
891
|
+
} else {
|
892
|
+
yp_buffer_append_u8(buffer, 1);
|
893
|
+
serialize_location(parser, &((yp_interpolated_symbol_node_t *)node)->closing_loc, buffer);
|
894
|
+
}
|
895
|
+
break;
|
896
|
+
}
|
897
|
+
case YP_NODE_INTERPOLATED_X_STRING_NODE: {
|
898
|
+
serialize_location(parser, &((yp_interpolated_x_string_node_t *)node)->opening_loc, buffer);
|
899
|
+
uint32_t parts_size = yp_sizet_to_u32(((yp_interpolated_x_string_node_t *)node)->parts.size);
|
900
|
+
yp_buffer_append_u32(buffer, parts_size);
|
901
|
+
for (uint32_t index = 0; index < parts_size; index++) {
|
902
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_interpolated_x_string_node_t *)node)->parts.nodes[index], buffer);
|
903
|
+
}
|
904
|
+
serialize_location(parser, &((yp_interpolated_x_string_node_t *)node)->closing_loc, buffer);
|
905
|
+
break;
|
906
|
+
}
|
907
|
+
case YP_NODE_KEYWORD_HASH_NODE: {
|
908
|
+
uint32_t elements_size = yp_sizet_to_u32(((yp_keyword_hash_node_t *)node)->elements.size);
|
909
|
+
yp_buffer_append_u32(buffer, elements_size);
|
910
|
+
for (uint32_t index = 0; index < elements_size; index++) {
|
911
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_keyword_hash_node_t *)node)->elements.nodes[index], buffer);
|
912
|
+
}
|
913
|
+
break;
|
914
|
+
}
|
915
|
+
case YP_NODE_KEYWORD_PARAMETER_NODE: {
|
916
|
+
serialize_location(parser, &((yp_keyword_parameter_node_t *)node)->name_loc, buffer);
|
917
|
+
if (((yp_keyword_parameter_node_t *)node)->value == NULL) {
|
918
|
+
yp_buffer_append_u8(buffer, 0);
|
919
|
+
} else {
|
920
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_keyword_parameter_node_t *)node)->value, buffer);
|
921
|
+
}
|
922
|
+
break;
|
923
|
+
}
|
924
|
+
case YP_NODE_KEYWORD_REST_PARAMETER_NODE: {
|
925
|
+
serialize_location(parser, &((yp_keyword_rest_parameter_node_t *)node)->operator_loc, buffer);
|
926
|
+
if (((yp_keyword_rest_parameter_node_t *)node)->name_loc.start == NULL) {
|
927
|
+
yp_buffer_append_u8(buffer, 0);
|
928
|
+
} else {
|
929
|
+
yp_buffer_append_u8(buffer, 1);
|
930
|
+
serialize_location(parser, &((yp_keyword_rest_parameter_node_t *)node)->name_loc, buffer);
|
931
|
+
}
|
932
|
+
break;
|
933
|
+
}
|
934
|
+
case YP_NODE_LAMBDA_NODE: {
|
935
|
+
uint32_t locals_size = yp_sizet_to_u32(((yp_lambda_node_t *)node)->locals.size);
|
936
|
+
yp_buffer_append_u32(buffer, locals_size);
|
937
|
+
for (uint32_t index = 0; index < locals_size; index++) {
|
938
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_lambda_node_t *)node)->locals.ids[index]));
|
939
|
+
}
|
940
|
+
serialize_location(parser, &((yp_lambda_node_t *)node)->opening_loc, buffer);
|
941
|
+
if (((yp_lambda_node_t *)node)->parameters == NULL) {
|
942
|
+
yp_buffer_append_u8(buffer, 0);
|
943
|
+
} else {
|
944
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_lambda_node_t *)node)->parameters, buffer);
|
945
|
+
}
|
946
|
+
if (((yp_lambda_node_t *)node)->statements == NULL) {
|
947
|
+
yp_buffer_append_u8(buffer, 0);
|
948
|
+
} else {
|
949
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_lambda_node_t *)node)->statements, buffer);
|
950
|
+
}
|
951
|
+
break;
|
952
|
+
}
|
953
|
+
case YP_NODE_LOCAL_VARIABLE_OPERATOR_AND_WRITE_NODE: {
|
954
|
+
serialize_location(parser, &((yp_local_variable_operator_and_write_node_t *)node)->name_loc, buffer);
|
955
|
+
serialize_location(parser, &((yp_local_variable_operator_and_write_node_t *)node)->operator_loc, buffer);
|
956
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_operator_and_write_node_t *)node)->value, buffer);
|
957
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_operator_and_write_node_t *)node)->constant_id));
|
958
|
+
break;
|
959
|
+
}
|
960
|
+
case YP_NODE_LOCAL_VARIABLE_OPERATOR_OR_WRITE_NODE: {
|
961
|
+
serialize_location(parser, &((yp_local_variable_operator_or_write_node_t *)node)->name_loc, buffer);
|
962
|
+
serialize_location(parser, &((yp_local_variable_operator_or_write_node_t *)node)->operator_loc, buffer);
|
963
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_operator_or_write_node_t *)node)->value, buffer);
|
964
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_operator_or_write_node_t *)node)->constant_id));
|
965
|
+
break;
|
966
|
+
}
|
967
|
+
case YP_NODE_LOCAL_VARIABLE_OPERATOR_WRITE_NODE: {
|
968
|
+
serialize_location(parser, &((yp_local_variable_operator_write_node_t *)node)->name_loc, buffer);
|
969
|
+
serialize_location(parser, &((yp_local_variable_operator_write_node_t *)node)->operator_loc, buffer);
|
970
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_operator_write_node_t *)node)->value, buffer);
|
971
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_operator_write_node_t *)node)->constant_id));
|
972
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_operator_write_node_t *)node)->operator_id));
|
973
|
+
break;
|
974
|
+
}
|
975
|
+
case YP_NODE_LOCAL_VARIABLE_READ_NODE: {
|
976
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_read_node_t *)node)->constant_id));
|
977
|
+
yp_buffer_append_u32(buffer, ((yp_local_variable_read_node_t *)node)->depth);
|
978
|
+
break;
|
979
|
+
}
|
980
|
+
case YP_NODE_LOCAL_VARIABLE_WRITE_NODE: {
|
981
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_write_node_t *)node)->constant_id));
|
982
|
+
yp_buffer_append_u32(buffer, ((yp_local_variable_write_node_t *)node)->depth);
|
983
|
+
if (((yp_local_variable_write_node_t *)node)->value == NULL) {
|
984
|
+
yp_buffer_append_u8(buffer, 0);
|
985
|
+
} else {
|
986
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_write_node_t *)node)->value, buffer);
|
987
|
+
}
|
988
|
+
serialize_location(parser, &((yp_local_variable_write_node_t *)node)->name_loc, buffer);
|
989
|
+
if (((yp_local_variable_write_node_t *)node)->operator_loc.start == NULL) {
|
990
|
+
yp_buffer_append_u8(buffer, 0);
|
991
|
+
} else {
|
992
|
+
yp_buffer_append_u8(buffer, 1);
|
993
|
+
serialize_location(parser, &((yp_local_variable_write_node_t *)node)->operator_loc, buffer);
|
994
|
+
}
|
995
|
+
break;
|
996
|
+
}
|
997
|
+
case YP_NODE_MATCH_PREDICATE_NODE: {
|
998
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_match_predicate_node_t *)node)->value, buffer);
|
999
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_match_predicate_node_t *)node)->pattern, buffer);
|
1000
|
+
serialize_location(parser, &((yp_match_predicate_node_t *)node)->operator_loc, buffer);
|
1001
|
+
break;
|
1002
|
+
}
|
1003
|
+
case YP_NODE_MATCH_REQUIRED_NODE: {
|
1004
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_match_required_node_t *)node)->value, buffer);
|
1005
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_match_required_node_t *)node)->pattern, buffer);
|
1006
|
+
serialize_location(parser, &((yp_match_required_node_t *)node)->operator_loc, buffer);
|
1007
|
+
break;
|
1008
|
+
}
|
1009
|
+
case YP_NODE_MISSING_NODE: {
|
1010
|
+
break;
|
1011
|
+
}
|
1012
|
+
case YP_NODE_MODULE_NODE: {
|
1013
|
+
uint32_t locals_size = yp_sizet_to_u32(((yp_module_node_t *)node)->locals.size);
|
1014
|
+
yp_buffer_append_u32(buffer, locals_size);
|
1015
|
+
for (uint32_t index = 0; index < locals_size; index++) {
|
1016
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_module_node_t *)node)->locals.ids[index]));
|
1017
|
+
}
|
1018
|
+
serialize_location(parser, &((yp_module_node_t *)node)->module_keyword_loc, buffer);
|
1019
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_module_node_t *)node)->constant_path, buffer);
|
1020
|
+
if (((yp_module_node_t *)node)->statements == NULL) {
|
1021
|
+
yp_buffer_append_u8(buffer, 0);
|
1022
|
+
} else {
|
1023
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_module_node_t *)node)->statements, buffer);
|
1024
|
+
}
|
1025
|
+
serialize_location(parser, &((yp_module_node_t *)node)->end_keyword_loc, buffer);
|
1026
|
+
break;
|
1027
|
+
}
|
1028
|
+
case YP_NODE_MULTI_WRITE_NODE: {
|
1029
|
+
uint32_t targets_size = yp_sizet_to_u32(((yp_multi_write_node_t *)node)->targets.size);
|
1030
|
+
yp_buffer_append_u32(buffer, targets_size);
|
1031
|
+
for (uint32_t index = 0; index < targets_size; index++) {
|
1032
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_multi_write_node_t *)node)->targets.nodes[index], buffer);
|
1033
|
+
}
|
1034
|
+
if (((yp_multi_write_node_t *)node)->operator_loc.start == NULL) {
|
1035
|
+
yp_buffer_append_u8(buffer, 0);
|
1036
|
+
} else {
|
1037
|
+
yp_buffer_append_u8(buffer, 1);
|
1038
|
+
serialize_location(parser, &((yp_multi_write_node_t *)node)->operator_loc, buffer);
|
1039
|
+
}
|
1040
|
+
if (((yp_multi_write_node_t *)node)->value == NULL) {
|
1041
|
+
yp_buffer_append_u8(buffer, 0);
|
1042
|
+
} else {
|
1043
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_multi_write_node_t *)node)->value, buffer);
|
1044
|
+
}
|
1045
|
+
if (((yp_multi_write_node_t *)node)->lparen_loc.start == NULL) {
|
1046
|
+
yp_buffer_append_u8(buffer, 0);
|
1047
|
+
} else {
|
1048
|
+
yp_buffer_append_u8(buffer, 1);
|
1049
|
+
serialize_location(parser, &((yp_multi_write_node_t *)node)->lparen_loc, buffer);
|
1050
|
+
}
|
1051
|
+
if (((yp_multi_write_node_t *)node)->rparen_loc.start == NULL) {
|
1052
|
+
yp_buffer_append_u8(buffer, 0);
|
1053
|
+
} else {
|
1054
|
+
yp_buffer_append_u8(buffer, 1);
|
1055
|
+
serialize_location(parser, &((yp_multi_write_node_t *)node)->rparen_loc, buffer);
|
1056
|
+
}
|
1057
|
+
break;
|
1058
|
+
}
|
1059
|
+
case YP_NODE_NEXT_NODE: {
|
1060
|
+
if (((yp_next_node_t *)node)->arguments == NULL) {
|
1061
|
+
yp_buffer_append_u8(buffer, 0);
|
1062
|
+
} else {
|
1063
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_next_node_t *)node)->arguments, buffer);
|
1064
|
+
}
|
1065
|
+
serialize_location(parser, &((yp_next_node_t *)node)->keyword_loc, buffer);
|
1066
|
+
break;
|
1067
|
+
}
|
1068
|
+
case YP_NODE_NIL_NODE: {
|
1069
|
+
break;
|
1070
|
+
}
|
1071
|
+
case YP_NODE_NO_KEYWORDS_PARAMETER_NODE: {
|
1072
|
+
serialize_location(parser, &((yp_no_keywords_parameter_node_t *)node)->operator_loc, buffer);
|
1073
|
+
serialize_location(parser, &((yp_no_keywords_parameter_node_t *)node)->keyword_loc, buffer);
|
1074
|
+
break;
|
1075
|
+
}
|
1076
|
+
case YP_NODE_NUMBERED_REFERENCE_READ_NODE: {
|
1077
|
+
break;
|
1078
|
+
}
|
1079
|
+
case YP_NODE_OPTIONAL_PARAMETER_NODE: {
|
1080
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_optional_parameter_node_t *)node)->constant_id));
|
1081
|
+
serialize_location(parser, &((yp_optional_parameter_node_t *)node)->name_loc, buffer);
|
1082
|
+
serialize_location(parser, &((yp_optional_parameter_node_t *)node)->operator_loc, buffer);
|
1083
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_optional_parameter_node_t *)node)->value, buffer);
|
1084
|
+
break;
|
1085
|
+
}
|
1086
|
+
case YP_NODE_OR_NODE: {
|
1087
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_or_node_t *)node)->left, buffer);
|
1088
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_or_node_t *)node)->right, buffer);
|
1089
|
+
serialize_location(parser, &((yp_or_node_t *)node)->operator_loc, buffer);
|
1090
|
+
break;
|
1091
|
+
}
|
1092
|
+
case YP_NODE_PARAMETERS_NODE: {
|
1093
|
+
uint32_t requireds_size = yp_sizet_to_u32(((yp_parameters_node_t *)node)->requireds.size);
|
1094
|
+
yp_buffer_append_u32(buffer, requireds_size);
|
1095
|
+
for (uint32_t index = 0; index < requireds_size; index++) {
|
1096
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_parameters_node_t *)node)->requireds.nodes[index], buffer);
|
1097
|
+
}
|
1098
|
+
uint32_t optionals_size = yp_sizet_to_u32(((yp_parameters_node_t *)node)->optionals.size);
|
1099
|
+
yp_buffer_append_u32(buffer, optionals_size);
|
1100
|
+
for (uint32_t index = 0; index < optionals_size; index++) {
|
1101
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_parameters_node_t *)node)->optionals.nodes[index], buffer);
|
1102
|
+
}
|
1103
|
+
uint32_t posts_size = yp_sizet_to_u32(((yp_parameters_node_t *)node)->posts.size);
|
1104
|
+
yp_buffer_append_u32(buffer, posts_size);
|
1105
|
+
for (uint32_t index = 0; index < posts_size; index++) {
|
1106
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_parameters_node_t *)node)->posts.nodes[index], buffer);
|
1107
|
+
}
|
1108
|
+
if (((yp_parameters_node_t *)node)->rest == NULL) {
|
1109
|
+
yp_buffer_append_u8(buffer, 0);
|
1110
|
+
} else {
|
1111
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_parameters_node_t *)node)->rest, buffer);
|
1112
|
+
}
|
1113
|
+
uint32_t keywords_size = yp_sizet_to_u32(((yp_parameters_node_t *)node)->keywords.size);
|
1114
|
+
yp_buffer_append_u32(buffer, keywords_size);
|
1115
|
+
for (uint32_t index = 0; index < keywords_size; index++) {
|
1116
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_parameters_node_t *)node)->keywords.nodes[index], buffer);
|
1117
|
+
}
|
1118
|
+
if (((yp_parameters_node_t *)node)->keyword_rest == NULL) {
|
1119
|
+
yp_buffer_append_u8(buffer, 0);
|
1120
|
+
} else {
|
1121
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_parameters_node_t *)node)->keyword_rest, buffer);
|
1122
|
+
}
|
1123
|
+
if (((yp_parameters_node_t *)node)->block == NULL) {
|
1124
|
+
yp_buffer_append_u8(buffer, 0);
|
1125
|
+
} else {
|
1126
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_parameters_node_t *)node)->block, buffer);
|
1127
|
+
}
|
1128
|
+
break;
|
1129
|
+
}
|
1130
|
+
case YP_NODE_PARENTHESES_NODE: {
|
1131
|
+
if (((yp_parentheses_node_t *)node)->statements == NULL) {
|
1132
|
+
yp_buffer_append_u8(buffer, 0);
|
1133
|
+
} else {
|
1134
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_parentheses_node_t *)node)->statements, buffer);
|
1135
|
+
}
|
1136
|
+
serialize_location(parser, &((yp_parentheses_node_t *)node)->opening_loc, buffer);
|
1137
|
+
serialize_location(parser, &((yp_parentheses_node_t *)node)->closing_loc, buffer);
|
1138
|
+
break;
|
1139
|
+
}
|
1140
|
+
case YP_NODE_PINNED_EXPRESSION_NODE: {
|
1141
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_pinned_expression_node_t *)node)->expression, buffer);
|
1142
|
+
serialize_location(parser, &((yp_pinned_expression_node_t *)node)->operator_loc, buffer);
|
1143
|
+
serialize_location(parser, &((yp_pinned_expression_node_t *)node)->lparen_loc, buffer);
|
1144
|
+
serialize_location(parser, &((yp_pinned_expression_node_t *)node)->rparen_loc, buffer);
|
1145
|
+
break;
|
1146
|
+
}
|
1147
|
+
case YP_NODE_PINNED_VARIABLE_NODE: {
|
1148
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_pinned_variable_node_t *)node)->variable, buffer);
|
1149
|
+
serialize_location(parser, &((yp_pinned_variable_node_t *)node)->operator_loc, buffer);
|
1150
|
+
break;
|
1151
|
+
}
|
1152
|
+
case YP_NODE_POST_EXECUTION_NODE: {
|
1153
|
+
if (((yp_post_execution_node_t *)node)->statements == NULL) {
|
1154
|
+
yp_buffer_append_u8(buffer, 0);
|
1155
|
+
} else {
|
1156
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_post_execution_node_t *)node)->statements, buffer);
|
1157
|
+
}
|
1158
|
+
serialize_location(parser, &((yp_post_execution_node_t *)node)->keyword_loc, buffer);
|
1159
|
+
serialize_location(parser, &((yp_post_execution_node_t *)node)->opening_loc, buffer);
|
1160
|
+
serialize_location(parser, &((yp_post_execution_node_t *)node)->closing_loc, buffer);
|
1161
|
+
break;
|
1162
|
+
}
|
1163
|
+
case YP_NODE_PRE_EXECUTION_NODE: {
|
1164
|
+
if (((yp_pre_execution_node_t *)node)->statements == NULL) {
|
1165
|
+
yp_buffer_append_u8(buffer, 0);
|
1166
|
+
} else {
|
1167
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_pre_execution_node_t *)node)->statements, buffer);
|
1168
|
+
}
|
1169
|
+
serialize_location(parser, &((yp_pre_execution_node_t *)node)->keyword_loc, buffer);
|
1170
|
+
serialize_location(parser, &((yp_pre_execution_node_t *)node)->opening_loc, buffer);
|
1171
|
+
serialize_location(parser, &((yp_pre_execution_node_t *)node)->closing_loc, buffer);
|
1172
|
+
break;
|
1173
|
+
}
|
1174
|
+
case YP_NODE_PROGRAM_NODE: {
|
1175
|
+
uint32_t locals_size = yp_sizet_to_u32(((yp_program_node_t *)node)->locals.size);
|
1176
|
+
yp_buffer_append_u32(buffer, locals_size);
|
1177
|
+
for (uint32_t index = 0; index < locals_size; index++) {
|
1178
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_program_node_t *)node)->locals.ids[index]));
|
1179
|
+
}
|
1180
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_program_node_t *)node)->statements, buffer);
|
1181
|
+
break;
|
1182
|
+
}
|
1183
|
+
case YP_NODE_RANGE_NODE: {
|
1184
|
+
if (((yp_range_node_t *)node)->left == NULL) {
|
1185
|
+
yp_buffer_append_u8(buffer, 0);
|
1186
|
+
} else {
|
1187
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_range_node_t *)node)->left, buffer);
|
1188
|
+
}
|
1189
|
+
if (((yp_range_node_t *)node)->right == NULL) {
|
1190
|
+
yp_buffer_append_u8(buffer, 0);
|
1191
|
+
} else {
|
1192
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_range_node_t *)node)->right, buffer);
|
1193
|
+
}
|
1194
|
+
serialize_location(parser, &((yp_range_node_t *)node)->operator_loc, buffer);
|
1195
|
+
yp_buffer_append_u32(buffer, ((yp_range_node_t *)node)->flags);
|
1196
|
+
break;
|
1197
|
+
}
|
1198
|
+
case YP_NODE_RATIONAL_NODE: {
|
1199
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_rational_node_t *)node)->numeric, buffer);
|
1200
|
+
break;
|
1201
|
+
}
|
1202
|
+
case YP_NODE_REDO_NODE: {
|
1203
|
+
break;
|
1204
|
+
}
|
1205
|
+
case YP_NODE_REGULAR_EXPRESSION_NODE: {
|
1206
|
+
serialize_location(parser, &((yp_regular_expression_node_t *)node)->opening_loc, buffer);
|
1207
|
+
serialize_location(parser, &((yp_regular_expression_node_t *)node)->content_loc, buffer);
|
1208
|
+
serialize_location(parser, &((yp_regular_expression_node_t *)node)->closing_loc, buffer);
|
1209
|
+
uint32_t unescaped_length = yp_sizet_to_u32(yp_string_length(&((yp_regular_expression_node_t *)node)->unescaped));
|
1210
|
+
yp_buffer_append_u32(buffer, unescaped_length);
|
1211
|
+
yp_buffer_append_str(buffer, yp_string_source(&((yp_regular_expression_node_t *)node)->unescaped), unescaped_length);
|
1212
|
+
yp_buffer_append_u32(buffer, ((yp_regular_expression_node_t *)node)->flags);
|
1213
|
+
break;
|
1214
|
+
}
|
1215
|
+
case YP_NODE_REQUIRED_DESTRUCTURED_PARAMETER_NODE: {
|
1216
|
+
uint32_t parameters_size = yp_sizet_to_u32(((yp_required_destructured_parameter_node_t *)node)->parameters.size);
|
1217
|
+
yp_buffer_append_u32(buffer, parameters_size);
|
1218
|
+
for (uint32_t index = 0; index < parameters_size; index++) {
|
1219
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_required_destructured_parameter_node_t *)node)->parameters.nodes[index], buffer);
|
1220
|
+
}
|
1221
|
+
serialize_location(parser, &((yp_required_destructured_parameter_node_t *)node)->opening_loc, buffer);
|
1222
|
+
serialize_location(parser, &((yp_required_destructured_parameter_node_t *)node)->closing_loc, buffer);
|
1223
|
+
break;
|
1224
|
+
}
|
1225
|
+
case YP_NODE_REQUIRED_PARAMETER_NODE: {
|
1226
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_required_parameter_node_t *)node)->constant_id));
|
1227
|
+
break;
|
1228
|
+
}
|
1229
|
+
case YP_NODE_RESCUE_MODIFIER_NODE: {
|
1230
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_rescue_modifier_node_t *)node)->expression, buffer);
|
1231
|
+
serialize_location(parser, &((yp_rescue_modifier_node_t *)node)->keyword_loc, buffer);
|
1232
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_rescue_modifier_node_t *)node)->rescue_expression, buffer);
|
1233
|
+
break;
|
1234
|
+
}
|
1235
|
+
case YP_NODE_RESCUE_NODE: {
|
1236
|
+
serialize_location(parser, &((yp_rescue_node_t *)node)->keyword_loc, buffer);
|
1237
|
+
uint32_t exceptions_size = yp_sizet_to_u32(((yp_rescue_node_t *)node)->exceptions.size);
|
1238
|
+
yp_buffer_append_u32(buffer, exceptions_size);
|
1239
|
+
for (uint32_t index = 0; index < exceptions_size; index++) {
|
1240
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_rescue_node_t *)node)->exceptions.nodes[index], buffer);
|
1241
|
+
}
|
1242
|
+
if (((yp_rescue_node_t *)node)->operator_loc.start == NULL) {
|
1243
|
+
yp_buffer_append_u8(buffer, 0);
|
1244
|
+
} else {
|
1245
|
+
yp_buffer_append_u8(buffer, 1);
|
1246
|
+
serialize_location(parser, &((yp_rescue_node_t *)node)->operator_loc, buffer);
|
1247
|
+
}
|
1248
|
+
if (((yp_rescue_node_t *)node)->reference == NULL) {
|
1249
|
+
yp_buffer_append_u8(buffer, 0);
|
1250
|
+
} else {
|
1251
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_rescue_node_t *)node)->reference, buffer);
|
1252
|
+
}
|
1253
|
+
if (((yp_rescue_node_t *)node)->statements == NULL) {
|
1254
|
+
yp_buffer_append_u8(buffer, 0);
|
1255
|
+
} else {
|
1256
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_rescue_node_t *)node)->statements, buffer);
|
1257
|
+
}
|
1258
|
+
if (((yp_rescue_node_t *)node)->consequent == NULL) {
|
1259
|
+
yp_buffer_append_u8(buffer, 0);
|
1260
|
+
} else {
|
1261
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_rescue_node_t *)node)->consequent, buffer);
|
1262
|
+
}
|
1263
|
+
break;
|
1264
|
+
}
|
1265
|
+
case YP_NODE_REST_PARAMETER_NODE: {
|
1266
|
+
serialize_location(parser, &((yp_rest_parameter_node_t *)node)->operator_loc, buffer);
|
1267
|
+
if (((yp_rest_parameter_node_t *)node)->name_loc.start == NULL) {
|
1268
|
+
yp_buffer_append_u8(buffer, 0);
|
1269
|
+
} else {
|
1270
|
+
yp_buffer_append_u8(buffer, 1);
|
1271
|
+
serialize_location(parser, &((yp_rest_parameter_node_t *)node)->name_loc, buffer);
|
1272
|
+
}
|
1273
|
+
break;
|
1274
|
+
}
|
1275
|
+
case YP_NODE_RETRY_NODE: {
|
1276
|
+
break;
|
1277
|
+
}
|
1278
|
+
case YP_NODE_RETURN_NODE: {
|
1279
|
+
serialize_location(parser, &((yp_return_node_t *)node)->keyword_loc, buffer);
|
1280
|
+
if (((yp_return_node_t *)node)->arguments == NULL) {
|
1281
|
+
yp_buffer_append_u8(buffer, 0);
|
1282
|
+
} else {
|
1283
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_return_node_t *)node)->arguments, buffer);
|
1284
|
+
}
|
1285
|
+
break;
|
1286
|
+
}
|
1287
|
+
case YP_NODE_SELF_NODE: {
|
1288
|
+
break;
|
1289
|
+
}
|
1290
|
+
case YP_NODE_SINGLETON_CLASS_NODE: {
|
1291
|
+
uint32_t locals_size = yp_sizet_to_u32(((yp_singleton_class_node_t *)node)->locals.size);
|
1292
|
+
yp_buffer_append_u32(buffer, locals_size);
|
1293
|
+
for (uint32_t index = 0; index < locals_size; index++) {
|
1294
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_singleton_class_node_t *)node)->locals.ids[index]));
|
1295
|
+
}
|
1296
|
+
serialize_location(parser, &((yp_singleton_class_node_t *)node)->class_keyword_loc, buffer);
|
1297
|
+
serialize_location(parser, &((yp_singleton_class_node_t *)node)->operator_loc, buffer);
|
1298
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_singleton_class_node_t *)node)->expression, buffer);
|
1299
|
+
if (((yp_singleton_class_node_t *)node)->statements == NULL) {
|
1300
|
+
yp_buffer_append_u8(buffer, 0);
|
1301
|
+
} else {
|
1302
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_singleton_class_node_t *)node)->statements, buffer);
|
1303
|
+
}
|
1304
|
+
serialize_location(parser, &((yp_singleton_class_node_t *)node)->end_keyword_loc, buffer);
|
1305
|
+
break;
|
1306
|
+
}
|
1307
|
+
case YP_NODE_SOURCE_ENCODING_NODE: {
|
1308
|
+
break;
|
1309
|
+
}
|
1310
|
+
case YP_NODE_SOURCE_FILE_NODE: {
|
1311
|
+
uint32_t filepath_length = yp_sizet_to_u32(yp_string_length(&((yp_source_file_node_t *)node)->filepath));
|
1312
|
+
yp_buffer_append_u32(buffer, filepath_length);
|
1313
|
+
yp_buffer_append_str(buffer, yp_string_source(&((yp_source_file_node_t *)node)->filepath), filepath_length);
|
1314
|
+
break;
|
1315
|
+
}
|
1316
|
+
case YP_NODE_SOURCE_LINE_NODE: {
|
1317
|
+
break;
|
1318
|
+
}
|
1319
|
+
case YP_NODE_SPLAT_NODE: {
|
1320
|
+
serialize_location(parser, &((yp_splat_node_t *)node)->operator_loc, buffer);
|
1321
|
+
if (((yp_splat_node_t *)node)->expression == NULL) {
|
1322
|
+
yp_buffer_append_u8(buffer, 0);
|
1323
|
+
} else {
|
1324
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_splat_node_t *)node)->expression, buffer);
|
1325
|
+
}
|
1326
|
+
break;
|
1327
|
+
}
|
1328
|
+
case YP_NODE_STATEMENTS_NODE: {
|
1329
|
+
uint32_t body_size = yp_sizet_to_u32(((yp_statements_node_t *)node)->body.size);
|
1330
|
+
yp_buffer_append_u32(buffer, body_size);
|
1331
|
+
for (uint32_t index = 0; index < body_size; index++) {
|
1332
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_statements_node_t *)node)->body.nodes[index], buffer);
|
1333
|
+
}
|
1334
|
+
break;
|
1335
|
+
}
|
1336
|
+
case YP_NODE_STRING_CONCAT_NODE: {
|
1337
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_string_concat_node_t *)node)->left, buffer);
|
1338
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_string_concat_node_t *)node)->right, buffer);
|
1339
|
+
break;
|
1340
|
+
}
|
1341
|
+
case YP_NODE_STRING_NODE: {
|
1342
|
+
if (((yp_string_node_t *)node)->opening_loc.start == NULL) {
|
1343
|
+
yp_buffer_append_u8(buffer, 0);
|
1344
|
+
} else {
|
1345
|
+
yp_buffer_append_u8(buffer, 1);
|
1346
|
+
serialize_location(parser, &((yp_string_node_t *)node)->opening_loc, buffer);
|
1347
|
+
}
|
1348
|
+
serialize_location(parser, &((yp_string_node_t *)node)->content_loc, buffer);
|
1349
|
+
if (((yp_string_node_t *)node)->closing_loc.start == NULL) {
|
1350
|
+
yp_buffer_append_u8(buffer, 0);
|
1351
|
+
} else {
|
1352
|
+
yp_buffer_append_u8(buffer, 1);
|
1353
|
+
serialize_location(parser, &((yp_string_node_t *)node)->closing_loc, buffer);
|
1354
|
+
}
|
1355
|
+
uint32_t unescaped_length = yp_sizet_to_u32(yp_string_length(&((yp_string_node_t *)node)->unescaped));
|
1356
|
+
yp_buffer_append_u32(buffer, unescaped_length);
|
1357
|
+
yp_buffer_append_str(buffer, yp_string_source(&((yp_string_node_t *)node)->unescaped), unescaped_length);
|
1358
|
+
break;
|
1359
|
+
}
|
1360
|
+
case YP_NODE_SUPER_NODE: {
|
1361
|
+
serialize_location(parser, &((yp_super_node_t *)node)->keyword_loc, buffer);
|
1362
|
+
if (((yp_super_node_t *)node)->lparen_loc.start == NULL) {
|
1363
|
+
yp_buffer_append_u8(buffer, 0);
|
1364
|
+
} else {
|
1365
|
+
yp_buffer_append_u8(buffer, 1);
|
1366
|
+
serialize_location(parser, &((yp_super_node_t *)node)->lparen_loc, buffer);
|
1367
|
+
}
|
1368
|
+
if (((yp_super_node_t *)node)->arguments == NULL) {
|
1369
|
+
yp_buffer_append_u8(buffer, 0);
|
1370
|
+
} else {
|
1371
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_super_node_t *)node)->arguments, buffer);
|
1372
|
+
}
|
1373
|
+
if (((yp_super_node_t *)node)->rparen_loc.start == NULL) {
|
1374
|
+
yp_buffer_append_u8(buffer, 0);
|
1375
|
+
} else {
|
1376
|
+
yp_buffer_append_u8(buffer, 1);
|
1377
|
+
serialize_location(parser, &((yp_super_node_t *)node)->rparen_loc, buffer);
|
1378
|
+
}
|
1379
|
+
if (((yp_super_node_t *)node)->block == NULL) {
|
1380
|
+
yp_buffer_append_u8(buffer, 0);
|
1381
|
+
} else {
|
1382
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_super_node_t *)node)->block, buffer);
|
1383
|
+
}
|
1384
|
+
break;
|
1385
|
+
}
|
1386
|
+
case YP_NODE_SYMBOL_NODE: {
|
1387
|
+
if (((yp_symbol_node_t *)node)->opening_loc.start == NULL) {
|
1388
|
+
yp_buffer_append_u8(buffer, 0);
|
1389
|
+
} else {
|
1390
|
+
yp_buffer_append_u8(buffer, 1);
|
1391
|
+
serialize_location(parser, &((yp_symbol_node_t *)node)->opening_loc, buffer);
|
1392
|
+
}
|
1393
|
+
serialize_location(parser, &((yp_symbol_node_t *)node)->value_loc, buffer);
|
1394
|
+
if (((yp_symbol_node_t *)node)->closing_loc.start == NULL) {
|
1395
|
+
yp_buffer_append_u8(buffer, 0);
|
1396
|
+
} else {
|
1397
|
+
yp_buffer_append_u8(buffer, 1);
|
1398
|
+
serialize_location(parser, &((yp_symbol_node_t *)node)->closing_loc, buffer);
|
1399
|
+
}
|
1400
|
+
uint32_t unescaped_length = yp_sizet_to_u32(yp_string_length(&((yp_symbol_node_t *)node)->unescaped));
|
1401
|
+
yp_buffer_append_u32(buffer, unescaped_length);
|
1402
|
+
yp_buffer_append_str(buffer, yp_string_source(&((yp_symbol_node_t *)node)->unescaped), unescaped_length);
|
1403
|
+
break;
|
1404
|
+
}
|
1405
|
+
case YP_NODE_TRUE_NODE: {
|
1406
|
+
break;
|
1407
|
+
}
|
1408
|
+
case YP_NODE_UNDEF_NODE: {
|
1409
|
+
uint32_t names_size = yp_sizet_to_u32(((yp_undef_node_t *)node)->names.size);
|
1410
|
+
yp_buffer_append_u32(buffer, names_size);
|
1411
|
+
for (uint32_t index = 0; index < names_size; index++) {
|
1412
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_undef_node_t *)node)->names.nodes[index], buffer);
|
1413
|
+
}
|
1414
|
+
serialize_location(parser, &((yp_undef_node_t *)node)->keyword_loc, buffer);
|
1415
|
+
break;
|
1416
|
+
}
|
1417
|
+
case YP_NODE_UNLESS_NODE: {
|
1418
|
+
serialize_location(parser, &((yp_unless_node_t *)node)->keyword_loc, buffer);
|
1419
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_unless_node_t *)node)->predicate, buffer);
|
1420
|
+
if (((yp_unless_node_t *)node)->statements == NULL) {
|
1421
|
+
yp_buffer_append_u8(buffer, 0);
|
1422
|
+
} else {
|
1423
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_unless_node_t *)node)->statements, buffer);
|
1424
|
+
}
|
1425
|
+
if (((yp_unless_node_t *)node)->consequent == NULL) {
|
1426
|
+
yp_buffer_append_u8(buffer, 0);
|
1427
|
+
} else {
|
1428
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_unless_node_t *)node)->consequent, buffer);
|
1429
|
+
}
|
1430
|
+
if (((yp_unless_node_t *)node)->end_keyword_loc.start == NULL) {
|
1431
|
+
yp_buffer_append_u8(buffer, 0);
|
1432
|
+
} else {
|
1433
|
+
yp_buffer_append_u8(buffer, 1);
|
1434
|
+
serialize_location(parser, &((yp_unless_node_t *)node)->end_keyword_loc, buffer);
|
1435
|
+
}
|
1436
|
+
break;
|
1437
|
+
}
|
1438
|
+
case YP_NODE_UNTIL_NODE: {
|
1439
|
+
serialize_location(parser, &((yp_until_node_t *)node)->keyword_loc, buffer);
|
1440
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_until_node_t *)node)->predicate, buffer);
|
1441
|
+
if (((yp_until_node_t *)node)->statements == NULL) {
|
1442
|
+
yp_buffer_append_u8(buffer, 0);
|
1443
|
+
} else {
|
1444
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_until_node_t *)node)->statements, buffer);
|
1445
|
+
}
|
1446
|
+
yp_buffer_append_u32(buffer, ((yp_until_node_t *)node)->flags);
|
1447
|
+
break;
|
1448
|
+
}
|
1449
|
+
case YP_NODE_WHEN_NODE: {
|
1450
|
+
serialize_location(parser, &((yp_when_node_t *)node)->keyword_loc, buffer);
|
1451
|
+
uint32_t conditions_size = yp_sizet_to_u32(((yp_when_node_t *)node)->conditions.size);
|
1452
|
+
yp_buffer_append_u32(buffer, conditions_size);
|
1453
|
+
for (uint32_t index = 0; index < conditions_size; index++) {
|
1454
|
+
yp_serialize_node(parser, (yp_node_t *) ((yp_when_node_t *)node)->conditions.nodes[index], buffer);
|
1455
|
+
}
|
1456
|
+
if (((yp_when_node_t *)node)->statements == NULL) {
|
1457
|
+
yp_buffer_append_u8(buffer, 0);
|
1458
|
+
} else {
|
1459
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_when_node_t *)node)->statements, buffer);
|
1460
|
+
}
|
1461
|
+
break;
|
1462
|
+
}
|
1463
|
+
case YP_NODE_WHILE_NODE: {
|
1464
|
+
serialize_location(parser, &((yp_while_node_t *)node)->keyword_loc, buffer);
|
1465
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_while_node_t *)node)->predicate, buffer);
|
1466
|
+
if (((yp_while_node_t *)node)->statements == NULL) {
|
1467
|
+
yp_buffer_append_u8(buffer, 0);
|
1468
|
+
} else {
|
1469
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_while_node_t *)node)->statements, buffer);
|
1470
|
+
}
|
1471
|
+
yp_buffer_append_u32(buffer, ((yp_while_node_t *)node)->flags);
|
1472
|
+
break;
|
1473
|
+
}
|
1474
|
+
case YP_NODE_X_STRING_NODE: {
|
1475
|
+
serialize_location(parser, &((yp_x_string_node_t *)node)->opening_loc, buffer);
|
1476
|
+
serialize_location(parser, &((yp_x_string_node_t *)node)->content_loc, buffer);
|
1477
|
+
serialize_location(parser, &((yp_x_string_node_t *)node)->closing_loc, buffer);
|
1478
|
+
uint32_t unescaped_length = yp_sizet_to_u32(yp_string_length(&((yp_x_string_node_t *)node)->unescaped));
|
1479
|
+
yp_buffer_append_u32(buffer, unescaped_length);
|
1480
|
+
yp_buffer_append_str(buffer, yp_string_source(&((yp_x_string_node_t *)node)->unescaped), unescaped_length);
|
1481
|
+
break;
|
1482
|
+
}
|
1483
|
+
case YP_NODE_YIELD_NODE: {
|
1484
|
+
serialize_location(parser, &((yp_yield_node_t *)node)->keyword_loc, buffer);
|
1485
|
+
if (((yp_yield_node_t *)node)->lparen_loc.start == NULL) {
|
1486
|
+
yp_buffer_append_u8(buffer, 0);
|
1487
|
+
} else {
|
1488
|
+
yp_buffer_append_u8(buffer, 1);
|
1489
|
+
serialize_location(parser, &((yp_yield_node_t *)node)->lparen_loc, buffer);
|
1490
|
+
}
|
1491
|
+
if (((yp_yield_node_t *)node)->arguments == NULL) {
|
1492
|
+
yp_buffer_append_u8(buffer, 0);
|
1493
|
+
} else {
|
1494
|
+
yp_serialize_node(parser, (yp_node_t *)((yp_yield_node_t *)node)->arguments, buffer);
|
1495
|
+
}
|
1496
|
+
if (((yp_yield_node_t *)node)->rparen_loc.start == NULL) {
|
1497
|
+
yp_buffer_append_u8(buffer, 0);
|
1498
|
+
} else {
|
1499
|
+
yp_buffer_append_u8(buffer, 1);
|
1500
|
+
serialize_location(parser, &((yp_yield_node_t *)node)->rparen_loc, buffer);
|
1501
|
+
}
|
1502
|
+
break;
|
1503
|
+
}
|
1504
|
+
}
|
1505
|
+
}
|
1506
|
+
|
1507
|
+
void yp_serialize_diagnostic(yp_parser_t *parser, yp_diagnostic_t *diagnostic, yp_buffer_t *buffer) {
|
1508
|
+
// serialize message
|
1509
|
+
size_t message_length = strlen(diagnostic->message);
|
1510
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(message_length));
|
1511
|
+
yp_buffer_append_str(buffer, diagnostic->message, message_length);
|
1512
|
+
|
1513
|
+
// serialize location
|
1514
|
+
yp_buffer_append_u32(buffer, yp_ptrdifft_to_u32(diagnostic->start - parser->start));
|
1515
|
+
yp_buffer_append_u32(buffer, yp_ptrdifft_to_u32(diagnostic->end - diagnostic->start));
|
1516
|
+
}
|
1517
|
+
|
1518
|
+
void yp_serialize_diagnostic_list(yp_parser_t *parser, yp_list_t list, yp_buffer_t *buffer) {
|
1519
|
+
yp_buffer_append_u32(buffer, yp_list_size(&list));
|
1520
|
+
|
1521
|
+
yp_diagnostic_t *diagnostic;
|
1522
|
+
for (diagnostic = (yp_diagnostic_t *) list.head; diagnostic != NULL; diagnostic = (yp_diagnostic_t *) diagnostic->node.next) {
|
1523
|
+
yp_serialize_diagnostic(parser, diagnostic, buffer);
|
1524
|
+
}
|
1525
|
+
}
|
1526
|
+
|
1527
|
+
void
|
1528
|
+
yp_serialize_content(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
|
1529
|
+
// First, serialize the encoding of the parser.
|
1530
|
+
size_t encoding_length = strlen(parser->encoding.name);
|
1531
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(encoding_length));
|
1532
|
+
yp_buffer_append_str(buffer, parser->encoding.name, encoding_length);
|
1533
|
+
|
1534
|
+
// Serialize the errors
|
1535
|
+
yp_serialize_diagnostic_list(parser, parser->error_list, buffer);
|
1536
|
+
|
1537
|
+
// Serialize the warnings
|
1538
|
+
yp_serialize_diagnostic_list(parser, parser->warning_list, buffer);
|
1539
|
+
|
1540
|
+
// Here we're going to leave space for the offset of the constant pool in
|
1541
|
+
// the buffer.
|
1542
|
+
size_t offset = buffer->length;
|
1543
|
+
yp_buffer_append_zeroes(buffer, 4);
|
1544
|
+
|
1545
|
+
// Next, encode the length of the constant pool.
|
1546
|
+
yp_buffer_append_u32(buffer, yp_sizet_to_u32(parser->constant_pool.size));
|
1547
|
+
|
1548
|
+
// Now we're going to serialize the content of the node.
|
1549
|
+
yp_serialize_node(parser, node, buffer);
|
1550
|
+
|
1551
|
+
// Now we're going to serialize the offset of the constant pool back where
|
1552
|
+
// we left space for it.
|
1553
|
+
uint32_t length = yp_sizet_to_u32(buffer->length);
|
1554
|
+
memcpy(buffer->value + offset, &length, sizeof(uint32_t));
|
1555
|
+
|
1556
|
+
// Now we're going to serialize the constant pool.
|
1557
|
+
offset = buffer->length;
|
1558
|
+
yp_buffer_append_zeroes(buffer, parser->constant_pool.size * 8);
|
1559
|
+
|
1560
|
+
yp_constant_t *constant;
|
1561
|
+
for (size_t index = 0; index < parser->constant_pool.capacity; index++) {
|
1562
|
+
constant = &parser->constant_pool.constants[index];
|
1563
|
+
|
1564
|
+
// If we find a constant at this index, serialize it at the correct
|
1565
|
+
// index in the buffer.
|
1566
|
+
if (constant->id != 0) {
|
1567
|
+
size_t buffer_offset = offset + ((constant->id - 1) * 8);
|
1568
|
+
|
1569
|
+
uint32_t source_offset = yp_ptrdifft_to_u32(constant->start - parser->start);
|
1570
|
+
uint32_t constant_length = yp_sizet_to_u32(constant->length);
|
1571
|
+
|
1572
|
+
memcpy(buffer->value + buffer_offset, &source_offset, 4);
|
1573
|
+
memcpy(buffer->value + buffer_offset + 4, &constant_length, 4);
|
1574
|
+
}
|
1575
|
+
}
|
1576
|
+
}
|