yarp 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ end
21
21
  module YARP
22
22
  module Serialize
23
23
  MAJOR_VERSION = 0
24
- MINOR_VERSION = 7
24
+ MINOR_VERSION = 8
25
25
  PATCH_VERSION = 0
26
26
 
27
27
  def self.load(input, serialized)
@@ -158,255 +158,225 @@ module YARP
158
158
  when 3 then
159
159
  AndNode.new(load_node, load_node, load_location, location)
160
160
  when 4 then
161
- ArgumentsNode.new(Array.new(load_varint) { load_node }, location)
161
+ AndWriteNode.new(load_node, load_node, load_location, location)
162
162
  when 5 then
163
- ArrayNode.new(Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
163
+ ArgumentsNode.new(Array.new(load_varint) { load_node }, location)
164
164
  when 6 then
165
- ArrayPatternNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
165
+ ArrayNode.new(Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
166
166
  when 7 then
167
- AssocNode.new(load_node, load_optional_node, load_optional_location, location)
167
+ ArrayPatternNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
168
168
  when 8 then
169
- AssocSplatNode.new(load_optional_node, load_location, location)
169
+ AssocNode.new(load_node, load_optional_node, load_optional_location, location)
170
170
  when 9 then
171
- BackReferenceReadNode.new(location)
171
+ AssocSplatNode.new(load_optional_node, load_location, location)
172
172
  when 10 then
173
- BeginNode.new(load_optional_location, load_optional_node, load_optional_node, load_optional_node, load_optional_node, load_optional_location, location)
173
+ BackReferenceReadNode.new(location)
174
174
  when 11 then
175
- BlockArgumentNode.new(load_optional_node, load_location, location)
175
+ BeginNode.new(load_optional_location, load_optional_node, load_optional_node, load_optional_node, load_optional_node, load_optional_location, location)
176
176
  when 12 then
177
- BlockNode.new(Array.new(load_varint) { load_constant }, load_optional_node, load_optional_node, load_location, load_location, location)
177
+ BlockArgumentNode.new(load_optional_node, load_location, location)
178
178
  when 13 then
179
- BlockParameterNode.new(load_optional_location, load_location, location)
179
+ BlockNode.new(Array.new(load_varint) { load_constant }, load_optional_node, load_optional_node, load_location, load_location, location)
180
180
  when 14 then
181
- BlockParametersNode.new(load_optional_node, Array.new(load_varint) { load_location }, load_optional_location, load_optional_location, location)
181
+ BlockParameterNode.new(load_optional_location, load_location, location)
182
182
  when 15 then
183
- BreakNode.new(load_optional_node, load_location, location)
183
+ BlockParametersNode.new(load_optional_node, Array.new(load_varint) { load_location }, load_optional_location, load_optional_location, location)
184
184
  when 16 then
185
- CallNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_optional_node, load_varint, load_string, location)
185
+ BreakNode.new(load_optional_node, load_location, location)
186
186
  when 17 then
187
- CallOperatorAndWriteNode.new(load_node, load_location, load_node, location)
187
+ CallNode.new(load_optional_node, load_optional_location, load_optional_location, load_optional_location, load_optional_node, load_optional_location, load_optional_node, load_varint, load_string, location)
188
188
  when 18 then
189
- CallOperatorOrWriteNode.new(load_node, load_node, load_location, location)
189
+ CallOperatorAndWriteNode.new(load_node, load_location, load_node, location)
190
190
  when 19 then
191
- CallOperatorWriteNode.new(load_node, load_location, load_node, load_constant, location)
191
+ CallOperatorOrWriteNode.new(load_node, load_node, load_location, location)
192
192
  when 20 then
193
- CapturePatternNode.new(load_node, load_node, load_location, location)
193
+ CallOperatorWriteNode.new(load_node, load_location, load_node, load_constant, location)
194
194
  when 21 then
195
- CaseNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_location, load_location, location)
195
+ CapturePatternNode.new(load_node, load_node, load_location, location)
196
196
  when 22 then
197
- ClassNode.new(Array.new(load_varint) { load_constant }, load_location, load_node, load_optional_location, load_optional_node, load_optional_node, load_location, location)
197
+ CaseNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_location, load_location, location)
198
198
  when 23 then
199
- ClassVariableOperatorAndWriteNode.new(load_location, load_location, load_node, location)
199
+ ClassNode.new(Array.new(load_varint) { load_constant }, load_location, load_node, load_optional_location, load_optional_node, load_optional_node, load_location, location)
200
200
  when 24 then
201
- ClassVariableOperatorOrWriteNode.new(load_location, load_location, load_node, location)
201
+ ClassVariableReadNode.new(location)
202
202
  when 25 then
203
- ClassVariableOperatorWriteNode.new(load_location, load_location, load_node, load_constant, location)
203
+ ClassVariableWriteNode.new(load_location, load_optional_node, load_optional_location, location)
204
204
  when 26 then
205
- ClassVariableReadNode.new(location)
205
+ ConstantPathNode.new(load_optional_node, load_node, load_location, location)
206
206
  when 27 then
207
- ClassVariableWriteNode.new(load_location, load_optional_node, load_optional_location, location)
207
+ ConstantPathWriteNode.new(load_node, load_optional_location, load_optional_node, location)
208
208
  when 28 then
209
- ConstantOperatorAndWriteNode.new(load_location, load_location, load_node, location)
209
+ ConstantReadNode.new(location)
210
210
  when 29 then
211
- ConstantOperatorOrWriteNode.new(load_location, load_location, load_node, location)
211
+ ConstantWriteNode.new(load_location, load_optional_node, load_optional_location, location)
212
212
  when 30 then
213
- ConstantOperatorWriteNode.new(load_location, load_location, load_node, load_constant, location)
213
+ load_serialized_length
214
+ DefNode.new(load_location, load_optional_node, load_optional_node, load_optional_node, Array.new(load_varint) { load_constant }, load_location, load_optional_location, load_optional_location, load_optional_location, load_optional_location, load_optional_location, location)
214
215
  when 31 then
215
- ConstantPathNode.new(load_optional_node, load_node, load_location, location)
216
+ DefinedNode.new(load_optional_location, load_node, load_optional_location, load_location, location)
216
217
  when 32 then
217
- ConstantPathOperatorAndWriteNode.new(load_node, load_location, load_node, location)
218
+ ElseNode.new(load_location, load_optional_node, load_optional_location, location)
218
219
  when 33 then
219
- ConstantPathOperatorOrWriteNode.new(load_node, load_location, load_node, location)
220
+ EmbeddedStatementsNode.new(load_location, load_optional_node, load_location, location)
220
221
  when 34 then
221
- ConstantPathOperatorWriteNode.new(load_node, load_location, load_node, load_constant, location)
222
+ EmbeddedVariableNode.new(load_location, load_node, location)
222
223
  when 35 then
223
- ConstantPathWriteNode.new(load_node, load_optional_location, load_optional_node, location)
224
+ EnsureNode.new(load_location, load_optional_node, load_location, location)
224
225
  when 36 then
225
- ConstantReadNode.new(location)
226
+ FalseNode.new(location)
226
227
  when 37 then
227
- ConstantWriteNode.new(load_location, load_optional_node, load_optional_location, location)
228
+ FindPatternNode.new(load_optional_node, load_node, Array.new(load_varint) { load_node }, load_node, load_optional_location, load_optional_location, location)
228
229
  when 38 then
229
- load_serialized_length
230
- DefNode.new(load_location, load_optional_node, load_optional_node, load_optional_node, Array.new(load_varint) { load_constant }, load_location, load_optional_location, load_optional_location, load_optional_location, load_optional_location, load_optional_location, location)
230
+ FlipFlopNode.new(load_optional_node, load_optional_node, load_location, load_varint, location)
231
231
  when 39 then
232
- DefinedNode.new(load_optional_location, load_node, load_optional_location, load_location, location)
232
+ FloatNode.new(location)
233
233
  when 40 then
234
- ElseNode.new(load_location, load_optional_node, load_optional_location, location)
234
+ ForNode.new(load_node, load_node, load_optional_node, load_location, load_location, load_optional_location, load_location, location)
235
235
  when 41 then
236
- EmbeddedStatementsNode.new(load_location, load_optional_node, load_location, location)
236
+ ForwardingArgumentsNode.new(location)
237
237
  when 42 then
238
- EmbeddedVariableNode.new(load_location, load_node, location)
238
+ ForwardingParameterNode.new(location)
239
239
  when 43 then
240
- EnsureNode.new(load_location, load_optional_node, load_location, location)
240
+ ForwardingSuperNode.new(load_optional_node, location)
241
241
  when 44 then
242
- FalseNode.new(location)
242
+ GlobalVariableReadNode.new(location)
243
243
  when 45 then
244
- FindPatternNode.new(load_optional_node, load_node, Array.new(load_varint) { load_node }, load_node, load_optional_location, load_optional_location, location)
244
+ GlobalVariableWriteNode.new(load_location, load_optional_location, load_optional_node, location)
245
245
  when 46 then
246
- FlipFlopNode.new(load_optional_node, load_optional_node, load_location, load_varint, location)
246
+ HashNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
247
247
  when 47 then
248
- FloatNode.new(location)
248
+ HashPatternNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_optional_location, load_optional_location, location)
249
249
  when 48 then
250
- ForNode.new(load_node, load_node, load_optional_node, load_location, load_location, load_optional_location, load_location, location)
250
+ IfNode.new(load_optional_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
251
251
  when 49 then
252
- ForwardingArgumentsNode.new(location)
252
+ ImaginaryNode.new(load_node, location)
253
253
  when 50 then
254
- ForwardingParameterNode.new(location)
254
+ InNode.new(load_node, load_optional_node, load_location, load_optional_location, location)
255
255
  when 51 then
256
- ForwardingSuperNode.new(load_optional_node, location)
256
+ InstanceVariableReadNode.new(location)
257
257
  when 52 then
258
- GlobalVariableOperatorAndWriteNode.new(load_location, load_location, load_node, location)
258
+ InstanceVariableWriteNode.new(load_location, load_optional_node, load_optional_location, location)
259
259
  when 53 then
260
- GlobalVariableOperatorOrWriteNode.new(load_location, load_location, load_node, location)
260
+ IntegerNode.new(location)
261
261
  when 54 then
262
- GlobalVariableOperatorWriteNode.new(load_location, load_location, load_node, load_constant, location)
262
+ InterpolatedRegularExpressionNode.new(load_location, Array.new(load_varint) { load_node }, load_location, load_varint, location)
263
263
  when 55 then
264
- GlobalVariableReadNode.new(location)
264
+ InterpolatedStringNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
265
265
  when 56 then
266
- GlobalVariableWriteNode.new(load_location, load_optional_location, load_optional_node, location)
266
+ InterpolatedSymbolNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
267
267
  when 57 then
268
- HashNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
268
+ InterpolatedXStringNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
269
269
  when 58 then
270
- HashPatternNode.new(load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_optional_location, load_optional_location, location)
270
+ KeywordHashNode.new(Array.new(load_varint) { load_node }, location)
271
271
  when 59 then
272
- IfNode.new(load_optional_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
272
+ KeywordParameterNode.new(load_location, load_optional_node, location)
273
273
  when 60 then
274
- ImaginaryNode.new(load_node, location)
274
+ KeywordRestParameterNode.new(load_location, load_optional_location, location)
275
275
  when 61 then
276
- InNode.new(load_node, load_optional_node, load_location, load_optional_location, location)
276
+ LambdaNode.new(Array.new(load_varint) { load_constant }, load_location, load_optional_node, load_optional_node, location)
277
277
  when 62 then
278
- InstanceVariableOperatorAndWriteNode.new(load_location, load_location, load_node, location)
278
+ LocalVariableReadNode.new(load_constant, load_varint, location)
279
279
  when 63 then
280
- InstanceVariableOperatorOrWriteNode.new(load_location, load_location, load_node, location)
280
+ LocalVariableWriteNode.new(load_constant, load_varint, load_optional_node, load_location, load_optional_location, location)
281
281
  when 64 then
282
- InstanceVariableOperatorWriteNode.new(load_location, load_location, load_node, load_constant, location)
282
+ MatchPredicateNode.new(load_node, load_node, load_location, location)
283
283
  when 65 then
284
- InstanceVariableReadNode.new(location)
284
+ MatchRequiredNode.new(load_node, load_node, load_location, location)
285
285
  when 66 then
286
- InstanceVariableWriteNode.new(load_location, load_optional_node, load_optional_location, location)
286
+ MissingNode.new(location)
287
287
  when 67 then
288
- IntegerNode.new(location)
288
+ ModuleNode.new(Array.new(load_varint) { load_constant }, load_location, load_node, load_optional_node, load_location, location)
289
289
  when 68 then
290
- InterpolatedRegularExpressionNode.new(load_location, Array.new(load_varint) { load_node }, load_location, load_varint, location)
290
+ MultiWriteNode.new(Array.new(load_varint) { load_node }, load_optional_location, load_optional_node, load_optional_location, load_optional_location, location)
291
291
  when 69 then
292
- InterpolatedStringNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
292
+ NextNode.new(load_optional_node, load_location, location)
293
293
  when 70 then
294
- InterpolatedSymbolNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
294
+ NilNode.new(location)
295
295
  when 71 then
296
- InterpolatedXStringNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
296
+ NoKeywordsParameterNode.new(load_location, load_location, location)
297
297
  when 72 then
298
- KeywordHashNode.new(Array.new(load_varint) { load_node }, location)
298
+ NumberedReferenceReadNode.new(location)
299
299
  when 73 then
300
- KeywordParameterNode.new(load_location, load_optional_node, location)
300
+ OperatorWriteNode.new(load_node, load_location, load_constant, load_node, location)
301
301
  when 74 then
302
- KeywordRestParameterNode.new(load_location, load_optional_location, location)
302
+ OptionalParameterNode.new(load_constant, load_location, load_location, load_node, location)
303
303
  when 75 then
304
- LambdaNode.new(Array.new(load_varint) { load_constant }, load_location, load_optional_node, load_optional_node, location)
304
+ OrNode.new(load_node, load_node, load_location, location)
305
305
  when 76 then
306
- LocalVariableOperatorAndWriteNode.new(load_location, load_location, load_node, load_constant, location)
306
+ OrWriteNode.new(load_node, load_node, load_location, location)
307
307
  when 77 then
308
- LocalVariableOperatorOrWriteNode.new(load_location, load_location, load_node, load_constant, location)
309
- when 78 then
310
- LocalVariableOperatorWriteNode.new(load_location, load_location, load_node, load_constant, load_constant, location)
311
- when 79 then
312
- LocalVariableReadNode.new(load_constant, load_varint, location)
313
- when 80 then
314
- LocalVariableWriteNode.new(load_constant, load_varint, load_optional_node, load_location, load_optional_location, location)
315
- when 81 then
316
- MatchPredicateNode.new(load_node, load_node, load_location, location)
317
- when 82 then
318
- MatchRequiredNode.new(load_node, load_node, load_location, location)
319
- when 83 then
320
- MissingNode.new(location)
321
- when 84 then
322
- ModuleNode.new(Array.new(load_varint) { load_constant }, load_location, load_node, load_optional_node, load_location, location)
323
- when 85 then
324
- MultiWriteNode.new(Array.new(load_varint) { load_node }, load_optional_location, load_optional_node, load_optional_location, load_optional_location, location)
325
- when 86 then
326
- NextNode.new(load_optional_node, load_location, location)
327
- when 87 then
328
- NilNode.new(location)
329
- when 88 then
330
- NoKeywordsParameterNode.new(load_location, load_location, location)
331
- when 89 then
332
- NumberedReferenceReadNode.new(location)
333
- when 90 then
334
- OptionalParameterNode.new(load_constant, load_location, load_location, load_node, location)
335
- when 91 then
336
- OrNode.new(load_node, load_node, load_location, location)
337
- when 92 then
338
308
  ParametersNode.new(Array.new(load_varint) { load_node }, Array.new(load_varint) { load_node }, Array.new(load_varint) { load_node }, load_optional_node, Array.new(load_varint) { load_node }, load_optional_node, load_optional_node, location)
339
- when 93 then
309
+ when 78 then
340
310
  ParenthesesNode.new(load_optional_node, load_location, load_location, location)
341
- when 94 then
311
+ when 79 then
342
312
  PinnedExpressionNode.new(load_node, load_location, load_location, load_location, location)
343
- when 95 then
313
+ when 80 then
344
314
  PinnedVariableNode.new(load_node, load_location, location)
345
- when 96 then
315
+ when 81 then
346
316
  PostExecutionNode.new(load_optional_node, load_location, load_location, load_location, location)
347
- when 97 then
317
+ when 82 then
348
318
  PreExecutionNode.new(load_optional_node, load_location, load_location, load_location, location)
349
- when 98 then
319
+ when 83 then
350
320
  ProgramNode.new(Array.new(load_varint) { load_constant }, load_node, location)
351
- when 99 then
321
+ when 84 then
352
322
  RangeNode.new(load_optional_node, load_optional_node, load_location, load_varint, location)
353
- when 100 then
323
+ when 85 then
354
324
  RationalNode.new(load_node, location)
355
- when 101 then
325
+ when 86 then
356
326
  RedoNode.new(location)
357
- when 102 then
327
+ when 87 then
358
328
  RegularExpressionNode.new(load_location, load_location, load_location, load_string, load_varint, location)
359
- when 103 then
329
+ when 88 then
360
330
  RequiredDestructuredParameterNode.new(Array.new(load_varint) { load_node }, load_location, load_location, location)
361
- when 104 then
331
+ when 89 then
362
332
  RequiredParameterNode.new(load_constant, location)
363
- when 105 then
333
+ when 90 then
364
334
  RescueModifierNode.new(load_node, load_location, load_node, location)
365
- when 106 then
335
+ when 91 then
366
336
  RescueNode.new(load_location, Array.new(load_varint) { load_node }, load_optional_location, load_optional_node, load_optional_node, load_optional_node, location)
367
- when 107 then
337
+ when 92 then
368
338
  RestParameterNode.new(load_location, load_optional_location, location)
369
- when 108 then
339
+ when 93 then
370
340
  RetryNode.new(location)
371
- when 109 then
341
+ when 94 then
372
342
  ReturnNode.new(load_location, load_optional_node, location)
373
- when 110 then
343
+ when 95 then
374
344
  SelfNode.new(location)
375
- when 111 then
345
+ when 96 then
376
346
  SingletonClassNode.new(Array.new(load_varint) { load_constant }, load_location, load_location, load_node, load_optional_node, load_location, location)
377
- when 112 then
347
+ when 97 then
378
348
  SourceEncodingNode.new(location)
379
- when 113 then
349
+ when 98 then
380
350
  SourceFileNode.new(load_string, location)
381
- when 114 then
351
+ when 99 then
382
352
  SourceLineNode.new(location)
383
- when 115 then
353
+ when 100 then
384
354
  SplatNode.new(load_location, load_optional_node, location)
385
- when 116 then
355
+ when 101 then
386
356
  StatementsNode.new(Array.new(load_varint) { load_node }, location)
387
- when 117 then
357
+ when 102 then
388
358
  StringConcatNode.new(load_node, load_node, location)
389
- when 118 then
359
+ when 103 then
390
360
  StringNode.new(load_optional_location, load_location, load_optional_location, load_string, location)
391
- when 119 then
361
+ when 104 then
392
362
  SuperNode.new(load_location, load_optional_location, load_optional_node, load_optional_location, load_optional_node, location)
393
- when 120 then
363
+ when 105 then
394
364
  SymbolNode.new(load_optional_location, load_location, load_optional_location, load_string, location)
395
- when 121 then
365
+ when 106 then
396
366
  TrueNode.new(location)
397
- when 122 then
367
+ when 107 then
398
368
  UndefNode.new(Array.new(load_varint) { load_node }, load_location, location)
399
- when 123 then
369
+ when 108 then
400
370
  UnlessNode.new(load_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
401
- when 124 then
371
+ when 109 then
402
372
  UntilNode.new(load_location, load_node, load_optional_node, load_varint, location)
403
- when 125 then
373
+ when 110 then
404
374
  WhenNode.new(load_location, Array.new(load_varint) { load_node }, load_optional_node, location)
405
- when 126 then
375
+ when 111 then
406
376
  WhileNode.new(load_location, load_node, load_optional_node, load_varint, location)
407
- when 127 then
377
+ when 112 then
408
378
  XStringNode.new(load_location, load_location, load_location, load_string, location)
409
- when 128 then
379
+ when 113 then
410
380
  YieldNode.new(load_location, load_optional_location, load_optional_node, load_optional_location, location)
411
381
  end
412
382
  end
data/lib/yarp.rb CHANGED
@@ -236,12 +236,6 @@ module YARP
236
236
  value.accept(visitor)
237
237
  value
238
238
  end
239
-
240
- # Construct a new ParseResult with the same internal values, but with the
241
- # given source.
242
- def with_source(source)
243
- ParseResult.new(value, comments, errors, warnings, source)
244
- end
245
239
  end
246
240
 
247
241
  # This represents a token from the Ruby source.
@@ -387,6 +381,10 @@ module YARP
387
381
  # of those here.
388
382
  names = names.grep_v(/^_\d$/)
389
383
 
384
+ # For some reason, CRuby occasionally pushes this special local
385
+ # variable when there are splat arguments. We get rid of that here.
386
+ names = names.grep_v(:"#arg_rest")
387
+
390
388
  # Now push them onto the list of locals.
391
389
  locals << names
392
390
  end
@@ -459,6 +457,8 @@ module YARP
459
457
  locals << []
460
458
  when PostExecutionNode
461
459
  locals.push([], [])
460
+ when InterpolatedRegularExpressionNode
461
+ locals << [] if node.once?
462
462
  end
463
463
 
464
464
  stack.concat(node.child_nodes.compact)