yarp 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -2
- data/Makefile +2 -0
- data/README.md +5 -2
- data/config.yml +54 -267
- data/ext/yarp/api_node.c +135 -579
- data/ext/yarp/extension.c +2 -2
- data/ext/yarp/extension.h +1 -1
- data/include/yarp/ast.h +142 -285
- data/include/yarp/defines.h +5 -0
- data/include/yarp/unescape.h +1 -1
- data/include/yarp/util/yp_buffer.h +9 -1
- data/include/yarp/util/yp_constant_pool.h +3 -0
- data/include/yarp/util/yp_list.h +7 -7
- data/include/yarp/util/yp_newline_list.h +4 -0
- data/include/yarp/util/yp_state_stack.h +1 -1
- data/include/yarp/version.h +2 -2
- data/lib/yarp/ffi.rb +62 -47
- data/lib/yarp/node.rb +504 -1399
- data/lib/yarp/serialize.rb +111 -141
- data/lib/yarp.rb +6 -6
- data/src/node.c +70 -250
- data/src/prettyprint.c +41 -185
- data/src/serialize.c +35 -133
- data/src/unescape.c +29 -35
- data/src/util/yp_buffer.c +18 -0
- data/src/util/yp_list.c +7 -16
- data/src/util/yp_state_stack.c +0 -6
- data/src/yarp.c +265 -670
- data/yarp.gemspec +1 -1
- metadata +2 -2
data/lib/yarp/serialize.rb
CHANGED
@@ -21,7 +21,7 @@ end
|
|
21
21
|
module YARP
|
22
22
|
module Serialize
|
23
23
|
MAJOR_VERSION = 0
|
24
|
-
MINOR_VERSION =
|
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
|
-
|
161
|
+
AndWriteNode.new(load_node, load_node, load_location, location)
|
162
162
|
when 5 then
|
163
|
-
|
163
|
+
ArgumentsNode.new(Array.new(load_varint) { load_node }, location)
|
164
164
|
when 6 then
|
165
|
-
|
165
|
+
ArrayNode.new(Array.new(load_varint) { load_node }, load_optional_location, load_optional_location, location)
|
166
166
|
when 7 then
|
167
|
-
|
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
|
-
|
169
|
+
AssocNode.new(load_node, load_optional_node, load_optional_location, location)
|
170
170
|
when 9 then
|
171
|
-
|
171
|
+
AssocSplatNode.new(load_optional_node, load_location, location)
|
172
172
|
when 10 then
|
173
|
-
|
173
|
+
BackReferenceReadNode.new(location)
|
174
174
|
when 11 then
|
175
|
-
|
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
|
-
|
177
|
+
BlockArgumentNode.new(load_optional_node, load_location, location)
|
178
178
|
when 13 then
|
179
|
-
|
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
|
-
|
181
|
+
BlockParameterNode.new(load_optional_location, load_location, location)
|
182
182
|
when 15 then
|
183
|
-
|
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
|
-
|
185
|
+
BreakNode.new(load_optional_node, load_location, location)
|
186
186
|
when 17 then
|
187
|
-
|
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
|
-
|
189
|
+
CallOperatorAndWriteNode.new(load_node, load_location, load_node, location)
|
190
190
|
when 19 then
|
191
|
-
|
191
|
+
CallOperatorOrWriteNode.new(load_node, load_node, load_location, location)
|
192
192
|
when 20 then
|
193
|
-
|
193
|
+
CallOperatorWriteNode.new(load_node, load_location, load_node, load_constant, location)
|
194
194
|
when 21 then
|
195
|
-
|
195
|
+
CapturePatternNode.new(load_node, load_node, load_location, location)
|
196
196
|
when 22 then
|
197
|
-
|
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
|
-
|
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
|
-
|
201
|
+
ClassVariableReadNode.new(location)
|
202
202
|
when 25 then
|
203
|
-
|
203
|
+
ClassVariableWriteNode.new(load_location, load_optional_node, load_optional_location, location)
|
204
204
|
when 26 then
|
205
|
-
|
205
|
+
ConstantPathNode.new(load_optional_node, load_node, load_location, location)
|
206
206
|
when 27 then
|
207
|
-
|
207
|
+
ConstantPathWriteNode.new(load_node, load_optional_location, load_optional_node, location)
|
208
208
|
when 28 then
|
209
|
-
|
209
|
+
ConstantReadNode.new(location)
|
210
210
|
when 29 then
|
211
|
-
|
211
|
+
ConstantWriteNode.new(load_location, load_optional_node, load_optional_location, location)
|
212
212
|
when 30 then
|
213
|
-
|
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
|
-
|
216
|
+
DefinedNode.new(load_optional_location, load_node, load_optional_location, load_location, location)
|
216
217
|
when 32 then
|
217
|
-
|
218
|
+
ElseNode.new(load_location, load_optional_node, load_optional_location, location)
|
218
219
|
when 33 then
|
219
|
-
|
220
|
+
EmbeddedStatementsNode.new(load_location, load_optional_node, load_location, location)
|
220
221
|
when 34 then
|
221
|
-
|
222
|
+
EmbeddedVariableNode.new(load_location, load_node, location)
|
222
223
|
when 35 then
|
223
|
-
|
224
|
+
EnsureNode.new(load_location, load_optional_node, load_location, location)
|
224
225
|
when 36 then
|
225
|
-
|
226
|
+
FalseNode.new(location)
|
226
227
|
when 37 then
|
227
|
-
|
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
|
-
|
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
|
-
|
232
|
+
FloatNode.new(location)
|
233
233
|
when 40 then
|
234
|
-
|
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
|
-
|
236
|
+
ForwardingArgumentsNode.new(location)
|
237
237
|
when 42 then
|
238
|
-
|
238
|
+
ForwardingParameterNode.new(location)
|
239
239
|
when 43 then
|
240
|
-
|
240
|
+
ForwardingSuperNode.new(load_optional_node, location)
|
241
241
|
when 44 then
|
242
|
-
|
242
|
+
GlobalVariableReadNode.new(location)
|
243
243
|
when 45 then
|
244
|
-
|
244
|
+
GlobalVariableWriteNode.new(load_location, load_optional_location, load_optional_node, location)
|
245
245
|
when 46 then
|
246
|
-
|
246
|
+
HashNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
|
247
247
|
when 47 then
|
248
|
-
|
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
|
-
|
250
|
+
IfNode.new(load_optional_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
|
251
251
|
when 49 then
|
252
|
-
|
252
|
+
ImaginaryNode.new(load_node, location)
|
253
253
|
when 50 then
|
254
|
-
|
254
|
+
InNode.new(load_node, load_optional_node, load_location, load_optional_location, location)
|
255
255
|
when 51 then
|
256
|
-
|
256
|
+
InstanceVariableReadNode.new(location)
|
257
257
|
when 52 then
|
258
|
-
|
258
|
+
InstanceVariableWriteNode.new(load_location, load_optional_node, load_optional_location, location)
|
259
259
|
when 53 then
|
260
|
-
|
260
|
+
IntegerNode.new(location)
|
261
261
|
when 54 then
|
262
|
-
|
262
|
+
InterpolatedRegularExpressionNode.new(load_location, Array.new(load_varint) { load_node }, load_location, load_varint, location)
|
263
263
|
when 55 then
|
264
|
-
|
264
|
+
InterpolatedStringNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
|
265
265
|
when 56 then
|
266
|
-
|
266
|
+
InterpolatedSymbolNode.new(load_optional_location, Array.new(load_varint) { load_node }, load_optional_location, location)
|
267
267
|
when 57 then
|
268
|
-
|
268
|
+
InterpolatedXStringNode.new(load_location, Array.new(load_varint) { load_node }, load_location, location)
|
269
269
|
when 58 then
|
270
|
-
|
270
|
+
KeywordHashNode.new(Array.new(load_varint) { load_node }, location)
|
271
271
|
when 59 then
|
272
|
-
|
272
|
+
KeywordParameterNode.new(load_location, load_optional_node, location)
|
273
273
|
when 60 then
|
274
|
-
|
274
|
+
KeywordRestParameterNode.new(load_location, load_optional_location, location)
|
275
275
|
when 61 then
|
276
|
-
|
276
|
+
LambdaNode.new(Array.new(load_varint) { load_constant }, load_location, load_optional_node, load_optional_node, location)
|
277
277
|
when 62 then
|
278
|
-
|
278
|
+
LocalVariableReadNode.new(load_constant, load_varint, location)
|
279
279
|
when 63 then
|
280
|
-
|
280
|
+
LocalVariableWriteNode.new(load_constant, load_varint, load_optional_node, load_location, load_optional_location, location)
|
281
281
|
when 64 then
|
282
|
-
|
282
|
+
MatchPredicateNode.new(load_node, load_node, load_location, location)
|
283
283
|
when 65 then
|
284
|
-
|
284
|
+
MatchRequiredNode.new(load_node, load_node, load_location, location)
|
285
285
|
when 66 then
|
286
|
-
|
286
|
+
MissingNode.new(location)
|
287
287
|
when 67 then
|
288
|
-
|
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
|
-
|
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
|
-
|
292
|
+
NextNode.new(load_optional_node, load_location, location)
|
293
293
|
when 70 then
|
294
|
-
|
294
|
+
NilNode.new(location)
|
295
295
|
when 71 then
|
296
|
-
|
296
|
+
NoKeywordsParameterNode.new(load_location, load_location, location)
|
297
297
|
when 72 then
|
298
|
-
|
298
|
+
NumberedReferenceReadNode.new(location)
|
299
299
|
when 73 then
|
300
|
-
|
300
|
+
OperatorWriteNode.new(load_node, load_location, load_constant, load_node, location)
|
301
301
|
when 74 then
|
302
|
-
|
302
|
+
OptionalParameterNode.new(load_constant, load_location, load_location, load_node, location)
|
303
303
|
when 75 then
|
304
|
-
|
304
|
+
OrNode.new(load_node, load_node, load_location, location)
|
305
305
|
when 76 then
|
306
|
-
|
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
|
309
|
+
when 78 then
|
340
310
|
ParenthesesNode.new(load_optional_node, load_location, load_location, location)
|
341
|
-
when
|
311
|
+
when 79 then
|
342
312
|
PinnedExpressionNode.new(load_node, load_location, load_location, load_location, location)
|
343
|
-
when
|
313
|
+
when 80 then
|
344
314
|
PinnedVariableNode.new(load_node, load_location, location)
|
345
|
-
when
|
315
|
+
when 81 then
|
346
316
|
PostExecutionNode.new(load_optional_node, load_location, load_location, load_location, location)
|
347
|
-
when
|
317
|
+
when 82 then
|
348
318
|
PreExecutionNode.new(load_optional_node, load_location, load_location, load_location, location)
|
349
|
-
when
|
319
|
+
when 83 then
|
350
320
|
ProgramNode.new(Array.new(load_varint) { load_constant }, load_node, location)
|
351
|
-
when
|
321
|
+
when 84 then
|
352
322
|
RangeNode.new(load_optional_node, load_optional_node, load_location, load_varint, location)
|
353
|
-
when
|
323
|
+
when 85 then
|
354
324
|
RationalNode.new(load_node, location)
|
355
|
-
when
|
325
|
+
when 86 then
|
356
326
|
RedoNode.new(location)
|
357
|
-
when
|
327
|
+
when 87 then
|
358
328
|
RegularExpressionNode.new(load_location, load_location, load_location, load_string, load_varint, location)
|
359
|
-
when
|
329
|
+
when 88 then
|
360
330
|
RequiredDestructuredParameterNode.new(Array.new(load_varint) { load_node }, load_location, load_location, location)
|
361
|
-
when
|
331
|
+
when 89 then
|
362
332
|
RequiredParameterNode.new(load_constant, location)
|
363
|
-
when
|
333
|
+
when 90 then
|
364
334
|
RescueModifierNode.new(load_node, load_location, load_node, location)
|
365
|
-
when
|
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
|
337
|
+
when 92 then
|
368
338
|
RestParameterNode.new(load_location, load_optional_location, location)
|
369
|
-
when
|
339
|
+
when 93 then
|
370
340
|
RetryNode.new(location)
|
371
|
-
when
|
341
|
+
when 94 then
|
372
342
|
ReturnNode.new(load_location, load_optional_node, location)
|
373
|
-
when
|
343
|
+
when 95 then
|
374
344
|
SelfNode.new(location)
|
375
|
-
when
|
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
|
347
|
+
when 97 then
|
378
348
|
SourceEncodingNode.new(location)
|
379
|
-
when
|
349
|
+
when 98 then
|
380
350
|
SourceFileNode.new(load_string, location)
|
381
|
-
when
|
351
|
+
when 99 then
|
382
352
|
SourceLineNode.new(location)
|
383
|
-
when
|
353
|
+
when 100 then
|
384
354
|
SplatNode.new(load_location, load_optional_node, location)
|
385
|
-
when
|
355
|
+
when 101 then
|
386
356
|
StatementsNode.new(Array.new(load_varint) { load_node }, location)
|
387
|
-
when
|
357
|
+
when 102 then
|
388
358
|
StringConcatNode.new(load_node, load_node, location)
|
389
|
-
when
|
359
|
+
when 103 then
|
390
360
|
StringNode.new(load_optional_location, load_location, load_optional_location, load_string, location)
|
391
|
-
when
|
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
|
363
|
+
when 105 then
|
394
364
|
SymbolNode.new(load_optional_location, load_location, load_optional_location, load_string, location)
|
395
|
-
when
|
365
|
+
when 106 then
|
396
366
|
TrueNode.new(location)
|
397
|
-
when
|
367
|
+
when 107 then
|
398
368
|
UndefNode.new(Array.new(load_varint) { load_node }, load_location, location)
|
399
|
-
when
|
369
|
+
when 108 then
|
400
370
|
UnlessNode.new(load_location, load_node, load_optional_node, load_optional_node, load_optional_location, location)
|
401
|
-
when
|
371
|
+
when 109 then
|
402
372
|
UntilNode.new(load_location, load_node, load_optional_node, load_varint, location)
|
403
|
-
when
|
373
|
+
when 110 then
|
404
374
|
WhenNode.new(load_location, Array.new(load_varint) { load_node }, load_optional_node, location)
|
405
|
-
when
|
375
|
+
when 111 then
|
406
376
|
WhileNode.new(load_location, load_node, load_optional_node, load_varint, location)
|
407
|
-
when
|
377
|
+
when 112 then
|
408
378
|
XStringNode.new(load_location, load_location, load_location, load_string, location)
|
409
|
-
when
|
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)
|