yarp 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
data/src/serialize.c CHANGED
@@ -65,27 +65,27 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
65
65
  switch (YP_NODE_TYPE(node)) {
66
66
  // We do not need to serialize a ScopeNode ever as
67
67
  // it is not part of the AST
68
- case YP_NODE_SCOPE_NODE:
68
+ case YP_SCOPE_NODE:
69
69
  return;
70
- case YP_NODE_ALIAS_NODE: {
70
+ case YP_ALIAS_NODE: {
71
71
  yp_serialize_node(parser, (yp_node_t *)((yp_alias_node_t *)node)->new_name, buffer);
72
72
  yp_serialize_node(parser, (yp_node_t *)((yp_alias_node_t *)node)->old_name, buffer);
73
73
  yp_serialize_location(parser, &((yp_alias_node_t *)node)->keyword_loc, buffer);
74
74
  break;
75
75
  }
76
- case YP_NODE_ALTERNATION_PATTERN_NODE: {
76
+ case YP_ALTERNATION_PATTERN_NODE: {
77
77
  yp_serialize_node(parser, (yp_node_t *)((yp_alternation_pattern_node_t *)node)->left, buffer);
78
78
  yp_serialize_node(parser, (yp_node_t *)((yp_alternation_pattern_node_t *)node)->right, buffer);
79
79
  yp_serialize_location(parser, &((yp_alternation_pattern_node_t *)node)->operator_loc, buffer);
80
80
  break;
81
81
  }
82
- case YP_NODE_AND_NODE: {
82
+ case YP_AND_NODE: {
83
83
  yp_serialize_node(parser, (yp_node_t *)((yp_and_node_t *)node)->left, buffer);
84
84
  yp_serialize_node(parser, (yp_node_t *)((yp_and_node_t *)node)->right, buffer);
85
85
  yp_serialize_location(parser, &((yp_and_node_t *)node)->operator_loc, buffer);
86
86
  break;
87
87
  }
88
- case YP_NODE_ARGUMENTS_NODE: {
88
+ case YP_ARGUMENTS_NODE: {
89
89
  uint32_t arguments_size = yp_sizet_to_u32(((yp_arguments_node_t *)node)->arguments.size);
90
90
  yp_buffer_append_u32(buffer, arguments_size);
91
91
  for (uint32_t index = 0; index < arguments_size; index++) {
@@ -93,7 +93,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
93
93
  }
94
94
  break;
95
95
  }
96
- case YP_NODE_ARRAY_NODE: {
96
+ case YP_ARRAY_NODE: {
97
97
  uint32_t elements_size = yp_sizet_to_u32(((yp_array_node_t *)node)->elements.size);
98
98
  yp_buffer_append_u32(buffer, elements_size);
99
99
  for (uint32_t index = 0; index < elements_size; index++) {
@@ -113,7 +113,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
113
113
  }
114
114
  break;
115
115
  }
116
- case YP_NODE_ARRAY_PATTERN_NODE: {
116
+ case YP_ARRAY_PATTERN_NODE: {
117
117
  if (((yp_array_pattern_node_t *)node)->constant == NULL) {
118
118
  yp_buffer_append_u8(buffer, 0);
119
119
  } else {
@@ -148,7 +148,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
148
148
  }
149
149
  break;
150
150
  }
151
- case YP_NODE_ASSOC_NODE: {
151
+ case YP_ASSOC_NODE: {
152
152
  yp_serialize_node(parser, (yp_node_t *)((yp_assoc_node_t *)node)->key, buffer);
153
153
  if (((yp_assoc_node_t *)node)->value == NULL) {
154
154
  yp_buffer_append_u8(buffer, 0);
@@ -163,7 +163,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
163
163
  }
164
164
  break;
165
165
  }
166
- case YP_NODE_ASSOC_SPLAT_NODE: {
166
+ case YP_ASSOC_SPLAT_NODE: {
167
167
  if (((yp_assoc_splat_node_t *)node)->value == NULL) {
168
168
  yp_buffer_append_u8(buffer, 0);
169
169
  } else {
@@ -172,10 +172,10 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
172
172
  yp_serialize_location(parser, &((yp_assoc_splat_node_t *)node)->operator_loc, buffer);
173
173
  break;
174
174
  }
175
- case YP_NODE_BACK_REFERENCE_READ_NODE: {
175
+ case YP_BACK_REFERENCE_READ_NODE: {
176
176
  break;
177
177
  }
178
- case YP_NODE_BEGIN_NODE: {
178
+ case YP_BEGIN_NODE: {
179
179
  if (((yp_begin_node_t *)node)->begin_keyword_loc.start == NULL) {
180
180
  yp_buffer_append_u8(buffer, 0);
181
181
  } else {
@@ -210,7 +210,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
210
210
  }
211
211
  break;
212
212
  }
213
- case YP_NODE_BLOCK_ARGUMENT_NODE: {
213
+ case YP_BLOCK_ARGUMENT_NODE: {
214
214
  if (((yp_block_argument_node_t *)node)->expression == NULL) {
215
215
  yp_buffer_append_u8(buffer, 0);
216
216
  } else {
@@ -219,7 +219,11 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
219
219
  yp_serialize_location(parser, &((yp_block_argument_node_t *)node)->operator_loc, buffer);
220
220
  break;
221
221
  }
222
- case YP_NODE_BLOCK_NODE: {
222
+ case YP_BLOCK_LOCAL_VARIABLE_NODE: {
223
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_block_local_variable_node_t *)node)->name));
224
+ break;
225
+ }
226
+ case YP_BLOCK_NODE: {
223
227
  uint32_t locals_size = yp_sizet_to_u32(((yp_block_node_t *)node)->locals.size);
224
228
  yp_buffer_append_u32(buffer, locals_size);
225
229
  for (uint32_t index = 0; index < locals_size; index++) {
@@ -239,7 +243,8 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
239
243
  yp_serialize_location(parser, &((yp_block_node_t *)node)->closing_loc, buffer);
240
244
  break;
241
245
  }
242
- case YP_NODE_BLOCK_PARAMETER_NODE: {
246
+ case YP_BLOCK_PARAMETER_NODE: {
247
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_block_parameter_node_t *)node)->name));
243
248
  if (((yp_block_parameter_node_t *)node)->name_loc.start == NULL) {
244
249
  yp_buffer_append_u8(buffer, 0);
245
250
  } else {
@@ -249,7 +254,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
249
254
  yp_serialize_location(parser, &((yp_block_parameter_node_t *)node)->operator_loc, buffer);
250
255
  break;
251
256
  }
252
- case YP_NODE_BLOCK_PARAMETERS_NODE: {
257
+ case YP_BLOCK_PARAMETERS_NODE: {
253
258
  if (((yp_block_parameters_node_t *)node)->parameters == NULL) {
254
259
  yp_buffer_append_u8(buffer, 0);
255
260
  } else {
@@ -258,7 +263,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
258
263
  uint32_t locals_size = yp_sizet_to_u32(((yp_block_parameters_node_t *)node)->locals.size);
259
264
  yp_buffer_append_u32(buffer, locals_size);
260
265
  for (uint32_t index = 0; index < locals_size; index++) {
261
- yp_serialize_location(parser, &((yp_block_parameters_node_t *)node)->locals.locations[index], buffer);
266
+ yp_serialize_node(parser, (yp_node_t *) ((yp_block_parameters_node_t *)node)->locals.nodes[index], buffer);
262
267
  }
263
268
  if (((yp_block_parameters_node_t *)node)->opening_loc.start == NULL) {
264
269
  yp_buffer_append_u8(buffer, 0);
@@ -274,7 +279,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
274
279
  }
275
280
  break;
276
281
  }
277
- case YP_NODE_BREAK_NODE: {
282
+ case YP_BREAK_NODE: {
278
283
  if (((yp_break_node_t *)node)->arguments == NULL) {
279
284
  yp_buffer_append_u8(buffer, 0);
280
285
  } else {
@@ -283,17 +288,59 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
283
288
  yp_serialize_location(parser, &((yp_break_node_t *)node)->keyword_loc, buffer);
284
289
  break;
285
290
  }
286
- case YP_NODE_CALL_NODE: {
291
+ case YP_CALL_AND_WRITE_NODE: {
292
+ if (((yp_call_and_write_node_t *)node)->receiver == NULL) {
293
+ yp_buffer_append_u8(buffer, 0);
294
+ } else {
295
+ yp_serialize_node(parser, (yp_node_t *)((yp_call_and_write_node_t *)node)->receiver, buffer);
296
+ }
297
+ if (((yp_call_and_write_node_t *)node)->call_operator_loc.start == NULL) {
298
+ yp_buffer_append_u8(buffer, 0);
299
+ } else {
300
+ yp_buffer_append_u8(buffer, 1);
301
+ yp_serialize_location(parser, &((yp_call_and_write_node_t *)node)->call_operator_loc, buffer);
302
+ }
303
+ if (((yp_call_and_write_node_t *)node)->message_loc.start == NULL) {
304
+ yp_buffer_append_u8(buffer, 0);
305
+ } else {
306
+ yp_buffer_append_u8(buffer, 1);
307
+ yp_serialize_location(parser, &((yp_call_and_write_node_t *)node)->message_loc, buffer);
308
+ }
309
+ if (((yp_call_and_write_node_t *)node)->opening_loc.start == NULL) {
310
+ yp_buffer_append_u8(buffer, 0);
311
+ } else {
312
+ yp_buffer_append_u8(buffer, 1);
313
+ yp_serialize_location(parser, &((yp_call_and_write_node_t *)node)->opening_loc, buffer);
314
+ }
315
+ if (((yp_call_and_write_node_t *)node)->arguments == NULL) {
316
+ yp_buffer_append_u8(buffer, 0);
317
+ } else {
318
+ yp_serialize_node(parser, (yp_node_t *)((yp_call_and_write_node_t *)node)->arguments, buffer);
319
+ }
320
+ if (((yp_call_and_write_node_t *)node)->closing_loc.start == NULL) {
321
+ yp_buffer_append_u8(buffer, 0);
322
+ } else {
323
+ yp_buffer_append_u8(buffer, 1);
324
+ yp_serialize_location(parser, &((yp_call_and_write_node_t *)node)->closing_loc, buffer);
325
+ }
326
+ yp_buffer_append_u32(buffer, node->flags >> 1);
327
+ yp_serialize_string(parser, &((yp_call_and_write_node_t *)node)->read_name, buffer);
328
+ yp_serialize_string(parser, &((yp_call_and_write_node_t *)node)->write_name, buffer);
329
+ yp_serialize_location(parser, &((yp_call_and_write_node_t *)node)->operator_loc, buffer);
330
+ yp_serialize_node(parser, (yp_node_t *)((yp_call_and_write_node_t *)node)->value, buffer);
331
+ break;
332
+ }
333
+ case YP_CALL_NODE: {
287
334
  if (((yp_call_node_t *)node)->receiver == NULL) {
288
335
  yp_buffer_append_u8(buffer, 0);
289
336
  } else {
290
337
  yp_serialize_node(parser, (yp_node_t *)((yp_call_node_t *)node)->receiver, buffer);
291
338
  }
292
- if (((yp_call_node_t *)node)->operator_loc.start == NULL) {
339
+ if (((yp_call_node_t *)node)->call_operator_loc.start == NULL) {
293
340
  yp_buffer_append_u8(buffer, 0);
294
341
  } else {
295
342
  yp_buffer_append_u8(buffer, 1);
296
- yp_serialize_location(parser, &((yp_call_node_t *)node)->operator_loc, buffer);
343
+ yp_serialize_location(parser, &((yp_call_node_t *)node)->call_operator_loc, buffer);
297
344
  }
298
345
  if (((yp_call_node_t *)node)->message_loc.start == NULL) {
299
346
  yp_buffer_append_u8(buffer, 0);
@@ -327,32 +374,98 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
327
374
  yp_serialize_string(parser, &((yp_call_node_t *)node)->name, buffer);
328
375
  break;
329
376
  }
330
- case YP_NODE_CALL_OPERATOR_AND_WRITE_NODE: {
331
- yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_and_write_node_t *)node)->target, buffer);
332
- yp_serialize_location(parser, &((yp_call_operator_and_write_node_t *)node)->operator_loc, buffer);
333
- yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_and_write_node_t *)node)->value, buffer);
334
- break;
335
- }
336
- case YP_NODE_CALL_OPERATOR_OR_WRITE_NODE: {
337
- yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_or_write_node_t *)node)->target, buffer);
338
- yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_or_write_node_t *)node)->value, buffer);
339
- yp_serialize_location(parser, &((yp_call_operator_or_write_node_t *)node)->operator_loc, buffer);
340
- break;
341
- }
342
- case YP_NODE_CALL_OPERATOR_WRITE_NODE: {
343
- yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_write_node_t *)node)->target, buffer);
377
+ case YP_CALL_OPERATOR_WRITE_NODE: {
378
+ if (((yp_call_operator_write_node_t *)node)->receiver == NULL) {
379
+ yp_buffer_append_u8(buffer, 0);
380
+ } else {
381
+ yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_write_node_t *)node)->receiver, buffer);
382
+ }
383
+ if (((yp_call_operator_write_node_t *)node)->call_operator_loc.start == NULL) {
384
+ yp_buffer_append_u8(buffer, 0);
385
+ } else {
386
+ yp_buffer_append_u8(buffer, 1);
387
+ yp_serialize_location(parser, &((yp_call_operator_write_node_t *)node)->call_operator_loc, buffer);
388
+ }
389
+ if (((yp_call_operator_write_node_t *)node)->message_loc.start == NULL) {
390
+ yp_buffer_append_u8(buffer, 0);
391
+ } else {
392
+ yp_buffer_append_u8(buffer, 1);
393
+ yp_serialize_location(parser, &((yp_call_operator_write_node_t *)node)->message_loc, buffer);
394
+ }
395
+ if (((yp_call_operator_write_node_t *)node)->opening_loc.start == NULL) {
396
+ yp_buffer_append_u8(buffer, 0);
397
+ } else {
398
+ yp_buffer_append_u8(buffer, 1);
399
+ yp_serialize_location(parser, &((yp_call_operator_write_node_t *)node)->opening_loc, buffer);
400
+ }
401
+ if (((yp_call_operator_write_node_t *)node)->arguments == NULL) {
402
+ yp_buffer_append_u8(buffer, 0);
403
+ } else {
404
+ yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_write_node_t *)node)->arguments, buffer);
405
+ }
406
+ if (((yp_call_operator_write_node_t *)node)->closing_loc.start == NULL) {
407
+ yp_buffer_append_u8(buffer, 0);
408
+ } else {
409
+ yp_buffer_append_u8(buffer, 1);
410
+ yp_serialize_location(parser, &((yp_call_operator_write_node_t *)node)->closing_loc, buffer);
411
+ }
412
+ yp_buffer_append_u32(buffer, node->flags >> 1);
413
+ yp_serialize_string(parser, &((yp_call_operator_write_node_t *)node)->read_name, buffer);
414
+ yp_serialize_string(parser, &((yp_call_operator_write_node_t *)node)->write_name, buffer);
415
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_call_operator_write_node_t *)node)->operator));
344
416
  yp_serialize_location(parser, &((yp_call_operator_write_node_t *)node)->operator_loc, buffer);
345
417
  yp_serialize_node(parser, (yp_node_t *)((yp_call_operator_write_node_t *)node)->value, buffer);
346
- yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_call_operator_write_node_t *)node)->operator));
347
418
  break;
348
419
  }
349
- case YP_NODE_CAPTURE_PATTERN_NODE: {
420
+ case YP_CALL_OR_WRITE_NODE: {
421
+ if (((yp_call_or_write_node_t *)node)->receiver == NULL) {
422
+ yp_buffer_append_u8(buffer, 0);
423
+ } else {
424
+ yp_serialize_node(parser, (yp_node_t *)((yp_call_or_write_node_t *)node)->receiver, buffer);
425
+ }
426
+ if (((yp_call_or_write_node_t *)node)->call_operator_loc.start == NULL) {
427
+ yp_buffer_append_u8(buffer, 0);
428
+ } else {
429
+ yp_buffer_append_u8(buffer, 1);
430
+ yp_serialize_location(parser, &((yp_call_or_write_node_t *)node)->call_operator_loc, buffer);
431
+ }
432
+ if (((yp_call_or_write_node_t *)node)->message_loc.start == NULL) {
433
+ yp_buffer_append_u8(buffer, 0);
434
+ } else {
435
+ yp_buffer_append_u8(buffer, 1);
436
+ yp_serialize_location(parser, &((yp_call_or_write_node_t *)node)->message_loc, buffer);
437
+ }
438
+ if (((yp_call_or_write_node_t *)node)->opening_loc.start == NULL) {
439
+ yp_buffer_append_u8(buffer, 0);
440
+ } else {
441
+ yp_buffer_append_u8(buffer, 1);
442
+ yp_serialize_location(parser, &((yp_call_or_write_node_t *)node)->opening_loc, buffer);
443
+ }
444
+ if (((yp_call_or_write_node_t *)node)->arguments == NULL) {
445
+ yp_buffer_append_u8(buffer, 0);
446
+ } else {
447
+ yp_serialize_node(parser, (yp_node_t *)((yp_call_or_write_node_t *)node)->arguments, buffer);
448
+ }
449
+ if (((yp_call_or_write_node_t *)node)->closing_loc.start == NULL) {
450
+ yp_buffer_append_u8(buffer, 0);
451
+ } else {
452
+ yp_buffer_append_u8(buffer, 1);
453
+ yp_serialize_location(parser, &((yp_call_or_write_node_t *)node)->closing_loc, buffer);
454
+ }
455
+ yp_buffer_append_u32(buffer, node->flags >> 1);
456
+ yp_serialize_string(parser, &((yp_call_or_write_node_t *)node)->read_name, buffer);
457
+ yp_serialize_string(parser, &((yp_call_or_write_node_t *)node)->write_name, buffer);
458
+ yp_serialize_location(parser, &((yp_call_or_write_node_t *)node)->operator_loc, buffer);
459
+ yp_serialize_node(parser, (yp_node_t *)((yp_call_or_write_node_t *)node)->value, buffer);
460
+ break;
461
+ }
462
+ case YP_CAPTURE_PATTERN_NODE: {
350
463
  yp_serialize_node(parser, (yp_node_t *)((yp_capture_pattern_node_t *)node)->value, buffer);
351
464
  yp_serialize_node(parser, (yp_node_t *)((yp_capture_pattern_node_t *)node)->target, buffer);
352
465
  yp_serialize_location(parser, &((yp_capture_pattern_node_t *)node)->operator_loc, buffer);
353
466
  break;
354
467
  }
355
- case YP_NODE_CASE_NODE: {
468
+ case YP_CASE_NODE: {
356
469
  if (((yp_case_node_t *)node)->predicate == NULL) {
357
470
  yp_buffer_append_u8(buffer, 0);
358
471
  } else {
@@ -372,7 +485,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
372
485
  yp_serialize_location(parser, &((yp_case_node_t *)node)->end_keyword_loc, buffer);
373
486
  break;
374
487
  }
375
- case YP_NODE_CLASS_NODE: {
488
+ case YP_CLASS_NODE: {
376
489
  uint32_t locals_size = yp_sizet_to_u32(((yp_class_node_t *)node)->locals.size);
377
490
  yp_buffer_append_u32(buffer, locals_size);
378
491
  for (uint32_t index = 0; index < locals_size; index++) {
@@ -397,17 +510,17 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
397
510
  yp_serialize_node(parser, (yp_node_t *)((yp_class_node_t *)node)->body, buffer);
398
511
  }
399
512
  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);
513
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_node_t *)node)->name));
401
514
  break;
402
515
  }
403
- case YP_NODE_CLASS_VARIABLE_AND_WRITE_NODE: {
516
+ case YP_CLASS_VARIABLE_AND_WRITE_NODE: {
404
517
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_variable_and_write_node_t *)node)->name));
405
518
  yp_serialize_location(parser, &((yp_class_variable_and_write_node_t *)node)->name_loc, buffer);
406
519
  yp_serialize_location(parser, &((yp_class_variable_and_write_node_t *)node)->operator_loc, buffer);
407
520
  yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_and_write_node_t *)node)->value, buffer);
408
521
  break;
409
522
  }
410
- case YP_NODE_CLASS_VARIABLE_OPERATOR_WRITE_NODE: {
523
+ case YP_CLASS_VARIABLE_OPERATOR_WRITE_NODE: {
411
524
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_variable_operator_write_node_t *)node)->name));
412
525
  yp_serialize_location(parser, &((yp_class_variable_operator_write_node_t *)node)->name_loc, buffer);
413
526
  yp_serialize_location(parser, &((yp_class_variable_operator_write_node_t *)node)->operator_loc, buffer);
@@ -415,29 +528,25 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
415
528
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_variable_operator_write_node_t *)node)->operator));
416
529
  break;
417
530
  }
418
- case YP_NODE_CLASS_VARIABLE_OR_WRITE_NODE: {
531
+ case YP_CLASS_VARIABLE_OR_WRITE_NODE: {
419
532
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_variable_or_write_node_t *)node)->name));
420
533
  yp_serialize_location(parser, &((yp_class_variable_or_write_node_t *)node)->name_loc, buffer);
421
534
  yp_serialize_location(parser, &((yp_class_variable_or_write_node_t *)node)->operator_loc, buffer);
422
535
  yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_or_write_node_t *)node)->value, buffer);
423
536
  break;
424
537
  }
425
- case YP_NODE_CLASS_VARIABLE_READ_NODE: {
538
+ case YP_CLASS_VARIABLE_READ_NODE: {
426
539
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_variable_read_node_t *)node)->name));
427
540
  break;
428
541
  }
429
- case YP_NODE_CLASS_VARIABLE_TARGET_NODE: {
542
+ case YP_CLASS_VARIABLE_TARGET_NODE: {
430
543
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_variable_target_node_t *)node)->name));
431
544
  break;
432
545
  }
433
- case YP_NODE_CLASS_VARIABLE_WRITE_NODE: {
546
+ case YP_CLASS_VARIABLE_WRITE_NODE: {
434
547
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_class_variable_write_node_t *)node)->name));
435
548
  yp_serialize_location(parser, &((yp_class_variable_write_node_t *)node)->name_loc, buffer);
436
- if (((yp_class_variable_write_node_t *)node)->value == NULL) {
437
- yp_buffer_append_u8(buffer, 0);
438
- } else {
439
- yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_write_node_t *)node)->value, buffer);
440
- }
549
+ yp_serialize_node(parser, (yp_node_t *)((yp_class_variable_write_node_t *)node)->value, buffer);
441
550
  if (((yp_class_variable_write_node_t *)node)->operator_loc.start == NULL) {
442
551
  yp_buffer_append_u8(buffer, 0);
443
552
  } else {
@@ -446,32 +555,35 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
446
555
  }
447
556
  break;
448
557
  }
449
- case YP_NODE_CONSTANT_AND_WRITE_NODE: {
558
+ case YP_CONSTANT_AND_WRITE_NODE: {
559
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_and_write_node_t *)node)->name));
450
560
  yp_serialize_location(parser, &((yp_constant_and_write_node_t *)node)->name_loc, buffer);
451
561
  yp_serialize_location(parser, &((yp_constant_and_write_node_t *)node)->operator_loc, buffer);
452
562
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_and_write_node_t *)node)->value, buffer);
453
563
  break;
454
564
  }
455
- case YP_NODE_CONSTANT_OPERATOR_WRITE_NODE: {
565
+ case YP_CONSTANT_OPERATOR_WRITE_NODE: {
566
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_operator_write_node_t *)node)->name));
456
567
  yp_serialize_location(parser, &((yp_constant_operator_write_node_t *)node)->name_loc, buffer);
457
568
  yp_serialize_location(parser, &((yp_constant_operator_write_node_t *)node)->operator_loc, buffer);
458
569
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_operator_write_node_t *)node)->value, buffer);
459
570
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_operator_write_node_t *)node)->operator));
460
571
  break;
461
572
  }
462
- case YP_NODE_CONSTANT_OR_WRITE_NODE: {
573
+ case YP_CONSTANT_OR_WRITE_NODE: {
574
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_or_write_node_t *)node)->name));
463
575
  yp_serialize_location(parser, &((yp_constant_or_write_node_t *)node)->name_loc, buffer);
464
576
  yp_serialize_location(parser, &((yp_constant_or_write_node_t *)node)->operator_loc, buffer);
465
577
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_or_write_node_t *)node)->value, buffer);
466
578
  break;
467
579
  }
468
- case YP_NODE_CONSTANT_PATH_AND_WRITE_NODE: {
580
+ case YP_CONSTANT_PATH_AND_WRITE_NODE: {
469
581
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_and_write_node_t *)node)->target, buffer);
470
582
  yp_serialize_location(parser, &((yp_constant_path_and_write_node_t *)node)->operator_loc, buffer);
471
583
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_and_write_node_t *)node)->value, buffer);
472
584
  break;
473
585
  }
474
- case YP_NODE_CONSTANT_PATH_NODE: {
586
+ case YP_CONSTANT_PATH_NODE: {
475
587
  if (((yp_constant_path_node_t *)node)->parent == NULL) {
476
588
  yp_buffer_append_u8(buffer, 0);
477
589
  } else {
@@ -481,20 +593,20 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
481
593
  yp_serialize_location(parser, &((yp_constant_path_node_t *)node)->delimiter_loc, buffer);
482
594
  break;
483
595
  }
484
- case YP_NODE_CONSTANT_PATH_OPERATOR_WRITE_NODE: {
596
+ case YP_CONSTANT_PATH_OPERATOR_WRITE_NODE: {
485
597
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_operator_write_node_t *)node)->target, buffer);
486
598
  yp_serialize_location(parser, &((yp_constant_path_operator_write_node_t *)node)->operator_loc, buffer);
487
599
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_operator_write_node_t *)node)->value, buffer);
488
600
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_path_operator_write_node_t *)node)->operator));
489
601
  break;
490
602
  }
491
- case YP_NODE_CONSTANT_PATH_OR_WRITE_NODE: {
603
+ case YP_CONSTANT_PATH_OR_WRITE_NODE: {
492
604
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_or_write_node_t *)node)->target, buffer);
493
605
  yp_serialize_location(parser, &((yp_constant_path_or_write_node_t *)node)->operator_loc, buffer);
494
606
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_or_write_node_t *)node)->value, buffer);
495
607
  break;
496
608
  }
497
- case YP_NODE_CONSTANT_PATH_TARGET_NODE: {
609
+ case YP_CONSTANT_PATH_TARGET_NODE: {
498
610
  if (((yp_constant_path_target_node_t *)node)->parent == NULL) {
499
611
  yp_buffer_append_u8(buffer, 0);
500
612
  } else {
@@ -504,29 +616,33 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
504
616
  yp_serialize_location(parser, &((yp_constant_path_target_node_t *)node)->delimiter_loc, buffer);
505
617
  break;
506
618
  }
507
- case YP_NODE_CONSTANT_PATH_WRITE_NODE: {
619
+ case YP_CONSTANT_PATH_WRITE_NODE: {
508
620
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_write_node_t *)node)->target, buffer);
509
621
  yp_serialize_location(parser, &((yp_constant_path_write_node_t *)node)->operator_loc, buffer);
510
622
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_path_write_node_t *)node)->value, buffer);
511
623
  break;
512
624
  }
513
- case YP_NODE_CONSTANT_READ_NODE: {
625
+ case YP_CONSTANT_READ_NODE: {
626
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_read_node_t *)node)->name));
514
627
  break;
515
628
  }
516
- case YP_NODE_CONSTANT_TARGET_NODE: {
629
+ case YP_CONSTANT_TARGET_NODE: {
630
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_target_node_t *)node)->name));
517
631
  break;
518
632
  }
519
- case YP_NODE_CONSTANT_WRITE_NODE: {
633
+ case YP_CONSTANT_WRITE_NODE: {
634
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_constant_write_node_t *)node)->name));
520
635
  yp_serialize_location(parser, &((yp_constant_write_node_t *)node)->name_loc, buffer);
521
636
  yp_serialize_node(parser, (yp_node_t *)((yp_constant_write_node_t *)node)->value, buffer);
522
637
  yp_serialize_location(parser, &((yp_constant_write_node_t *)node)->operator_loc, buffer);
523
638
  break;
524
639
  }
525
- case YP_NODE_DEF_NODE: {
640
+ case YP_DEF_NODE: {
526
641
  // serialize length
527
642
  // encoding of location u32s make us need to save this offset.
528
643
  size_t length_offset = buffer->length;
529
644
  yp_buffer_append_str(buffer, "\0\0\0\0", 4); /* consume 4 bytes, updated below */
645
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_def_node_t *)node)->name));
530
646
  yp_serialize_location(parser, &((yp_def_node_t *)node)->name_loc, buffer);
531
647
  if (((yp_def_node_t *)node)->receiver == NULL) {
532
648
  yp_buffer_append_u8(buffer, 0);
@@ -584,7 +700,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
584
700
  memcpy(buffer->value + length_offset, &length, sizeof(uint32_t));
585
701
  break;
586
702
  }
587
- case YP_NODE_DEFINED_NODE: {
703
+ case YP_DEFINED_NODE: {
588
704
  if (((yp_defined_node_t *)node)->lparen_loc.start == NULL) {
589
705
  yp_buffer_append_u8(buffer, 0);
590
706
  } else {
@@ -601,7 +717,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
601
717
  yp_serialize_location(parser, &((yp_defined_node_t *)node)->keyword_loc, buffer);
602
718
  break;
603
719
  }
604
- case YP_NODE_ELSE_NODE: {
720
+ case YP_ELSE_NODE: {
605
721
  yp_serialize_location(parser, &((yp_else_node_t *)node)->else_keyword_loc, buffer);
606
722
  if (((yp_else_node_t *)node)->statements == NULL) {
607
723
  yp_buffer_append_u8(buffer, 0);
@@ -616,7 +732,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
616
732
  }
617
733
  break;
618
734
  }
619
- case YP_NODE_EMBEDDED_STATEMENTS_NODE: {
735
+ case YP_EMBEDDED_STATEMENTS_NODE: {
620
736
  yp_serialize_location(parser, &((yp_embedded_statements_node_t *)node)->opening_loc, buffer);
621
737
  if (((yp_embedded_statements_node_t *)node)->statements == NULL) {
622
738
  yp_buffer_append_u8(buffer, 0);
@@ -626,12 +742,12 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
626
742
  yp_serialize_location(parser, &((yp_embedded_statements_node_t *)node)->closing_loc, buffer);
627
743
  break;
628
744
  }
629
- case YP_NODE_EMBEDDED_VARIABLE_NODE: {
745
+ case YP_EMBEDDED_VARIABLE_NODE: {
630
746
  yp_serialize_location(parser, &((yp_embedded_variable_node_t *)node)->operator_loc, buffer);
631
747
  yp_serialize_node(parser, (yp_node_t *)((yp_embedded_variable_node_t *)node)->variable, buffer);
632
748
  break;
633
749
  }
634
- case YP_NODE_ENSURE_NODE: {
750
+ case YP_ENSURE_NODE: {
635
751
  yp_serialize_location(parser, &((yp_ensure_node_t *)node)->ensure_keyword_loc, buffer);
636
752
  if (((yp_ensure_node_t *)node)->statements == NULL) {
637
753
  yp_buffer_append_u8(buffer, 0);
@@ -641,10 +757,10 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
641
757
  yp_serialize_location(parser, &((yp_ensure_node_t *)node)->end_keyword_loc, buffer);
642
758
  break;
643
759
  }
644
- case YP_NODE_FALSE_NODE: {
760
+ case YP_FALSE_NODE: {
645
761
  break;
646
762
  }
647
- case YP_NODE_FIND_PATTERN_NODE: {
763
+ case YP_FIND_PATTERN_NODE: {
648
764
  if (((yp_find_pattern_node_t *)node)->constant == NULL) {
649
765
  yp_buffer_append_u8(buffer, 0);
650
766
  } else {
@@ -671,7 +787,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
671
787
  }
672
788
  break;
673
789
  }
674
- case YP_NODE_FLIP_FLOP_NODE: {
790
+ case YP_FLIP_FLOP_NODE: {
675
791
  if (((yp_flip_flop_node_t *)node)->left == NULL) {
676
792
  yp_buffer_append_u8(buffer, 0);
677
793
  } else {
@@ -686,10 +802,10 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
686
802
  yp_buffer_append_u32(buffer, node->flags >> 1);
687
803
  break;
688
804
  }
689
- case YP_NODE_FLOAT_NODE: {
805
+ case YP_FLOAT_NODE: {
690
806
  break;
691
807
  }
692
- case YP_NODE_FOR_NODE: {
808
+ case YP_FOR_NODE: {
693
809
  yp_serialize_node(parser, (yp_node_t *)((yp_for_node_t *)node)->index, buffer);
694
810
  yp_serialize_node(parser, (yp_node_t *)((yp_for_node_t *)node)->collection, buffer);
695
811
  if (((yp_for_node_t *)node)->statements == NULL) {
@@ -708,13 +824,13 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
708
824
  yp_serialize_location(parser, &((yp_for_node_t *)node)->end_keyword_loc, buffer);
709
825
  break;
710
826
  }
711
- case YP_NODE_FORWARDING_ARGUMENTS_NODE: {
827
+ case YP_FORWARDING_ARGUMENTS_NODE: {
712
828
  break;
713
829
  }
714
- case YP_NODE_FORWARDING_PARAMETER_NODE: {
830
+ case YP_FORWARDING_PARAMETER_NODE: {
715
831
  break;
716
832
  }
717
- case YP_NODE_FORWARDING_SUPER_NODE: {
833
+ case YP_FORWARDING_SUPER_NODE: {
718
834
  if (((yp_forwarding_super_node_t *)node)->block == NULL) {
719
835
  yp_buffer_append_u8(buffer, 0);
720
836
  } else {
@@ -722,38 +838,44 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
722
838
  }
723
839
  break;
724
840
  }
725
- case YP_NODE_GLOBAL_VARIABLE_AND_WRITE_NODE: {
841
+ case YP_GLOBAL_VARIABLE_AND_WRITE_NODE: {
842
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_global_variable_and_write_node_t *)node)->name));
726
843
  yp_serialize_location(parser, &((yp_global_variable_and_write_node_t *)node)->name_loc, buffer);
727
844
  yp_serialize_location(parser, &((yp_global_variable_and_write_node_t *)node)->operator_loc, buffer);
728
845
  yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_and_write_node_t *)node)->value, buffer);
729
846
  break;
730
847
  }
731
- case YP_NODE_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE: {
848
+ case YP_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE: {
849
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_global_variable_operator_write_node_t *)node)->name));
732
850
  yp_serialize_location(parser, &((yp_global_variable_operator_write_node_t *)node)->name_loc, buffer);
733
851
  yp_serialize_location(parser, &((yp_global_variable_operator_write_node_t *)node)->operator_loc, buffer);
734
852
  yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_operator_write_node_t *)node)->value, buffer);
735
853
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_global_variable_operator_write_node_t *)node)->operator));
736
854
  break;
737
855
  }
738
- case YP_NODE_GLOBAL_VARIABLE_OR_WRITE_NODE: {
856
+ case YP_GLOBAL_VARIABLE_OR_WRITE_NODE: {
857
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_global_variable_or_write_node_t *)node)->name));
739
858
  yp_serialize_location(parser, &((yp_global_variable_or_write_node_t *)node)->name_loc, buffer);
740
859
  yp_serialize_location(parser, &((yp_global_variable_or_write_node_t *)node)->operator_loc, buffer);
741
860
  yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_or_write_node_t *)node)->value, buffer);
742
861
  break;
743
862
  }
744
- case YP_NODE_GLOBAL_VARIABLE_READ_NODE: {
863
+ case YP_GLOBAL_VARIABLE_READ_NODE: {
864
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_global_variable_read_node_t *)node)->name));
745
865
  break;
746
866
  }
747
- case YP_NODE_GLOBAL_VARIABLE_TARGET_NODE: {
867
+ case YP_GLOBAL_VARIABLE_TARGET_NODE: {
868
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_global_variable_target_node_t *)node)->name));
748
869
  break;
749
870
  }
750
- case YP_NODE_GLOBAL_VARIABLE_WRITE_NODE: {
871
+ case YP_GLOBAL_VARIABLE_WRITE_NODE: {
872
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_global_variable_write_node_t *)node)->name));
751
873
  yp_serialize_location(parser, &((yp_global_variable_write_node_t *)node)->name_loc, buffer);
752
874
  yp_serialize_node(parser, (yp_node_t *)((yp_global_variable_write_node_t *)node)->value, buffer);
753
875
  yp_serialize_location(parser, &((yp_global_variable_write_node_t *)node)->operator_loc, buffer);
754
876
  break;
755
877
  }
756
- case YP_NODE_HASH_NODE: {
878
+ case YP_HASH_NODE: {
757
879
  yp_serialize_location(parser, &((yp_hash_node_t *)node)->opening_loc, buffer);
758
880
  uint32_t elements_size = yp_sizet_to_u32(((yp_hash_node_t *)node)->elements.size);
759
881
  yp_buffer_append_u32(buffer, elements_size);
@@ -763,7 +885,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
763
885
  yp_serialize_location(parser, &((yp_hash_node_t *)node)->closing_loc, buffer);
764
886
  break;
765
887
  }
766
- case YP_NODE_HASH_PATTERN_NODE: {
888
+ case YP_HASH_PATTERN_NODE: {
767
889
  if (((yp_hash_pattern_node_t *)node)->constant == NULL) {
768
890
  yp_buffer_append_u8(buffer, 0);
769
891
  } else {
@@ -793,7 +915,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
793
915
  }
794
916
  break;
795
917
  }
796
- case YP_NODE_IF_NODE: {
918
+ case YP_IF_NODE: {
797
919
  if (((yp_if_node_t *)node)->if_keyword_loc.start == NULL) {
798
920
  yp_buffer_append_u8(buffer, 0);
799
921
  } else {
@@ -819,11 +941,11 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
819
941
  }
820
942
  break;
821
943
  }
822
- case YP_NODE_IMAGINARY_NODE: {
944
+ case YP_IMAGINARY_NODE: {
823
945
  yp_serialize_node(parser, (yp_node_t *)((yp_imaginary_node_t *)node)->numeric, buffer);
824
946
  break;
825
947
  }
826
- case YP_NODE_IN_NODE: {
948
+ case YP_IN_NODE: {
827
949
  yp_serialize_node(parser, (yp_node_t *)((yp_in_node_t *)node)->pattern, buffer);
828
950
  if (((yp_in_node_t *)node)->statements == NULL) {
829
951
  yp_buffer_append_u8(buffer, 0);
@@ -839,14 +961,14 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
839
961
  }
840
962
  break;
841
963
  }
842
- case YP_NODE_INSTANCE_VARIABLE_AND_WRITE_NODE: {
964
+ case YP_INSTANCE_VARIABLE_AND_WRITE_NODE: {
843
965
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_instance_variable_and_write_node_t *)node)->name));
844
966
  yp_serialize_location(parser, &((yp_instance_variable_and_write_node_t *)node)->name_loc, buffer);
845
967
  yp_serialize_location(parser, &((yp_instance_variable_and_write_node_t *)node)->operator_loc, buffer);
846
968
  yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_and_write_node_t *)node)->value, buffer);
847
969
  break;
848
970
  }
849
- case YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE: {
971
+ case YP_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE: {
850
972
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_instance_variable_operator_write_node_t *)node)->name));
851
973
  yp_serialize_location(parser, &((yp_instance_variable_operator_write_node_t *)node)->name_loc, buffer);
852
974
  yp_serialize_location(parser, &((yp_instance_variable_operator_write_node_t *)node)->operator_loc, buffer);
@@ -854,32 +976,32 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
854
976
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_instance_variable_operator_write_node_t *)node)->operator));
855
977
  break;
856
978
  }
857
- case YP_NODE_INSTANCE_VARIABLE_OR_WRITE_NODE: {
979
+ case YP_INSTANCE_VARIABLE_OR_WRITE_NODE: {
858
980
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_instance_variable_or_write_node_t *)node)->name));
859
981
  yp_serialize_location(parser, &((yp_instance_variable_or_write_node_t *)node)->name_loc, buffer);
860
982
  yp_serialize_location(parser, &((yp_instance_variable_or_write_node_t *)node)->operator_loc, buffer);
861
983
  yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_or_write_node_t *)node)->value, buffer);
862
984
  break;
863
985
  }
864
- case YP_NODE_INSTANCE_VARIABLE_READ_NODE: {
986
+ case YP_INSTANCE_VARIABLE_READ_NODE: {
865
987
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_instance_variable_read_node_t *)node)->name));
866
988
  break;
867
989
  }
868
- case YP_NODE_INSTANCE_VARIABLE_TARGET_NODE: {
990
+ case YP_INSTANCE_VARIABLE_TARGET_NODE: {
869
991
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_instance_variable_target_node_t *)node)->name));
870
992
  break;
871
993
  }
872
- case YP_NODE_INSTANCE_VARIABLE_WRITE_NODE: {
994
+ case YP_INSTANCE_VARIABLE_WRITE_NODE: {
873
995
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_instance_variable_write_node_t *)node)->name));
874
996
  yp_serialize_location(parser, &((yp_instance_variable_write_node_t *)node)->name_loc, buffer);
875
997
  yp_serialize_node(parser, (yp_node_t *)((yp_instance_variable_write_node_t *)node)->value, buffer);
876
998
  yp_serialize_location(parser, &((yp_instance_variable_write_node_t *)node)->operator_loc, buffer);
877
999
  break;
878
1000
  }
879
- case YP_NODE_INTEGER_NODE: {
1001
+ case YP_INTEGER_NODE: {
880
1002
  break;
881
1003
  }
882
- case YP_NODE_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
1004
+ case YP_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
883
1005
  yp_serialize_location(parser, &((yp_interpolated_regular_expression_node_t *)node)->opening_loc, buffer);
884
1006
  uint32_t parts_size = yp_sizet_to_u32(((yp_interpolated_regular_expression_node_t *)node)->parts.size);
885
1007
  yp_buffer_append_u32(buffer, parts_size);
@@ -890,7 +1012,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
890
1012
  yp_buffer_append_u32(buffer, node->flags >> 1);
891
1013
  break;
892
1014
  }
893
- case YP_NODE_INTERPOLATED_STRING_NODE: {
1015
+ case YP_INTERPOLATED_STRING_NODE: {
894
1016
  if (((yp_interpolated_string_node_t *)node)->opening_loc.start == NULL) {
895
1017
  yp_buffer_append_u8(buffer, 0);
896
1018
  } else {
@@ -910,7 +1032,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
910
1032
  }
911
1033
  break;
912
1034
  }
913
- case YP_NODE_INTERPOLATED_SYMBOL_NODE: {
1035
+ case YP_INTERPOLATED_SYMBOL_NODE: {
914
1036
  if (((yp_interpolated_symbol_node_t *)node)->opening_loc.start == NULL) {
915
1037
  yp_buffer_append_u8(buffer, 0);
916
1038
  } else {
@@ -930,7 +1052,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
930
1052
  }
931
1053
  break;
932
1054
  }
933
- case YP_NODE_INTERPOLATED_X_STRING_NODE: {
1055
+ case YP_INTERPOLATED_X_STRING_NODE: {
934
1056
  yp_serialize_location(parser, &((yp_interpolated_x_string_node_t *)node)->opening_loc, buffer);
935
1057
  uint32_t parts_size = yp_sizet_to_u32(((yp_interpolated_x_string_node_t *)node)->parts.size);
936
1058
  yp_buffer_append_u32(buffer, parts_size);
@@ -940,7 +1062,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
940
1062
  yp_serialize_location(parser, &((yp_interpolated_x_string_node_t *)node)->closing_loc, buffer);
941
1063
  break;
942
1064
  }
943
- case YP_NODE_KEYWORD_HASH_NODE: {
1065
+ case YP_KEYWORD_HASH_NODE: {
944
1066
  uint32_t elements_size = yp_sizet_to_u32(((yp_keyword_hash_node_t *)node)->elements.size);
945
1067
  yp_buffer_append_u32(buffer, elements_size);
946
1068
  for (uint32_t index = 0; index < elements_size; index++) {
@@ -948,7 +1070,8 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
948
1070
  }
949
1071
  break;
950
1072
  }
951
- case YP_NODE_KEYWORD_PARAMETER_NODE: {
1073
+ case YP_KEYWORD_PARAMETER_NODE: {
1074
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_keyword_parameter_node_t *)node)->name));
952
1075
  yp_serialize_location(parser, &((yp_keyword_parameter_node_t *)node)->name_loc, buffer);
953
1076
  if (((yp_keyword_parameter_node_t *)node)->value == NULL) {
954
1077
  yp_buffer_append_u8(buffer, 0);
@@ -957,17 +1080,18 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
957
1080
  }
958
1081
  break;
959
1082
  }
960
- case YP_NODE_KEYWORD_REST_PARAMETER_NODE: {
961
- yp_serialize_location(parser, &((yp_keyword_rest_parameter_node_t *)node)->operator_loc, buffer);
1083
+ case YP_KEYWORD_REST_PARAMETER_NODE: {
1084
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_keyword_rest_parameter_node_t *)node)->name));
962
1085
  if (((yp_keyword_rest_parameter_node_t *)node)->name_loc.start == NULL) {
963
1086
  yp_buffer_append_u8(buffer, 0);
964
1087
  } else {
965
1088
  yp_buffer_append_u8(buffer, 1);
966
1089
  yp_serialize_location(parser, &((yp_keyword_rest_parameter_node_t *)node)->name_loc, buffer);
967
1090
  }
1091
+ yp_serialize_location(parser, &((yp_keyword_rest_parameter_node_t *)node)->operator_loc, buffer);
968
1092
  break;
969
1093
  }
970
- case YP_NODE_LAMBDA_NODE: {
1094
+ case YP_LAMBDA_NODE: {
971
1095
  uint32_t locals_size = yp_sizet_to_u32(((yp_lambda_node_t *)node)->locals.size);
972
1096
  yp_buffer_append_u32(buffer, locals_size);
973
1097
  for (uint32_t index = 0; index < locals_size; index++) {
@@ -988,7 +1112,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
988
1112
  }
989
1113
  break;
990
1114
  }
991
- case YP_NODE_LOCAL_VARIABLE_AND_WRITE_NODE: {
1115
+ case YP_LOCAL_VARIABLE_AND_WRITE_NODE: {
992
1116
  yp_serialize_location(parser, &((yp_local_variable_and_write_node_t *)node)->name_loc, buffer);
993
1117
  yp_serialize_location(parser, &((yp_local_variable_and_write_node_t *)node)->operator_loc, buffer);
994
1118
  yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_and_write_node_t *)node)->value, buffer);
@@ -996,7 +1120,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
996
1120
  yp_buffer_append_u32(buffer, ((yp_local_variable_and_write_node_t *)node)->depth);
997
1121
  break;
998
1122
  }
999
- case YP_NODE_LOCAL_VARIABLE_OPERATOR_WRITE_NODE: {
1123
+ case YP_LOCAL_VARIABLE_OPERATOR_WRITE_NODE: {
1000
1124
  yp_serialize_location(parser, &((yp_local_variable_operator_write_node_t *)node)->name_loc, buffer);
1001
1125
  yp_serialize_location(parser, &((yp_local_variable_operator_write_node_t *)node)->operator_loc, buffer);
1002
1126
  yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_operator_write_node_t *)node)->value, buffer);
@@ -1005,7 +1129,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1005
1129
  yp_buffer_append_u32(buffer, ((yp_local_variable_operator_write_node_t *)node)->depth);
1006
1130
  break;
1007
1131
  }
1008
- case YP_NODE_LOCAL_VARIABLE_OR_WRITE_NODE: {
1132
+ case YP_LOCAL_VARIABLE_OR_WRITE_NODE: {
1009
1133
  yp_serialize_location(parser, &((yp_local_variable_or_write_node_t *)node)->name_loc, buffer);
1010
1134
  yp_serialize_location(parser, &((yp_local_variable_or_write_node_t *)node)->operator_loc, buffer);
1011
1135
  yp_serialize_node(parser, (yp_node_t *)((yp_local_variable_or_write_node_t *)node)->value, buffer);
@@ -1013,17 +1137,17 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1013
1137
  yp_buffer_append_u32(buffer, ((yp_local_variable_or_write_node_t *)node)->depth);
1014
1138
  break;
1015
1139
  }
1016
- case YP_NODE_LOCAL_VARIABLE_READ_NODE: {
1140
+ case YP_LOCAL_VARIABLE_READ_NODE: {
1017
1141
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_read_node_t *)node)->name));
1018
1142
  yp_buffer_append_u32(buffer, ((yp_local_variable_read_node_t *)node)->depth);
1019
1143
  break;
1020
1144
  }
1021
- case YP_NODE_LOCAL_VARIABLE_TARGET_NODE: {
1145
+ case YP_LOCAL_VARIABLE_TARGET_NODE: {
1022
1146
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_target_node_t *)node)->name));
1023
1147
  yp_buffer_append_u32(buffer, ((yp_local_variable_target_node_t *)node)->depth);
1024
1148
  break;
1025
1149
  }
1026
- case YP_NODE_LOCAL_VARIABLE_WRITE_NODE: {
1150
+ case YP_LOCAL_VARIABLE_WRITE_NODE: {
1027
1151
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_local_variable_write_node_t *)node)->name));
1028
1152
  yp_buffer_append_u32(buffer, ((yp_local_variable_write_node_t *)node)->depth);
1029
1153
  yp_serialize_location(parser, &((yp_local_variable_write_node_t *)node)->name_loc, buffer);
@@ -1031,22 +1155,22 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1031
1155
  yp_serialize_location(parser, &((yp_local_variable_write_node_t *)node)->operator_loc, buffer);
1032
1156
  break;
1033
1157
  }
1034
- case YP_NODE_MATCH_PREDICATE_NODE: {
1158
+ case YP_MATCH_PREDICATE_NODE: {
1035
1159
  yp_serialize_node(parser, (yp_node_t *)((yp_match_predicate_node_t *)node)->value, buffer);
1036
1160
  yp_serialize_node(parser, (yp_node_t *)((yp_match_predicate_node_t *)node)->pattern, buffer);
1037
1161
  yp_serialize_location(parser, &((yp_match_predicate_node_t *)node)->operator_loc, buffer);
1038
1162
  break;
1039
1163
  }
1040
- case YP_NODE_MATCH_REQUIRED_NODE: {
1164
+ case YP_MATCH_REQUIRED_NODE: {
1041
1165
  yp_serialize_node(parser, (yp_node_t *)((yp_match_required_node_t *)node)->value, buffer);
1042
1166
  yp_serialize_node(parser, (yp_node_t *)((yp_match_required_node_t *)node)->pattern, buffer);
1043
1167
  yp_serialize_location(parser, &((yp_match_required_node_t *)node)->operator_loc, buffer);
1044
1168
  break;
1045
1169
  }
1046
- case YP_NODE_MISSING_NODE: {
1170
+ case YP_MISSING_NODE: {
1047
1171
  break;
1048
1172
  }
1049
- case YP_NODE_MODULE_NODE: {
1173
+ case YP_MODULE_NODE: {
1050
1174
  uint32_t locals_size = yp_sizet_to_u32(((yp_module_node_t *)node)->locals.size);
1051
1175
  yp_buffer_append_u32(buffer, locals_size);
1052
1176
  for (uint32_t index = 0; index < locals_size; index++) {
@@ -1060,25 +1184,34 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1060
1184
  yp_serialize_node(parser, (yp_node_t *)((yp_module_node_t *)node)->body, buffer);
1061
1185
  }
1062
1186
  yp_serialize_location(parser, &((yp_module_node_t *)node)->end_keyword_loc, buffer);
1063
- yp_serialize_string(parser, &((yp_module_node_t *)node)->name, buffer);
1187
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_module_node_t *)node)->name));
1064
1188
  break;
1065
1189
  }
1066
- case YP_NODE_MULTI_WRITE_NODE: {
1067
- uint32_t targets_size = yp_sizet_to_u32(((yp_multi_write_node_t *)node)->targets.size);
1190
+ case YP_MULTI_TARGET_NODE: {
1191
+ uint32_t targets_size = yp_sizet_to_u32(((yp_multi_target_node_t *)node)->targets.size);
1068
1192
  yp_buffer_append_u32(buffer, targets_size);
1069
1193
  for (uint32_t index = 0; index < targets_size; index++) {
1070
- yp_serialize_node(parser, (yp_node_t *) ((yp_multi_write_node_t *)node)->targets.nodes[index], buffer);
1194
+ yp_serialize_node(parser, (yp_node_t *) ((yp_multi_target_node_t *)node)->targets.nodes[index], buffer);
1071
1195
  }
1072
- if (((yp_multi_write_node_t *)node)->operator_loc.start == NULL) {
1196
+ if (((yp_multi_target_node_t *)node)->lparen_loc.start == NULL) {
1073
1197
  yp_buffer_append_u8(buffer, 0);
1074
1198
  } else {
1075
1199
  yp_buffer_append_u8(buffer, 1);
1076
- yp_serialize_location(parser, &((yp_multi_write_node_t *)node)->operator_loc, buffer);
1200
+ yp_serialize_location(parser, &((yp_multi_target_node_t *)node)->lparen_loc, buffer);
1077
1201
  }
1078
- if (((yp_multi_write_node_t *)node)->value == NULL) {
1202
+ if (((yp_multi_target_node_t *)node)->rparen_loc.start == NULL) {
1079
1203
  yp_buffer_append_u8(buffer, 0);
1080
1204
  } else {
1081
- yp_serialize_node(parser, (yp_node_t *)((yp_multi_write_node_t *)node)->value, buffer);
1205
+ yp_buffer_append_u8(buffer, 1);
1206
+ yp_serialize_location(parser, &((yp_multi_target_node_t *)node)->rparen_loc, buffer);
1207
+ }
1208
+ break;
1209
+ }
1210
+ case YP_MULTI_WRITE_NODE: {
1211
+ uint32_t targets_size = yp_sizet_to_u32(((yp_multi_write_node_t *)node)->targets.size);
1212
+ yp_buffer_append_u32(buffer, targets_size);
1213
+ for (uint32_t index = 0; index < targets_size; index++) {
1214
+ yp_serialize_node(parser, (yp_node_t *) ((yp_multi_write_node_t *)node)->targets.nodes[index], buffer);
1082
1215
  }
1083
1216
  if (((yp_multi_write_node_t *)node)->lparen_loc.start == NULL) {
1084
1217
  yp_buffer_append_u8(buffer, 0);
@@ -1092,9 +1225,11 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1092
1225
  yp_buffer_append_u8(buffer, 1);
1093
1226
  yp_serialize_location(parser, &((yp_multi_write_node_t *)node)->rparen_loc, buffer);
1094
1227
  }
1228
+ yp_serialize_location(parser, &((yp_multi_write_node_t *)node)->operator_loc, buffer);
1229
+ yp_serialize_node(parser, (yp_node_t *)((yp_multi_write_node_t *)node)->value, buffer);
1095
1230
  break;
1096
1231
  }
1097
- case YP_NODE_NEXT_NODE: {
1232
+ case YP_NEXT_NODE: {
1098
1233
  if (((yp_next_node_t *)node)->arguments == NULL) {
1099
1234
  yp_buffer_append_u8(buffer, 0);
1100
1235
  } else {
@@ -1103,32 +1238,32 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1103
1238
  yp_serialize_location(parser, &((yp_next_node_t *)node)->keyword_loc, buffer);
1104
1239
  break;
1105
1240
  }
1106
- case YP_NODE_NIL_NODE: {
1241
+ case YP_NIL_NODE: {
1107
1242
  break;
1108
1243
  }
1109
- case YP_NODE_NO_KEYWORDS_PARAMETER_NODE: {
1244
+ case YP_NO_KEYWORDS_PARAMETER_NODE: {
1110
1245
  yp_serialize_location(parser, &((yp_no_keywords_parameter_node_t *)node)->operator_loc, buffer);
1111
1246
  yp_serialize_location(parser, &((yp_no_keywords_parameter_node_t *)node)->keyword_loc, buffer);
1112
1247
  break;
1113
1248
  }
1114
- case YP_NODE_NUMBERED_REFERENCE_READ_NODE: {
1249
+ case YP_NUMBERED_REFERENCE_READ_NODE: {
1115
1250
  yp_buffer_append_u32(buffer, ((yp_numbered_reference_read_node_t *)node)->number);
1116
1251
  break;
1117
1252
  }
1118
- case YP_NODE_OPTIONAL_PARAMETER_NODE: {
1253
+ case YP_OPTIONAL_PARAMETER_NODE: {
1119
1254
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_optional_parameter_node_t *)node)->name));
1120
1255
  yp_serialize_location(parser, &((yp_optional_parameter_node_t *)node)->name_loc, buffer);
1121
1256
  yp_serialize_location(parser, &((yp_optional_parameter_node_t *)node)->operator_loc, buffer);
1122
1257
  yp_serialize_node(parser, (yp_node_t *)((yp_optional_parameter_node_t *)node)->value, buffer);
1123
1258
  break;
1124
1259
  }
1125
- case YP_NODE_OR_NODE: {
1260
+ case YP_OR_NODE: {
1126
1261
  yp_serialize_node(parser, (yp_node_t *)((yp_or_node_t *)node)->left, buffer);
1127
1262
  yp_serialize_node(parser, (yp_node_t *)((yp_or_node_t *)node)->right, buffer);
1128
1263
  yp_serialize_location(parser, &((yp_or_node_t *)node)->operator_loc, buffer);
1129
1264
  break;
1130
1265
  }
1131
- case YP_NODE_PARAMETERS_NODE: {
1266
+ case YP_PARAMETERS_NODE: {
1132
1267
  uint32_t requireds_size = yp_sizet_to_u32(((yp_parameters_node_t *)node)->requireds.size);
1133
1268
  yp_buffer_append_u32(buffer, requireds_size);
1134
1269
  for (uint32_t index = 0; index < requireds_size; index++) {
@@ -1166,7 +1301,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1166
1301
  }
1167
1302
  break;
1168
1303
  }
1169
- case YP_NODE_PARENTHESES_NODE: {
1304
+ case YP_PARENTHESES_NODE: {
1170
1305
  if (((yp_parentheses_node_t *)node)->body == NULL) {
1171
1306
  yp_buffer_append_u8(buffer, 0);
1172
1307
  } else {
@@ -1176,19 +1311,19 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1176
1311
  yp_serialize_location(parser, &((yp_parentheses_node_t *)node)->closing_loc, buffer);
1177
1312
  break;
1178
1313
  }
1179
- case YP_NODE_PINNED_EXPRESSION_NODE: {
1314
+ case YP_PINNED_EXPRESSION_NODE: {
1180
1315
  yp_serialize_node(parser, (yp_node_t *)((yp_pinned_expression_node_t *)node)->expression, buffer);
1181
1316
  yp_serialize_location(parser, &((yp_pinned_expression_node_t *)node)->operator_loc, buffer);
1182
1317
  yp_serialize_location(parser, &((yp_pinned_expression_node_t *)node)->lparen_loc, buffer);
1183
1318
  yp_serialize_location(parser, &((yp_pinned_expression_node_t *)node)->rparen_loc, buffer);
1184
1319
  break;
1185
1320
  }
1186
- case YP_NODE_PINNED_VARIABLE_NODE: {
1321
+ case YP_PINNED_VARIABLE_NODE: {
1187
1322
  yp_serialize_node(parser, (yp_node_t *)((yp_pinned_variable_node_t *)node)->variable, buffer);
1188
1323
  yp_serialize_location(parser, &((yp_pinned_variable_node_t *)node)->operator_loc, buffer);
1189
1324
  break;
1190
1325
  }
1191
- case YP_NODE_POST_EXECUTION_NODE: {
1326
+ case YP_POST_EXECUTION_NODE: {
1192
1327
  if (((yp_post_execution_node_t *)node)->statements == NULL) {
1193
1328
  yp_buffer_append_u8(buffer, 0);
1194
1329
  } else {
@@ -1199,7 +1334,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1199
1334
  yp_serialize_location(parser, &((yp_post_execution_node_t *)node)->closing_loc, buffer);
1200
1335
  break;
1201
1336
  }
1202
- case YP_NODE_PRE_EXECUTION_NODE: {
1337
+ case YP_PRE_EXECUTION_NODE: {
1203
1338
  if (((yp_pre_execution_node_t *)node)->statements == NULL) {
1204
1339
  yp_buffer_append_u8(buffer, 0);
1205
1340
  } else {
@@ -1210,7 +1345,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1210
1345
  yp_serialize_location(parser, &((yp_pre_execution_node_t *)node)->closing_loc, buffer);
1211
1346
  break;
1212
1347
  }
1213
- case YP_NODE_PROGRAM_NODE: {
1348
+ case YP_PROGRAM_NODE: {
1214
1349
  uint32_t locals_size = yp_sizet_to_u32(((yp_program_node_t *)node)->locals.size);
1215
1350
  yp_buffer_append_u32(buffer, locals_size);
1216
1351
  for (uint32_t index = 0; index < locals_size; index++) {
@@ -1219,7 +1354,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1219
1354
  yp_serialize_node(parser, (yp_node_t *)((yp_program_node_t *)node)->statements, buffer);
1220
1355
  break;
1221
1356
  }
1222
- case YP_NODE_RANGE_NODE: {
1357
+ case YP_RANGE_NODE: {
1223
1358
  if (((yp_range_node_t *)node)->left == NULL) {
1224
1359
  yp_buffer_append_u8(buffer, 0);
1225
1360
  } else {
@@ -1234,14 +1369,14 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1234
1369
  yp_buffer_append_u32(buffer, node->flags >> 1);
1235
1370
  break;
1236
1371
  }
1237
- case YP_NODE_RATIONAL_NODE: {
1372
+ case YP_RATIONAL_NODE: {
1238
1373
  yp_serialize_node(parser, (yp_node_t *)((yp_rational_node_t *)node)->numeric, buffer);
1239
1374
  break;
1240
1375
  }
1241
- case YP_NODE_REDO_NODE: {
1376
+ case YP_REDO_NODE: {
1242
1377
  break;
1243
1378
  }
1244
- case YP_NODE_REGULAR_EXPRESSION_NODE: {
1379
+ case YP_REGULAR_EXPRESSION_NODE: {
1245
1380
  yp_serialize_location(parser, &((yp_regular_expression_node_t *)node)->opening_loc, buffer);
1246
1381
  yp_serialize_location(parser, &((yp_regular_expression_node_t *)node)->content_loc, buffer);
1247
1382
  yp_serialize_location(parser, &((yp_regular_expression_node_t *)node)->closing_loc, buffer);
@@ -1249,7 +1384,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1249
1384
  yp_buffer_append_u32(buffer, node->flags >> 1);
1250
1385
  break;
1251
1386
  }
1252
- case YP_NODE_REQUIRED_DESTRUCTURED_PARAMETER_NODE: {
1387
+ case YP_REQUIRED_DESTRUCTURED_PARAMETER_NODE: {
1253
1388
  uint32_t parameters_size = yp_sizet_to_u32(((yp_required_destructured_parameter_node_t *)node)->parameters.size);
1254
1389
  yp_buffer_append_u32(buffer, parameters_size);
1255
1390
  for (uint32_t index = 0; index < parameters_size; index++) {
@@ -1259,17 +1394,17 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1259
1394
  yp_serialize_location(parser, &((yp_required_destructured_parameter_node_t *)node)->closing_loc, buffer);
1260
1395
  break;
1261
1396
  }
1262
- case YP_NODE_REQUIRED_PARAMETER_NODE: {
1397
+ case YP_REQUIRED_PARAMETER_NODE: {
1263
1398
  yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_required_parameter_node_t *)node)->name));
1264
1399
  break;
1265
1400
  }
1266
- case YP_NODE_RESCUE_MODIFIER_NODE: {
1401
+ case YP_RESCUE_MODIFIER_NODE: {
1267
1402
  yp_serialize_node(parser, (yp_node_t *)((yp_rescue_modifier_node_t *)node)->expression, buffer);
1268
1403
  yp_serialize_location(parser, &((yp_rescue_modifier_node_t *)node)->keyword_loc, buffer);
1269
1404
  yp_serialize_node(parser, (yp_node_t *)((yp_rescue_modifier_node_t *)node)->rescue_expression, buffer);
1270
1405
  break;
1271
1406
  }
1272
- case YP_NODE_RESCUE_NODE: {
1407
+ case YP_RESCUE_NODE: {
1273
1408
  yp_serialize_location(parser, &((yp_rescue_node_t *)node)->keyword_loc, buffer);
1274
1409
  uint32_t exceptions_size = yp_sizet_to_u32(((yp_rescue_node_t *)node)->exceptions.size);
1275
1410
  yp_buffer_append_u32(buffer, exceptions_size);
@@ -1299,20 +1434,21 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1299
1434
  }
1300
1435
  break;
1301
1436
  }
1302
- case YP_NODE_REST_PARAMETER_NODE: {
1303
- yp_serialize_location(parser, &((yp_rest_parameter_node_t *)node)->operator_loc, buffer);
1437
+ case YP_REST_PARAMETER_NODE: {
1438
+ yp_buffer_append_u32(buffer, yp_sizet_to_u32(((yp_rest_parameter_node_t *)node)->name));
1304
1439
  if (((yp_rest_parameter_node_t *)node)->name_loc.start == NULL) {
1305
1440
  yp_buffer_append_u8(buffer, 0);
1306
1441
  } else {
1307
1442
  yp_buffer_append_u8(buffer, 1);
1308
1443
  yp_serialize_location(parser, &((yp_rest_parameter_node_t *)node)->name_loc, buffer);
1309
1444
  }
1445
+ yp_serialize_location(parser, &((yp_rest_parameter_node_t *)node)->operator_loc, buffer);
1310
1446
  break;
1311
1447
  }
1312
- case YP_NODE_RETRY_NODE: {
1448
+ case YP_RETRY_NODE: {
1313
1449
  break;
1314
1450
  }
1315
- case YP_NODE_RETURN_NODE: {
1451
+ case YP_RETURN_NODE: {
1316
1452
  yp_serialize_location(parser, &((yp_return_node_t *)node)->keyword_loc, buffer);
1317
1453
  if (((yp_return_node_t *)node)->arguments == NULL) {
1318
1454
  yp_buffer_append_u8(buffer, 0);
@@ -1321,10 +1457,10 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1321
1457
  }
1322
1458
  break;
1323
1459
  }
1324
- case YP_NODE_SELF_NODE: {
1460
+ case YP_SELF_NODE: {
1325
1461
  break;
1326
1462
  }
1327
- case YP_NODE_SINGLETON_CLASS_NODE: {
1463
+ case YP_SINGLETON_CLASS_NODE: {
1328
1464
  uint32_t locals_size = yp_sizet_to_u32(((yp_singleton_class_node_t *)node)->locals.size);
1329
1465
  yp_buffer_append_u32(buffer, locals_size);
1330
1466
  for (uint32_t index = 0; index < locals_size; index++) {
@@ -1341,17 +1477,17 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1341
1477
  yp_serialize_location(parser, &((yp_singleton_class_node_t *)node)->end_keyword_loc, buffer);
1342
1478
  break;
1343
1479
  }
1344
- case YP_NODE_SOURCE_ENCODING_NODE: {
1480
+ case YP_SOURCE_ENCODING_NODE: {
1345
1481
  break;
1346
1482
  }
1347
- case YP_NODE_SOURCE_FILE_NODE: {
1483
+ case YP_SOURCE_FILE_NODE: {
1348
1484
  yp_serialize_string(parser, &((yp_source_file_node_t *)node)->filepath, buffer);
1349
1485
  break;
1350
1486
  }
1351
- case YP_NODE_SOURCE_LINE_NODE: {
1487
+ case YP_SOURCE_LINE_NODE: {
1352
1488
  break;
1353
1489
  }
1354
- case YP_NODE_SPLAT_NODE: {
1490
+ case YP_SPLAT_NODE: {
1355
1491
  yp_serialize_location(parser, &((yp_splat_node_t *)node)->operator_loc, buffer);
1356
1492
  if (((yp_splat_node_t *)node)->expression == NULL) {
1357
1493
  yp_buffer_append_u8(buffer, 0);
@@ -1360,7 +1496,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1360
1496
  }
1361
1497
  break;
1362
1498
  }
1363
- case YP_NODE_STATEMENTS_NODE: {
1499
+ case YP_STATEMENTS_NODE: {
1364
1500
  uint32_t body_size = yp_sizet_to_u32(((yp_statements_node_t *)node)->body.size);
1365
1501
  yp_buffer_append_u32(buffer, body_size);
1366
1502
  for (uint32_t index = 0; index < body_size; index++) {
@@ -1368,12 +1504,12 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1368
1504
  }
1369
1505
  break;
1370
1506
  }
1371
- case YP_NODE_STRING_CONCAT_NODE: {
1507
+ case YP_STRING_CONCAT_NODE: {
1372
1508
  yp_serialize_node(parser, (yp_node_t *)((yp_string_concat_node_t *)node)->left, buffer);
1373
1509
  yp_serialize_node(parser, (yp_node_t *)((yp_string_concat_node_t *)node)->right, buffer);
1374
1510
  break;
1375
1511
  }
1376
- case YP_NODE_STRING_NODE: {
1512
+ case YP_STRING_NODE: {
1377
1513
  if (((yp_string_node_t *)node)->opening_loc.start == NULL) {
1378
1514
  yp_buffer_append_u8(buffer, 0);
1379
1515
  } else {
@@ -1390,7 +1526,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1390
1526
  yp_serialize_string(parser, &((yp_string_node_t *)node)->unescaped, buffer);
1391
1527
  break;
1392
1528
  }
1393
- case YP_NODE_SUPER_NODE: {
1529
+ case YP_SUPER_NODE: {
1394
1530
  yp_serialize_location(parser, &((yp_super_node_t *)node)->keyword_loc, buffer);
1395
1531
  if (((yp_super_node_t *)node)->lparen_loc.start == NULL) {
1396
1532
  yp_buffer_append_u8(buffer, 0);
@@ -1416,7 +1552,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1416
1552
  }
1417
1553
  break;
1418
1554
  }
1419
- case YP_NODE_SYMBOL_NODE: {
1555
+ case YP_SYMBOL_NODE: {
1420
1556
  if (((yp_symbol_node_t *)node)->opening_loc.start == NULL) {
1421
1557
  yp_buffer_append_u8(buffer, 0);
1422
1558
  } else {
@@ -1438,10 +1574,10 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1438
1574
  yp_serialize_string(parser, &((yp_symbol_node_t *)node)->unescaped, buffer);
1439
1575
  break;
1440
1576
  }
1441
- case YP_NODE_TRUE_NODE: {
1577
+ case YP_TRUE_NODE: {
1442
1578
  break;
1443
1579
  }
1444
- case YP_NODE_UNDEF_NODE: {
1580
+ case YP_UNDEF_NODE: {
1445
1581
  uint32_t names_size = yp_sizet_to_u32(((yp_undef_node_t *)node)->names.size);
1446
1582
  yp_buffer_append_u32(buffer, names_size);
1447
1583
  for (uint32_t index = 0; index < names_size; index++) {
@@ -1450,7 +1586,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1450
1586
  yp_serialize_location(parser, &((yp_undef_node_t *)node)->keyword_loc, buffer);
1451
1587
  break;
1452
1588
  }
1453
- case YP_NODE_UNLESS_NODE: {
1589
+ case YP_UNLESS_NODE: {
1454
1590
  yp_serialize_location(parser, &((yp_unless_node_t *)node)->keyword_loc, buffer);
1455
1591
  yp_serialize_node(parser, (yp_node_t *)((yp_unless_node_t *)node)->predicate, buffer);
1456
1592
  if (((yp_unless_node_t *)node)->statements == NULL) {
@@ -1471,7 +1607,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1471
1607
  }
1472
1608
  break;
1473
1609
  }
1474
- case YP_NODE_UNTIL_NODE: {
1610
+ case YP_UNTIL_NODE: {
1475
1611
  yp_serialize_location(parser, &((yp_until_node_t *)node)->keyword_loc, buffer);
1476
1612
  if (((yp_until_node_t *)node)->closing_loc.start == NULL) {
1477
1613
  yp_buffer_append_u8(buffer, 0);
@@ -1488,7 +1624,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1488
1624
  yp_buffer_append_u32(buffer, node->flags >> 1);
1489
1625
  break;
1490
1626
  }
1491
- case YP_NODE_WHEN_NODE: {
1627
+ case YP_WHEN_NODE: {
1492
1628
  yp_serialize_location(parser, &((yp_when_node_t *)node)->keyword_loc, buffer);
1493
1629
  uint32_t conditions_size = yp_sizet_to_u32(((yp_when_node_t *)node)->conditions.size);
1494
1630
  yp_buffer_append_u32(buffer, conditions_size);
@@ -1502,7 +1638,7 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1502
1638
  }
1503
1639
  break;
1504
1640
  }
1505
- case YP_NODE_WHILE_NODE: {
1641
+ case YP_WHILE_NODE: {
1506
1642
  yp_serialize_location(parser, &((yp_while_node_t *)node)->keyword_loc, buffer);
1507
1643
  if (((yp_while_node_t *)node)->closing_loc.start == NULL) {
1508
1644
  yp_buffer_append_u8(buffer, 0);
@@ -1519,14 +1655,14 @@ yp_serialize_node(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1519
1655
  yp_buffer_append_u32(buffer, node->flags >> 1);
1520
1656
  break;
1521
1657
  }
1522
- case YP_NODE_X_STRING_NODE: {
1658
+ case YP_X_STRING_NODE: {
1523
1659
  yp_serialize_location(parser, &((yp_x_string_node_t *)node)->opening_loc, buffer);
1524
1660
  yp_serialize_location(parser, &((yp_x_string_node_t *)node)->content_loc, buffer);
1525
1661
  yp_serialize_location(parser, &((yp_x_string_node_t *)node)->closing_loc, buffer);
1526
1662
  yp_serialize_string(parser, &((yp_x_string_node_t *)node)->unescaped, buffer);
1527
1663
  break;
1528
1664
  }
1529
- case YP_NODE_YIELD_NODE: {
1665
+ case YP_YIELD_NODE: {
1530
1666
  yp_serialize_location(parser, &((yp_yield_node_t *)node)->keyword_loc, buffer);
1531
1667
  if (((yp_yield_node_t *)node)->lparen_loc.start == NULL) {
1532
1668
  yp_buffer_append_u8(buffer, 0);
@@ -1599,7 +1735,7 @@ yp_serialize_encoding(yp_encoding_t *encoding, yp_buffer_t *buffer) {
1599
1735
  yp_buffer_append_str(buffer, encoding->name, encoding_length);
1600
1736
  }
1601
1737
 
1602
- #line 181 "serialize.c.erb"
1738
+ #line 175 "serialize.c.erb"
1603
1739
  void
1604
1740
  yp_serialize_content(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer) {
1605
1741
  yp_serialize_encoding(&parser->encoding, buffer);
@@ -1634,12 +1770,31 @@ yp_serialize_content(yp_parser_t *parser, yp_node_t *node, yp_buffer_t *buffer)
1634
1770
  // If we find a constant at this index, serialize it at the correct
1635
1771
  // index in the buffer.
1636
1772
  if (constant->id != 0) {
1637
- size_t buffer_offset = offset + ((constant->id - 1) * 8);
1773
+ size_t buffer_offset = offset + ((((size_t) constant->id) - 1) * 8);
1638
1774
 
1639
- uint32_t source_offset = yp_ptrdifft_to_u32(constant->start - parser->start);
1640
- uint32_t constant_length = yp_sizet_to_u32(constant->length);
1775
+ if (constant->owned) {
1776
+ // Since this is an owned constant, we are going to write its
1777
+ // contents into the buffer after the constant pool. So
1778
+ // effectively in place of the source offset, we have a buffer
1779
+ // offset. We will add a leading 1 to indicate that this is a
1780
+ // buffer offset.
1781
+ uint32_t content_offset = yp_sizet_to_u32(buffer->length);
1782
+ uint32_t owned_mask = (uint32_t) (1 << 31);
1783
+
1784
+ assert(content_offset < owned_mask);
1785
+ content_offset |= owned_mask;
1786
+
1787
+ memcpy(buffer->value + buffer_offset, &content_offset, 4);
1788
+ yp_buffer_append_bytes(buffer, constant->start, constant->length);
1789
+ } else {
1790
+ // Since this is a shared constant, we are going to write its
1791
+ // source offset directly into the buffer.
1792
+ uint32_t source_offset = yp_ptrdifft_to_u32(constant->start - parser->start);
1793
+ memcpy(buffer->value + buffer_offset, &source_offset, 4);
1794
+ }
1641
1795
 
1642
- memcpy(buffer->value + buffer_offset, &source_offset, 4);
1796
+ // Now we can write the length of the constant into the buffer.
1797
+ uint32_t constant_length = yp_sizet_to_u32(constant->length);
1643
1798
  memcpy(buffer->value + buffer_offset + 4, &constant_length, 4);
1644
1799
  }
1645
1800
  }