prism 0.15.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/Makefile +6 -0
  4. data/README.md +2 -0
  5. data/config.yml +21 -20
  6. data/docs/configuration.md +2 -0
  7. data/docs/javascript.md +90 -0
  8. data/docs/releasing.md +27 -0
  9. data/docs/ruby_api.md +2 -0
  10. data/ext/prism/api_node.c +66 -68
  11. data/ext/prism/extension.c +73 -0
  12. data/ext/prism/extension.h +1 -1
  13. data/include/prism/ast.h +40 -40
  14. data/include/prism/defines.h +9 -0
  15. data/include/prism/enc/pm_encoding.h +1 -0
  16. data/include/prism/node.h +0 -17
  17. data/include/prism/parser.h +1 -0
  18. data/include/prism/prettyprint.h +15 -0
  19. data/include/prism/util/pm_buffer.h +10 -4
  20. data/include/prism/util/pm_constant_pool.h +1 -1
  21. data/include/prism/util/pm_newline_list.h +1 -1
  22. data/include/prism/version.h +3 -3
  23. data/include/prism.h +11 -11
  24. data/lib/prism/compiler.rb +0 -3
  25. data/lib/prism/debug.rb +20 -6
  26. data/lib/prism/desugar_compiler.rb +1 -1
  27. data/lib/prism/dispatcher.rb +0 -14
  28. data/lib/prism/dsl.rb +8 -13
  29. data/lib/prism/ffi.rb +25 -0
  30. data/lib/prism/lex_compat.rb +1 -1
  31. data/lib/prism/mutation_compiler.rb +3 -8
  32. data/lib/prism/node.rb +123 -159
  33. data/lib/prism/node_ext.rb +23 -16
  34. data/lib/prism/parse_result.rb +21 -5
  35. data/lib/prism/pattern.rb +3 -3
  36. data/lib/prism/serialize.rb +901 -305
  37. data/lib/prism/visitor.rb +0 -3
  38. data/prism.gemspec +8 -1
  39. data/rbi/prism.rbi +7261 -0
  40. data/rbi/prism_static.rbi +182 -0
  41. data/sig/prism.rbs +4439 -0
  42. data/sig/prism_static.rbs +110 -0
  43. data/src/enc/pm_unicode.c +1 -1
  44. data/src/node.c +28 -29
  45. data/src/prettyprint.c +7674 -1647
  46. data/src/prism.c +353 -300
  47. data/src/regexp.c +2 -0
  48. data/src/serialize.c +392 -381
  49. data/src/util/pm_buffer.c +47 -12
  50. data/src/util/pm_constant_pool.c +1 -1
  51. data/src/util/pm_newline_list.c +8 -54
  52. metadata +9 -2
data/src/serialize.c CHANGED
@@ -27,24 +27,24 @@ pm_serialize_location(pm_parser_t *parser, pm_location_t *location, pm_buffer_t
27
27
  assert(location->end);
28
28
  assert(location->start <= location->end);
29
29
 
30
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(location->start - parser->start));
31
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(location->end - location->start));
30
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(location->start - parser->start));
31
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(location->end - location->start));
32
32
  }
33
33
 
34
34
  static void
35
35
  pm_serialize_string(pm_parser_t *parser, pm_string_t *string, pm_buffer_t *buffer) {
36
36
  switch (string->type) {
37
37
  case PM_STRING_SHARED: {
38
- pm_buffer_append_u8(buffer, 1);
39
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(pm_string_source(string) - parser->start));
40
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(pm_string_length(string)));
38
+ pm_buffer_append_byte(buffer, 1);
39
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(pm_string_source(string) - parser->start));
40
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(pm_string_length(string)));
41
41
  break;
42
42
  }
43
43
  case PM_STRING_OWNED:
44
44
  case PM_STRING_CONSTANT: {
45
45
  uint32_t length = pm_sizet_to_u32(pm_string_length(string));
46
- pm_buffer_append_u8(buffer, 2);
47
- pm_buffer_append_u32(buffer, length);
46
+ pm_buffer_append_byte(buffer, 2);
47
+ pm_buffer_append_varint(buffer, length);
48
48
  pm_buffer_append_bytes(buffer, pm_string_source(string), length);
49
49
  break;
50
50
  }
@@ -56,7 +56,7 @@ pm_serialize_string(pm_parser_t *parser, pm_string_t *string, pm_buffer_t *buffe
56
56
 
57
57
  void
58
58
  pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
59
- pm_buffer_append_u8(buffer, (uint8_t) PM_NODE_TYPE(node));
59
+ pm_buffer_append_byte(buffer, (uint8_t) PM_NODE_TYPE(node));
60
60
 
61
61
  size_t offset = buffer->length;
62
62
 
@@ -93,63 +93,64 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
93
93
  }
94
94
  case PM_ARGUMENTS_NODE: {
95
95
  uint32_t arguments_size = pm_sizet_to_u32(((pm_arguments_node_t *)node)->arguments.size);
96
- pm_buffer_append_u32(buffer, arguments_size);
96
+ pm_buffer_append_varint(buffer, arguments_size);
97
97
  for (uint32_t index = 0; index < arguments_size; index++) {
98
98
  pm_serialize_node(parser, (pm_node_t *) ((pm_arguments_node_t *)node)->arguments.nodes[index], buffer);
99
99
  }
100
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
100
101
  break;
101
102
  }
102
103
  case PM_ARRAY_NODE: {
103
104
  uint32_t elements_size = pm_sizet_to_u32(((pm_array_node_t *)node)->elements.size);
104
- pm_buffer_append_u32(buffer, elements_size);
105
+ pm_buffer_append_varint(buffer, elements_size);
105
106
  for (uint32_t index = 0; index < elements_size; index++) {
106
107
  pm_serialize_node(parser, (pm_node_t *) ((pm_array_node_t *)node)->elements.nodes[index], buffer);
107
108
  }
108
109
  if (((pm_array_node_t *)node)->opening_loc.start == NULL) {
109
- pm_buffer_append_u8(buffer, 0);
110
+ pm_buffer_append_byte(buffer, 0);
110
111
  } else {
111
- pm_buffer_append_u8(buffer, 1);
112
+ pm_buffer_append_byte(buffer, 1);
112
113
  pm_serialize_location(parser, &((pm_array_node_t *)node)->opening_loc, buffer);
113
114
  }
114
115
  if (((pm_array_node_t *)node)->closing_loc.start == NULL) {
115
- pm_buffer_append_u8(buffer, 0);
116
+ pm_buffer_append_byte(buffer, 0);
116
117
  } else {
117
- pm_buffer_append_u8(buffer, 1);
118
+ pm_buffer_append_byte(buffer, 1);
118
119
  pm_serialize_location(parser, &((pm_array_node_t *)node)->closing_loc, buffer);
119
120
  }
120
121
  break;
121
122
  }
122
123
  case PM_ARRAY_PATTERN_NODE: {
123
124
  if (((pm_array_pattern_node_t *)node)->constant == NULL) {
124
- pm_buffer_append_u8(buffer, 0);
125
+ pm_buffer_append_byte(buffer, 0);
125
126
  } else {
126
127
  pm_serialize_node(parser, (pm_node_t *)((pm_array_pattern_node_t *)node)->constant, buffer);
127
128
  }
128
129
  uint32_t requireds_size = pm_sizet_to_u32(((pm_array_pattern_node_t *)node)->requireds.size);
129
- pm_buffer_append_u32(buffer, requireds_size);
130
+ pm_buffer_append_varint(buffer, requireds_size);
130
131
  for (uint32_t index = 0; index < requireds_size; index++) {
131
132
  pm_serialize_node(parser, (pm_node_t *) ((pm_array_pattern_node_t *)node)->requireds.nodes[index], buffer);
132
133
  }
133
134
  if (((pm_array_pattern_node_t *)node)->rest == NULL) {
134
- pm_buffer_append_u8(buffer, 0);
135
+ pm_buffer_append_byte(buffer, 0);
135
136
  } else {
136
137
  pm_serialize_node(parser, (pm_node_t *)((pm_array_pattern_node_t *)node)->rest, buffer);
137
138
  }
138
139
  uint32_t posts_size = pm_sizet_to_u32(((pm_array_pattern_node_t *)node)->posts.size);
139
- pm_buffer_append_u32(buffer, posts_size);
140
+ pm_buffer_append_varint(buffer, posts_size);
140
141
  for (uint32_t index = 0; index < posts_size; index++) {
141
142
  pm_serialize_node(parser, (pm_node_t *) ((pm_array_pattern_node_t *)node)->posts.nodes[index], buffer);
142
143
  }
143
144
  if (((pm_array_pattern_node_t *)node)->opening_loc.start == NULL) {
144
- pm_buffer_append_u8(buffer, 0);
145
+ pm_buffer_append_byte(buffer, 0);
145
146
  } else {
146
- pm_buffer_append_u8(buffer, 1);
147
+ pm_buffer_append_byte(buffer, 1);
147
148
  pm_serialize_location(parser, &((pm_array_pattern_node_t *)node)->opening_loc, buffer);
148
149
  }
149
150
  if (((pm_array_pattern_node_t *)node)->closing_loc.start == NULL) {
150
- pm_buffer_append_u8(buffer, 0);
151
+ pm_buffer_append_byte(buffer, 0);
151
152
  } else {
152
- pm_buffer_append_u8(buffer, 1);
153
+ pm_buffer_append_byte(buffer, 1);
153
154
  pm_serialize_location(parser, &((pm_array_pattern_node_t *)node)->closing_loc, buffer);
154
155
  }
155
156
  break;
@@ -157,21 +158,21 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
157
158
  case PM_ASSOC_NODE: {
158
159
  pm_serialize_node(parser, (pm_node_t *)((pm_assoc_node_t *)node)->key, buffer);
159
160
  if (((pm_assoc_node_t *)node)->value == NULL) {
160
- pm_buffer_append_u8(buffer, 0);
161
+ pm_buffer_append_byte(buffer, 0);
161
162
  } else {
162
163
  pm_serialize_node(parser, (pm_node_t *)((pm_assoc_node_t *)node)->value, buffer);
163
164
  }
164
165
  if (((pm_assoc_node_t *)node)->operator_loc.start == NULL) {
165
- pm_buffer_append_u8(buffer, 0);
166
+ pm_buffer_append_byte(buffer, 0);
166
167
  } else {
167
- pm_buffer_append_u8(buffer, 1);
168
+ pm_buffer_append_byte(buffer, 1);
168
169
  pm_serialize_location(parser, &((pm_assoc_node_t *)node)->operator_loc, buffer);
169
170
  }
170
171
  break;
171
172
  }
172
173
  case PM_ASSOC_SPLAT_NODE: {
173
174
  if (((pm_assoc_splat_node_t *)node)->value == NULL) {
174
- pm_buffer_append_u8(buffer, 0);
175
+ pm_buffer_append_byte(buffer, 0);
175
176
  } else {
176
177
  pm_serialize_node(parser, (pm_node_t *)((pm_assoc_splat_node_t *)node)->value, buffer);
177
178
  }
@@ -179,47 +180,47 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
179
180
  break;
180
181
  }
181
182
  case PM_BACK_REFERENCE_READ_NODE: {
182
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_back_reference_read_node_t *)node)->name));
183
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_back_reference_read_node_t *)node)->name));
183
184
  break;
184
185
  }
185
186
  case PM_BEGIN_NODE: {
186
187
  if (((pm_begin_node_t *)node)->begin_keyword_loc.start == NULL) {
187
- pm_buffer_append_u8(buffer, 0);
188
+ pm_buffer_append_byte(buffer, 0);
188
189
  } else {
189
- pm_buffer_append_u8(buffer, 1);
190
+ pm_buffer_append_byte(buffer, 1);
190
191
  pm_serialize_location(parser, &((pm_begin_node_t *)node)->begin_keyword_loc, buffer);
191
192
  }
192
193
  if (((pm_begin_node_t *)node)->statements == NULL) {
193
- pm_buffer_append_u8(buffer, 0);
194
+ pm_buffer_append_byte(buffer, 0);
194
195
  } else {
195
196
  pm_serialize_node(parser, (pm_node_t *)((pm_begin_node_t *)node)->statements, buffer);
196
197
  }
197
198
  if (((pm_begin_node_t *)node)->rescue_clause == NULL) {
198
- pm_buffer_append_u8(buffer, 0);
199
+ pm_buffer_append_byte(buffer, 0);
199
200
  } else {
200
201
  pm_serialize_node(parser, (pm_node_t *)((pm_begin_node_t *)node)->rescue_clause, buffer);
201
202
  }
202
203
  if (((pm_begin_node_t *)node)->else_clause == NULL) {
203
- pm_buffer_append_u8(buffer, 0);
204
+ pm_buffer_append_byte(buffer, 0);
204
205
  } else {
205
206
  pm_serialize_node(parser, (pm_node_t *)((pm_begin_node_t *)node)->else_clause, buffer);
206
207
  }
207
208
  if (((pm_begin_node_t *)node)->ensure_clause == NULL) {
208
- pm_buffer_append_u8(buffer, 0);
209
+ pm_buffer_append_byte(buffer, 0);
209
210
  } else {
210
211
  pm_serialize_node(parser, (pm_node_t *)((pm_begin_node_t *)node)->ensure_clause, buffer);
211
212
  }
212
213
  if (((pm_begin_node_t *)node)->end_keyword_loc.start == NULL) {
213
- pm_buffer_append_u8(buffer, 0);
214
+ pm_buffer_append_byte(buffer, 0);
214
215
  } else {
215
- pm_buffer_append_u8(buffer, 1);
216
+ pm_buffer_append_byte(buffer, 1);
216
217
  pm_serialize_location(parser, &((pm_begin_node_t *)node)->end_keyword_loc, buffer);
217
218
  }
218
219
  break;
219
220
  }
220
221
  case PM_BLOCK_ARGUMENT_NODE: {
221
222
  if (((pm_block_argument_node_t *)node)->expression == NULL) {
222
- pm_buffer_append_u8(buffer, 0);
223
+ pm_buffer_append_byte(buffer, 0);
223
224
  } else {
224
225
  pm_serialize_node(parser, (pm_node_t *)((pm_block_argument_node_t *)node)->expression, buffer);
225
226
  }
@@ -227,22 +228,22 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
227
228
  break;
228
229
  }
229
230
  case PM_BLOCK_LOCAL_VARIABLE_NODE: {
230
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_block_local_variable_node_t *)node)->name));
231
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_block_local_variable_node_t *)node)->name));
231
232
  break;
232
233
  }
233
234
  case PM_BLOCK_NODE: {
234
235
  uint32_t locals_size = pm_sizet_to_u32(((pm_block_node_t *)node)->locals.size);
235
- pm_buffer_append_u32(buffer, locals_size);
236
+ pm_buffer_append_varint(buffer, locals_size);
236
237
  for (uint32_t index = 0; index < locals_size; index++) {
237
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_block_node_t *)node)->locals.ids[index]));
238
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_block_node_t *)node)->locals.ids[index]));
238
239
  }
239
240
  if (((pm_block_node_t *)node)->parameters == NULL) {
240
- pm_buffer_append_u8(buffer, 0);
241
+ pm_buffer_append_byte(buffer, 0);
241
242
  } else {
242
243
  pm_serialize_node(parser, (pm_node_t *)((pm_block_node_t *)node)->parameters, buffer);
243
244
  }
244
245
  if (((pm_block_node_t *)node)->body == NULL) {
245
- pm_buffer_append_u8(buffer, 0);
246
+ pm_buffer_append_byte(buffer, 0);
246
247
  } else {
247
248
  pm_serialize_node(parser, (pm_node_t *)((pm_block_node_t *)node)->body, buffer);
248
249
  }
@@ -251,11 +252,11 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
251
252
  break;
252
253
  }
253
254
  case PM_BLOCK_PARAMETER_NODE: {
254
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_block_parameter_node_t *)node)->name));
255
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_block_parameter_node_t *)node)->name));
255
256
  if (((pm_block_parameter_node_t *)node)->name_loc.start == NULL) {
256
- pm_buffer_append_u8(buffer, 0);
257
+ pm_buffer_append_byte(buffer, 0);
257
258
  } else {
258
- pm_buffer_append_u8(buffer, 1);
259
+ pm_buffer_append_byte(buffer, 1);
259
260
  pm_serialize_location(parser, &((pm_block_parameter_node_t *)node)->name_loc, buffer);
260
261
  }
261
262
  pm_serialize_location(parser, &((pm_block_parameter_node_t *)node)->operator_loc, buffer);
@@ -263,32 +264,32 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
263
264
  }
264
265
  case PM_BLOCK_PARAMETERS_NODE: {
265
266
  if (((pm_block_parameters_node_t *)node)->parameters == NULL) {
266
- pm_buffer_append_u8(buffer, 0);
267
+ pm_buffer_append_byte(buffer, 0);
267
268
  } else {
268
269
  pm_serialize_node(parser, (pm_node_t *)((pm_block_parameters_node_t *)node)->parameters, buffer);
269
270
  }
270
271
  uint32_t locals_size = pm_sizet_to_u32(((pm_block_parameters_node_t *)node)->locals.size);
271
- pm_buffer_append_u32(buffer, locals_size);
272
+ pm_buffer_append_varint(buffer, locals_size);
272
273
  for (uint32_t index = 0; index < locals_size; index++) {
273
274
  pm_serialize_node(parser, (pm_node_t *) ((pm_block_parameters_node_t *)node)->locals.nodes[index], buffer);
274
275
  }
275
276
  if (((pm_block_parameters_node_t *)node)->opening_loc.start == NULL) {
276
- pm_buffer_append_u8(buffer, 0);
277
+ pm_buffer_append_byte(buffer, 0);
277
278
  } else {
278
- pm_buffer_append_u8(buffer, 1);
279
+ pm_buffer_append_byte(buffer, 1);
279
280
  pm_serialize_location(parser, &((pm_block_parameters_node_t *)node)->opening_loc, buffer);
280
281
  }
281
282
  if (((pm_block_parameters_node_t *)node)->closing_loc.start == NULL) {
282
- pm_buffer_append_u8(buffer, 0);
283
+ pm_buffer_append_byte(buffer, 0);
283
284
  } else {
284
- pm_buffer_append_u8(buffer, 1);
285
+ pm_buffer_append_byte(buffer, 1);
285
286
  pm_serialize_location(parser, &((pm_block_parameters_node_t *)node)->closing_loc, buffer);
286
287
  }
287
288
  break;
288
289
  }
289
290
  case PM_BREAK_NODE: {
290
291
  if (((pm_break_node_t *)node)->arguments == NULL) {
291
- pm_buffer_append_u8(buffer, 0);
292
+ pm_buffer_append_byte(buffer, 0);
292
293
  } else {
293
294
  pm_serialize_node(parser, (pm_node_t *)((pm_break_node_t *)node)->arguments, buffer);
294
295
  }
@@ -297,120 +298,120 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
297
298
  }
298
299
  case PM_CALL_AND_WRITE_NODE: {
299
300
  if (((pm_call_and_write_node_t *)node)->receiver == NULL) {
300
- pm_buffer_append_u8(buffer, 0);
301
+ pm_buffer_append_byte(buffer, 0);
301
302
  } else {
302
303
  pm_serialize_node(parser, (pm_node_t *)((pm_call_and_write_node_t *)node)->receiver, buffer);
303
304
  }
304
305
  if (((pm_call_and_write_node_t *)node)->call_operator_loc.start == NULL) {
305
- pm_buffer_append_u8(buffer, 0);
306
+ pm_buffer_append_byte(buffer, 0);
306
307
  } else {
307
- pm_buffer_append_u8(buffer, 1);
308
+ pm_buffer_append_byte(buffer, 1);
308
309
  pm_serialize_location(parser, &((pm_call_and_write_node_t *)node)->call_operator_loc, buffer);
309
310
  }
310
311
  if (((pm_call_and_write_node_t *)node)->message_loc.start == NULL) {
311
- pm_buffer_append_u8(buffer, 0);
312
+ pm_buffer_append_byte(buffer, 0);
312
313
  } else {
313
- pm_buffer_append_u8(buffer, 1);
314
+ pm_buffer_append_byte(buffer, 1);
314
315
  pm_serialize_location(parser, &((pm_call_and_write_node_t *)node)->message_loc, buffer);
315
316
  }
316
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
317
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_call_and_write_node_t *)node)->read_name));
318
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_call_and_write_node_t *)node)->write_name));
317
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
318
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_and_write_node_t *)node)->read_name));
319
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_and_write_node_t *)node)->write_name));
319
320
  pm_serialize_location(parser, &((pm_call_and_write_node_t *)node)->operator_loc, buffer);
320
321
  pm_serialize_node(parser, (pm_node_t *)((pm_call_and_write_node_t *)node)->value, buffer);
321
322
  break;
322
323
  }
323
324
  case PM_CALL_NODE: {
324
325
  if (((pm_call_node_t *)node)->receiver == NULL) {
325
- pm_buffer_append_u8(buffer, 0);
326
+ pm_buffer_append_byte(buffer, 0);
326
327
  } else {
327
328
  pm_serialize_node(parser, (pm_node_t *)((pm_call_node_t *)node)->receiver, buffer);
328
329
  }
329
330
  if (((pm_call_node_t *)node)->call_operator_loc.start == NULL) {
330
- pm_buffer_append_u8(buffer, 0);
331
+ pm_buffer_append_byte(buffer, 0);
331
332
  } else {
332
- pm_buffer_append_u8(buffer, 1);
333
+ pm_buffer_append_byte(buffer, 1);
333
334
  pm_serialize_location(parser, &((pm_call_node_t *)node)->call_operator_loc, buffer);
334
335
  }
335
336
  if (((pm_call_node_t *)node)->message_loc.start == NULL) {
336
- pm_buffer_append_u8(buffer, 0);
337
+ pm_buffer_append_byte(buffer, 0);
337
338
  } else {
338
- pm_buffer_append_u8(buffer, 1);
339
+ pm_buffer_append_byte(buffer, 1);
339
340
  pm_serialize_location(parser, &((pm_call_node_t *)node)->message_loc, buffer);
340
341
  }
341
342
  if (((pm_call_node_t *)node)->opening_loc.start == NULL) {
342
- pm_buffer_append_u8(buffer, 0);
343
+ pm_buffer_append_byte(buffer, 0);
343
344
  } else {
344
- pm_buffer_append_u8(buffer, 1);
345
+ pm_buffer_append_byte(buffer, 1);
345
346
  pm_serialize_location(parser, &((pm_call_node_t *)node)->opening_loc, buffer);
346
347
  }
347
348
  if (((pm_call_node_t *)node)->arguments == NULL) {
348
- pm_buffer_append_u8(buffer, 0);
349
+ pm_buffer_append_byte(buffer, 0);
349
350
  } else {
350
351
  pm_serialize_node(parser, (pm_node_t *)((pm_call_node_t *)node)->arguments, buffer);
351
352
  }
352
353
  if (((pm_call_node_t *)node)->closing_loc.start == NULL) {
353
- pm_buffer_append_u8(buffer, 0);
354
+ pm_buffer_append_byte(buffer, 0);
354
355
  } else {
355
- pm_buffer_append_u8(buffer, 1);
356
+ pm_buffer_append_byte(buffer, 1);
356
357
  pm_serialize_location(parser, &((pm_call_node_t *)node)->closing_loc, buffer);
357
358
  }
358
359
  if (((pm_call_node_t *)node)->block == NULL) {
359
- pm_buffer_append_u8(buffer, 0);
360
+ pm_buffer_append_byte(buffer, 0);
360
361
  } else {
361
362
  pm_serialize_node(parser, (pm_node_t *)((pm_call_node_t *)node)->block, buffer);
362
363
  }
363
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
364
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_call_node_t *)node)->name));
364
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
365
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_node_t *)node)->name));
365
366
  break;
366
367
  }
367
368
  case PM_CALL_OPERATOR_WRITE_NODE: {
368
369
  if (((pm_call_operator_write_node_t *)node)->receiver == NULL) {
369
- pm_buffer_append_u8(buffer, 0);
370
+ pm_buffer_append_byte(buffer, 0);
370
371
  } else {
371
372
  pm_serialize_node(parser, (pm_node_t *)((pm_call_operator_write_node_t *)node)->receiver, buffer);
372
373
  }
373
374
  if (((pm_call_operator_write_node_t *)node)->call_operator_loc.start == NULL) {
374
- pm_buffer_append_u8(buffer, 0);
375
+ pm_buffer_append_byte(buffer, 0);
375
376
  } else {
376
- pm_buffer_append_u8(buffer, 1);
377
+ pm_buffer_append_byte(buffer, 1);
377
378
  pm_serialize_location(parser, &((pm_call_operator_write_node_t *)node)->call_operator_loc, buffer);
378
379
  }
379
380
  if (((pm_call_operator_write_node_t *)node)->message_loc.start == NULL) {
380
- pm_buffer_append_u8(buffer, 0);
381
+ pm_buffer_append_byte(buffer, 0);
381
382
  } else {
382
- pm_buffer_append_u8(buffer, 1);
383
+ pm_buffer_append_byte(buffer, 1);
383
384
  pm_serialize_location(parser, &((pm_call_operator_write_node_t *)node)->message_loc, buffer);
384
385
  }
385
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
386
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->read_name));
387
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->write_name));
388
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->operator));
386
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
387
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->read_name));
388
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->write_name));
389
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_operator_write_node_t *)node)->operator));
389
390
  pm_serialize_location(parser, &((pm_call_operator_write_node_t *)node)->operator_loc, buffer);
390
391
  pm_serialize_node(parser, (pm_node_t *)((pm_call_operator_write_node_t *)node)->value, buffer);
391
392
  break;
392
393
  }
393
394
  case PM_CALL_OR_WRITE_NODE: {
394
395
  if (((pm_call_or_write_node_t *)node)->receiver == NULL) {
395
- pm_buffer_append_u8(buffer, 0);
396
+ pm_buffer_append_byte(buffer, 0);
396
397
  } else {
397
398
  pm_serialize_node(parser, (pm_node_t *)((pm_call_or_write_node_t *)node)->receiver, buffer);
398
399
  }
399
400
  if (((pm_call_or_write_node_t *)node)->call_operator_loc.start == NULL) {
400
- pm_buffer_append_u8(buffer, 0);
401
+ pm_buffer_append_byte(buffer, 0);
401
402
  } else {
402
- pm_buffer_append_u8(buffer, 1);
403
+ pm_buffer_append_byte(buffer, 1);
403
404
  pm_serialize_location(parser, &((pm_call_or_write_node_t *)node)->call_operator_loc, buffer);
404
405
  }
405
406
  if (((pm_call_or_write_node_t *)node)->message_loc.start == NULL) {
406
- pm_buffer_append_u8(buffer, 0);
407
+ pm_buffer_append_byte(buffer, 0);
407
408
  } else {
408
- pm_buffer_append_u8(buffer, 1);
409
+ pm_buffer_append_byte(buffer, 1);
409
410
  pm_serialize_location(parser, &((pm_call_or_write_node_t *)node)->message_loc, buffer);
410
411
  }
411
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
412
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_call_or_write_node_t *)node)->read_name));
413
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_call_or_write_node_t *)node)->write_name));
412
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
413
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_or_write_node_t *)node)->read_name));
414
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_call_or_write_node_t *)node)->write_name));
414
415
  pm_serialize_location(parser, &((pm_call_or_write_node_t *)node)->operator_loc, buffer);
415
416
  pm_serialize_node(parser, (pm_node_t *)((pm_call_or_write_node_t *)node)->value, buffer);
416
417
  break;
@@ -423,17 +424,17 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
423
424
  }
424
425
  case PM_CASE_NODE: {
425
426
  if (((pm_case_node_t *)node)->predicate == NULL) {
426
- pm_buffer_append_u8(buffer, 0);
427
+ pm_buffer_append_byte(buffer, 0);
427
428
  } else {
428
429
  pm_serialize_node(parser, (pm_node_t *)((pm_case_node_t *)node)->predicate, buffer);
429
430
  }
430
431
  uint32_t conditions_size = pm_sizet_to_u32(((pm_case_node_t *)node)->conditions.size);
431
- pm_buffer_append_u32(buffer, conditions_size);
432
+ pm_buffer_append_varint(buffer, conditions_size);
432
433
  for (uint32_t index = 0; index < conditions_size; index++) {
433
434
  pm_serialize_node(parser, (pm_node_t *) ((pm_case_node_t *)node)->conditions.nodes[index], buffer);
434
435
  }
435
436
  if (((pm_case_node_t *)node)->consequent == NULL) {
436
- pm_buffer_append_u8(buffer, 0);
437
+ pm_buffer_append_byte(buffer, 0);
437
438
  } else {
438
439
  pm_serialize_node(parser, (pm_node_t *)((pm_case_node_t *)node)->consequent, buffer);
439
440
  }
@@ -443,91 +444,91 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
443
444
  }
444
445
  case PM_CLASS_NODE: {
445
446
  uint32_t locals_size = pm_sizet_to_u32(((pm_class_node_t *)node)->locals.size);
446
- pm_buffer_append_u32(buffer, locals_size);
447
+ pm_buffer_append_varint(buffer, locals_size);
447
448
  for (uint32_t index = 0; index < locals_size; index++) {
448
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_class_node_t *)node)->locals.ids[index]));
449
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_node_t *)node)->locals.ids[index]));
449
450
  }
450
451
  pm_serialize_location(parser, &((pm_class_node_t *)node)->class_keyword_loc, buffer);
451
452
  pm_serialize_node(parser, (pm_node_t *)((pm_class_node_t *)node)->constant_path, buffer);
452
453
  if (((pm_class_node_t *)node)->inheritance_operator_loc.start == NULL) {
453
- pm_buffer_append_u8(buffer, 0);
454
+ pm_buffer_append_byte(buffer, 0);
454
455
  } else {
455
- pm_buffer_append_u8(buffer, 1);
456
+ pm_buffer_append_byte(buffer, 1);
456
457
  pm_serialize_location(parser, &((pm_class_node_t *)node)->inheritance_operator_loc, buffer);
457
458
  }
458
459
  if (((pm_class_node_t *)node)->superclass == NULL) {
459
- pm_buffer_append_u8(buffer, 0);
460
+ pm_buffer_append_byte(buffer, 0);
460
461
  } else {
461
462
  pm_serialize_node(parser, (pm_node_t *)((pm_class_node_t *)node)->superclass, buffer);
462
463
  }
463
464
  if (((pm_class_node_t *)node)->body == NULL) {
464
- pm_buffer_append_u8(buffer, 0);
465
+ pm_buffer_append_byte(buffer, 0);
465
466
  } else {
466
467
  pm_serialize_node(parser, (pm_node_t *)((pm_class_node_t *)node)->body, buffer);
467
468
  }
468
469
  pm_serialize_location(parser, &((pm_class_node_t *)node)->end_keyword_loc, buffer);
469
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_class_node_t *)node)->name));
470
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_node_t *)node)->name));
470
471
  break;
471
472
  }
472
473
  case PM_CLASS_VARIABLE_AND_WRITE_NODE: {
473
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_class_variable_and_write_node_t *)node)->name));
474
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_and_write_node_t *)node)->name));
474
475
  pm_serialize_location(parser, &((pm_class_variable_and_write_node_t *)node)->name_loc, buffer);
475
476
  pm_serialize_location(parser, &((pm_class_variable_and_write_node_t *)node)->operator_loc, buffer);
476
477
  pm_serialize_node(parser, (pm_node_t *)((pm_class_variable_and_write_node_t *)node)->value, buffer);
477
478
  break;
478
479
  }
479
480
  case PM_CLASS_VARIABLE_OPERATOR_WRITE_NODE: {
480
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_class_variable_operator_write_node_t *)node)->name));
481
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_operator_write_node_t *)node)->name));
481
482
  pm_serialize_location(parser, &((pm_class_variable_operator_write_node_t *)node)->name_loc, buffer);
482
483
  pm_serialize_location(parser, &((pm_class_variable_operator_write_node_t *)node)->operator_loc, buffer);
483
484
  pm_serialize_node(parser, (pm_node_t *)((pm_class_variable_operator_write_node_t *)node)->value, buffer);
484
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_class_variable_operator_write_node_t *)node)->operator));
485
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_operator_write_node_t *)node)->operator));
485
486
  break;
486
487
  }
487
488
  case PM_CLASS_VARIABLE_OR_WRITE_NODE: {
488
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_class_variable_or_write_node_t *)node)->name));
489
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_or_write_node_t *)node)->name));
489
490
  pm_serialize_location(parser, &((pm_class_variable_or_write_node_t *)node)->name_loc, buffer);
490
491
  pm_serialize_location(parser, &((pm_class_variable_or_write_node_t *)node)->operator_loc, buffer);
491
492
  pm_serialize_node(parser, (pm_node_t *)((pm_class_variable_or_write_node_t *)node)->value, buffer);
492
493
  break;
493
494
  }
494
495
  case PM_CLASS_VARIABLE_READ_NODE: {
495
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_class_variable_read_node_t *)node)->name));
496
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_read_node_t *)node)->name));
496
497
  break;
497
498
  }
498
499
  case PM_CLASS_VARIABLE_TARGET_NODE: {
499
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_class_variable_target_node_t *)node)->name));
500
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_target_node_t *)node)->name));
500
501
  break;
501
502
  }
502
503
  case PM_CLASS_VARIABLE_WRITE_NODE: {
503
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_class_variable_write_node_t *)node)->name));
504
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_class_variable_write_node_t *)node)->name));
504
505
  pm_serialize_location(parser, &((pm_class_variable_write_node_t *)node)->name_loc, buffer);
505
506
  pm_serialize_node(parser, (pm_node_t *)((pm_class_variable_write_node_t *)node)->value, buffer);
506
507
  if (((pm_class_variable_write_node_t *)node)->operator_loc.start == NULL) {
507
- pm_buffer_append_u8(buffer, 0);
508
+ pm_buffer_append_byte(buffer, 0);
508
509
  } else {
509
- pm_buffer_append_u8(buffer, 1);
510
+ pm_buffer_append_byte(buffer, 1);
510
511
  pm_serialize_location(parser, &((pm_class_variable_write_node_t *)node)->operator_loc, buffer);
511
512
  }
512
513
  break;
513
514
  }
514
515
  case PM_CONSTANT_AND_WRITE_NODE: {
515
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_constant_and_write_node_t *)node)->name));
516
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_and_write_node_t *)node)->name));
516
517
  pm_serialize_location(parser, &((pm_constant_and_write_node_t *)node)->name_loc, buffer);
517
518
  pm_serialize_location(parser, &((pm_constant_and_write_node_t *)node)->operator_loc, buffer);
518
519
  pm_serialize_node(parser, (pm_node_t *)((pm_constant_and_write_node_t *)node)->value, buffer);
519
520
  break;
520
521
  }
521
522
  case PM_CONSTANT_OPERATOR_WRITE_NODE: {
522
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_constant_operator_write_node_t *)node)->name));
523
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_operator_write_node_t *)node)->name));
523
524
  pm_serialize_location(parser, &((pm_constant_operator_write_node_t *)node)->name_loc, buffer);
524
525
  pm_serialize_location(parser, &((pm_constant_operator_write_node_t *)node)->operator_loc, buffer);
525
526
  pm_serialize_node(parser, (pm_node_t *)((pm_constant_operator_write_node_t *)node)->value, buffer);
526
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_constant_operator_write_node_t *)node)->operator));
527
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_operator_write_node_t *)node)->operator));
527
528
  break;
528
529
  }
529
530
  case PM_CONSTANT_OR_WRITE_NODE: {
530
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_constant_or_write_node_t *)node)->name));
531
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_or_write_node_t *)node)->name));
531
532
  pm_serialize_location(parser, &((pm_constant_or_write_node_t *)node)->name_loc, buffer);
532
533
  pm_serialize_location(parser, &((pm_constant_or_write_node_t *)node)->operator_loc, buffer);
533
534
  pm_serialize_node(parser, (pm_node_t *)((pm_constant_or_write_node_t *)node)->value, buffer);
@@ -541,7 +542,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
541
542
  }
542
543
  case PM_CONSTANT_PATH_NODE: {
543
544
  if (((pm_constant_path_node_t *)node)->parent == NULL) {
544
- pm_buffer_append_u8(buffer, 0);
545
+ pm_buffer_append_byte(buffer, 0);
545
546
  } else {
546
547
  pm_serialize_node(parser, (pm_node_t *)((pm_constant_path_node_t *)node)->parent, buffer);
547
548
  }
@@ -553,7 +554,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
553
554
  pm_serialize_node(parser, (pm_node_t *)((pm_constant_path_operator_write_node_t *)node)->target, buffer);
554
555
  pm_serialize_location(parser, &((pm_constant_path_operator_write_node_t *)node)->operator_loc, buffer);
555
556
  pm_serialize_node(parser, (pm_node_t *)((pm_constant_path_operator_write_node_t *)node)->value, buffer);
556
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_constant_path_operator_write_node_t *)node)->operator));
557
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_path_operator_write_node_t *)node)->operator));
557
558
  break;
558
559
  }
559
560
  case PM_CONSTANT_PATH_OR_WRITE_NODE: {
@@ -564,7 +565,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
564
565
  }
565
566
  case PM_CONSTANT_PATH_TARGET_NODE: {
566
567
  if (((pm_constant_path_target_node_t *)node)->parent == NULL) {
567
- pm_buffer_append_u8(buffer, 0);
568
+ pm_buffer_append_byte(buffer, 0);
568
569
  } else {
569
570
  pm_serialize_node(parser, (pm_node_t *)((pm_constant_path_target_node_t *)node)->parent, buffer);
570
571
  }
@@ -579,15 +580,15 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
579
580
  break;
580
581
  }
581
582
  case PM_CONSTANT_READ_NODE: {
582
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_constant_read_node_t *)node)->name));
583
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_read_node_t *)node)->name));
583
584
  break;
584
585
  }
585
586
  case PM_CONSTANT_TARGET_NODE: {
586
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_constant_target_node_t *)node)->name));
587
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_target_node_t *)node)->name));
587
588
  break;
588
589
  }
589
590
  case PM_CONSTANT_WRITE_NODE: {
590
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_constant_write_node_t *)node)->name));
591
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_constant_write_node_t *)node)->name));
591
592
  pm_serialize_location(parser, &((pm_constant_write_node_t *)node)->name_loc, buffer);
592
593
  pm_serialize_node(parser, (pm_node_t *)((pm_constant_write_node_t *)node)->value, buffer);
593
594
  pm_serialize_location(parser, &((pm_constant_write_node_t *)node)->operator_loc, buffer);
@@ -597,58 +598,58 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
597
598
  // serialize length
598
599
  // encoding of location u32s make us need to save this offset.
599
600
  size_t length_offset = buffer->length;
600
- pm_buffer_append_str(buffer, "\0\0\0\0", 4); /* consume 4 bytes, updated below */
601
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_def_node_t *)node)->name));
601
+ pm_buffer_append_string(buffer, "\0\0\0\0", 4); /* consume 4 bytes, updated below */
602
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_def_node_t *)node)->name));
602
603
  pm_serialize_location(parser, &((pm_def_node_t *)node)->name_loc, buffer);
603
604
  if (((pm_def_node_t *)node)->receiver == NULL) {
604
- pm_buffer_append_u8(buffer, 0);
605
+ pm_buffer_append_byte(buffer, 0);
605
606
  } else {
606
607
  pm_serialize_node(parser, (pm_node_t *)((pm_def_node_t *)node)->receiver, buffer);
607
608
  }
608
609
  if (((pm_def_node_t *)node)->parameters == NULL) {
609
- pm_buffer_append_u8(buffer, 0);
610
+ pm_buffer_append_byte(buffer, 0);
610
611
  } else {
611
612
  pm_serialize_node(parser, (pm_node_t *)((pm_def_node_t *)node)->parameters, buffer);
612
613
  }
613
614
  if (((pm_def_node_t *)node)->body == NULL) {
614
- pm_buffer_append_u8(buffer, 0);
615
+ pm_buffer_append_byte(buffer, 0);
615
616
  } else {
616
617
  pm_serialize_node(parser, (pm_node_t *)((pm_def_node_t *)node)->body, buffer);
617
618
  }
618
619
  uint32_t locals_size = pm_sizet_to_u32(((pm_def_node_t *)node)->locals.size);
619
- pm_buffer_append_u32(buffer, locals_size);
620
+ pm_buffer_append_varint(buffer, locals_size);
620
621
  for (uint32_t index = 0; index < locals_size; index++) {
621
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_def_node_t *)node)->locals.ids[index]));
622
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_def_node_t *)node)->locals.ids[index]));
622
623
  }
623
624
  pm_serialize_location(parser, &((pm_def_node_t *)node)->def_keyword_loc, buffer);
624
625
  if (((pm_def_node_t *)node)->operator_loc.start == NULL) {
625
- pm_buffer_append_u8(buffer, 0);
626
+ pm_buffer_append_byte(buffer, 0);
626
627
  } else {
627
- pm_buffer_append_u8(buffer, 1);
628
+ pm_buffer_append_byte(buffer, 1);
628
629
  pm_serialize_location(parser, &((pm_def_node_t *)node)->operator_loc, buffer);
629
630
  }
630
631
  if (((pm_def_node_t *)node)->lparen_loc.start == NULL) {
631
- pm_buffer_append_u8(buffer, 0);
632
+ pm_buffer_append_byte(buffer, 0);
632
633
  } else {
633
- pm_buffer_append_u8(buffer, 1);
634
+ pm_buffer_append_byte(buffer, 1);
634
635
  pm_serialize_location(parser, &((pm_def_node_t *)node)->lparen_loc, buffer);
635
636
  }
636
637
  if (((pm_def_node_t *)node)->rparen_loc.start == NULL) {
637
- pm_buffer_append_u8(buffer, 0);
638
+ pm_buffer_append_byte(buffer, 0);
638
639
  } else {
639
- pm_buffer_append_u8(buffer, 1);
640
+ pm_buffer_append_byte(buffer, 1);
640
641
  pm_serialize_location(parser, &((pm_def_node_t *)node)->rparen_loc, buffer);
641
642
  }
642
643
  if (((pm_def_node_t *)node)->equal_loc.start == NULL) {
643
- pm_buffer_append_u8(buffer, 0);
644
+ pm_buffer_append_byte(buffer, 0);
644
645
  } else {
645
- pm_buffer_append_u8(buffer, 1);
646
+ pm_buffer_append_byte(buffer, 1);
646
647
  pm_serialize_location(parser, &((pm_def_node_t *)node)->equal_loc, buffer);
647
648
  }
648
649
  if (((pm_def_node_t *)node)->end_keyword_loc.start == NULL) {
649
- pm_buffer_append_u8(buffer, 0);
650
+ pm_buffer_append_byte(buffer, 0);
650
651
  } else {
651
- pm_buffer_append_u8(buffer, 1);
652
+ pm_buffer_append_byte(buffer, 1);
652
653
  pm_serialize_location(parser, &((pm_def_node_t *)node)->end_keyword_loc, buffer);
653
654
  }
654
655
  // serialize length
@@ -658,16 +659,16 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
658
659
  }
659
660
  case PM_DEFINED_NODE: {
660
661
  if (((pm_defined_node_t *)node)->lparen_loc.start == NULL) {
661
- pm_buffer_append_u8(buffer, 0);
662
+ pm_buffer_append_byte(buffer, 0);
662
663
  } else {
663
- pm_buffer_append_u8(buffer, 1);
664
+ pm_buffer_append_byte(buffer, 1);
664
665
  pm_serialize_location(parser, &((pm_defined_node_t *)node)->lparen_loc, buffer);
665
666
  }
666
667
  pm_serialize_node(parser, (pm_node_t *)((pm_defined_node_t *)node)->value, buffer);
667
668
  if (((pm_defined_node_t *)node)->rparen_loc.start == NULL) {
668
- pm_buffer_append_u8(buffer, 0);
669
+ pm_buffer_append_byte(buffer, 0);
669
670
  } else {
670
- pm_buffer_append_u8(buffer, 1);
671
+ pm_buffer_append_byte(buffer, 1);
671
672
  pm_serialize_location(parser, &((pm_defined_node_t *)node)->rparen_loc, buffer);
672
673
  }
673
674
  pm_serialize_location(parser, &((pm_defined_node_t *)node)->keyword_loc, buffer);
@@ -676,14 +677,14 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
676
677
  case PM_ELSE_NODE: {
677
678
  pm_serialize_location(parser, &((pm_else_node_t *)node)->else_keyword_loc, buffer);
678
679
  if (((pm_else_node_t *)node)->statements == NULL) {
679
- pm_buffer_append_u8(buffer, 0);
680
+ pm_buffer_append_byte(buffer, 0);
680
681
  } else {
681
682
  pm_serialize_node(parser, (pm_node_t *)((pm_else_node_t *)node)->statements, buffer);
682
683
  }
683
684
  if (((pm_else_node_t *)node)->end_keyword_loc.start == NULL) {
684
- pm_buffer_append_u8(buffer, 0);
685
+ pm_buffer_append_byte(buffer, 0);
685
686
  } else {
686
- pm_buffer_append_u8(buffer, 1);
687
+ pm_buffer_append_byte(buffer, 1);
687
688
  pm_serialize_location(parser, &((pm_else_node_t *)node)->end_keyword_loc, buffer);
688
689
  }
689
690
  break;
@@ -691,7 +692,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
691
692
  case PM_EMBEDDED_STATEMENTS_NODE: {
692
693
  pm_serialize_location(parser, &((pm_embedded_statements_node_t *)node)->opening_loc, buffer);
693
694
  if (((pm_embedded_statements_node_t *)node)->statements == NULL) {
694
- pm_buffer_append_u8(buffer, 0);
695
+ pm_buffer_append_byte(buffer, 0);
695
696
  } else {
696
697
  pm_serialize_node(parser, (pm_node_t *)((pm_embedded_statements_node_t *)node)->statements, buffer);
697
698
  }
@@ -706,7 +707,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
706
707
  case PM_ENSURE_NODE: {
707
708
  pm_serialize_location(parser, &((pm_ensure_node_t *)node)->ensure_keyword_loc, buffer);
708
709
  if (((pm_ensure_node_t *)node)->statements == NULL) {
709
- pm_buffer_append_u8(buffer, 0);
710
+ pm_buffer_append_byte(buffer, 0);
710
711
  } else {
711
712
  pm_serialize_node(parser, (pm_node_t *)((pm_ensure_node_t *)node)->statements, buffer);
712
713
  }
@@ -718,44 +719,44 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
718
719
  }
719
720
  case PM_FIND_PATTERN_NODE: {
720
721
  if (((pm_find_pattern_node_t *)node)->constant == NULL) {
721
- pm_buffer_append_u8(buffer, 0);
722
+ pm_buffer_append_byte(buffer, 0);
722
723
  } else {
723
724
  pm_serialize_node(parser, (pm_node_t *)((pm_find_pattern_node_t *)node)->constant, buffer);
724
725
  }
725
726
  pm_serialize_node(parser, (pm_node_t *)((pm_find_pattern_node_t *)node)->left, buffer);
726
727
  uint32_t requireds_size = pm_sizet_to_u32(((pm_find_pattern_node_t *)node)->requireds.size);
727
- pm_buffer_append_u32(buffer, requireds_size);
728
+ pm_buffer_append_varint(buffer, requireds_size);
728
729
  for (uint32_t index = 0; index < requireds_size; index++) {
729
730
  pm_serialize_node(parser, (pm_node_t *) ((pm_find_pattern_node_t *)node)->requireds.nodes[index], buffer);
730
731
  }
731
732
  pm_serialize_node(parser, (pm_node_t *)((pm_find_pattern_node_t *)node)->right, buffer);
732
733
  if (((pm_find_pattern_node_t *)node)->opening_loc.start == NULL) {
733
- pm_buffer_append_u8(buffer, 0);
734
+ pm_buffer_append_byte(buffer, 0);
734
735
  } else {
735
- pm_buffer_append_u8(buffer, 1);
736
+ pm_buffer_append_byte(buffer, 1);
736
737
  pm_serialize_location(parser, &((pm_find_pattern_node_t *)node)->opening_loc, buffer);
737
738
  }
738
739
  if (((pm_find_pattern_node_t *)node)->closing_loc.start == NULL) {
739
- pm_buffer_append_u8(buffer, 0);
740
+ pm_buffer_append_byte(buffer, 0);
740
741
  } else {
741
- pm_buffer_append_u8(buffer, 1);
742
+ pm_buffer_append_byte(buffer, 1);
742
743
  pm_serialize_location(parser, &((pm_find_pattern_node_t *)node)->closing_loc, buffer);
743
744
  }
744
745
  break;
745
746
  }
746
747
  case PM_FLIP_FLOP_NODE: {
747
748
  if (((pm_flip_flop_node_t *)node)->left == NULL) {
748
- pm_buffer_append_u8(buffer, 0);
749
+ pm_buffer_append_byte(buffer, 0);
749
750
  } else {
750
751
  pm_serialize_node(parser, (pm_node_t *)((pm_flip_flop_node_t *)node)->left, buffer);
751
752
  }
752
753
  if (((pm_flip_flop_node_t *)node)->right == NULL) {
753
- pm_buffer_append_u8(buffer, 0);
754
+ pm_buffer_append_byte(buffer, 0);
754
755
  } else {
755
756
  pm_serialize_node(parser, (pm_node_t *)((pm_flip_flop_node_t *)node)->right, buffer);
756
757
  }
757
758
  pm_serialize_location(parser, &((pm_flip_flop_node_t *)node)->operator_loc, buffer);
758
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
759
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
759
760
  break;
760
761
  }
761
762
  case PM_FLOAT_NODE: {
@@ -765,16 +766,16 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
765
766
  pm_serialize_node(parser, (pm_node_t *)((pm_for_node_t *)node)->index, buffer);
766
767
  pm_serialize_node(parser, (pm_node_t *)((pm_for_node_t *)node)->collection, buffer);
767
768
  if (((pm_for_node_t *)node)->statements == NULL) {
768
- pm_buffer_append_u8(buffer, 0);
769
+ pm_buffer_append_byte(buffer, 0);
769
770
  } else {
770
771
  pm_serialize_node(parser, (pm_node_t *)((pm_for_node_t *)node)->statements, buffer);
771
772
  }
772
773
  pm_serialize_location(parser, &((pm_for_node_t *)node)->for_keyword_loc, buffer);
773
774
  pm_serialize_location(parser, &((pm_for_node_t *)node)->in_keyword_loc, buffer);
774
775
  if (((pm_for_node_t *)node)->do_keyword_loc.start == NULL) {
775
- pm_buffer_append_u8(buffer, 0);
776
+ pm_buffer_append_byte(buffer, 0);
776
777
  } else {
777
- pm_buffer_append_u8(buffer, 1);
778
+ pm_buffer_append_byte(buffer, 1);
778
779
  pm_serialize_location(parser, &((pm_for_node_t *)node)->do_keyword_loc, buffer);
779
780
  }
780
781
  pm_serialize_location(parser, &((pm_for_node_t *)node)->end_keyword_loc, buffer);
@@ -788,44 +789,44 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
788
789
  }
789
790
  case PM_FORWARDING_SUPER_NODE: {
790
791
  if (((pm_forwarding_super_node_t *)node)->block == NULL) {
791
- pm_buffer_append_u8(buffer, 0);
792
+ pm_buffer_append_byte(buffer, 0);
792
793
  } else {
793
794
  pm_serialize_node(parser, (pm_node_t *)((pm_forwarding_super_node_t *)node)->block, buffer);
794
795
  }
795
796
  break;
796
797
  }
797
798
  case PM_GLOBAL_VARIABLE_AND_WRITE_NODE: {
798
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_global_variable_and_write_node_t *)node)->name));
799
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_and_write_node_t *)node)->name));
799
800
  pm_serialize_location(parser, &((pm_global_variable_and_write_node_t *)node)->name_loc, buffer);
800
801
  pm_serialize_location(parser, &((pm_global_variable_and_write_node_t *)node)->operator_loc, buffer);
801
802
  pm_serialize_node(parser, (pm_node_t *)((pm_global_variable_and_write_node_t *)node)->value, buffer);
802
803
  break;
803
804
  }
804
805
  case PM_GLOBAL_VARIABLE_OPERATOR_WRITE_NODE: {
805
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_global_variable_operator_write_node_t *)node)->name));
806
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_operator_write_node_t *)node)->name));
806
807
  pm_serialize_location(parser, &((pm_global_variable_operator_write_node_t *)node)->name_loc, buffer);
807
808
  pm_serialize_location(parser, &((pm_global_variable_operator_write_node_t *)node)->operator_loc, buffer);
808
809
  pm_serialize_node(parser, (pm_node_t *)((pm_global_variable_operator_write_node_t *)node)->value, buffer);
809
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_global_variable_operator_write_node_t *)node)->operator));
810
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_operator_write_node_t *)node)->operator));
810
811
  break;
811
812
  }
812
813
  case PM_GLOBAL_VARIABLE_OR_WRITE_NODE: {
813
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_global_variable_or_write_node_t *)node)->name));
814
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_or_write_node_t *)node)->name));
814
815
  pm_serialize_location(parser, &((pm_global_variable_or_write_node_t *)node)->name_loc, buffer);
815
816
  pm_serialize_location(parser, &((pm_global_variable_or_write_node_t *)node)->operator_loc, buffer);
816
817
  pm_serialize_node(parser, (pm_node_t *)((pm_global_variable_or_write_node_t *)node)->value, buffer);
817
818
  break;
818
819
  }
819
820
  case PM_GLOBAL_VARIABLE_READ_NODE: {
820
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_global_variable_read_node_t *)node)->name));
821
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_read_node_t *)node)->name));
821
822
  break;
822
823
  }
823
824
  case PM_GLOBAL_VARIABLE_TARGET_NODE: {
824
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_global_variable_target_node_t *)node)->name));
825
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_target_node_t *)node)->name));
825
826
  break;
826
827
  }
827
828
  case PM_GLOBAL_VARIABLE_WRITE_NODE: {
828
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_global_variable_write_node_t *)node)->name));
829
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_global_variable_write_node_t *)node)->name));
829
830
  pm_serialize_location(parser, &((pm_global_variable_write_node_t *)node)->name_loc, buffer);
830
831
  pm_serialize_node(parser, (pm_node_t *)((pm_global_variable_write_node_t *)node)->value, buffer);
831
832
  pm_serialize_location(parser, &((pm_global_variable_write_node_t *)node)->operator_loc, buffer);
@@ -834,7 +835,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
834
835
  case PM_HASH_NODE: {
835
836
  pm_serialize_location(parser, &((pm_hash_node_t *)node)->opening_loc, buffer);
836
837
  uint32_t elements_size = pm_sizet_to_u32(((pm_hash_node_t *)node)->elements.size);
837
- pm_buffer_append_u32(buffer, elements_size);
838
+ pm_buffer_append_varint(buffer, elements_size);
838
839
  for (uint32_t index = 0; index < elements_size; index++) {
839
840
  pm_serialize_node(parser, (pm_node_t *) ((pm_hash_node_t *)node)->elements.nodes[index], buffer);
840
841
  }
@@ -843,56 +844,56 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
843
844
  }
844
845
  case PM_HASH_PATTERN_NODE: {
845
846
  if (((pm_hash_pattern_node_t *)node)->constant == NULL) {
846
- pm_buffer_append_u8(buffer, 0);
847
+ pm_buffer_append_byte(buffer, 0);
847
848
  } else {
848
849
  pm_serialize_node(parser, (pm_node_t *)((pm_hash_pattern_node_t *)node)->constant, buffer);
849
850
  }
850
- uint32_t assocs_size = pm_sizet_to_u32(((pm_hash_pattern_node_t *)node)->assocs.size);
851
- pm_buffer_append_u32(buffer, assocs_size);
852
- for (uint32_t index = 0; index < assocs_size; index++) {
853
- pm_serialize_node(parser, (pm_node_t *) ((pm_hash_pattern_node_t *)node)->assocs.nodes[index], buffer);
851
+ uint32_t elements_size = pm_sizet_to_u32(((pm_hash_pattern_node_t *)node)->elements.size);
852
+ pm_buffer_append_varint(buffer, elements_size);
853
+ for (uint32_t index = 0; index < elements_size; index++) {
854
+ pm_serialize_node(parser, (pm_node_t *) ((pm_hash_pattern_node_t *)node)->elements.nodes[index], buffer);
854
855
  }
855
- if (((pm_hash_pattern_node_t *)node)->kwrest == NULL) {
856
- pm_buffer_append_u8(buffer, 0);
856
+ if (((pm_hash_pattern_node_t *)node)->rest == NULL) {
857
+ pm_buffer_append_byte(buffer, 0);
857
858
  } else {
858
- pm_serialize_node(parser, (pm_node_t *)((pm_hash_pattern_node_t *)node)->kwrest, buffer);
859
+ pm_serialize_node(parser, (pm_node_t *)((pm_hash_pattern_node_t *)node)->rest, buffer);
859
860
  }
860
861
  if (((pm_hash_pattern_node_t *)node)->opening_loc.start == NULL) {
861
- pm_buffer_append_u8(buffer, 0);
862
+ pm_buffer_append_byte(buffer, 0);
862
863
  } else {
863
- pm_buffer_append_u8(buffer, 1);
864
+ pm_buffer_append_byte(buffer, 1);
864
865
  pm_serialize_location(parser, &((pm_hash_pattern_node_t *)node)->opening_loc, buffer);
865
866
  }
866
867
  if (((pm_hash_pattern_node_t *)node)->closing_loc.start == NULL) {
867
- pm_buffer_append_u8(buffer, 0);
868
+ pm_buffer_append_byte(buffer, 0);
868
869
  } else {
869
- pm_buffer_append_u8(buffer, 1);
870
+ pm_buffer_append_byte(buffer, 1);
870
871
  pm_serialize_location(parser, &((pm_hash_pattern_node_t *)node)->closing_loc, buffer);
871
872
  }
872
873
  break;
873
874
  }
874
875
  case PM_IF_NODE: {
875
876
  if (((pm_if_node_t *)node)->if_keyword_loc.start == NULL) {
876
- pm_buffer_append_u8(buffer, 0);
877
+ pm_buffer_append_byte(buffer, 0);
877
878
  } else {
878
- pm_buffer_append_u8(buffer, 1);
879
+ pm_buffer_append_byte(buffer, 1);
879
880
  pm_serialize_location(parser, &((pm_if_node_t *)node)->if_keyword_loc, buffer);
880
881
  }
881
882
  pm_serialize_node(parser, (pm_node_t *)((pm_if_node_t *)node)->predicate, buffer);
882
883
  if (((pm_if_node_t *)node)->statements == NULL) {
883
- pm_buffer_append_u8(buffer, 0);
884
+ pm_buffer_append_byte(buffer, 0);
884
885
  } else {
885
886
  pm_serialize_node(parser, (pm_node_t *)((pm_if_node_t *)node)->statements, buffer);
886
887
  }
887
888
  if (((pm_if_node_t *)node)->consequent == NULL) {
888
- pm_buffer_append_u8(buffer, 0);
889
+ pm_buffer_append_byte(buffer, 0);
889
890
  } else {
890
891
  pm_serialize_node(parser, (pm_node_t *)((pm_if_node_t *)node)->consequent, buffer);
891
892
  }
892
893
  if (((pm_if_node_t *)node)->end_keyword_loc.start == NULL) {
893
- pm_buffer_append_u8(buffer, 0);
894
+ pm_buffer_append_byte(buffer, 0);
894
895
  } else {
895
- pm_buffer_append_u8(buffer, 1);
896
+ pm_buffer_append_byte(buffer, 1);
896
897
  pm_serialize_location(parser, &((pm_if_node_t *)node)->end_keyword_loc, buffer);
897
898
  }
898
899
  break;
@@ -908,206 +909,206 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
908
909
  case PM_IN_NODE: {
909
910
  pm_serialize_node(parser, (pm_node_t *)((pm_in_node_t *)node)->pattern, buffer);
910
911
  if (((pm_in_node_t *)node)->statements == NULL) {
911
- pm_buffer_append_u8(buffer, 0);
912
+ pm_buffer_append_byte(buffer, 0);
912
913
  } else {
913
914
  pm_serialize_node(parser, (pm_node_t *)((pm_in_node_t *)node)->statements, buffer);
914
915
  }
915
916
  pm_serialize_location(parser, &((pm_in_node_t *)node)->in_loc, buffer);
916
917
  if (((pm_in_node_t *)node)->then_loc.start == NULL) {
917
- pm_buffer_append_u8(buffer, 0);
918
+ pm_buffer_append_byte(buffer, 0);
918
919
  } else {
919
- pm_buffer_append_u8(buffer, 1);
920
+ pm_buffer_append_byte(buffer, 1);
920
921
  pm_serialize_location(parser, &((pm_in_node_t *)node)->then_loc, buffer);
921
922
  }
922
923
  break;
923
924
  }
924
925
  case PM_INDEX_AND_WRITE_NODE: {
925
926
  if (((pm_index_and_write_node_t *)node)->receiver == NULL) {
926
- pm_buffer_append_u8(buffer, 0);
927
+ pm_buffer_append_byte(buffer, 0);
927
928
  } else {
928
929
  pm_serialize_node(parser, (pm_node_t *)((pm_index_and_write_node_t *)node)->receiver, buffer);
929
930
  }
930
931
  if (((pm_index_and_write_node_t *)node)->call_operator_loc.start == NULL) {
931
- pm_buffer_append_u8(buffer, 0);
932
+ pm_buffer_append_byte(buffer, 0);
932
933
  } else {
933
- pm_buffer_append_u8(buffer, 1);
934
+ pm_buffer_append_byte(buffer, 1);
934
935
  pm_serialize_location(parser, &((pm_index_and_write_node_t *)node)->call_operator_loc, buffer);
935
936
  }
936
937
  pm_serialize_location(parser, &((pm_index_and_write_node_t *)node)->opening_loc, buffer);
937
938
  if (((pm_index_and_write_node_t *)node)->arguments == NULL) {
938
- pm_buffer_append_u8(buffer, 0);
939
+ pm_buffer_append_byte(buffer, 0);
939
940
  } else {
940
941
  pm_serialize_node(parser, (pm_node_t *)((pm_index_and_write_node_t *)node)->arguments, buffer);
941
942
  }
942
943
  pm_serialize_location(parser, &((pm_index_and_write_node_t *)node)->closing_loc, buffer);
943
944
  if (((pm_index_and_write_node_t *)node)->block == NULL) {
944
- pm_buffer_append_u8(buffer, 0);
945
+ pm_buffer_append_byte(buffer, 0);
945
946
  } else {
946
947
  pm_serialize_node(parser, (pm_node_t *)((pm_index_and_write_node_t *)node)->block, buffer);
947
948
  }
948
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
949
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
949
950
  pm_serialize_location(parser, &((pm_index_and_write_node_t *)node)->operator_loc, buffer);
950
951
  pm_serialize_node(parser, (pm_node_t *)((pm_index_and_write_node_t *)node)->value, buffer);
951
952
  break;
952
953
  }
953
954
  case PM_INDEX_OPERATOR_WRITE_NODE: {
954
955
  if (((pm_index_operator_write_node_t *)node)->receiver == NULL) {
955
- pm_buffer_append_u8(buffer, 0);
956
+ pm_buffer_append_byte(buffer, 0);
956
957
  } else {
957
958
  pm_serialize_node(parser, (pm_node_t *)((pm_index_operator_write_node_t *)node)->receiver, buffer);
958
959
  }
959
960
  if (((pm_index_operator_write_node_t *)node)->call_operator_loc.start == NULL) {
960
- pm_buffer_append_u8(buffer, 0);
961
+ pm_buffer_append_byte(buffer, 0);
961
962
  } else {
962
- pm_buffer_append_u8(buffer, 1);
963
+ pm_buffer_append_byte(buffer, 1);
963
964
  pm_serialize_location(parser, &((pm_index_operator_write_node_t *)node)->call_operator_loc, buffer);
964
965
  }
965
966
  pm_serialize_location(parser, &((pm_index_operator_write_node_t *)node)->opening_loc, buffer);
966
967
  if (((pm_index_operator_write_node_t *)node)->arguments == NULL) {
967
- pm_buffer_append_u8(buffer, 0);
968
+ pm_buffer_append_byte(buffer, 0);
968
969
  } else {
969
970
  pm_serialize_node(parser, (pm_node_t *)((pm_index_operator_write_node_t *)node)->arguments, buffer);
970
971
  }
971
972
  pm_serialize_location(parser, &((pm_index_operator_write_node_t *)node)->closing_loc, buffer);
972
973
  if (((pm_index_operator_write_node_t *)node)->block == NULL) {
973
- pm_buffer_append_u8(buffer, 0);
974
+ pm_buffer_append_byte(buffer, 0);
974
975
  } else {
975
976
  pm_serialize_node(parser, (pm_node_t *)((pm_index_operator_write_node_t *)node)->block, buffer);
976
977
  }
977
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
978
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_index_operator_write_node_t *)node)->operator));
978
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
979
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_index_operator_write_node_t *)node)->operator));
979
980
  pm_serialize_location(parser, &((pm_index_operator_write_node_t *)node)->operator_loc, buffer);
980
981
  pm_serialize_node(parser, (pm_node_t *)((pm_index_operator_write_node_t *)node)->value, buffer);
981
982
  break;
982
983
  }
983
984
  case PM_INDEX_OR_WRITE_NODE: {
984
985
  if (((pm_index_or_write_node_t *)node)->receiver == NULL) {
985
- pm_buffer_append_u8(buffer, 0);
986
+ pm_buffer_append_byte(buffer, 0);
986
987
  } else {
987
988
  pm_serialize_node(parser, (pm_node_t *)((pm_index_or_write_node_t *)node)->receiver, buffer);
988
989
  }
989
990
  if (((pm_index_or_write_node_t *)node)->call_operator_loc.start == NULL) {
990
- pm_buffer_append_u8(buffer, 0);
991
+ pm_buffer_append_byte(buffer, 0);
991
992
  } else {
992
- pm_buffer_append_u8(buffer, 1);
993
+ pm_buffer_append_byte(buffer, 1);
993
994
  pm_serialize_location(parser, &((pm_index_or_write_node_t *)node)->call_operator_loc, buffer);
994
995
  }
995
996
  pm_serialize_location(parser, &((pm_index_or_write_node_t *)node)->opening_loc, buffer);
996
997
  if (((pm_index_or_write_node_t *)node)->arguments == NULL) {
997
- pm_buffer_append_u8(buffer, 0);
998
+ pm_buffer_append_byte(buffer, 0);
998
999
  } else {
999
1000
  pm_serialize_node(parser, (pm_node_t *)((pm_index_or_write_node_t *)node)->arguments, buffer);
1000
1001
  }
1001
1002
  pm_serialize_location(parser, &((pm_index_or_write_node_t *)node)->closing_loc, buffer);
1002
1003
  if (((pm_index_or_write_node_t *)node)->block == NULL) {
1003
- pm_buffer_append_u8(buffer, 0);
1004
+ pm_buffer_append_byte(buffer, 0);
1004
1005
  } else {
1005
1006
  pm_serialize_node(parser, (pm_node_t *)((pm_index_or_write_node_t *)node)->block, buffer);
1006
1007
  }
1007
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1008
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1008
1009
  pm_serialize_location(parser, &((pm_index_or_write_node_t *)node)->operator_loc, buffer);
1009
1010
  pm_serialize_node(parser, (pm_node_t *)((pm_index_or_write_node_t *)node)->value, buffer);
1010
1011
  break;
1011
1012
  }
1012
1013
  case PM_INSTANCE_VARIABLE_AND_WRITE_NODE: {
1013
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_instance_variable_and_write_node_t *)node)->name));
1014
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_and_write_node_t *)node)->name));
1014
1015
  pm_serialize_location(parser, &((pm_instance_variable_and_write_node_t *)node)->name_loc, buffer);
1015
1016
  pm_serialize_location(parser, &((pm_instance_variable_and_write_node_t *)node)->operator_loc, buffer);
1016
1017
  pm_serialize_node(parser, (pm_node_t *)((pm_instance_variable_and_write_node_t *)node)->value, buffer);
1017
1018
  break;
1018
1019
  }
1019
1020
  case PM_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE: {
1020
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_instance_variable_operator_write_node_t *)node)->name));
1021
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_operator_write_node_t *)node)->name));
1021
1022
  pm_serialize_location(parser, &((pm_instance_variable_operator_write_node_t *)node)->name_loc, buffer);
1022
1023
  pm_serialize_location(parser, &((pm_instance_variable_operator_write_node_t *)node)->operator_loc, buffer);
1023
1024
  pm_serialize_node(parser, (pm_node_t *)((pm_instance_variable_operator_write_node_t *)node)->value, buffer);
1024
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_instance_variable_operator_write_node_t *)node)->operator));
1025
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_operator_write_node_t *)node)->operator));
1025
1026
  break;
1026
1027
  }
1027
1028
  case PM_INSTANCE_VARIABLE_OR_WRITE_NODE: {
1028
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_instance_variable_or_write_node_t *)node)->name));
1029
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_or_write_node_t *)node)->name));
1029
1030
  pm_serialize_location(parser, &((pm_instance_variable_or_write_node_t *)node)->name_loc, buffer);
1030
1031
  pm_serialize_location(parser, &((pm_instance_variable_or_write_node_t *)node)->operator_loc, buffer);
1031
1032
  pm_serialize_node(parser, (pm_node_t *)((pm_instance_variable_or_write_node_t *)node)->value, buffer);
1032
1033
  break;
1033
1034
  }
1034
1035
  case PM_INSTANCE_VARIABLE_READ_NODE: {
1035
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_instance_variable_read_node_t *)node)->name));
1036
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_read_node_t *)node)->name));
1036
1037
  break;
1037
1038
  }
1038
1039
  case PM_INSTANCE_VARIABLE_TARGET_NODE: {
1039
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_instance_variable_target_node_t *)node)->name));
1040
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_target_node_t *)node)->name));
1040
1041
  break;
1041
1042
  }
1042
1043
  case PM_INSTANCE_VARIABLE_WRITE_NODE: {
1043
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_instance_variable_write_node_t *)node)->name));
1044
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_instance_variable_write_node_t *)node)->name));
1044
1045
  pm_serialize_location(parser, &((pm_instance_variable_write_node_t *)node)->name_loc, buffer);
1045
1046
  pm_serialize_node(parser, (pm_node_t *)((pm_instance_variable_write_node_t *)node)->value, buffer);
1046
1047
  pm_serialize_location(parser, &((pm_instance_variable_write_node_t *)node)->operator_loc, buffer);
1047
1048
  break;
1048
1049
  }
1049
1050
  case PM_INTEGER_NODE: {
1050
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1051
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1051
1052
  break;
1052
1053
  }
1053
1054
  case PM_INTERPOLATED_MATCH_LAST_LINE_NODE: {
1054
1055
  pm_serialize_location(parser, &((pm_interpolated_match_last_line_node_t *)node)->opening_loc, buffer);
1055
1056
  uint32_t parts_size = pm_sizet_to_u32(((pm_interpolated_match_last_line_node_t *)node)->parts.size);
1056
- pm_buffer_append_u32(buffer, parts_size);
1057
+ pm_buffer_append_varint(buffer, parts_size);
1057
1058
  for (uint32_t index = 0; index < parts_size; index++) {
1058
1059
  pm_serialize_node(parser, (pm_node_t *) ((pm_interpolated_match_last_line_node_t *)node)->parts.nodes[index], buffer);
1059
1060
  }
1060
1061
  pm_serialize_location(parser, &((pm_interpolated_match_last_line_node_t *)node)->closing_loc, buffer);
1061
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1062
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1062
1063
  break;
1063
1064
  }
1064
1065
  case PM_INTERPOLATED_REGULAR_EXPRESSION_NODE: {
1065
1066
  pm_serialize_location(parser, &((pm_interpolated_regular_expression_node_t *)node)->opening_loc, buffer);
1066
1067
  uint32_t parts_size = pm_sizet_to_u32(((pm_interpolated_regular_expression_node_t *)node)->parts.size);
1067
- pm_buffer_append_u32(buffer, parts_size);
1068
+ pm_buffer_append_varint(buffer, parts_size);
1068
1069
  for (uint32_t index = 0; index < parts_size; index++) {
1069
1070
  pm_serialize_node(parser, (pm_node_t *) ((pm_interpolated_regular_expression_node_t *)node)->parts.nodes[index], buffer);
1070
1071
  }
1071
1072
  pm_serialize_location(parser, &((pm_interpolated_regular_expression_node_t *)node)->closing_loc, buffer);
1072
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1073
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1073
1074
  break;
1074
1075
  }
1075
1076
  case PM_INTERPOLATED_STRING_NODE: {
1076
1077
  if (((pm_interpolated_string_node_t *)node)->opening_loc.start == NULL) {
1077
- pm_buffer_append_u8(buffer, 0);
1078
+ pm_buffer_append_byte(buffer, 0);
1078
1079
  } else {
1079
- pm_buffer_append_u8(buffer, 1);
1080
+ pm_buffer_append_byte(buffer, 1);
1080
1081
  pm_serialize_location(parser, &((pm_interpolated_string_node_t *)node)->opening_loc, buffer);
1081
1082
  }
1082
1083
  uint32_t parts_size = pm_sizet_to_u32(((pm_interpolated_string_node_t *)node)->parts.size);
1083
- pm_buffer_append_u32(buffer, parts_size);
1084
+ pm_buffer_append_varint(buffer, parts_size);
1084
1085
  for (uint32_t index = 0; index < parts_size; index++) {
1085
1086
  pm_serialize_node(parser, (pm_node_t *) ((pm_interpolated_string_node_t *)node)->parts.nodes[index], buffer);
1086
1087
  }
1087
1088
  if (((pm_interpolated_string_node_t *)node)->closing_loc.start == NULL) {
1088
- pm_buffer_append_u8(buffer, 0);
1089
+ pm_buffer_append_byte(buffer, 0);
1089
1090
  } else {
1090
- pm_buffer_append_u8(buffer, 1);
1091
+ pm_buffer_append_byte(buffer, 1);
1091
1092
  pm_serialize_location(parser, &((pm_interpolated_string_node_t *)node)->closing_loc, buffer);
1092
1093
  }
1093
1094
  break;
1094
1095
  }
1095
1096
  case PM_INTERPOLATED_SYMBOL_NODE: {
1096
1097
  if (((pm_interpolated_symbol_node_t *)node)->opening_loc.start == NULL) {
1097
- pm_buffer_append_u8(buffer, 0);
1098
+ pm_buffer_append_byte(buffer, 0);
1098
1099
  } else {
1099
- pm_buffer_append_u8(buffer, 1);
1100
+ pm_buffer_append_byte(buffer, 1);
1100
1101
  pm_serialize_location(parser, &((pm_interpolated_symbol_node_t *)node)->opening_loc, buffer);
1101
1102
  }
1102
1103
  uint32_t parts_size = pm_sizet_to_u32(((pm_interpolated_symbol_node_t *)node)->parts.size);
1103
- pm_buffer_append_u32(buffer, parts_size);
1104
+ pm_buffer_append_varint(buffer, parts_size);
1104
1105
  for (uint32_t index = 0; index < parts_size; index++) {
1105
1106
  pm_serialize_node(parser, (pm_node_t *) ((pm_interpolated_symbol_node_t *)node)->parts.nodes[index], buffer);
1106
1107
  }
1107
1108
  if (((pm_interpolated_symbol_node_t *)node)->closing_loc.start == NULL) {
1108
- pm_buffer_append_u8(buffer, 0);
1109
+ pm_buffer_append_byte(buffer, 0);
1109
1110
  } else {
1110
- pm_buffer_append_u8(buffer, 1);
1111
+ pm_buffer_append_byte(buffer, 1);
1111
1112
  pm_serialize_location(parser, &((pm_interpolated_symbol_node_t *)node)->closing_loc, buffer);
1112
1113
  }
1113
1114
  break;
@@ -1115,7 +1116,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1115
1116
  case PM_INTERPOLATED_X_STRING_NODE: {
1116
1117
  pm_serialize_location(parser, &((pm_interpolated_x_string_node_t *)node)->opening_loc, buffer);
1117
1118
  uint32_t parts_size = pm_sizet_to_u32(((pm_interpolated_x_string_node_t *)node)->parts.size);
1118
- pm_buffer_append_u32(buffer, parts_size);
1119
+ pm_buffer_append_varint(buffer, parts_size);
1119
1120
  for (uint32_t index = 0; index < parts_size; index++) {
1120
1121
  pm_serialize_node(parser, (pm_node_t *) ((pm_interpolated_x_string_node_t *)node)->parts.nodes[index], buffer);
1121
1122
  }
@@ -1124,28 +1125,28 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1124
1125
  }
1125
1126
  case PM_KEYWORD_HASH_NODE: {
1126
1127
  uint32_t elements_size = pm_sizet_to_u32(((pm_keyword_hash_node_t *)node)->elements.size);
1127
- pm_buffer_append_u32(buffer, elements_size);
1128
+ pm_buffer_append_varint(buffer, elements_size);
1128
1129
  for (uint32_t index = 0; index < elements_size; index++) {
1129
1130
  pm_serialize_node(parser, (pm_node_t *) ((pm_keyword_hash_node_t *)node)->elements.nodes[index], buffer);
1130
1131
  }
1131
1132
  break;
1132
1133
  }
1133
1134
  case PM_KEYWORD_PARAMETER_NODE: {
1134
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_keyword_parameter_node_t *)node)->name));
1135
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_keyword_parameter_node_t *)node)->name));
1135
1136
  pm_serialize_location(parser, &((pm_keyword_parameter_node_t *)node)->name_loc, buffer);
1136
1137
  if (((pm_keyword_parameter_node_t *)node)->value == NULL) {
1137
- pm_buffer_append_u8(buffer, 0);
1138
+ pm_buffer_append_byte(buffer, 0);
1138
1139
  } else {
1139
1140
  pm_serialize_node(parser, (pm_node_t *)((pm_keyword_parameter_node_t *)node)->value, buffer);
1140
1141
  }
1141
1142
  break;
1142
1143
  }
1143
1144
  case PM_KEYWORD_REST_PARAMETER_NODE: {
1144
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_keyword_rest_parameter_node_t *)node)->name));
1145
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_keyword_rest_parameter_node_t *)node)->name));
1145
1146
  if (((pm_keyword_rest_parameter_node_t *)node)->name_loc.start == NULL) {
1146
- pm_buffer_append_u8(buffer, 0);
1147
+ pm_buffer_append_byte(buffer, 0);
1147
1148
  } else {
1148
- pm_buffer_append_u8(buffer, 1);
1149
+ pm_buffer_append_byte(buffer, 1);
1149
1150
  pm_serialize_location(parser, &((pm_keyword_rest_parameter_node_t *)node)->name_loc, buffer);
1150
1151
  }
1151
1152
  pm_serialize_location(parser, &((pm_keyword_rest_parameter_node_t *)node)->operator_loc, buffer);
@@ -1153,20 +1154,20 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1153
1154
  }
1154
1155
  case PM_LAMBDA_NODE: {
1155
1156
  uint32_t locals_size = pm_sizet_to_u32(((pm_lambda_node_t *)node)->locals.size);
1156
- pm_buffer_append_u32(buffer, locals_size);
1157
+ pm_buffer_append_varint(buffer, locals_size);
1157
1158
  for (uint32_t index = 0; index < locals_size; index++) {
1158
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_lambda_node_t *)node)->locals.ids[index]));
1159
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_lambda_node_t *)node)->locals.ids[index]));
1159
1160
  }
1160
1161
  pm_serialize_location(parser, &((pm_lambda_node_t *)node)->operator_loc, buffer);
1161
1162
  pm_serialize_location(parser, &((pm_lambda_node_t *)node)->opening_loc, buffer);
1162
1163
  pm_serialize_location(parser, &((pm_lambda_node_t *)node)->closing_loc, buffer);
1163
1164
  if (((pm_lambda_node_t *)node)->parameters == NULL) {
1164
- pm_buffer_append_u8(buffer, 0);
1165
+ pm_buffer_append_byte(buffer, 0);
1165
1166
  } else {
1166
1167
  pm_serialize_node(parser, (pm_node_t *)((pm_lambda_node_t *)node)->parameters, buffer);
1167
1168
  }
1168
1169
  if (((pm_lambda_node_t *)node)->body == NULL) {
1169
- pm_buffer_append_u8(buffer, 0);
1170
+ pm_buffer_append_byte(buffer, 0);
1170
1171
  } else {
1171
1172
  pm_serialize_node(parser, (pm_node_t *)((pm_lambda_node_t *)node)->body, buffer);
1172
1173
  }
@@ -1176,40 +1177,40 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1176
1177
  pm_serialize_location(parser, &((pm_local_variable_and_write_node_t *)node)->name_loc, buffer);
1177
1178
  pm_serialize_location(parser, &((pm_local_variable_and_write_node_t *)node)->operator_loc, buffer);
1178
1179
  pm_serialize_node(parser, (pm_node_t *)((pm_local_variable_and_write_node_t *)node)->value, buffer);
1179
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_local_variable_and_write_node_t *)node)->name));
1180
- pm_buffer_append_u32(buffer, ((pm_local_variable_and_write_node_t *)node)->depth);
1180
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_and_write_node_t *)node)->name));
1181
+ pm_buffer_append_varint(buffer, ((pm_local_variable_and_write_node_t *)node)->depth);
1181
1182
  break;
1182
1183
  }
1183
1184
  case PM_LOCAL_VARIABLE_OPERATOR_WRITE_NODE: {
1184
1185
  pm_serialize_location(parser, &((pm_local_variable_operator_write_node_t *)node)->name_loc, buffer);
1185
1186
  pm_serialize_location(parser, &((pm_local_variable_operator_write_node_t *)node)->operator_loc, buffer);
1186
1187
  pm_serialize_node(parser, (pm_node_t *)((pm_local_variable_operator_write_node_t *)node)->value, buffer);
1187
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_local_variable_operator_write_node_t *)node)->name));
1188
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_local_variable_operator_write_node_t *)node)->operator));
1189
- pm_buffer_append_u32(buffer, ((pm_local_variable_operator_write_node_t *)node)->depth);
1188
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_operator_write_node_t *)node)->name));
1189
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_operator_write_node_t *)node)->operator));
1190
+ pm_buffer_append_varint(buffer, ((pm_local_variable_operator_write_node_t *)node)->depth);
1190
1191
  break;
1191
1192
  }
1192
1193
  case PM_LOCAL_VARIABLE_OR_WRITE_NODE: {
1193
1194
  pm_serialize_location(parser, &((pm_local_variable_or_write_node_t *)node)->name_loc, buffer);
1194
1195
  pm_serialize_location(parser, &((pm_local_variable_or_write_node_t *)node)->operator_loc, buffer);
1195
1196
  pm_serialize_node(parser, (pm_node_t *)((pm_local_variable_or_write_node_t *)node)->value, buffer);
1196
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_local_variable_or_write_node_t *)node)->name));
1197
- pm_buffer_append_u32(buffer, ((pm_local_variable_or_write_node_t *)node)->depth);
1197
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_or_write_node_t *)node)->name));
1198
+ pm_buffer_append_varint(buffer, ((pm_local_variable_or_write_node_t *)node)->depth);
1198
1199
  break;
1199
1200
  }
1200
1201
  case PM_LOCAL_VARIABLE_READ_NODE: {
1201
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_local_variable_read_node_t *)node)->name));
1202
- pm_buffer_append_u32(buffer, ((pm_local_variable_read_node_t *)node)->depth);
1202
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_read_node_t *)node)->name));
1203
+ pm_buffer_append_varint(buffer, ((pm_local_variable_read_node_t *)node)->depth);
1203
1204
  break;
1204
1205
  }
1205
1206
  case PM_LOCAL_VARIABLE_TARGET_NODE: {
1206
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_local_variable_target_node_t *)node)->name));
1207
- pm_buffer_append_u32(buffer, ((pm_local_variable_target_node_t *)node)->depth);
1207
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_target_node_t *)node)->name));
1208
+ pm_buffer_append_varint(buffer, ((pm_local_variable_target_node_t *)node)->depth);
1208
1209
  break;
1209
1210
  }
1210
1211
  case PM_LOCAL_VARIABLE_WRITE_NODE: {
1211
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_local_variable_write_node_t *)node)->name));
1212
- pm_buffer_append_u32(buffer, ((pm_local_variable_write_node_t *)node)->depth);
1212
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_local_variable_write_node_t *)node)->name));
1213
+ pm_buffer_append_varint(buffer, ((pm_local_variable_write_node_t *)node)->depth);
1213
1214
  pm_serialize_location(parser, &((pm_local_variable_write_node_t *)node)->name_loc, buffer);
1214
1215
  pm_serialize_node(parser, (pm_node_t *)((pm_local_variable_write_node_t *)node)->value, buffer);
1215
1216
  pm_serialize_location(parser, &((pm_local_variable_write_node_t *)node)->operator_loc, buffer);
@@ -1220,7 +1221,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1220
1221
  pm_serialize_location(parser, &((pm_match_last_line_node_t *)node)->content_loc, buffer);
1221
1222
  pm_serialize_location(parser, &((pm_match_last_line_node_t *)node)->closing_loc, buffer);
1222
1223
  pm_serialize_string(parser, &((pm_match_last_line_node_t *)node)->unescaped, buffer);
1223
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1224
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1224
1225
  break;
1225
1226
  }
1226
1227
  case PM_MATCH_PREDICATE_NODE: {
@@ -1238,9 +1239,9 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1238
1239
  case PM_MATCH_WRITE_NODE: {
1239
1240
  pm_serialize_node(parser, (pm_node_t *)((pm_match_write_node_t *)node)->call, buffer);
1240
1241
  uint32_t locals_size = pm_sizet_to_u32(((pm_match_write_node_t *)node)->locals.size);
1241
- pm_buffer_append_u32(buffer, locals_size);
1242
+ pm_buffer_append_varint(buffer, locals_size);
1242
1243
  for (uint32_t index = 0; index < locals_size; index++) {
1243
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_match_write_node_t *)node)->locals.ids[index]));
1244
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_match_write_node_t *)node)->locals.ids[index]));
1244
1245
  }
1245
1246
  break;
1246
1247
  }
@@ -1249,57 +1250,77 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1249
1250
  }
1250
1251
  case PM_MODULE_NODE: {
1251
1252
  uint32_t locals_size = pm_sizet_to_u32(((pm_module_node_t *)node)->locals.size);
1252
- pm_buffer_append_u32(buffer, locals_size);
1253
+ pm_buffer_append_varint(buffer, locals_size);
1253
1254
  for (uint32_t index = 0; index < locals_size; index++) {
1254
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_module_node_t *)node)->locals.ids[index]));
1255
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_module_node_t *)node)->locals.ids[index]));
1255
1256
  }
1256
1257
  pm_serialize_location(parser, &((pm_module_node_t *)node)->module_keyword_loc, buffer);
1257
1258
  pm_serialize_node(parser, (pm_node_t *)((pm_module_node_t *)node)->constant_path, buffer);
1258
1259
  if (((pm_module_node_t *)node)->body == NULL) {
1259
- pm_buffer_append_u8(buffer, 0);
1260
+ pm_buffer_append_byte(buffer, 0);
1260
1261
  } else {
1261
1262
  pm_serialize_node(parser, (pm_node_t *)((pm_module_node_t *)node)->body, buffer);
1262
1263
  }
1263
1264
  pm_serialize_location(parser, &((pm_module_node_t *)node)->end_keyword_loc, buffer);
1264
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_module_node_t *)node)->name));
1265
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_module_node_t *)node)->name));
1265
1266
  break;
1266
1267
  }
1267
1268
  case PM_MULTI_TARGET_NODE: {
1268
- uint32_t targets_size = pm_sizet_to_u32(((pm_multi_target_node_t *)node)->targets.size);
1269
- pm_buffer_append_u32(buffer, targets_size);
1270
- for (uint32_t index = 0; index < targets_size; index++) {
1271
- pm_serialize_node(parser, (pm_node_t *) ((pm_multi_target_node_t *)node)->targets.nodes[index], buffer);
1269
+ uint32_t lefts_size = pm_sizet_to_u32(((pm_multi_target_node_t *)node)->lefts.size);
1270
+ pm_buffer_append_varint(buffer, lefts_size);
1271
+ for (uint32_t index = 0; index < lefts_size; index++) {
1272
+ pm_serialize_node(parser, (pm_node_t *) ((pm_multi_target_node_t *)node)->lefts.nodes[index], buffer);
1273
+ }
1274
+ if (((pm_multi_target_node_t *)node)->rest == NULL) {
1275
+ pm_buffer_append_byte(buffer, 0);
1276
+ } else {
1277
+ pm_serialize_node(parser, (pm_node_t *)((pm_multi_target_node_t *)node)->rest, buffer);
1278
+ }
1279
+ uint32_t rights_size = pm_sizet_to_u32(((pm_multi_target_node_t *)node)->rights.size);
1280
+ pm_buffer_append_varint(buffer, rights_size);
1281
+ for (uint32_t index = 0; index < rights_size; index++) {
1282
+ pm_serialize_node(parser, (pm_node_t *) ((pm_multi_target_node_t *)node)->rights.nodes[index], buffer);
1272
1283
  }
1273
1284
  if (((pm_multi_target_node_t *)node)->lparen_loc.start == NULL) {
1274
- pm_buffer_append_u8(buffer, 0);
1285
+ pm_buffer_append_byte(buffer, 0);
1275
1286
  } else {
1276
- pm_buffer_append_u8(buffer, 1);
1287
+ pm_buffer_append_byte(buffer, 1);
1277
1288
  pm_serialize_location(parser, &((pm_multi_target_node_t *)node)->lparen_loc, buffer);
1278
1289
  }
1279
1290
  if (((pm_multi_target_node_t *)node)->rparen_loc.start == NULL) {
1280
- pm_buffer_append_u8(buffer, 0);
1291
+ pm_buffer_append_byte(buffer, 0);
1281
1292
  } else {
1282
- pm_buffer_append_u8(buffer, 1);
1293
+ pm_buffer_append_byte(buffer, 1);
1283
1294
  pm_serialize_location(parser, &((pm_multi_target_node_t *)node)->rparen_loc, buffer);
1284
1295
  }
1285
1296
  break;
1286
1297
  }
1287
1298
  case PM_MULTI_WRITE_NODE: {
1288
- uint32_t targets_size = pm_sizet_to_u32(((pm_multi_write_node_t *)node)->targets.size);
1289
- pm_buffer_append_u32(buffer, targets_size);
1290
- for (uint32_t index = 0; index < targets_size; index++) {
1291
- pm_serialize_node(parser, (pm_node_t *) ((pm_multi_write_node_t *)node)->targets.nodes[index], buffer);
1299
+ uint32_t lefts_size = pm_sizet_to_u32(((pm_multi_write_node_t *)node)->lefts.size);
1300
+ pm_buffer_append_varint(buffer, lefts_size);
1301
+ for (uint32_t index = 0; index < lefts_size; index++) {
1302
+ pm_serialize_node(parser, (pm_node_t *) ((pm_multi_write_node_t *)node)->lefts.nodes[index], buffer);
1303
+ }
1304
+ if (((pm_multi_write_node_t *)node)->rest == NULL) {
1305
+ pm_buffer_append_byte(buffer, 0);
1306
+ } else {
1307
+ pm_serialize_node(parser, (pm_node_t *)((pm_multi_write_node_t *)node)->rest, buffer);
1308
+ }
1309
+ uint32_t rights_size = pm_sizet_to_u32(((pm_multi_write_node_t *)node)->rights.size);
1310
+ pm_buffer_append_varint(buffer, rights_size);
1311
+ for (uint32_t index = 0; index < rights_size; index++) {
1312
+ pm_serialize_node(parser, (pm_node_t *) ((pm_multi_write_node_t *)node)->rights.nodes[index], buffer);
1292
1313
  }
1293
1314
  if (((pm_multi_write_node_t *)node)->lparen_loc.start == NULL) {
1294
- pm_buffer_append_u8(buffer, 0);
1315
+ pm_buffer_append_byte(buffer, 0);
1295
1316
  } else {
1296
- pm_buffer_append_u8(buffer, 1);
1317
+ pm_buffer_append_byte(buffer, 1);
1297
1318
  pm_serialize_location(parser, &((pm_multi_write_node_t *)node)->lparen_loc, buffer);
1298
1319
  }
1299
1320
  if (((pm_multi_write_node_t *)node)->rparen_loc.start == NULL) {
1300
- pm_buffer_append_u8(buffer, 0);
1321
+ pm_buffer_append_byte(buffer, 0);
1301
1322
  } else {
1302
- pm_buffer_append_u8(buffer, 1);
1323
+ pm_buffer_append_byte(buffer, 1);
1303
1324
  pm_serialize_location(parser, &((pm_multi_write_node_t *)node)->rparen_loc, buffer);
1304
1325
  }
1305
1326
  pm_serialize_location(parser, &((pm_multi_write_node_t *)node)->operator_loc, buffer);
@@ -1308,7 +1329,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1308
1329
  }
1309
1330
  case PM_NEXT_NODE: {
1310
1331
  if (((pm_next_node_t *)node)->arguments == NULL) {
1311
- pm_buffer_append_u8(buffer, 0);
1332
+ pm_buffer_append_byte(buffer, 0);
1312
1333
  } else {
1313
1334
  pm_serialize_node(parser, (pm_node_t *)((pm_next_node_t *)node)->arguments, buffer);
1314
1335
  }
@@ -1324,11 +1345,11 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1324
1345
  break;
1325
1346
  }
1326
1347
  case PM_NUMBERED_REFERENCE_READ_NODE: {
1327
- pm_buffer_append_u32(buffer, ((pm_numbered_reference_read_node_t *)node)->number);
1348
+ pm_buffer_append_varint(buffer, ((pm_numbered_reference_read_node_t *)node)->number);
1328
1349
  break;
1329
1350
  }
1330
1351
  case PM_OPTIONAL_PARAMETER_NODE: {
1331
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_optional_parameter_node_t *)node)->name));
1352
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_optional_parameter_node_t *)node)->name));
1332
1353
  pm_serialize_location(parser, &((pm_optional_parameter_node_t *)node)->name_loc, buffer);
1333
1354
  pm_serialize_location(parser, &((pm_optional_parameter_node_t *)node)->operator_loc, buffer);
1334
1355
  pm_serialize_node(parser, (pm_node_t *)((pm_optional_parameter_node_t *)node)->value, buffer);
@@ -1342,37 +1363,37 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1342
1363
  }
1343
1364
  case PM_PARAMETERS_NODE: {
1344
1365
  uint32_t requireds_size = pm_sizet_to_u32(((pm_parameters_node_t *)node)->requireds.size);
1345
- pm_buffer_append_u32(buffer, requireds_size);
1366
+ pm_buffer_append_varint(buffer, requireds_size);
1346
1367
  for (uint32_t index = 0; index < requireds_size; index++) {
1347
1368
  pm_serialize_node(parser, (pm_node_t *) ((pm_parameters_node_t *)node)->requireds.nodes[index], buffer);
1348
1369
  }
1349
1370
  uint32_t optionals_size = pm_sizet_to_u32(((pm_parameters_node_t *)node)->optionals.size);
1350
- pm_buffer_append_u32(buffer, optionals_size);
1371
+ pm_buffer_append_varint(buffer, optionals_size);
1351
1372
  for (uint32_t index = 0; index < optionals_size; index++) {
1352
1373
  pm_serialize_node(parser, (pm_node_t *) ((pm_parameters_node_t *)node)->optionals.nodes[index], buffer);
1353
1374
  }
1354
1375
  if (((pm_parameters_node_t *)node)->rest == NULL) {
1355
- pm_buffer_append_u8(buffer, 0);
1376
+ pm_buffer_append_byte(buffer, 0);
1356
1377
  } else {
1357
1378
  pm_serialize_node(parser, (pm_node_t *)((pm_parameters_node_t *)node)->rest, buffer);
1358
1379
  }
1359
1380
  uint32_t posts_size = pm_sizet_to_u32(((pm_parameters_node_t *)node)->posts.size);
1360
- pm_buffer_append_u32(buffer, posts_size);
1381
+ pm_buffer_append_varint(buffer, posts_size);
1361
1382
  for (uint32_t index = 0; index < posts_size; index++) {
1362
1383
  pm_serialize_node(parser, (pm_node_t *) ((pm_parameters_node_t *)node)->posts.nodes[index], buffer);
1363
1384
  }
1364
1385
  uint32_t keywords_size = pm_sizet_to_u32(((pm_parameters_node_t *)node)->keywords.size);
1365
- pm_buffer_append_u32(buffer, keywords_size);
1386
+ pm_buffer_append_varint(buffer, keywords_size);
1366
1387
  for (uint32_t index = 0; index < keywords_size; index++) {
1367
1388
  pm_serialize_node(parser, (pm_node_t *) ((pm_parameters_node_t *)node)->keywords.nodes[index], buffer);
1368
1389
  }
1369
1390
  if (((pm_parameters_node_t *)node)->keyword_rest == NULL) {
1370
- pm_buffer_append_u8(buffer, 0);
1391
+ pm_buffer_append_byte(buffer, 0);
1371
1392
  } else {
1372
1393
  pm_serialize_node(parser, (pm_node_t *)((pm_parameters_node_t *)node)->keyword_rest, buffer);
1373
1394
  }
1374
1395
  if (((pm_parameters_node_t *)node)->block == NULL) {
1375
- pm_buffer_append_u8(buffer, 0);
1396
+ pm_buffer_append_byte(buffer, 0);
1376
1397
  } else {
1377
1398
  pm_serialize_node(parser, (pm_node_t *)((pm_parameters_node_t *)node)->block, buffer);
1378
1399
  }
@@ -1380,7 +1401,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1380
1401
  }
1381
1402
  case PM_PARENTHESES_NODE: {
1382
1403
  if (((pm_parentheses_node_t *)node)->body == NULL) {
1383
- pm_buffer_append_u8(buffer, 0);
1404
+ pm_buffer_append_byte(buffer, 0);
1384
1405
  } else {
1385
1406
  pm_serialize_node(parser, (pm_node_t *)((pm_parentheses_node_t *)node)->body, buffer);
1386
1407
  }
@@ -1402,7 +1423,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1402
1423
  }
1403
1424
  case PM_POST_EXECUTION_NODE: {
1404
1425
  if (((pm_post_execution_node_t *)node)->statements == NULL) {
1405
- pm_buffer_append_u8(buffer, 0);
1426
+ pm_buffer_append_byte(buffer, 0);
1406
1427
  } else {
1407
1428
  pm_serialize_node(parser, (pm_node_t *)((pm_post_execution_node_t *)node)->statements, buffer);
1408
1429
  }
@@ -1413,7 +1434,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1413
1434
  }
1414
1435
  case PM_PRE_EXECUTION_NODE: {
1415
1436
  if (((pm_pre_execution_node_t *)node)->statements == NULL) {
1416
- pm_buffer_append_u8(buffer, 0);
1437
+ pm_buffer_append_byte(buffer, 0);
1417
1438
  } else {
1418
1439
  pm_serialize_node(parser, (pm_node_t *)((pm_pre_execution_node_t *)node)->statements, buffer);
1419
1440
  }
@@ -1424,26 +1445,26 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1424
1445
  }
1425
1446
  case PM_PROGRAM_NODE: {
1426
1447
  uint32_t locals_size = pm_sizet_to_u32(((pm_program_node_t *)node)->locals.size);
1427
- pm_buffer_append_u32(buffer, locals_size);
1448
+ pm_buffer_append_varint(buffer, locals_size);
1428
1449
  for (uint32_t index = 0; index < locals_size; index++) {
1429
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_program_node_t *)node)->locals.ids[index]));
1450
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_program_node_t *)node)->locals.ids[index]));
1430
1451
  }
1431
1452
  pm_serialize_node(parser, (pm_node_t *)((pm_program_node_t *)node)->statements, buffer);
1432
1453
  break;
1433
1454
  }
1434
1455
  case PM_RANGE_NODE: {
1435
1456
  if (((pm_range_node_t *)node)->left == NULL) {
1436
- pm_buffer_append_u8(buffer, 0);
1457
+ pm_buffer_append_byte(buffer, 0);
1437
1458
  } else {
1438
1459
  pm_serialize_node(parser, (pm_node_t *)((pm_range_node_t *)node)->left, buffer);
1439
1460
  }
1440
1461
  if (((pm_range_node_t *)node)->right == NULL) {
1441
- pm_buffer_append_u8(buffer, 0);
1462
+ pm_buffer_append_byte(buffer, 0);
1442
1463
  } else {
1443
1464
  pm_serialize_node(parser, (pm_node_t *)((pm_range_node_t *)node)->right, buffer);
1444
1465
  }
1445
1466
  pm_serialize_location(parser, &((pm_range_node_t *)node)->operator_loc, buffer);
1446
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1467
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1447
1468
  break;
1448
1469
  }
1449
1470
  case PM_RATIONAL_NODE: {
@@ -1458,21 +1479,11 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1458
1479
  pm_serialize_location(parser, &((pm_regular_expression_node_t *)node)->content_loc, buffer);
1459
1480
  pm_serialize_location(parser, &((pm_regular_expression_node_t *)node)->closing_loc, buffer);
1460
1481
  pm_serialize_string(parser, &((pm_regular_expression_node_t *)node)->unescaped, buffer);
1461
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1462
- break;
1463
- }
1464
- case PM_REQUIRED_DESTRUCTURED_PARAMETER_NODE: {
1465
- uint32_t parameters_size = pm_sizet_to_u32(((pm_required_destructured_parameter_node_t *)node)->parameters.size);
1466
- pm_buffer_append_u32(buffer, parameters_size);
1467
- for (uint32_t index = 0; index < parameters_size; index++) {
1468
- pm_serialize_node(parser, (pm_node_t *) ((pm_required_destructured_parameter_node_t *)node)->parameters.nodes[index], buffer);
1469
- }
1470
- pm_serialize_location(parser, &((pm_required_destructured_parameter_node_t *)node)->opening_loc, buffer);
1471
- pm_serialize_location(parser, &((pm_required_destructured_parameter_node_t *)node)->closing_loc, buffer);
1482
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1472
1483
  break;
1473
1484
  }
1474
1485
  case PM_REQUIRED_PARAMETER_NODE: {
1475
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_required_parameter_node_t *)node)->name));
1486
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_required_parameter_node_t *)node)->name));
1476
1487
  break;
1477
1488
  }
1478
1489
  case PM_RESCUE_MODIFIER_NODE: {
@@ -1484,39 +1495,39 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1484
1495
  case PM_RESCUE_NODE: {
1485
1496
  pm_serialize_location(parser, &((pm_rescue_node_t *)node)->keyword_loc, buffer);
1486
1497
  uint32_t exceptions_size = pm_sizet_to_u32(((pm_rescue_node_t *)node)->exceptions.size);
1487
- pm_buffer_append_u32(buffer, exceptions_size);
1498
+ pm_buffer_append_varint(buffer, exceptions_size);
1488
1499
  for (uint32_t index = 0; index < exceptions_size; index++) {
1489
1500
  pm_serialize_node(parser, (pm_node_t *) ((pm_rescue_node_t *)node)->exceptions.nodes[index], buffer);
1490
1501
  }
1491
1502
  if (((pm_rescue_node_t *)node)->operator_loc.start == NULL) {
1492
- pm_buffer_append_u8(buffer, 0);
1503
+ pm_buffer_append_byte(buffer, 0);
1493
1504
  } else {
1494
- pm_buffer_append_u8(buffer, 1);
1505
+ pm_buffer_append_byte(buffer, 1);
1495
1506
  pm_serialize_location(parser, &((pm_rescue_node_t *)node)->operator_loc, buffer);
1496
1507
  }
1497
1508
  if (((pm_rescue_node_t *)node)->reference == NULL) {
1498
- pm_buffer_append_u8(buffer, 0);
1509
+ pm_buffer_append_byte(buffer, 0);
1499
1510
  } else {
1500
1511
  pm_serialize_node(parser, (pm_node_t *)((pm_rescue_node_t *)node)->reference, buffer);
1501
1512
  }
1502
1513
  if (((pm_rescue_node_t *)node)->statements == NULL) {
1503
- pm_buffer_append_u8(buffer, 0);
1514
+ pm_buffer_append_byte(buffer, 0);
1504
1515
  } else {
1505
1516
  pm_serialize_node(parser, (pm_node_t *)((pm_rescue_node_t *)node)->statements, buffer);
1506
1517
  }
1507
1518
  if (((pm_rescue_node_t *)node)->consequent == NULL) {
1508
- pm_buffer_append_u8(buffer, 0);
1519
+ pm_buffer_append_byte(buffer, 0);
1509
1520
  } else {
1510
1521
  pm_serialize_node(parser, (pm_node_t *)((pm_rescue_node_t *)node)->consequent, buffer);
1511
1522
  }
1512
1523
  break;
1513
1524
  }
1514
1525
  case PM_REST_PARAMETER_NODE: {
1515
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_rest_parameter_node_t *)node)->name));
1526
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_rest_parameter_node_t *)node)->name));
1516
1527
  if (((pm_rest_parameter_node_t *)node)->name_loc.start == NULL) {
1517
- pm_buffer_append_u8(buffer, 0);
1528
+ pm_buffer_append_byte(buffer, 0);
1518
1529
  } else {
1519
- pm_buffer_append_u8(buffer, 1);
1530
+ pm_buffer_append_byte(buffer, 1);
1520
1531
  pm_serialize_location(parser, &((pm_rest_parameter_node_t *)node)->name_loc, buffer);
1521
1532
  }
1522
1533
  pm_serialize_location(parser, &((pm_rest_parameter_node_t *)node)->operator_loc, buffer);
@@ -1528,7 +1539,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1528
1539
  case PM_RETURN_NODE: {
1529
1540
  pm_serialize_location(parser, &((pm_return_node_t *)node)->keyword_loc, buffer);
1530
1541
  if (((pm_return_node_t *)node)->arguments == NULL) {
1531
- pm_buffer_append_u8(buffer, 0);
1542
+ pm_buffer_append_byte(buffer, 0);
1532
1543
  } else {
1533
1544
  pm_serialize_node(parser, (pm_node_t *)((pm_return_node_t *)node)->arguments, buffer);
1534
1545
  }
@@ -1539,15 +1550,15 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1539
1550
  }
1540
1551
  case PM_SINGLETON_CLASS_NODE: {
1541
1552
  uint32_t locals_size = pm_sizet_to_u32(((pm_singleton_class_node_t *)node)->locals.size);
1542
- pm_buffer_append_u32(buffer, locals_size);
1553
+ pm_buffer_append_varint(buffer, locals_size);
1543
1554
  for (uint32_t index = 0; index < locals_size; index++) {
1544
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(((pm_singleton_class_node_t *)node)->locals.ids[index]));
1555
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(((pm_singleton_class_node_t *)node)->locals.ids[index]));
1545
1556
  }
1546
1557
  pm_serialize_location(parser, &((pm_singleton_class_node_t *)node)->class_keyword_loc, buffer);
1547
1558
  pm_serialize_location(parser, &((pm_singleton_class_node_t *)node)->operator_loc, buffer);
1548
1559
  pm_serialize_node(parser, (pm_node_t *)((pm_singleton_class_node_t *)node)->expression, buffer);
1549
1560
  if (((pm_singleton_class_node_t *)node)->body == NULL) {
1550
- pm_buffer_append_u8(buffer, 0);
1561
+ pm_buffer_append_byte(buffer, 0);
1551
1562
  } else {
1552
1563
  pm_serialize_node(parser, (pm_node_t *)((pm_singleton_class_node_t *)node)->body, buffer);
1553
1564
  }
@@ -1567,7 +1578,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1567
1578
  case PM_SPLAT_NODE: {
1568
1579
  pm_serialize_location(parser, &((pm_splat_node_t *)node)->operator_loc, buffer);
1569
1580
  if (((pm_splat_node_t *)node)->expression == NULL) {
1570
- pm_buffer_append_u8(buffer, 0);
1581
+ pm_buffer_append_byte(buffer, 0);
1571
1582
  } else {
1572
1583
  pm_serialize_node(parser, (pm_node_t *)((pm_splat_node_t *)node)->expression, buffer);
1573
1584
  }
@@ -1575,7 +1586,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1575
1586
  }
1576
1587
  case PM_STATEMENTS_NODE: {
1577
1588
  uint32_t body_size = pm_sizet_to_u32(((pm_statements_node_t *)node)->body.size);
1578
- pm_buffer_append_u32(buffer, body_size);
1589
+ pm_buffer_append_varint(buffer, body_size);
1579
1590
  for (uint32_t index = 0; index < body_size; index++) {
1580
1591
  pm_serialize_node(parser, (pm_node_t *) ((pm_statements_node_t *)node)->body.nodes[index], buffer);
1581
1592
  }
@@ -1587,18 +1598,18 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1587
1598
  break;
1588
1599
  }
1589
1600
  case PM_STRING_NODE: {
1590
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1601
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1591
1602
  if (((pm_string_node_t *)node)->opening_loc.start == NULL) {
1592
- pm_buffer_append_u8(buffer, 0);
1603
+ pm_buffer_append_byte(buffer, 0);
1593
1604
  } else {
1594
- pm_buffer_append_u8(buffer, 1);
1605
+ pm_buffer_append_byte(buffer, 1);
1595
1606
  pm_serialize_location(parser, &((pm_string_node_t *)node)->opening_loc, buffer);
1596
1607
  }
1597
1608
  pm_serialize_location(parser, &((pm_string_node_t *)node)->content_loc, buffer);
1598
1609
  if (((pm_string_node_t *)node)->closing_loc.start == NULL) {
1599
- pm_buffer_append_u8(buffer, 0);
1610
+ pm_buffer_append_byte(buffer, 0);
1600
1611
  } else {
1601
- pm_buffer_append_u8(buffer, 1);
1612
+ pm_buffer_append_byte(buffer, 1);
1602
1613
  pm_serialize_location(parser, &((pm_string_node_t *)node)->closing_loc, buffer);
1603
1614
  }
1604
1615
  pm_serialize_string(parser, &((pm_string_node_t *)node)->unescaped, buffer);
@@ -1607,24 +1618,24 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1607
1618
  case PM_SUPER_NODE: {
1608
1619
  pm_serialize_location(parser, &((pm_super_node_t *)node)->keyword_loc, buffer);
1609
1620
  if (((pm_super_node_t *)node)->lparen_loc.start == NULL) {
1610
- pm_buffer_append_u8(buffer, 0);
1621
+ pm_buffer_append_byte(buffer, 0);
1611
1622
  } else {
1612
- pm_buffer_append_u8(buffer, 1);
1623
+ pm_buffer_append_byte(buffer, 1);
1613
1624
  pm_serialize_location(parser, &((pm_super_node_t *)node)->lparen_loc, buffer);
1614
1625
  }
1615
1626
  if (((pm_super_node_t *)node)->arguments == NULL) {
1616
- pm_buffer_append_u8(buffer, 0);
1627
+ pm_buffer_append_byte(buffer, 0);
1617
1628
  } else {
1618
1629
  pm_serialize_node(parser, (pm_node_t *)((pm_super_node_t *)node)->arguments, buffer);
1619
1630
  }
1620
1631
  if (((pm_super_node_t *)node)->rparen_loc.start == NULL) {
1621
- pm_buffer_append_u8(buffer, 0);
1632
+ pm_buffer_append_byte(buffer, 0);
1622
1633
  } else {
1623
- pm_buffer_append_u8(buffer, 1);
1634
+ pm_buffer_append_byte(buffer, 1);
1624
1635
  pm_serialize_location(parser, &((pm_super_node_t *)node)->rparen_loc, buffer);
1625
1636
  }
1626
1637
  if (((pm_super_node_t *)node)->block == NULL) {
1627
- pm_buffer_append_u8(buffer, 0);
1638
+ pm_buffer_append_byte(buffer, 0);
1628
1639
  } else {
1629
1640
  pm_serialize_node(parser, (pm_node_t *)((pm_super_node_t *)node)->block, buffer);
1630
1641
  }
@@ -1632,21 +1643,21 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1632
1643
  }
1633
1644
  case PM_SYMBOL_NODE: {
1634
1645
  if (((pm_symbol_node_t *)node)->opening_loc.start == NULL) {
1635
- pm_buffer_append_u8(buffer, 0);
1646
+ pm_buffer_append_byte(buffer, 0);
1636
1647
  } else {
1637
- pm_buffer_append_u8(buffer, 1);
1648
+ pm_buffer_append_byte(buffer, 1);
1638
1649
  pm_serialize_location(parser, &((pm_symbol_node_t *)node)->opening_loc, buffer);
1639
1650
  }
1640
1651
  if (((pm_symbol_node_t *)node)->value_loc.start == NULL) {
1641
- pm_buffer_append_u8(buffer, 0);
1652
+ pm_buffer_append_byte(buffer, 0);
1642
1653
  } else {
1643
- pm_buffer_append_u8(buffer, 1);
1654
+ pm_buffer_append_byte(buffer, 1);
1644
1655
  pm_serialize_location(parser, &((pm_symbol_node_t *)node)->value_loc, buffer);
1645
1656
  }
1646
1657
  if (((pm_symbol_node_t *)node)->closing_loc.start == NULL) {
1647
- pm_buffer_append_u8(buffer, 0);
1658
+ pm_buffer_append_byte(buffer, 0);
1648
1659
  } else {
1649
- pm_buffer_append_u8(buffer, 1);
1660
+ pm_buffer_append_byte(buffer, 1);
1650
1661
  pm_serialize_location(parser, &((pm_symbol_node_t *)node)->closing_loc, buffer);
1651
1662
  }
1652
1663
  pm_serialize_string(parser, &((pm_symbol_node_t *)node)->unescaped, buffer);
@@ -1657,7 +1668,7 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1657
1668
  }
1658
1669
  case PM_UNDEF_NODE: {
1659
1670
  uint32_t names_size = pm_sizet_to_u32(((pm_undef_node_t *)node)->names.size);
1660
- pm_buffer_append_u32(buffer, names_size);
1671
+ pm_buffer_append_varint(buffer, names_size);
1661
1672
  for (uint32_t index = 0; index < names_size; index++) {
1662
1673
  pm_serialize_node(parser, (pm_node_t *) ((pm_undef_node_t *)node)->names.nodes[index], buffer);
1663
1674
  }
@@ -1668,19 +1679,19 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1668
1679
  pm_serialize_location(parser, &((pm_unless_node_t *)node)->keyword_loc, buffer);
1669
1680
  pm_serialize_node(parser, (pm_node_t *)((pm_unless_node_t *)node)->predicate, buffer);
1670
1681
  if (((pm_unless_node_t *)node)->statements == NULL) {
1671
- pm_buffer_append_u8(buffer, 0);
1682
+ pm_buffer_append_byte(buffer, 0);
1672
1683
  } else {
1673
1684
  pm_serialize_node(parser, (pm_node_t *)((pm_unless_node_t *)node)->statements, buffer);
1674
1685
  }
1675
1686
  if (((pm_unless_node_t *)node)->consequent == NULL) {
1676
- pm_buffer_append_u8(buffer, 0);
1687
+ pm_buffer_append_byte(buffer, 0);
1677
1688
  } else {
1678
1689
  pm_serialize_node(parser, (pm_node_t *)((pm_unless_node_t *)node)->consequent, buffer);
1679
1690
  }
1680
1691
  if (((pm_unless_node_t *)node)->end_keyword_loc.start == NULL) {
1681
- pm_buffer_append_u8(buffer, 0);
1692
+ pm_buffer_append_byte(buffer, 0);
1682
1693
  } else {
1683
- pm_buffer_append_u8(buffer, 1);
1694
+ pm_buffer_append_byte(buffer, 1);
1684
1695
  pm_serialize_location(parser, &((pm_unless_node_t *)node)->end_keyword_loc, buffer);
1685
1696
  }
1686
1697
  break;
@@ -1688,29 +1699,29 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1688
1699
  case PM_UNTIL_NODE: {
1689
1700
  pm_serialize_location(parser, &((pm_until_node_t *)node)->keyword_loc, buffer);
1690
1701
  if (((pm_until_node_t *)node)->closing_loc.start == NULL) {
1691
- pm_buffer_append_u8(buffer, 0);
1702
+ pm_buffer_append_byte(buffer, 0);
1692
1703
  } else {
1693
- pm_buffer_append_u8(buffer, 1);
1704
+ pm_buffer_append_byte(buffer, 1);
1694
1705
  pm_serialize_location(parser, &((pm_until_node_t *)node)->closing_loc, buffer);
1695
1706
  }
1696
1707
  pm_serialize_node(parser, (pm_node_t *)((pm_until_node_t *)node)->predicate, buffer);
1697
1708
  if (((pm_until_node_t *)node)->statements == NULL) {
1698
- pm_buffer_append_u8(buffer, 0);
1709
+ pm_buffer_append_byte(buffer, 0);
1699
1710
  } else {
1700
1711
  pm_serialize_node(parser, (pm_node_t *)((pm_until_node_t *)node)->statements, buffer);
1701
1712
  }
1702
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1713
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1703
1714
  break;
1704
1715
  }
1705
1716
  case PM_WHEN_NODE: {
1706
1717
  pm_serialize_location(parser, &((pm_when_node_t *)node)->keyword_loc, buffer);
1707
1718
  uint32_t conditions_size = pm_sizet_to_u32(((pm_when_node_t *)node)->conditions.size);
1708
- pm_buffer_append_u32(buffer, conditions_size);
1719
+ pm_buffer_append_varint(buffer, conditions_size);
1709
1720
  for (uint32_t index = 0; index < conditions_size; index++) {
1710
1721
  pm_serialize_node(parser, (pm_node_t *) ((pm_when_node_t *)node)->conditions.nodes[index], buffer);
1711
1722
  }
1712
1723
  if (((pm_when_node_t *)node)->statements == NULL) {
1713
- pm_buffer_append_u8(buffer, 0);
1724
+ pm_buffer_append_byte(buffer, 0);
1714
1725
  } else {
1715
1726
  pm_serialize_node(parser, (pm_node_t *)((pm_when_node_t *)node)->statements, buffer);
1716
1727
  }
@@ -1719,18 +1730,18 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1719
1730
  case PM_WHILE_NODE: {
1720
1731
  pm_serialize_location(parser, &((pm_while_node_t *)node)->keyword_loc, buffer);
1721
1732
  if (((pm_while_node_t *)node)->closing_loc.start == NULL) {
1722
- pm_buffer_append_u8(buffer, 0);
1733
+ pm_buffer_append_byte(buffer, 0);
1723
1734
  } else {
1724
- pm_buffer_append_u8(buffer, 1);
1735
+ pm_buffer_append_byte(buffer, 1);
1725
1736
  pm_serialize_location(parser, &((pm_while_node_t *)node)->closing_loc, buffer);
1726
1737
  }
1727
1738
  pm_serialize_node(parser, (pm_node_t *)((pm_while_node_t *)node)->predicate, buffer);
1728
1739
  if (((pm_while_node_t *)node)->statements == NULL) {
1729
- pm_buffer_append_u8(buffer, 0);
1740
+ pm_buffer_append_byte(buffer, 0);
1730
1741
  } else {
1731
1742
  pm_serialize_node(parser, (pm_node_t *)((pm_while_node_t *)node)->statements, buffer);
1732
1743
  }
1733
- pm_buffer_append_u32(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1744
+ pm_buffer_append_varint(buffer, (uint32_t)(node->flags & ~PM_NODE_FLAG_COMMON_MASK));
1734
1745
  break;
1735
1746
  }
1736
1747
  case PM_X_STRING_NODE: {
@@ -1743,20 +1754,20 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1743
1754
  case PM_YIELD_NODE: {
1744
1755
  pm_serialize_location(parser, &((pm_yield_node_t *)node)->keyword_loc, buffer);
1745
1756
  if (((pm_yield_node_t *)node)->lparen_loc.start == NULL) {
1746
- pm_buffer_append_u8(buffer, 0);
1757
+ pm_buffer_append_byte(buffer, 0);
1747
1758
  } else {
1748
- pm_buffer_append_u8(buffer, 1);
1759
+ pm_buffer_append_byte(buffer, 1);
1749
1760
  pm_serialize_location(parser, &((pm_yield_node_t *)node)->lparen_loc, buffer);
1750
1761
  }
1751
1762
  if (((pm_yield_node_t *)node)->arguments == NULL) {
1752
- pm_buffer_append_u8(buffer, 0);
1763
+ pm_buffer_append_byte(buffer, 0);
1753
1764
  } else {
1754
1765
  pm_serialize_node(parser, (pm_node_t *)((pm_yield_node_t *)node)->arguments, buffer);
1755
1766
  }
1756
1767
  if (((pm_yield_node_t *)node)->rparen_loc.start == NULL) {
1757
- pm_buffer_append_u8(buffer, 0);
1768
+ pm_buffer_append_byte(buffer, 0);
1758
1769
  } else {
1759
- pm_buffer_append_u8(buffer, 1);
1770
+ pm_buffer_append_byte(buffer, 1);
1760
1771
  pm_serialize_location(parser, &((pm_yield_node_t *)node)->rparen_loc, buffer);
1761
1772
  }
1762
1773
  break;
@@ -1767,16 +1778,16 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1767
1778
  static void
1768
1779
  pm_serialize_comment(pm_parser_t *parser, pm_comment_t *comment, pm_buffer_t *buffer) {
1769
1780
  // serialize type
1770
- pm_buffer_append_u8(buffer, (uint8_t) comment->type);
1781
+ pm_buffer_append_byte(buffer, (uint8_t) comment->type);
1771
1782
 
1772
1783
  // serialize location
1773
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(comment->start - parser->start));
1774
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(comment->end - comment->start));
1784
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(comment->start - parser->start));
1785
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(comment->end - comment->start));
1775
1786
  }
1776
1787
 
1777
- static void
1788
+ void
1778
1789
  pm_serialize_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buffer) {
1779
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(pm_list_size(list)));
1790
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(pm_list_size(list)));
1780
1791
 
1781
1792
  pm_comment_t *comment;
1782
1793
  for (comment = (pm_comment_t *) list->head; comment != NULL; comment = (pm_comment_t *) comment->node.next) {
@@ -1787,17 +1798,17 @@ pm_serialize_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buf
1787
1798
  static void
1788
1799
  pm_serialize_magic_comment(pm_parser_t *parser, pm_magic_comment_t *magic_comment, pm_buffer_t *buffer) {
1789
1800
  // serialize key location
1790
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(magic_comment->key_start - parser->start));
1791
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(magic_comment->key_length));
1801
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(magic_comment->key_start - parser->start));
1802
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(magic_comment->key_length));
1792
1803
 
1793
1804
  // serialize value location
1794
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(magic_comment->value_start - parser->start));
1795
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(magic_comment->value_length));
1805
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(magic_comment->value_start - parser->start));
1806
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(magic_comment->value_length));
1796
1807
  }
1797
1808
 
1798
1809
  static void
1799
1810
  pm_serialize_magic_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buffer) {
1800
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(pm_list_size(list)));
1811
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(pm_list_size(list)));
1801
1812
 
1802
1813
  pm_magic_comment_t *magic_comment;
1803
1814
  for (magic_comment = (pm_magic_comment_t *) list->head; magic_comment != NULL; magic_comment = (pm_magic_comment_t *) magic_comment->node.next) {
@@ -1809,17 +1820,17 @@ static void
1809
1820
  pm_serialize_diagnostic(pm_parser_t *parser, pm_diagnostic_t *diagnostic, pm_buffer_t *buffer) {
1810
1821
  // serialize message
1811
1822
  size_t message_length = strlen(diagnostic->message);
1812
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(message_length));
1813
- pm_buffer_append_str(buffer, diagnostic->message, message_length);
1823
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(message_length));
1824
+ pm_buffer_append_string(buffer, diagnostic->message, message_length);
1814
1825
 
1815
1826
  // serialize location
1816
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(diagnostic->start - parser->start));
1817
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(diagnostic->end - diagnostic->start));
1827
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(diagnostic->start - parser->start));
1828
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(diagnostic->end - diagnostic->start));
1818
1829
  }
1819
1830
 
1820
1831
  static void
1821
1832
  pm_serialize_diagnostic_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buffer) {
1822
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(pm_list_size(list)));
1833
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(pm_list_size(list)));
1823
1834
 
1824
1835
  pm_diagnostic_t *diagnostic;
1825
1836
  for (diagnostic = (pm_diagnostic_t *) list->head; diagnostic != NULL; diagnostic = (pm_diagnostic_t *) diagnostic->node.next) {
@@ -1827,11 +1838,11 @@ pm_serialize_diagnostic_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *
1827
1838
  }
1828
1839
  }
1829
1840
 
1830
- static void
1841
+ void
1831
1842
  pm_serialize_encoding(pm_encoding_t *encoding, pm_buffer_t *buffer) {
1832
1843
  size_t encoding_length = strlen(encoding->name);
1833
- pm_buffer_append_u32(buffer, pm_sizet_to_u32(encoding_length));
1834
- pm_buffer_append_str(buffer, encoding->name, encoding_length);
1844
+ pm_buffer_append_varint(buffer, pm_sizet_to_u32(encoding_length));
1845
+ pm_buffer_append_string(buffer, encoding->name, encoding_length);
1835
1846
  }
1836
1847
 
1837
1848
  #line 200 "serialize.c.erb"
@@ -1849,7 +1860,7 @@ pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer)
1849
1860
  pm_buffer_append_zeroes(buffer, 4);
1850
1861
 
1851
1862
  // Next, encode the length of the constant pool.
1852
- pm_buffer_append_u32(buffer, parser->constant_pool.size);
1863
+ pm_buffer_append_varint(buffer, parser->constant_pool.size);
1853
1864
 
1854
1865
  // Now we're going to serialize the content of the node.
1855
1866
  pm_serialize_node(parser, node, buffer);
@@ -1904,10 +1915,10 @@ static void
1904
1915
  serialize_token(void *data, pm_parser_t *parser, pm_token_t *token) {
1905
1916
  pm_buffer_t *buffer = (pm_buffer_t *) data;
1906
1917
 
1907
- pm_buffer_append_u32(buffer, token->type);
1908
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(token->start - parser->start));
1909
- pm_buffer_append_u32(buffer, pm_ptrdifft_to_u32(token->end - token->start));
1910
- pm_buffer_append_u32(buffer, parser->lex_state);
1918
+ pm_buffer_append_varint(buffer, token->type);
1919
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(token->start - parser->start));
1920
+ pm_buffer_append_varint(buffer, pm_ptrdifft_to_u32(token->end - token->start));
1921
+ pm_buffer_append_varint(buffer, parser->lex_state);
1911
1922
  }
1912
1923
 
1913
1924
  PRISM_EXPORTED_FUNCTION void
@@ -1924,7 +1935,7 @@ pm_lex_serialize(const uint8_t *source, size_t size, const char *filepath, pm_bu
1924
1935
  pm_node_t *node = pm_parse(&parser);
1925
1936
 
1926
1937
  // Append 0 to mark end of tokens
1927
- pm_buffer_append_u8(buffer, 0);
1938
+ pm_buffer_append_byte(buffer, 0);
1928
1939
 
1929
1940
  pm_serialize_encoding(&parser.encoding, buffer);
1930
1941
  pm_serialize_comment_list(&parser, &parser.comment_list, buffer);
@@ -1952,7 +1963,7 @@ pm_parse_lex_serialize(const uint8_t *source, size_t size, pm_buffer_t *buffer,
1952
1963
  parser.lex_callback = &lex_callback;
1953
1964
  pm_node_t *node = pm_parse(&parser);
1954
1965
 
1955
- pm_buffer_append_u8(buffer, 0);
1966
+ pm_buffer_append_byte(buffer, 0);
1956
1967
  pm_serialize(&parser, node, buffer);
1957
1968
 
1958
1969
  pm_node_destroy(&parser, node);