prism 0.24.0 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/BSDmakefile +58 -0
  3. data/CHANGELOG.md +69 -1
  4. data/Makefile +22 -16
  5. data/README.md +45 -6
  6. data/config.yml +510 -4
  7. data/docs/build_system.md +31 -0
  8. data/docs/configuration.md +3 -0
  9. data/docs/cruby_compilation.md +1 -1
  10. data/docs/parser_translation.md +14 -9
  11. data/docs/releasing.md +7 -9
  12. data/docs/ripper_translation.md +50 -0
  13. data/docs/ruby_api.md +1 -0
  14. data/docs/serialization.md +26 -5
  15. data/ext/prism/api_node.c +911 -815
  16. data/ext/prism/api_pack.c +9 -0
  17. data/ext/prism/extconf.rb +34 -13
  18. data/ext/prism/extension.c +341 -68
  19. data/ext/prism/extension.h +5 -4
  20. data/include/prism/ast.h +213 -64
  21. data/include/prism/defines.h +106 -2
  22. data/include/prism/diagnostic.h +146 -72
  23. data/include/prism/encoding.h +22 -4
  24. data/include/prism/node.h +93 -0
  25. data/include/prism/options.h +82 -7
  26. data/include/prism/pack.h +11 -0
  27. data/include/prism/parser.h +203 -54
  28. data/include/prism/prettyprint.h +8 -0
  29. data/include/prism/static_literals.h +118 -0
  30. data/include/prism/util/pm_buffer.h +65 -2
  31. data/include/prism/util/pm_constant_pool.h +18 -1
  32. data/include/prism/util/pm_integer.h +119 -0
  33. data/include/prism/util/pm_list.h +1 -1
  34. data/include/prism/util/pm_newline_list.h +8 -0
  35. data/include/prism/util/pm_string.h +26 -2
  36. data/include/prism/version.h +2 -2
  37. data/include/prism.h +59 -1
  38. data/lib/prism/compiler.rb +8 -1
  39. data/lib/prism/debug.rb +46 -3
  40. data/lib/prism/desugar_compiler.rb +4 -2
  41. data/lib/prism/dispatcher.rb +29 -0
  42. data/lib/prism/dot_visitor.rb +87 -16
  43. data/lib/prism/dsl.rb +24 -12
  44. data/lib/prism/ffi.rb +77 -12
  45. data/lib/prism/lex_compat.rb +17 -15
  46. data/lib/prism/mutation_compiler.rb +11 -0
  47. data/lib/prism/node.rb +2112 -2499
  48. data/lib/prism/node_ext.rb +77 -29
  49. data/lib/prism/pack.rb +4 -0
  50. data/lib/prism/parse_result/comments.rb +34 -17
  51. data/lib/prism/parse_result/newlines.rb +3 -1
  52. data/lib/prism/parse_result.rb +83 -32
  53. data/lib/prism/pattern.rb +16 -4
  54. data/lib/prism/polyfill/string.rb +12 -0
  55. data/lib/prism/reflection.rb +421 -0
  56. data/lib/prism/serialize.rb +450 -102
  57. data/lib/prism/translation/parser/compiler.rb +189 -50
  58. data/lib/prism/translation/parser/lexer.rb +103 -22
  59. data/lib/prism/translation/parser/rubocop.rb +41 -13
  60. data/lib/prism/translation/parser.rb +119 -7
  61. data/lib/prism/translation/parser33.rb +1 -1
  62. data/lib/prism/translation/parser34.rb +1 -1
  63. data/lib/prism/translation/ripper/sexp.rb +125 -0
  64. data/lib/prism/translation/ripper/shim.rb +5 -0
  65. data/lib/prism/translation/ripper.rb +3212 -462
  66. data/lib/prism/translation/ruby_parser.rb +35 -18
  67. data/lib/prism/translation.rb +3 -1
  68. data/lib/prism/visitor.rb +10 -0
  69. data/lib/prism.rb +9 -18
  70. data/prism.gemspec +39 -6
  71. data/rbi/prism/compiler.rbi +14 -0
  72. data/rbi/prism/desugar_compiler.rbi +5 -0
  73. data/rbi/prism/mutation_compiler.rbi +5 -0
  74. data/rbi/prism/node.rbi +8674 -0
  75. data/rbi/prism/node_ext.rbi +102 -0
  76. data/rbi/prism/parse_result.rbi +307 -0
  77. data/rbi/prism/reflection.rbi +64 -0
  78. data/rbi/prism/translation/parser/compiler.rbi +13 -0
  79. data/rbi/prism/translation/parser.rbi +11 -0
  80. data/rbi/prism/translation/parser33.rbi +6 -0
  81. data/rbi/prism/translation/parser34.rbi +6 -0
  82. data/rbi/prism/translation/ripper/ripper_compiler.rbi +5 -0
  83. data/rbi/prism/translation/ripper.rbi +25 -0
  84. data/rbi/prism/translation/ruby_parser.rbi +11 -0
  85. data/rbi/prism/visitor.rbi +470 -0
  86. data/rbi/prism.rbi +38 -7748
  87. data/sig/prism/compiler.rbs +9 -0
  88. data/sig/prism/dispatcher.rbs +16 -0
  89. data/sig/prism/dot_visitor.rbs +6 -0
  90. data/sig/prism/dsl.rbs +462 -0
  91. data/sig/prism/mutation_compiler.rbs +158 -0
  92. data/sig/prism/node.rbs +3538 -0
  93. data/sig/prism/node_ext.rbs +78 -0
  94. data/sig/prism/pack.rbs +43 -0
  95. data/sig/prism/parse_result.rbs +128 -0
  96. data/sig/prism/pattern.rbs +13 -0
  97. data/sig/prism/reflection.rbs +56 -0
  98. data/sig/prism/serialize.rbs +7 -0
  99. data/sig/prism/visitor.rbs +168 -0
  100. data/sig/prism.rbs +188 -4767
  101. data/src/diagnostic.c +597 -230
  102. data/src/encoding.c +211 -108
  103. data/src/node.c +7526 -447
  104. data/src/options.c +66 -31
  105. data/src/pack.c +33 -17
  106. data/src/prettyprint.c +1294 -1385
  107. data/src/prism.c +4015 -1149
  108. data/src/regexp.c +17 -2
  109. data/src/serialize.c +47 -28
  110. data/src/static_literals.c +552 -0
  111. data/src/token_type.c +4 -3
  112. data/src/util/pm_buffer.c +147 -20
  113. data/src/util/pm_char.c +4 -4
  114. data/src/util/pm_constant_pool.c +35 -11
  115. data/src/util/pm_integer.c +635 -0
  116. data/src/util/pm_list.c +1 -1
  117. data/src/util/pm_newline_list.c +14 -5
  118. data/src/util/pm_string.c +134 -5
  119. data/src/util/pm_string_list.c +2 -2
  120. metadata +41 -8
  121. data/docs/ripper.md +0 -36
  122. data/include/prism/util/pm_state_stack.h +0 -42
  123. data/rbi/prism_static.rbi +0 -207
  124. data/sig/prism_static.rbs +0 -201
  125. data/src/util/pm_state_stack.c +0 -25
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  =begin
3
4
  This file is generated by the templates/template.rb script and should not be
4
5
  modified manually. See templates/lib/prism/serialize.rb.erb
@@ -6,17 +7,7 @@ if you are looking to modify the template
6
7
  =end
7
8
 
8
9
  require "stringio"
9
-
10
- # Polyfill for String#unpack1 with the offset parameter.
11
- if String.instance_method(:unpack1).parameters.none? { |_, name| name == :offset }
12
- String.prepend(
13
- Module.new {
14
- def unpack1(format, offset: 0) # :nodoc:
15
- offset == 0 ? super(format) : self[offset..].unpack1(format)
16
- end
17
- }
18
- )
19
- end
10
+ require_relative "polyfill/string"
20
11
 
21
12
  module Prism
22
13
  # A module responsible for deserializing parse results.
@@ -27,7 +18,7 @@ module Prism
27
18
 
28
19
  # The minor version of prism that we are expecting to find in the serialized
29
20
  # strings.
30
- MINOR_VERSION = 24
21
+ MINOR_VERSION = 26
31
22
 
32
23
  # The patch version of prism that we are expecting to find in the serialized
33
24
  # strings.
@@ -51,6 +42,37 @@ module Prism
51
42
  end
52
43
 
53
44
  class Loader # :nodoc:
45
+ if RUBY_ENGINE == "truffleruby"
46
+ # StringIO is synchronized and that adds a high overhead on TruffleRuby.
47
+ class FastStringIO # :nodoc:
48
+ attr_accessor :pos
49
+
50
+ def initialize(string)
51
+ @string = string
52
+ @pos = 0
53
+ end
54
+
55
+ def getbyte
56
+ byte = @string.getbyte(@pos)
57
+ @pos += 1
58
+ byte
59
+ end
60
+
61
+ def read(n)
62
+ slice = @string.byteslice(@pos, n)
63
+ @pos += n
64
+ slice
65
+ end
66
+
67
+ def eof?
68
+ @pos >= @string.bytesize
69
+ end
70
+ end
71
+ else
72
+ FastStringIO = ::StringIO
73
+ end
74
+ private_constant :FastStringIO
75
+
54
76
  attr_reader :encoding, :input, :serialized, :io
55
77
  attr_reader :constant_pool_offset, :constant_pool, :source
56
78
  attr_reader :start_line
@@ -59,9 +81,9 @@ module Prism
59
81
  @encoding = Encoding::UTF_8
60
82
 
61
83
  @input = source.source.dup
84
+ raise unless serialized.encoding == Encoding::BINARY
62
85
  @serialized = serialized
63
- @io = StringIO.new(serialized)
64
- @io.set_encoding(Encoding::BINARY)
86
+ @io = FastStringIO.new(serialized)
65
87
 
66
88
  @constant_pool_offset = nil
67
89
  @constant_pool = nil
@@ -73,7 +95,7 @@ module Prism
73
95
  def load_header
74
96
  raise "Invalid serialization" if io.read(5) != "PRISM"
75
97
  raise "Invalid serialization" if io.read(3).unpack("C3") != [MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION]
76
- only_semantic_fields = io.read(1).unpack1("C")
98
+ only_semantic_fields = io.getbyte
77
99
  unless only_semantic_fields == 0
78
100
  raise "Invalid serialization (location fields must be included but are not)"
79
101
  end
@@ -96,19 +118,304 @@ module Prism
96
118
  def load_comments
97
119
  Array.new(load_varuint) do
98
120
  case load_varuint
99
- when 0 then InlineComment.new(load_location)
100
- when 1 then EmbDocComment.new(load_location)
101
- when 2 then DATAComment.new(load_location)
121
+ when 0 then InlineComment.new(load_location_object)
122
+ when 1 then EmbDocComment.new(load_location_object)
102
123
  end
103
124
  end
104
125
  end
105
126
 
127
+ DIAGNOSTIC_TYPES = [
128
+ :alias_argument,
129
+ :alias_argument_numbered_reference,
130
+ :ampampeq_multi_assign,
131
+ :argument_after_block,
132
+ :argument_after_forwarding_ellipses,
133
+ :argument_bare_hash,
134
+ :argument_block_forwarding,
135
+ :argument_block_multi,
136
+ :argument_formal_class,
137
+ :argument_formal_constant,
138
+ :argument_formal_global,
139
+ :argument_formal_ivar,
140
+ :argument_forwarding_unbound,
141
+ :argument_in,
142
+ :argument_no_forwarding_amp,
143
+ :argument_no_forwarding_ellipses,
144
+ :argument_no_forwarding_star,
145
+ :argument_no_forwarding_star_star,
146
+ :argument_splat_after_assoc_splat,
147
+ :argument_splat_after_splat,
148
+ :argument_term_paren,
149
+ :argument_unexpected_block,
150
+ :array_element,
151
+ :array_expression,
152
+ :array_expression_after_star,
153
+ :array_separator,
154
+ :array_term,
155
+ :begin_lonely_else,
156
+ :begin_term,
157
+ :begin_upcase_brace,
158
+ :begin_upcase_term,
159
+ :begin_upcase_toplevel,
160
+ :block_param_local_variable,
161
+ :block_param_pipe_term,
162
+ :block_term_brace,
163
+ :block_term_end,
164
+ :cannot_parse_expression,
165
+ :cannot_parse_string_part,
166
+ :case_expression_after_case,
167
+ :case_expression_after_when,
168
+ :case_match_missing_predicate,
169
+ :case_missing_conditions,
170
+ :case_term,
171
+ :class_in_method,
172
+ :class_name,
173
+ :class_superclass,
174
+ :class_term,
175
+ :class_unexpected_end,
176
+ :class_variable_bare,
177
+ :conditional_elsif_predicate,
178
+ :conditional_if_predicate,
179
+ :conditional_predicate_term,
180
+ :conditional_term,
181
+ :conditional_term_else,
182
+ :conditional_unless_predicate,
183
+ :conditional_until_predicate,
184
+ :conditional_while_predicate,
185
+ :constant_path_colon_colon_constant,
186
+ :def_endless,
187
+ :def_endless_setter,
188
+ :def_name,
189
+ :def_params_term,
190
+ :def_params_term_paren,
191
+ :def_receiver,
192
+ :def_receiver_term,
193
+ :def_term,
194
+ :defined_expression,
195
+ :embdoc_term,
196
+ :embexpr_end,
197
+ :embvar_invalid,
198
+ :end_upcase_brace,
199
+ :end_upcase_term,
200
+ :escape_invalid_control,
201
+ :escape_invalid_control_repeat,
202
+ :escape_invalid_hexadecimal,
203
+ :escape_invalid_meta,
204
+ :escape_invalid_meta_repeat,
205
+ :escape_invalid_unicode,
206
+ :escape_invalid_unicode_cm_flags,
207
+ :escape_invalid_unicode_literal,
208
+ :escape_invalid_unicode_long,
209
+ :escape_invalid_unicode_term,
210
+ :expect_argument,
211
+ :expect_eol_after_statement,
212
+ :expect_expression_after_ampampeq,
213
+ :expect_expression_after_comma,
214
+ :expect_expression_after_equal,
215
+ :expect_expression_after_less_less,
216
+ :expect_expression_after_lparen,
217
+ :expect_expression_after_operator,
218
+ :expect_expression_after_pipepipeeq,
219
+ :expect_expression_after_question,
220
+ :expect_expression_after_splat,
221
+ :expect_expression_after_splat_hash,
222
+ :expect_expression_after_star,
223
+ :expect_ident_req_parameter,
224
+ :expect_lparen_req_parameter,
225
+ :expect_message,
226
+ :expect_rbracket,
227
+ :expect_rparen,
228
+ :expect_rparen_after_multi,
229
+ :expect_rparen_req_parameter,
230
+ :expect_string_content,
231
+ :expect_when_delimiter,
232
+ :expression_bare_hash,
233
+ :expression_not_writable,
234
+ :expression_not_writable_encoding,
235
+ :expression_not_writable_false,
236
+ :expression_not_writable_file,
237
+ :expression_not_writable_line,
238
+ :expression_not_writable_nil,
239
+ :expression_not_writable_self,
240
+ :expression_not_writable_true,
241
+ :float_parse,
242
+ :for_collection,
243
+ :for_in,
244
+ :for_index,
245
+ :for_term,
246
+ :global_variable_bare,
247
+ :hash_expression_after_label,
248
+ :hash_key,
249
+ :hash_rocket,
250
+ :hash_term,
251
+ :hash_value,
252
+ :heredoc_term,
253
+ :incomplete_question_mark,
254
+ :incomplete_variable_class,
255
+ :incomplete_variable_class_3_3_0,
256
+ :incomplete_variable_instance,
257
+ :incomplete_variable_instance_3_3_0,
258
+ :instance_variable_bare,
259
+ :invalid_block_exit,
260
+ :invalid_character,
261
+ :invalid_encoding_magic_comment,
262
+ :invalid_float_exponent,
263
+ :invalid_multibyte_char,
264
+ :invalid_multibyte_character,
265
+ :invalid_multibyte_escape,
266
+ :invalid_number_binary,
267
+ :invalid_number_decimal,
268
+ :invalid_number_hexadecimal,
269
+ :invalid_number_octal,
270
+ :invalid_number_underscore,
271
+ :invalid_percent,
272
+ :invalid_printable_character,
273
+ :invalid_retry_after_else,
274
+ :invalid_retry_after_ensure,
275
+ :invalid_retry_without_rescue,
276
+ :invalid_variable_global,
277
+ :invalid_variable_global_3_3_0,
278
+ :invalid_yield,
279
+ :it_not_allowed_numbered,
280
+ :it_not_allowed_ordinary,
281
+ :lambda_open,
282
+ :lambda_term_brace,
283
+ :lambda_term_end,
284
+ :list_i_lower_element,
285
+ :list_i_lower_term,
286
+ :list_i_upper_element,
287
+ :list_i_upper_term,
288
+ :list_w_lower_element,
289
+ :list_w_lower_term,
290
+ :list_w_upper_element,
291
+ :list_w_upper_term,
292
+ :malloc_failed,
293
+ :mixed_encoding,
294
+ :module_in_method,
295
+ :module_name,
296
+ :module_term,
297
+ :multi_assign_multi_splats,
298
+ :multi_assign_unexpected_rest,
299
+ :no_local_variable,
300
+ :not_expression,
301
+ :number_literal_underscore,
302
+ :numbered_parameter_it,
303
+ :numbered_parameter_ordinary,
304
+ :numbered_parameter_outer_scope,
305
+ :operator_multi_assign,
306
+ :operator_write_arguments,
307
+ :operator_write_block,
308
+ :parameter_assoc_splat_multi,
309
+ :parameter_block_multi,
310
+ :parameter_circular,
311
+ :parameter_method_name,
312
+ :parameter_name_duplicated,
313
+ :parameter_no_default,
314
+ :parameter_no_default_kw,
315
+ :parameter_numbered_reserved,
316
+ :parameter_order,
317
+ :parameter_splat_multi,
318
+ :parameter_star,
319
+ :parameter_unexpected_fwd,
320
+ :parameter_wild_loose_comma,
321
+ :pattern_capture_duplicate,
322
+ :pattern_expression_after_bracket,
323
+ :pattern_expression_after_comma,
324
+ :pattern_expression_after_hrocket,
325
+ :pattern_expression_after_in,
326
+ :pattern_expression_after_key,
327
+ :pattern_expression_after_paren,
328
+ :pattern_expression_after_pin,
329
+ :pattern_expression_after_pipe,
330
+ :pattern_expression_after_range,
331
+ :pattern_expression_after_rest,
332
+ :pattern_hash_key,
333
+ :pattern_hash_key_duplicate,
334
+ :pattern_hash_key_label,
335
+ :pattern_ident_after_hrocket,
336
+ :pattern_label_after_comma,
337
+ :pattern_rest,
338
+ :pattern_term_brace,
339
+ :pattern_term_bracket,
340
+ :pattern_term_paren,
341
+ :pipepipeeq_multi_assign,
342
+ :regexp_encoding_option_mismatch,
343
+ :regexp_incompat_char_encoding,
344
+ :regexp_invalid_unicode_range,
345
+ :regexp_non_escaped_mbc,
346
+ :regexp_term,
347
+ :regexp_unknown_options,
348
+ :regexp_utf8_char_non_utf8_regexp,
349
+ :rescue_expression,
350
+ :rescue_modifier_value,
351
+ :rescue_term,
352
+ :rescue_variable,
353
+ :return_invalid,
354
+ :script_not_found,
355
+ :singleton_for_literals,
356
+ :statement_alias,
357
+ :statement_postexe_end,
358
+ :statement_preexe_begin,
359
+ :statement_undef,
360
+ :string_concatenation,
361
+ :string_interpolated_term,
362
+ :string_literal_eof,
363
+ :string_literal_term,
364
+ :symbol_invalid,
365
+ :symbol_term_dynamic,
366
+ :symbol_term_interpolated,
367
+ :ternary_colon,
368
+ :ternary_expression_false,
369
+ :ternary_expression_true,
370
+ :unary_receiver,
371
+ :undef_argument,
372
+ :unexpected_block_argument,
373
+ :unexpected_token_close_context,
374
+ :unexpected_token_ignore,
375
+ :until_term,
376
+ :void_expression,
377
+ :while_term,
378
+ :write_target_in_method,
379
+ :write_target_readonly,
380
+ :write_target_unexpected,
381
+ :xstring_term,
382
+ :ambiguous_first_argument_minus,
383
+ :ambiguous_first_argument_plus,
384
+ :ambiguous_prefix_ampersand,
385
+ :ambiguous_prefix_star,
386
+ :ambiguous_prefix_star_star,
387
+ :ambiguous_slash,
388
+ :comparison_after_comparison,
389
+ :dot_dot_dot_eol,
390
+ :equal_in_conditional,
391
+ :equal_in_conditional_3_3_0,
392
+ :end_in_method,
393
+ :duplicated_hash_key,
394
+ :duplicated_when_clause,
395
+ :float_out_of_range,
396
+ :ignored_frozen_string_literal,
397
+ :integer_in_flip_flop,
398
+ :invalid_character,
399
+ :invalid_numbered_reference,
400
+ :invalid_shareable_constant_value,
401
+ :keyword_eol,
402
+ :literal_in_condition_default,
403
+ :literal_in_condition_verbose,
404
+ :shebang_carriage_return,
405
+ :unexpected_carriage_return,
406
+ :unreachable_statement,
407
+ :unused_local_variable,
408
+ :void_statement,
409
+ ].freeze
410
+
411
+ private_constant :DIAGNOSTIC_TYPES
412
+
106
413
  def load_metadata
107
414
  comments = load_comments
108
- magic_comments = Array.new(load_varuint) { MagicComment.new(load_location, load_location) }
109
- data_loc = load_optional_location
110
- errors = Array.new(load_varuint) { ParseError.new(load_embedded_string, load_location, load_error_level) }
111
- warnings = Array.new(load_varuint) { ParseWarning.new(load_embedded_string, load_location, load_warning_level) }
415
+ magic_comments = Array.new(load_varuint) { MagicComment.new(load_location_object, load_location_object) }
416
+ data_loc = load_optional_location_object
417
+ errors = Array.new(load_varuint) { ParseError.new(DIAGNOSTIC_TYPES[load_varuint], load_embedded_string, load_location_object, load_error_level) }
418
+ warnings = Array.new(load_varuint) { ParseWarning.new(DIAGNOSTIC_TYPES[load_varuint], load_embedded_string, load_location_object, load_warning_level) }
112
419
  [comments, magic_comments, data_loc, errors, warnings]
113
420
  end
114
421
 
@@ -145,7 +452,7 @@ module Prism
145
452
 
146
453
  comments, magic_comments, data_loc, errors, warnings = load_metadata
147
454
 
148
- @constant_pool_offset = io.read(4).unpack1("L")
455
+ @constant_pool_offset = load_uint32
149
456
  @constant_pool = Array.new(load_varuint, nil)
150
457
 
151
458
  [load_node, comments, magic_comments, data_loc, errors, warnings]
@@ -179,7 +486,22 @@ module Prism
179
486
  (n >> 1) ^ (-(n & 1))
180
487
  end
181
488
 
182
- def load_serialized_length
489
+ def load_integer
490
+ negative = io.getbyte != 0
491
+ length = load_varuint
492
+
493
+ value = 0
494
+ length.times { |index| value |= (load_varuint << (index * 32)) }
495
+
496
+ value = -value if negative
497
+ value
498
+ end
499
+
500
+ def load_double
501
+ io.read(8).unpack1("D")
502
+ end
503
+
504
+ def load_uint32
183
505
  io.read(4).unpack1("L")
184
506
  end
185
507
 
@@ -207,6 +529,10 @@ module Prism
207
529
  end
208
530
 
209
531
  def load_location
532
+ (load_varuint << 32) | load_varuint
533
+ end
534
+
535
+ def load_location_object
210
536
  Location.new(source, load_varuint, load_varuint)
211
537
  end
212
538
 
@@ -214,19 +540,23 @@ module Prism
214
540
  load_location if io.getbyte != 0
215
541
  end
216
542
 
543
+ def load_optional_location_object
544
+ load_location_object if io.getbyte != 0
545
+ end
546
+
217
547
  def load_constant(index)
218
548
  constant = constant_pool[index]
219
549
 
220
550
  unless constant
221
551
  offset = constant_pool_offset + index * 8
222
- start = serialized.unpack1("L", offset: offset)
223
- length = serialized.unpack1("L", offset: offset + 4)
552
+ start = @serialized.unpack1("L", offset: offset)
553
+ length = @serialized.unpack1("L", offset: offset + 4)
224
554
 
225
555
  constant =
226
556
  if start.nobits?(1 << 31)
227
557
  input.byteslice(start, length).force_encoding(@encoding).to_sym
228
558
  else
229
- serialized.byteslice(start & ((1 << 31) - 1), length).force_encoding(@encoding).to_sym
559
+ @serialized.byteslice(start & ((1 << 31) - 1), length).force_encoding(@encoding).to_sym
230
560
  end
231
561
 
232
562
  constant_pool[index] = constant
@@ -249,9 +579,11 @@ module Prism
249
579
 
250
580
  case level
251
581
  when 0
252
- :fatal
582
+ :syntax
253
583
  when 1
254
584
  :argument
585
+ when 2
586
+ :load
255
587
  else
256
588
  raise "Unknown level: #{level}"
257
589
  end
@@ -371,7 +703,7 @@ module Prism
371
703
  source, load_required_constant, location)
372
704
  when 32 then
373
705
  ClassVariableWriteNode.new(
374
- source, load_required_constant, load_location, load_node, load_optional_location, location)
706
+ source, load_required_constant, load_location, load_node, load_location, location)
375
707
  when 33 then
376
708
  ConstantAndWriteNode.new(
377
709
  source, load_required_constant, load_location, load_location, load_node, location)
@@ -409,7 +741,7 @@ module Prism
409
741
  ConstantWriteNode.new(
410
742
  source, load_required_constant, load_location, load_node, load_location, location)
411
743
  when 45 then
412
- load_serialized_length
744
+ load_uint32
413
745
  DefNode.new(
414
746
  source, load_required_constant, load_location, load_optional_node, load_optional_node, load_optional_node, Array.new(load_varuint) { load_required_constant }, load_location, load_optional_location, load_optional_location, load_optional_location, load_optional_location, load_optional_location, location)
415
747
  when 46 then
@@ -438,7 +770,7 @@ module Prism
438
770
  source, load_varuint, load_optional_node, load_optional_node, load_location, location)
439
771
  when 54 then
440
772
  FloatNode.new(
441
- source, location)
773
+ source, load_double, location)
442
774
  when 55 then
443
775
  ForNode.new(
444
776
  source, load_node, load_node, load_optional_node, load_location, load_location, load_optional_location, load_location, location)
@@ -522,7 +854,7 @@ module Prism
522
854
  source, load_required_constant, load_location, load_node, load_location, location)
523
855
  when 82 then
524
856
  IntegerNode.new(
525
- source, load_varuint, location)
857
+ source, load_varuint, load_integer, location)
526
858
  when 83 then
527
859
  InterpolatedMatchLastLineNode.new(
528
860
  source, load_varuint, load_location, Array.new(load_varuint) { load_node }, load_location, location)
@@ -531,7 +863,7 @@ module Prism
531
863
  source, load_varuint, load_location, Array.new(load_varuint) { load_node }, load_location, location)
532
864
  when 85 then
533
865
  InterpolatedStringNode.new(
534
- source, load_optional_location, Array.new(load_varuint) { load_node }, load_optional_location, location)
866
+ source, load_varuint, load_optional_location, Array.new(load_varuint) { load_node }, load_optional_location, location)
535
867
  when 86 then
536
868
  InterpolatedSymbolNode.new(
537
869
  source, load_optional_location, Array.new(load_varuint) { load_node }, load_optional_location, location)
@@ -539,186 +871,192 @@ module Prism
539
871
  InterpolatedXStringNode.new(
540
872
  source, load_location, Array.new(load_varuint) { load_node }, load_location, location)
541
873
  when 88 then
874
+ ItParametersNode.new(
875
+ source, location)
876
+ when 89 then
542
877
  KeywordHashNode.new(
543
878
  source, load_varuint, Array.new(load_varuint) { load_node }, location)
544
- when 89 then
879
+ when 90 then
545
880
  KeywordRestParameterNode.new(
546
881
  source, load_varuint, load_optional_constant, load_optional_location, load_location, location)
547
- when 90 then
882
+ when 91 then
548
883
  LambdaNode.new(
549
884
  source, Array.new(load_varuint) { load_required_constant }, load_location, load_location, load_location, load_optional_node, load_optional_node, location)
550
- when 91 then
885
+ when 92 then
551
886
  LocalVariableAndWriteNode.new(
552
887
  source, load_location, load_location, load_node, load_required_constant, load_varuint, location)
553
- when 92 then
888
+ when 93 then
554
889
  LocalVariableOperatorWriteNode.new(
555
890
  source, load_location, load_location, load_node, load_required_constant, load_required_constant, load_varuint, location)
556
- when 93 then
891
+ when 94 then
557
892
  LocalVariableOrWriteNode.new(
558
893
  source, load_location, load_location, load_node, load_required_constant, load_varuint, location)
559
- when 94 then
894
+ when 95 then
560
895
  LocalVariableReadNode.new(
561
896
  source, load_required_constant, load_varuint, location)
562
- when 95 then
897
+ when 96 then
563
898
  LocalVariableTargetNode.new(
564
899
  source, load_required_constant, load_varuint, location)
565
- when 96 then
900
+ when 97 then
566
901
  LocalVariableWriteNode.new(
567
902
  source, load_required_constant, load_varuint, load_location, load_node, load_location, location)
568
- when 97 then
903
+ when 98 then
569
904
  MatchLastLineNode.new(
570
905
  source, load_varuint, load_location, load_location, load_location, load_string, location)
571
- when 98 then
906
+ when 99 then
572
907
  MatchPredicateNode.new(
573
908
  source, load_node, load_node, load_location, location)
574
- when 99 then
909
+ when 100 then
575
910
  MatchRequiredNode.new(
576
911
  source, load_node, load_node, load_location, location)
577
- when 100 then
912
+ when 101 then
578
913
  MatchWriteNode.new(
579
914
  source, load_node, Array.new(load_varuint) { load_node }, location)
580
- when 101 then
915
+ when 102 then
581
916
  MissingNode.new(
582
917
  source, location)
583
- when 102 then
918
+ when 103 then
584
919
  ModuleNode.new(
585
920
  source, Array.new(load_varuint) { load_required_constant }, load_location, load_node, load_optional_node, load_location, load_required_constant, location)
586
- when 103 then
921
+ when 104 then
587
922
  MultiTargetNode.new(
588
923
  source, Array.new(load_varuint) { load_node }, load_optional_node, Array.new(load_varuint) { load_node }, load_optional_location, load_optional_location, location)
589
- when 104 then
924
+ when 105 then
590
925
  MultiWriteNode.new(
591
926
  source, Array.new(load_varuint) { load_node }, load_optional_node, Array.new(load_varuint) { load_node }, load_optional_location, load_optional_location, load_location, load_node, location)
592
- when 105 then
927
+ when 106 then
593
928
  NextNode.new(
594
929
  source, load_optional_node, load_location, location)
595
- when 106 then
930
+ when 107 then
596
931
  NilNode.new(
597
932
  source, location)
598
- when 107 then
933
+ when 108 then
599
934
  NoKeywordsParameterNode.new(
600
935
  source, load_location, load_location, location)
601
- when 108 then
936
+ when 109 then
602
937
  NumberedParametersNode.new(
603
938
  source, io.getbyte, location)
604
- when 109 then
939
+ when 110 then
605
940
  NumberedReferenceReadNode.new(
606
941
  source, load_varuint, location)
607
- when 110 then
942
+ when 111 then
608
943
  OptionalKeywordParameterNode.new(
609
944
  source, load_varuint, load_required_constant, load_location, load_node, location)
610
- when 111 then
945
+ when 112 then
611
946
  OptionalParameterNode.new(
612
947
  source, load_varuint, load_required_constant, load_location, load_location, load_node, location)
613
- when 112 then
948
+ when 113 then
614
949
  OrNode.new(
615
950
  source, load_node, load_node, load_location, location)
616
- when 113 then
951
+ when 114 then
617
952
  ParametersNode.new(
618
953
  source, Array.new(load_varuint) { load_node }, Array.new(load_varuint) { load_node }, load_optional_node, Array.new(load_varuint) { load_node }, Array.new(load_varuint) { load_node }, load_optional_node, load_optional_node, location)
619
- when 114 then
954
+ when 115 then
620
955
  ParenthesesNode.new(
621
956
  source, load_optional_node, load_location, load_location, location)
622
- when 115 then
957
+ when 116 then
623
958
  PinnedExpressionNode.new(
624
959
  source, load_node, load_location, load_location, load_location, location)
625
- when 116 then
960
+ when 117 then
626
961
  PinnedVariableNode.new(
627
962
  source, load_node, load_location, location)
628
- when 117 then
963
+ when 118 then
629
964
  PostExecutionNode.new(
630
965
  source, load_optional_node, load_location, load_location, load_location, location)
631
- when 118 then
966
+ when 119 then
632
967
  PreExecutionNode.new(
633
968
  source, load_optional_node, load_location, load_location, load_location, location)
634
- when 119 then
969
+ when 120 then
635
970
  ProgramNode.new(
636
971
  source, Array.new(load_varuint) { load_required_constant }, load_node, location)
637
- when 120 then
972
+ when 121 then
638
973
  RangeNode.new(
639
974
  source, load_varuint, load_optional_node, load_optional_node, load_location, location)
640
- when 121 then
975
+ when 122 then
641
976
  RationalNode.new(
642
977
  source, load_node, location)
643
- when 122 then
978
+ when 123 then
644
979
  RedoNode.new(
645
980
  source, location)
646
- when 123 then
981
+ when 124 then
647
982
  RegularExpressionNode.new(
648
983
  source, load_varuint, load_location, load_location, load_location, load_string, location)
649
- when 124 then
984
+ when 125 then
650
985
  RequiredKeywordParameterNode.new(
651
986
  source, load_varuint, load_required_constant, load_location, location)
652
- when 125 then
987
+ when 126 then
653
988
  RequiredParameterNode.new(
654
989
  source, load_varuint, load_required_constant, location)
655
- when 126 then
990
+ when 127 then
656
991
  RescueModifierNode.new(
657
992
  source, load_node, load_location, load_node, location)
658
- when 127 then
993
+ when 128 then
659
994
  RescueNode.new(
660
995
  source, load_location, Array.new(load_varuint) { load_node }, load_optional_location, load_optional_node, load_optional_node, load_optional_node, location)
661
- when 128 then
996
+ when 129 then
662
997
  RestParameterNode.new(
663
998
  source, load_varuint, load_optional_constant, load_optional_location, load_location, location)
664
- when 129 then
999
+ when 130 then
665
1000
  RetryNode.new(
666
1001
  source, location)
667
- when 130 then
1002
+ when 131 then
668
1003
  ReturnNode.new(
669
1004
  source, load_location, load_optional_node, location)
670
- when 131 then
1005
+ when 132 then
671
1006
  SelfNode.new(
672
1007
  source, location)
673
- when 132 then
1008
+ when 133 then
1009
+ ShareableConstantNode.new(
1010
+ source, load_varuint, load_node, location)
1011
+ when 134 then
674
1012
  SingletonClassNode.new(
675
1013
  source, Array.new(load_varuint) { load_required_constant }, load_location, load_location, load_node, load_optional_node, load_location, location)
676
- when 133 then
1014
+ when 135 then
677
1015
  SourceEncodingNode.new(
678
1016
  source, location)
679
- when 134 then
1017
+ when 136 then
680
1018
  SourceFileNode.new(
681
- source, load_string, location)
682
- when 135 then
1019
+ source, load_varuint, load_string, location)
1020
+ when 137 then
683
1021
  SourceLineNode.new(
684
1022
  source, location)
685
- when 136 then
1023
+ when 138 then
686
1024
  SplatNode.new(
687
1025
  source, load_location, load_optional_node, location)
688
- when 137 then
1026
+ when 139 then
689
1027
  StatementsNode.new(
690
1028
  source, Array.new(load_varuint) { load_node }, location)
691
- when 138 then
1029
+ when 140 then
692
1030
  StringNode.new(
693
1031
  source, load_varuint, load_optional_location, load_location, load_optional_location, load_string, location)
694
- when 139 then
1032
+ when 141 then
695
1033
  SuperNode.new(
696
1034
  source, load_location, load_optional_location, load_optional_node, load_optional_location, load_optional_node, location)
697
- when 140 then
1035
+ when 142 then
698
1036
  SymbolNode.new(
699
1037
  source, load_varuint, load_optional_location, load_optional_location, load_optional_location, load_string, location)
700
- when 141 then
1038
+ when 143 then
701
1039
  TrueNode.new(
702
1040
  source, location)
703
- when 142 then
1041
+ when 144 then
704
1042
  UndefNode.new(
705
1043
  source, Array.new(load_varuint) { load_node }, load_location, location)
706
- when 143 then
1044
+ when 145 then
707
1045
  UnlessNode.new(
708
1046
  source, load_location, load_node, load_optional_location, load_optional_node, load_optional_node, load_optional_location, location)
709
- when 144 then
1047
+ when 146 then
710
1048
  UntilNode.new(
711
1049
  source, load_varuint, load_location, load_optional_location, load_node, load_optional_node, location)
712
- when 145 then
1050
+ when 147 then
713
1051
  WhenNode.new(
714
- source, load_location, Array.new(load_varuint) { load_node }, load_optional_node, location)
715
- when 146 then
1052
+ source, load_location, Array.new(load_varuint) { load_node }, load_optional_location, load_optional_node, location)
1053
+ when 148 then
716
1054
  WhileNode.new(
717
1055
  source, load_varuint, load_location, load_optional_location, load_node, load_optional_node, location)
718
- when 147 then
1056
+ when 149 then
719
1057
  XStringNode.new(
720
1058
  source, load_varuint, load_location, load_location, load_location, load_string, location)
721
- when 148 then
1059
+ when 150 then
722
1060
  YieldNode.new(
723
1061
  source, load_location, load_optional_location, load_optional_node, load_optional_location, location)
724
1062
  end
@@ -890,7 +1228,7 @@ module Prism
890
1228
  -> {
891
1229
  location = load_location
892
1230
  ClassVariableWriteNode.new(
893
- source, load_required_constant, load_location, load_node, load_optional_location, location)
1231
+ source, load_required_constant, load_location, load_node, load_location, location)
894
1232
  },
895
1233
  -> {
896
1234
  location = load_location
@@ -954,7 +1292,7 @@ module Prism
954
1292
  },
955
1293
  -> {
956
1294
  location = load_location
957
- load_serialized_length
1295
+ load_uint32
958
1296
  DefNode.new(
959
1297
  source, load_required_constant, load_location, load_optional_node, load_optional_node, load_optional_node, Array.new(load_varuint) { load_required_constant }, load_location, load_optional_location, load_optional_location, load_optional_location, load_optional_location, load_optional_location, location)
960
1298
  },
@@ -1001,7 +1339,7 @@ module Prism
1001
1339
  -> {
1002
1340
  location = load_location
1003
1341
  FloatNode.new(
1004
- source, location)
1342
+ source, load_double, location)
1005
1343
  },
1006
1344
  -> {
1007
1345
  location = load_location
@@ -1141,7 +1479,7 @@ module Prism
1141
1479
  -> {
1142
1480
  location = load_location
1143
1481
  IntegerNode.new(
1144
- source, load_varuint, location)
1482
+ source, load_varuint, load_integer, location)
1145
1483
  },
1146
1484
  -> {
1147
1485
  location = load_location
@@ -1156,7 +1494,7 @@ module Prism
1156
1494
  -> {
1157
1495
  location = load_location
1158
1496
  InterpolatedStringNode.new(
1159
- source, load_optional_location, Array.new(load_varuint) { load_node }, load_optional_location, location)
1497
+ source, load_varuint, load_optional_location, Array.new(load_varuint) { load_node }, load_optional_location, location)
1160
1498
  },
1161
1499
  -> {
1162
1500
  location = load_location
@@ -1168,6 +1506,11 @@ module Prism
1168
1506
  InterpolatedXStringNode.new(
1169
1507
  source, load_location, Array.new(load_varuint) { load_node }, load_location, location)
1170
1508
  },
1509
+ -> {
1510
+ location = load_location
1511
+ ItParametersNode.new(
1512
+ source, location)
1513
+ },
1171
1514
  -> {
1172
1515
  location = load_location
1173
1516
  KeywordHashNode.new(
@@ -1388,6 +1731,11 @@ module Prism
1388
1731
  SelfNode.new(
1389
1732
  source, location)
1390
1733
  },
1734
+ -> {
1735
+ location = load_location
1736
+ ShareableConstantNode.new(
1737
+ source, load_varuint, load_node, location)
1738
+ },
1391
1739
  -> {
1392
1740
  location = load_location
1393
1741
  SingletonClassNode.new(
@@ -1401,7 +1749,7 @@ module Prism
1401
1749
  -> {
1402
1750
  location = load_location
1403
1751
  SourceFileNode.new(
1404
- source, load_string, location)
1752
+ source, load_varuint, load_string, location)
1405
1753
  },
1406
1754
  -> {
1407
1755
  location = load_location
@@ -1456,7 +1804,7 @@ module Prism
1456
1804
  -> {
1457
1805
  location = load_location
1458
1806
  WhenNode.new(
1459
- source, load_location, Array.new(load_varuint) { load_node }, load_optional_node, location)
1807
+ source, load_location, Array.new(load_varuint) { load_node }, load_optional_location, load_optional_node, location)
1460
1808
  },
1461
1809
  -> {
1462
1810
  location = load_location