syntax_tree 5.1.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +4 -0
- data/.github/workflows/auto-merge.yml +1 -1
- data/.github/workflows/gh-pages.yml +1 -1
- data/.github/workflows/main.yml +5 -2
- data/.gitmodules +9 -0
- data/.rubocop.yml +11 -1
- data/CHANGELOG.md +29 -1
- data/Gemfile.lock +10 -10
- data/README.md +1 -0
- data/Rakefile +7 -0
- data/exe/yarv +63 -0
- data/lib/syntax_tree/cli.rb +3 -2
- data/lib/syntax_tree/formatter.rb +23 -2
- data/lib/syntax_tree/index.rb +374 -0
- data/lib/syntax_tree/node.rb +146 -107
- data/lib/syntax_tree/parser.rb +20 -3
- data/lib/syntax_tree/plugin/disable_ternary.rb +7 -0
- data/lib/syntax_tree/version.rb +1 -1
- data/lib/syntax_tree/yarv/assembler.rb +17 -13
- data/lib/syntax_tree/yarv/bf.rb +13 -16
- data/lib/syntax_tree/yarv/compiler.rb +25 -14
- data/lib/syntax_tree/yarv/decompiler.rb +10 -1
- data/lib/syntax_tree/yarv/disassembler.rb +3 -2
- data/lib/syntax_tree/yarv/instruction_sequence.rb +191 -87
- data/lib/syntax_tree/yarv/instructions.rb +1011 -42
- data/lib/syntax_tree/yarv/legacy.rb +59 -3
- data/lib/syntax_tree/yarv/vm.rb +628 -0
- data/lib/syntax_tree/yarv.rb +0 -269
- data/lib/syntax_tree.rb +16 -0
- metadata +9 -3
@@ -91,6 +91,14 @@ module SyntaxTree
|
|
91
91
|
[:adjuststack, number]
|
92
92
|
end
|
93
93
|
|
94
|
+
def deconstruct_keys(_keys)
|
95
|
+
{ number: number }
|
96
|
+
end
|
97
|
+
|
98
|
+
def ==(other)
|
99
|
+
other.is_a?(AdjustStack) && other.number == number
|
100
|
+
end
|
101
|
+
|
94
102
|
def length
|
95
103
|
2
|
96
104
|
end
|
@@ -139,6 +147,14 @@ module SyntaxTree
|
|
139
147
|
[:anytostring]
|
140
148
|
end
|
141
149
|
|
150
|
+
def deconstruct_keys(_keys)
|
151
|
+
{}
|
152
|
+
end
|
153
|
+
|
154
|
+
def ==(other)
|
155
|
+
other.is_a?(AnyToString)
|
156
|
+
end
|
157
|
+
|
142
158
|
def length
|
143
159
|
1
|
144
160
|
end
|
@@ -197,6 +213,14 @@ module SyntaxTree
|
|
197
213
|
[:branchif, label.name]
|
198
214
|
end
|
199
215
|
|
216
|
+
def deconstruct_keys(_keys)
|
217
|
+
{ label: label }
|
218
|
+
end
|
219
|
+
|
220
|
+
def ==(other)
|
221
|
+
other.is_a?(BranchIf) && other.label == label
|
222
|
+
end
|
223
|
+
|
200
224
|
def length
|
201
225
|
2
|
202
226
|
end
|
@@ -250,6 +274,14 @@ module SyntaxTree
|
|
250
274
|
[:branchnil, label.name]
|
251
275
|
end
|
252
276
|
|
277
|
+
def deconstruct_keys(_keys)
|
278
|
+
{ label: label }
|
279
|
+
end
|
280
|
+
|
281
|
+
def ==(other)
|
282
|
+
other.is_a?(BranchNil) && other.label == label
|
283
|
+
end
|
284
|
+
|
253
285
|
def length
|
254
286
|
2
|
255
287
|
end
|
@@ -302,6 +334,14 @@ module SyntaxTree
|
|
302
334
|
[:branchunless, label.name]
|
303
335
|
end
|
304
336
|
|
337
|
+
def deconstruct_keys(_keys)
|
338
|
+
{ label: label }
|
339
|
+
end
|
340
|
+
|
341
|
+
def ==(other)
|
342
|
+
other.is_a?(BranchUnless) && other.label == label
|
343
|
+
end
|
344
|
+
|
305
345
|
def length
|
306
346
|
2
|
307
347
|
end
|
@@ -365,6 +405,16 @@ module SyntaxTree
|
|
365
405
|
]
|
366
406
|
end
|
367
407
|
|
408
|
+
def deconstruct_keys(_keys)
|
409
|
+
{ keyword_bits_index: keyword_bits_index, keyword_index: keyword_index }
|
410
|
+
end
|
411
|
+
|
412
|
+
def ==(other)
|
413
|
+
other.is_a?(CheckKeyword) &&
|
414
|
+
other.keyword_bits_index == keyword_bits_index &&
|
415
|
+
other.keyword_index == keyword_index
|
416
|
+
end
|
417
|
+
|
368
418
|
def length
|
369
419
|
3
|
370
420
|
end
|
@@ -399,9 +449,11 @@ module SyntaxTree
|
|
399
449
|
# ~~~
|
400
450
|
#
|
401
451
|
class CheckMatch
|
402
|
-
|
403
|
-
|
404
|
-
|
452
|
+
VM_CHECKMATCH_TYPE_WHEN = 1
|
453
|
+
VM_CHECKMATCH_TYPE_CASE = 2
|
454
|
+
VM_CHECKMATCH_TYPE_RESCUE = 3
|
455
|
+
VM_CHECKMATCH_TYPE_MASK = 0x03
|
456
|
+
VM_CHECKMATCH_ARRAY = 0x04
|
405
457
|
|
406
458
|
attr_reader :type
|
407
459
|
|
@@ -417,6 +469,14 @@ module SyntaxTree
|
|
417
469
|
[:checkmatch, type]
|
418
470
|
end
|
419
471
|
|
472
|
+
def deconstruct_keys(_keys)
|
473
|
+
{ type: type }
|
474
|
+
end
|
475
|
+
|
476
|
+
def ==(other)
|
477
|
+
other.is_a?(CheckMatch) && other.type == type
|
478
|
+
end
|
479
|
+
|
420
480
|
def length
|
421
481
|
2
|
422
482
|
end
|
@@ -434,7 +494,32 @@ module SyntaxTree
|
|
434
494
|
end
|
435
495
|
|
436
496
|
def call(vm)
|
437
|
-
|
497
|
+
target, pattern = vm.pop(2)
|
498
|
+
|
499
|
+
vm.push(
|
500
|
+
if type & VM_CHECKMATCH_ARRAY > 0
|
501
|
+
pattern.any? { |item| check?(item, target) }
|
502
|
+
else
|
503
|
+
check?(pattern, target)
|
504
|
+
end
|
505
|
+
)
|
506
|
+
end
|
507
|
+
|
508
|
+
private
|
509
|
+
|
510
|
+
def check?(pattern, target)
|
511
|
+
case type & VM_CHECKMATCH_TYPE_MASK
|
512
|
+
when VM_CHECKMATCH_TYPE_WHEN
|
513
|
+
pattern
|
514
|
+
when VM_CHECKMATCH_TYPE_CASE
|
515
|
+
pattern === target
|
516
|
+
when VM_CHECKMATCH_TYPE_RESCUE
|
517
|
+
unless pattern.is_a?(Module)
|
518
|
+
raise TypeError, "class or module required for rescue clause"
|
519
|
+
end
|
520
|
+
|
521
|
+
pattern === target
|
522
|
+
end
|
438
523
|
end
|
439
524
|
end
|
440
525
|
|
@@ -534,6 +619,14 @@ module SyntaxTree
|
|
534
619
|
[:checktype, type]
|
535
620
|
end
|
536
621
|
|
622
|
+
def deconstruct_keys(_keys)
|
623
|
+
{ type: type }
|
624
|
+
end
|
625
|
+
|
626
|
+
def ==(other)
|
627
|
+
other.is_a?(CheckType) && other.type == type
|
628
|
+
end
|
629
|
+
|
537
630
|
def length
|
538
631
|
2
|
539
632
|
end
|
@@ -629,6 +722,14 @@ module SyntaxTree
|
|
629
722
|
[:concatarray]
|
630
723
|
end
|
631
724
|
|
725
|
+
def deconstruct_keys(_keys)
|
726
|
+
{}
|
727
|
+
end
|
728
|
+
|
729
|
+
def ==(other)
|
730
|
+
other.is_a?(ConcatArray)
|
731
|
+
end
|
732
|
+
|
632
733
|
def length
|
633
734
|
1
|
634
735
|
end
|
@@ -681,6 +782,14 @@ module SyntaxTree
|
|
681
782
|
[:concatstrings, number]
|
682
783
|
end
|
683
784
|
|
785
|
+
def deconstruct_keys(_keys)
|
786
|
+
{ number: number }
|
787
|
+
end
|
788
|
+
|
789
|
+
def ==(other)
|
790
|
+
other.is_a?(ConcatStrings) && other.number == number
|
791
|
+
end
|
792
|
+
|
684
793
|
def length
|
685
794
|
2
|
686
795
|
end
|
@@ -744,6 +853,15 @@ module SyntaxTree
|
|
744
853
|
[:defineclass, name, class_iseq.to_a, flags]
|
745
854
|
end
|
746
855
|
|
856
|
+
def deconstruct_keys(_keys)
|
857
|
+
{ name: name, class_iseq: class_iseq, flags: flags }
|
858
|
+
end
|
859
|
+
|
860
|
+
def ==(other)
|
861
|
+
other.is_a?(DefineClass) && other.name == name &&
|
862
|
+
other.class_iseq == class_iseq && other.flags == flags
|
863
|
+
end
|
864
|
+
|
747
865
|
def length
|
748
866
|
4
|
749
867
|
end
|
@@ -762,12 +880,26 @@ module SyntaxTree
|
|
762
880
|
|
763
881
|
def call(vm)
|
764
882
|
object, superclass = vm.pop(2)
|
765
|
-
iseq = class_iseq
|
766
883
|
|
767
|
-
|
768
|
-
|
884
|
+
if name == :singletonclass
|
885
|
+
vm.push(vm.run_class_frame(class_iseq, object.singleton_class))
|
886
|
+
elsif object.const_defined?(name)
|
887
|
+
vm.push(vm.run_class_frame(class_iseq, object.const_get(name)))
|
888
|
+
elsif flags & TYPE_MODULE > 0
|
889
|
+
clazz = Module.new
|
890
|
+
object.const_set(name, clazz)
|
891
|
+
vm.push(vm.run_class_frame(class_iseq, clazz))
|
892
|
+
else
|
893
|
+
clazz =
|
894
|
+
if flags & FLAG_HAS_SUPERCLASS > 0
|
895
|
+
Class.new(superclass)
|
896
|
+
else
|
897
|
+
Class.new
|
898
|
+
end
|
769
899
|
|
770
|
-
|
900
|
+
object.const_set(name, clazz)
|
901
|
+
vm.push(vm.run_class_frame(class_iseq, clazz))
|
902
|
+
end
|
771
903
|
end
|
772
904
|
end
|
773
905
|
|
@@ -858,6 +990,15 @@ module SyntaxTree
|
|
858
990
|
[:defined, type, name, message]
|
859
991
|
end
|
860
992
|
|
993
|
+
def deconstruct_keys(_keys)
|
994
|
+
{ type: type, name: name, message: message }
|
995
|
+
end
|
996
|
+
|
997
|
+
def ==(other)
|
998
|
+
other.is_a?(Defined) && other.type == type && other.name == name &&
|
999
|
+
other.message == message
|
1000
|
+
end
|
1001
|
+
|
861
1002
|
def length
|
862
1003
|
4
|
863
1004
|
end
|
@@ -882,17 +1023,19 @@ module SyntaxTree
|
|
882
1023
|
when TYPE_NIL, TYPE_SELF, TYPE_TRUE, TYPE_FALSE, TYPE_ASGN, TYPE_EXPR
|
883
1024
|
message
|
884
1025
|
when TYPE_IVAR
|
885
|
-
message if vm._self.instance_variable_defined?(name)
|
1026
|
+
message if vm.frame._self.instance_variable_defined?(name)
|
886
1027
|
when TYPE_LVAR
|
887
1028
|
raise NotImplementedError, "defined TYPE_LVAR"
|
888
1029
|
when TYPE_GVAR
|
889
1030
|
message if global_variables.include?(name)
|
890
1031
|
when TYPE_CVAR
|
891
|
-
clazz = vm._self
|
1032
|
+
clazz = vm.frame._self
|
892
1033
|
clazz = clazz.singleton_class unless clazz.is_a?(Module)
|
893
1034
|
message if clazz.class_variable_defined?(name)
|
894
1035
|
when TYPE_CONST
|
895
|
-
|
1036
|
+
clazz = vm.frame._self
|
1037
|
+
clazz = clazz.singleton_class unless clazz.is_a?(Module)
|
1038
|
+
message if clazz.const_defined?(name)
|
896
1039
|
when TYPE_METHOD
|
897
1040
|
raise NotImplementedError, "defined TYPE_METHOD"
|
898
1041
|
when TYPE_YIELD
|
@@ -904,7 +1047,9 @@ module SyntaxTree
|
|
904
1047
|
when TYPE_FUNC
|
905
1048
|
message if object.respond_to?(name, true)
|
906
1049
|
when TYPE_CONST_FROM
|
907
|
-
|
1050
|
+
defined =
|
1051
|
+
vm.frame.nesting.any? { |scope| scope.const_defined?(name, true) }
|
1052
|
+
message if defined
|
908
1053
|
end
|
909
1054
|
|
910
1055
|
vm.push(result)
|
@@ -944,6 +1089,15 @@ module SyntaxTree
|
|
944
1089
|
[:definemethod, method_name, method_iseq.to_a]
|
945
1090
|
end
|
946
1091
|
|
1092
|
+
def deconstruct_keys(_keys)
|
1093
|
+
{ method_name: method_name, method_iseq: method_iseq }
|
1094
|
+
end
|
1095
|
+
|
1096
|
+
def ==(other)
|
1097
|
+
other.is_a?(DefineMethod) && other.method_name == method_name &&
|
1098
|
+
other.method_iseq == method_iseq
|
1099
|
+
end
|
1100
|
+
|
947
1101
|
def length
|
948
1102
|
3
|
949
1103
|
end
|
@@ -962,12 +1116,22 @@ module SyntaxTree
|
|
962
1116
|
|
963
1117
|
def call(vm)
|
964
1118
|
name = method_name
|
1119
|
+
nesting = vm.frame.nesting
|
965
1120
|
iseq = method_iseq
|
966
1121
|
|
967
1122
|
vm
|
1123
|
+
.frame
|
968
1124
|
._self
|
969
1125
|
.__send__(:define_method, name) do |*args, **kwargs, &block|
|
970
|
-
vm.run_method_frame(
|
1126
|
+
vm.run_method_frame(
|
1127
|
+
name,
|
1128
|
+
nesting,
|
1129
|
+
iseq,
|
1130
|
+
self,
|
1131
|
+
*args,
|
1132
|
+
**kwargs,
|
1133
|
+
&block
|
1134
|
+
)
|
971
1135
|
end
|
972
1136
|
end
|
973
1137
|
end
|
@@ -1006,6 +1170,15 @@ module SyntaxTree
|
|
1006
1170
|
[:definesmethod, method_name, method_iseq.to_a]
|
1007
1171
|
end
|
1008
1172
|
|
1173
|
+
def deconstruct_keys(_keys)
|
1174
|
+
{ method_name: method_name, method_iseq: method_iseq }
|
1175
|
+
end
|
1176
|
+
|
1177
|
+
def ==(other)
|
1178
|
+
other.is_a?(DefineSMethod) && other.method_name == method_name &&
|
1179
|
+
other.method_iseq == method_iseq
|
1180
|
+
end
|
1181
|
+
|
1009
1182
|
def length
|
1010
1183
|
3
|
1011
1184
|
end
|
@@ -1024,12 +1197,22 @@ module SyntaxTree
|
|
1024
1197
|
|
1025
1198
|
def call(vm)
|
1026
1199
|
name = method_name
|
1200
|
+
nesting = vm.frame.nesting
|
1027
1201
|
iseq = method_iseq
|
1028
1202
|
|
1029
1203
|
vm
|
1204
|
+
.frame
|
1030
1205
|
._self
|
1031
1206
|
.__send__(:define_singleton_method, name) do |*args, **kwargs, &block|
|
1032
|
-
vm.run_method_frame(
|
1207
|
+
vm.run_method_frame(
|
1208
|
+
name,
|
1209
|
+
nesting,
|
1210
|
+
iseq,
|
1211
|
+
self,
|
1212
|
+
*args,
|
1213
|
+
**kwargs,
|
1214
|
+
&block
|
1215
|
+
)
|
1033
1216
|
end
|
1034
1217
|
end
|
1035
1218
|
end
|
@@ -1053,6 +1236,14 @@ module SyntaxTree
|
|
1053
1236
|
[:dup]
|
1054
1237
|
end
|
1055
1238
|
|
1239
|
+
def deconstruct_keys(_keys)
|
1240
|
+
{}
|
1241
|
+
end
|
1242
|
+
|
1243
|
+
def ==(other)
|
1244
|
+
other.is_a?(Dup)
|
1245
|
+
end
|
1246
|
+
|
1056
1247
|
def length
|
1057
1248
|
1
|
1058
1249
|
end
|
@@ -1099,6 +1290,14 @@ module SyntaxTree
|
|
1099
1290
|
[:duparray, object]
|
1100
1291
|
end
|
1101
1292
|
|
1293
|
+
def deconstruct_keys(_keys)
|
1294
|
+
{ object: object }
|
1295
|
+
end
|
1296
|
+
|
1297
|
+
def ==(other)
|
1298
|
+
other.is_a?(DupArray) && other.object == object
|
1299
|
+
end
|
1300
|
+
|
1102
1301
|
def length
|
1103
1302
|
2
|
1104
1303
|
end
|
@@ -1145,6 +1344,14 @@ module SyntaxTree
|
|
1145
1344
|
[:duphash, object]
|
1146
1345
|
end
|
1147
1346
|
|
1347
|
+
def deconstruct_keys(_keys)
|
1348
|
+
{ object: object }
|
1349
|
+
end
|
1350
|
+
|
1351
|
+
def ==(other)
|
1352
|
+
other.is_a?(DupHash) && other.object == object
|
1353
|
+
end
|
1354
|
+
|
1148
1355
|
def length
|
1149
1356
|
2
|
1150
1357
|
end
|
@@ -1191,6 +1398,14 @@ module SyntaxTree
|
|
1191
1398
|
[:dupn, number]
|
1192
1399
|
end
|
1193
1400
|
|
1401
|
+
def deconstruct_keys(_keys)
|
1402
|
+
{ number: number }
|
1403
|
+
end
|
1404
|
+
|
1405
|
+
def ==(other)
|
1406
|
+
other.is_a?(DupN) && other.number == number
|
1407
|
+
end
|
1408
|
+
|
1194
1409
|
def length
|
1195
1410
|
2
|
1196
1411
|
end
|
@@ -1242,6 +1457,15 @@ module SyntaxTree
|
|
1242
1457
|
[:expandarray, number, flags]
|
1243
1458
|
end
|
1244
1459
|
|
1460
|
+
def deconstruct_keys(_keys)
|
1461
|
+
{ number: number, flags: flags }
|
1462
|
+
end
|
1463
|
+
|
1464
|
+
def ==(other)
|
1465
|
+
other.is_a?(ExpandArray) && other.number == number &&
|
1466
|
+
other.flags == flags
|
1467
|
+
end
|
1468
|
+
|
1245
1469
|
def length
|
1246
1470
|
3
|
1247
1471
|
end
|
@@ -1259,7 +1483,42 @@ module SyntaxTree
|
|
1259
1483
|
end
|
1260
1484
|
|
1261
1485
|
def call(vm)
|
1262
|
-
|
1486
|
+
object = vm.pop
|
1487
|
+
object =
|
1488
|
+
if Array === object
|
1489
|
+
object.dup
|
1490
|
+
elsif object.respond_to?(:to_ary, true)
|
1491
|
+
object.to_ary
|
1492
|
+
else
|
1493
|
+
[object]
|
1494
|
+
end
|
1495
|
+
|
1496
|
+
splat_flag = flags & 0x01 > 0
|
1497
|
+
postarg_flag = flags & 0x02 > 0
|
1498
|
+
|
1499
|
+
if number == 0 && splat_flag == 0
|
1500
|
+
# no space left on stack
|
1501
|
+
elsif postarg_flag
|
1502
|
+
values = []
|
1503
|
+
|
1504
|
+
if number > object.size
|
1505
|
+
(number - object.size).times { values.push(nil) }
|
1506
|
+
end
|
1507
|
+
[number, object.size].min.times { values.push(object.pop) }
|
1508
|
+
values.push(object.to_a) if splat_flag
|
1509
|
+
|
1510
|
+
values.each { |item| vm.push(item) }
|
1511
|
+
else
|
1512
|
+
values = []
|
1513
|
+
|
1514
|
+
[number, object.size].min.times { values.push(object.shift) }
|
1515
|
+
if number > values.size
|
1516
|
+
(number - values.size).times { values.push(nil) }
|
1517
|
+
end
|
1518
|
+
values.push(object.to_a) if splat_flag
|
1519
|
+
|
1520
|
+
values.reverse_each { |item| vm.push(item) }
|
1521
|
+
end
|
1263
1522
|
end
|
1264
1523
|
end
|
1265
1524
|
|
@@ -1298,6 +1557,15 @@ module SyntaxTree
|
|
1298
1557
|
[:getblockparam, current.local_table.offset(index), level]
|
1299
1558
|
end
|
1300
1559
|
|
1560
|
+
def deconstruct_keys(_keys)
|
1561
|
+
{ index: index, level: level }
|
1562
|
+
end
|
1563
|
+
|
1564
|
+
def ==(other)
|
1565
|
+
other.is_a?(GetBlockParam) && other.index == index &&
|
1566
|
+
other.level == level
|
1567
|
+
end
|
1568
|
+
|
1301
1569
|
def length
|
1302
1570
|
3
|
1303
1571
|
end
|
@@ -1355,6 +1623,15 @@ module SyntaxTree
|
|
1355
1623
|
[:getblockparamproxy, current.local_table.offset(index), level]
|
1356
1624
|
end
|
1357
1625
|
|
1626
|
+
def deconstruct_keys(_keys)
|
1627
|
+
{ index: index, level: level }
|
1628
|
+
end
|
1629
|
+
|
1630
|
+
def ==(other)
|
1631
|
+
other.is_a?(GetBlockParamProxy) && other.index == index &&
|
1632
|
+
other.level == level
|
1633
|
+
end
|
1634
|
+
|
1358
1635
|
def length
|
1359
1636
|
3
|
1360
1637
|
end
|
@@ -1407,6 +1684,15 @@ module SyntaxTree
|
|
1407
1684
|
[:getclassvariable, name, cache]
|
1408
1685
|
end
|
1409
1686
|
|
1687
|
+
def deconstruct_keys(_keys)
|
1688
|
+
{ name: name, cache: cache }
|
1689
|
+
end
|
1690
|
+
|
1691
|
+
def ==(other)
|
1692
|
+
other.is_a?(GetClassVariable) && other.name == name &&
|
1693
|
+
other.cache == cache
|
1694
|
+
end
|
1695
|
+
|
1410
1696
|
def length
|
1411
1697
|
3
|
1412
1698
|
end
|
@@ -1424,7 +1710,7 @@ module SyntaxTree
|
|
1424
1710
|
end
|
1425
1711
|
|
1426
1712
|
def call(vm)
|
1427
|
-
clazz = vm._self
|
1713
|
+
clazz = vm.frame._self
|
1428
1714
|
clazz = clazz.class unless clazz.is_a?(Class)
|
1429
1715
|
vm.push(clazz.class_variable_get(name))
|
1430
1716
|
end
|
@@ -1457,6 +1743,14 @@ module SyntaxTree
|
|
1457
1743
|
[:getconstant, name]
|
1458
1744
|
end
|
1459
1745
|
|
1746
|
+
def deconstruct_keys(_keys)
|
1747
|
+
{ name: name }
|
1748
|
+
end
|
1749
|
+
|
1750
|
+
def ==(other)
|
1751
|
+
other.is_a?(GetConstant) && other.name == name
|
1752
|
+
end
|
1753
|
+
|
1460
1754
|
def length
|
1461
1755
|
2
|
1462
1756
|
end
|
@@ -1474,14 +1768,20 @@ module SyntaxTree
|
|
1474
1768
|
end
|
1475
1769
|
|
1476
1770
|
def call(vm)
|
1477
|
-
|
1478
|
-
vm.pop(2)
|
1771
|
+
const_base, allow_nil = vm.pop(2)
|
1479
1772
|
|
1480
|
-
|
1481
|
-
if
|
1482
|
-
vm.push(
|
1773
|
+
if const_base
|
1774
|
+
if const_base.const_defined?(name)
|
1775
|
+
vm.push(const_base.const_get(name))
|
1483
1776
|
return
|
1484
1777
|
end
|
1778
|
+
elsif const_base.nil? && allow_nil
|
1779
|
+
vm.frame.nesting.reverse_each do |clazz|
|
1780
|
+
if clazz.const_defined?(name)
|
1781
|
+
vm.push(clazz.const_get(name))
|
1782
|
+
return
|
1783
|
+
end
|
1784
|
+
end
|
1485
1785
|
end
|
1486
1786
|
|
1487
1787
|
raise NameError, "uninitialized constant #{name}"
|
@@ -1513,6 +1813,14 @@ module SyntaxTree
|
|
1513
1813
|
[:getglobal, name]
|
1514
1814
|
end
|
1515
1815
|
|
1816
|
+
def deconstruct_keys(_keys)
|
1817
|
+
{ name: name }
|
1818
|
+
end
|
1819
|
+
|
1820
|
+
def ==(other)
|
1821
|
+
other.is_a?(GetGlobal) && other.name == name
|
1822
|
+
end
|
1823
|
+
|
1516
1824
|
def length
|
1517
1825
|
2
|
1518
1826
|
end
|
@@ -1572,6 +1880,15 @@ module SyntaxTree
|
|
1572
1880
|
[:getinstancevariable, name, cache]
|
1573
1881
|
end
|
1574
1882
|
|
1883
|
+
def deconstruct_keys(_keys)
|
1884
|
+
{ name: name, cache: cache }
|
1885
|
+
end
|
1886
|
+
|
1887
|
+
def ==(other)
|
1888
|
+
other.is_a?(GetInstanceVariable) && other.name == name &&
|
1889
|
+
other.cache == cache
|
1890
|
+
end
|
1891
|
+
|
1575
1892
|
def length
|
1576
1893
|
3
|
1577
1894
|
end
|
@@ -1590,7 +1907,7 @@ module SyntaxTree
|
|
1590
1907
|
|
1591
1908
|
def call(vm)
|
1592
1909
|
method = Object.instance_method(:instance_variable_get)
|
1593
|
-
vm.push(method.bind(vm._self).call(name))
|
1910
|
+
vm.push(method.bind(vm.frame._self).call(name))
|
1594
1911
|
end
|
1595
1912
|
end
|
1596
1913
|
|
@@ -1626,6 +1943,14 @@ module SyntaxTree
|
|
1626
1943
|
[:getlocal, current.local_table.offset(index), level]
|
1627
1944
|
end
|
1628
1945
|
|
1946
|
+
def deconstruct_keys(_keys)
|
1947
|
+
{ index: index, level: level }
|
1948
|
+
end
|
1949
|
+
|
1950
|
+
def ==(other)
|
1951
|
+
other.is_a?(GetLocal) && other.index == index && other.level == level
|
1952
|
+
end
|
1953
|
+
|
1629
1954
|
def length
|
1630
1955
|
3
|
1631
1956
|
end
|
@@ -1675,6 +2000,14 @@ module SyntaxTree
|
|
1675
2000
|
[:getlocal_WC_0, iseq.local_table.offset(index)]
|
1676
2001
|
end
|
1677
2002
|
|
2003
|
+
def deconstruct_keys(_keys)
|
2004
|
+
{ index: index }
|
2005
|
+
end
|
2006
|
+
|
2007
|
+
def ==(other)
|
2008
|
+
other.is_a?(GetLocalWC0) && other.index == index
|
2009
|
+
end
|
2010
|
+
|
1678
2011
|
def length
|
1679
2012
|
2
|
1680
2013
|
end
|
@@ -1724,6 +2057,14 @@ module SyntaxTree
|
|
1724
2057
|
[:getlocal_WC_1, iseq.parent_iseq.local_table.offset(index)]
|
1725
2058
|
end
|
1726
2059
|
|
2060
|
+
def deconstruct_keys(_keys)
|
2061
|
+
{ index: index }
|
2062
|
+
end
|
2063
|
+
|
2064
|
+
def ==(other)
|
2065
|
+
other.is_a?(GetLocalWC1) && other.index == index
|
2066
|
+
end
|
2067
|
+
|
1727
2068
|
def length
|
1728
2069
|
2
|
1729
2070
|
end
|
@@ -1775,6 +2116,14 @@ module SyntaxTree
|
|
1775
2116
|
[:getspecial, key, type]
|
1776
2117
|
end
|
1777
2118
|
|
2119
|
+
def deconstruct_keys(_keys)
|
2120
|
+
{ key: key, type: type }
|
2121
|
+
end
|
2122
|
+
|
2123
|
+
def ==(other)
|
2124
|
+
other.is_a?(GetSpecial) && other.key == key && other.type == type
|
2125
|
+
end
|
2126
|
+
|
1778
2127
|
def length
|
1779
2128
|
3
|
1780
2129
|
end
|
@@ -1823,6 +2172,14 @@ module SyntaxTree
|
|
1823
2172
|
[:intern]
|
1824
2173
|
end
|
1825
2174
|
|
2175
|
+
def deconstruct_keys(_keys)
|
2176
|
+
{}
|
2177
|
+
end
|
2178
|
+
|
2179
|
+
def ==(other)
|
2180
|
+
other.is_a?(Intern)
|
2181
|
+
end
|
2182
|
+
|
1826
2183
|
def length
|
1827
2184
|
1
|
1828
2185
|
end
|
@@ -1873,6 +2230,14 @@ module SyntaxTree
|
|
1873
2230
|
[:invokeblock, calldata.to_h]
|
1874
2231
|
end
|
1875
2232
|
|
2233
|
+
def deconstruct_keys(_keys)
|
2234
|
+
{ calldata: calldata }
|
2235
|
+
end
|
2236
|
+
|
2237
|
+
def ==(other)
|
2238
|
+
other.is_a?(InvokeBlock) && other.calldata == calldata
|
2239
|
+
end
|
2240
|
+
|
1876
2241
|
def length
|
1877
2242
|
2
|
1878
2243
|
end
|
@@ -1928,6 +2293,15 @@ module SyntaxTree
|
|
1928
2293
|
[:invokesuper, calldata.to_h, block_iseq&.to_a]
|
1929
2294
|
end
|
1930
2295
|
|
2296
|
+
def deconstruct_keys(_keys)
|
2297
|
+
{ calldata: calldata, block_iseq: block_iseq }
|
2298
|
+
end
|
2299
|
+
|
2300
|
+
def ==(other)
|
2301
|
+
other.is_a?(InvokeSuper) && other.calldata == calldata &&
|
2302
|
+
other.block_iseq == block_iseq
|
2303
|
+
end
|
2304
|
+
|
1931
2305
|
def length
|
1932
2306
|
1
|
1933
2307
|
end
|
@@ -1948,8 +2322,9 @@ module SyntaxTree
|
|
1948
2322
|
def call(vm)
|
1949
2323
|
block =
|
1950
2324
|
if (iseq = block_iseq)
|
2325
|
+
frame = vm.frame
|
1951
2326
|
->(*args, **kwargs, &blk) do
|
1952
|
-
vm.run_block_frame(iseq, *args, **kwargs, &blk)
|
2327
|
+
vm.run_block_frame(iseq, frame, *args, **kwargs, &blk)
|
1953
2328
|
end
|
1954
2329
|
end
|
1955
2330
|
|
@@ -1998,6 +2373,14 @@ module SyntaxTree
|
|
1998
2373
|
[:jump, label.name]
|
1999
2374
|
end
|
2000
2375
|
|
2376
|
+
def deconstruct_keys(_keys)
|
2377
|
+
{ label: label }
|
2378
|
+
end
|
2379
|
+
|
2380
|
+
def ==(other)
|
2381
|
+
other.is_a?(Jump) && other.label == label
|
2382
|
+
end
|
2383
|
+
|
2001
2384
|
def length
|
2002
2385
|
2
|
2003
2386
|
end
|
@@ -2038,6 +2421,14 @@ module SyntaxTree
|
|
2038
2421
|
[:leave]
|
2039
2422
|
end
|
2040
2423
|
|
2424
|
+
def deconstruct_keys(_keys)
|
2425
|
+
{}
|
2426
|
+
end
|
2427
|
+
|
2428
|
+
def ==(other)
|
2429
|
+
other.is_a?(Leave)
|
2430
|
+
end
|
2431
|
+
|
2041
2432
|
def length
|
2042
2433
|
1
|
2043
2434
|
end
|
@@ -2088,6 +2479,14 @@ module SyntaxTree
|
|
2088
2479
|
[:newarray, number]
|
2089
2480
|
end
|
2090
2481
|
|
2482
|
+
def deconstruct_keys(_keys)
|
2483
|
+
{ number: number }
|
2484
|
+
end
|
2485
|
+
|
2486
|
+
def ==(other)
|
2487
|
+
other.is_a?(NewArray) && other.number == number
|
2488
|
+
end
|
2489
|
+
|
2091
2490
|
def length
|
2092
2491
|
2
|
2093
2492
|
end
|
@@ -2136,6 +2535,14 @@ module SyntaxTree
|
|
2136
2535
|
[:newarraykwsplat, number]
|
2137
2536
|
end
|
2138
2537
|
|
2538
|
+
def deconstruct_keys(_keys)
|
2539
|
+
{ number: number }
|
2540
|
+
end
|
2541
|
+
|
2542
|
+
def ==(other)
|
2543
|
+
other.is_a?(NewArrayKwSplat) && other.number == number
|
2544
|
+
end
|
2545
|
+
|
2139
2546
|
def length
|
2140
2547
|
2
|
2141
2548
|
end
|
@@ -2186,6 +2593,14 @@ module SyntaxTree
|
|
2186
2593
|
[:newhash, number]
|
2187
2594
|
end
|
2188
2595
|
|
2596
|
+
def deconstruct_keys(_keys)
|
2597
|
+
{ number: number }
|
2598
|
+
end
|
2599
|
+
|
2600
|
+
def ==(other)
|
2601
|
+
other.is_a?(NewHash) && other.number == number
|
2602
|
+
end
|
2603
|
+
|
2189
2604
|
def length
|
2190
2605
|
2
|
2191
2606
|
end
|
@@ -2237,6 +2652,14 @@ module SyntaxTree
|
|
2237
2652
|
[:newrange, exclude_end]
|
2238
2653
|
end
|
2239
2654
|
|
2655
|
+
def deconstruct_keys(_keys)
|
2656
|
+
{ exclude_end: exclude_end }
|
2657
|
+
end
|
2658
|
+
|
2659
|
+
def ==(other)
|
2660
|
+
other.is_a?(NewRange) && other.exclude_end == exclude_end
|
2661
|
+
end
|
2662
|
+
|
2240
2663
|
def length
|
2241
2664
|
2
|
2242
2665
|
end
|
@@ -2278,6 +2701,14 @@ module SyntaxTree
|
|
2278
2701
|
[:nop]
|
2279
2702
|
end
|
2280
2703
|
|
2704
|
+
def deconstruct_keys(_keys)
|
2705
|
+
{}
|
2706
|
+
end
|
2707
|
+
|
2708
|
+
def ==(other)
|
2709
|
+
other.is_a?(Nop)
|
2710
|
+
end
|
2711
|
+
|
2281
2712
|
def length
|
2282
2713
|
1
|
2283
2714
|
end
|
@@ -2327,6 +2758,14 @@ module SyntaxTree
|
|
2327
2758
|
[:objtostring, calldata.to_h]
|
2328
2759
|
end
|
2329
2760
|
|
2761
|
+
def deconstruct_keys(_keys)
|
2762
|
+
{ calldata: calldata }
|
2763
|
+
end
|
2764
|
+
|
2765
|
+
def ==(other)
|
2766
|
+
other.is_a?(ObjToString) && other.calldata == calldata
|
2767
|
+
end
|
2768
|
+
|
2330
2769
|
def length
|
2331
2770
|
2
|
2332
2771
|
end
|
@@ -2378,6 +2817,14 @@ module SyntaxTree
|
|
2378
2817
|
[:once, iseq.to_a, cache]
|
2379
2818
|
end
|
2380
2819
|
|
2820
|
+
def deconstruct_keys(_keys)
|
2821
|
+
{ iseq: iseq, cache: cache }
|
2822
|
+
end
|
2823
|
+
|
2824
|
+
def ==(other)
|
2825
|
+
other.is_a?(Once) && other.iseq == iseq && other.cache == cache
|
2826
|
+
end
|
2827
|
+
|
2381
2828
|
def length
|
2382
2829
|
3
|
2383
2830
|
end
|
@@ -2396,7 +2843,7 @@ module SyntaxTree
|
|
2396
2843
|
|
2397
2844
|
def call(vm)
|
2398
2845
|
return if @executed
|
2399
|
-
vm.push(vm.run_block_frame(iseq))
|
2846
|
+
vm.push(vm.run_block_frame(iseq, vm.frame))
|
2400
2847
|
@executed = true
|
2401
2848
|
end
|
2402
2849
|
end
|
@@ -2429,6 +2876,14 @@ module SyntaxTree
|
|
2429
2876
|
[:opt_and, calldata.to_h]
|
2430
2877
|
end
|
2431
2878
|
|
2879
|
+
def deconstruct_keys(_keys)
|
2880
|
+
{ calldata: calldata }
|
2881
|
+
end
|
2882
|
+
|
2883
|
+
def ==(other)
|
2884
|
+
other.is_a?(OptAnd) && other.calldata == calldata
|
2885
|
+
end
|
2886
|
+
|
2432
2887
|
def length
|
2433
2888
|
2
|
2434
2889
|
end
|
@@ -2477,6 +2932,14 @@ module SyntaxTree
|
|
2477
2932
|
[:opt_aref, calldata.to_h]
|
2478
2933
|
end
|
2479
2934
|
|
2935
|
+
def deconstruct_keys(_keys)
|
2936
|
+
{ calldata: calldata }
|
2937
|
+
end
|
2938
|
+
|
2939
|
+
def ==(other)
|
2940
|
+
other.is_a?(OptAref) && other.calldata == calldata
|
2941
|
+
end
|
2942
|
+
|
2480
2943
|
def length
|
2481
2944
|
2
|
2482
2945
|
end
|
@@ -2530,6 +2993,15 @@ module SyntaxTree
|
|
2530
2993
|
[:opt_aref_with, object, calldata.to_h]
|
2531
2994
|
end
|
2532
2995
|
|
2996
|
+
def deconstruct_keys(_keys)
|
2997
|
+
{ object: object, calldata: calldata }
|
2998
|
+
end
|
2999
|
+
|
3000
|
+
def ==(other)
|
3001
|
+
other.is_a?(OptArefWith) && other.object == object &&
|
3002
|
+
other.calldata == calldata
|
3003
|
+
end
|
3004
|
+
|
2533
3005
|
def length
|
2534
3006
|
3
|
2535
3007
|
end
|
@@ -2579,6 +3051,14 @@ module SyntaxTree
|
|
2579
3051
|
[:opt_aset, calldata.to_h]
|
2580
3052
|
end
|
2581
3053
|
|
3054
|
+
def deconstruct_keys(_keys)
|
3055
|
+
{ calldata: calldata }
|
3056
|
+
end
|
3057
|
+
|
3058
|
+
def ==(other)
|
3059
|
+
other.is_a?(OptAset) && other.calldata == calldata
|
3060
|
+
end
|
3061
|
+
|
2582
3062
|
def length
|
2583
3063
|
2
|
2584
3064
|
end
|
@@ -2631,6 +3111,15 @@ module SyntaxTree
|
|
2631
3111
|
[:opt_aset_with, object, calldata.to_h]
|
2632
3112
|
end
|
2633
3113
|
|
3114
|
+
def deconstruct_keys(_keys)
|
3115
|
+
{ object: object, calldata: calldata }
|
3116
|
+
end
|
3117
|
+
|
3118
|
+
def ==(other)
|
3119
|
+
other.is_a?(OptAsetWith) && other.object == object &&
|
3120
|
+
other.calldata == calldata
|
3121
|
+
end
|
3122
|
+
|
2634
3123
|
def length
|
2635
3124
|
3
|
2636
3125
|
end
|
@@ -2699,6 +3188,16 @@ module SyntaxTree
|
|
2699
3188
|
]
|
2700
3189
|
end
|
2701
3190
|
|
3191
|
+
def deconstruct_keys(_keys)
|
3192
|
+
{ case_dispatch_hash: case_dispatch_hash, else_label: else_label }
|
3193
|
+
end
|
3194
|
+
|
3195
|
+
def ==(other)
|
3196
|
+
other.is_a?(OptCaseDispatch) &&
|
3197
|
+
other.case_dispatch_hash == case_dispatch_hash &&
|
3198
|
+
other.else_label == else_label
|
3199
|
+
end
|
3200
|
+
|
2702
3201
|
def length
|
2703
3202
|
3
|
2704
3203
|
end
|
@@ -2748,6 +3247,14 @@ module SyntaxTree
|
|
2748
3247
|
[:opt_div, calldata.to_h]
|
2749
3248
|
end
|
2750
3249
|
|
3250
|
+
def deconstruct_keys(_keys)
|
3251
|
+
{ calldata: calldata }
|
3252
|
+
end
|
3253
|
+
|
3254
|
+
def ==(other)
|
3255
|
+
other.is_a?(OptDiv) && other.calldata == calldata
|
3256
|
+
end
|
3257
|
+
|
2751
3258
|
def length
|
2752
3259
|
2
|
2753
3260
|
end
|
@@ -2796,6 +3303,14 @@ module SyntaxTree
|
|
2796
3303
|
[:opt_empty_p, calldata.to_h]
|
2797
3304
|
end
|
2798
3305
|
|
3306
|
+
def deconstruct_keys(_keys)
|
3307
|
+
{ calldata: calldata }
|
3308
|
+
end
|
3309
|
+
|
3310
|
+
def ==(other)
|
3311
|
+
other.is_a?(OptEmptyP) && other.calldata == calldata
|
3312
|
+
end
|
3313
|
+
|
2799
3314
|
def length
|
2800
3315
|
2
|
2801
3316
|
end
|
@@ -2845,6 +3360,14 @@ module SyntaxTree
|
|
2845
3360
|
[:opt_eq, calldata.to_h]
|
2846
3361
|
end
|
2847
3362
|
|
3363
|
+
def deconstruct_keys(_keys)
|
3364
|
+
{ calldata: calldata }
|
3365
|
+
end
|
3366
|
+
|
3367
|
+
def ==(other)
|
3368
|
+
other.is_a?(OptEq) && other.calldata == calldata
|
3369
|
+
end
|
3370
|
+
|
2848
3371
|
def length
|
2849
3372
|
2
|
2850
3373
|
end
|
@@ -2894,6 +3417,14 @@ module SyntaxTree
|
|
2894
3417
|
[:opt_ge, calldata.to_h]
|
2895
3418
|
end
|
2896
3419
|
|
3420
|
+
def deconstruct_keys(_keys)
|
3421
|
+
{ calldata: calldata }
|
3422
|
+
end
|
3423
|
+
|
3424
|
+
def ==(other)
|
3425
|
+
other.is_a?(OptGE) && other.calldata == calldata
|
3426
|
+
end
|
3427
|
+
|
2897
3428
|
def length
|
2898
3429
|
2
|
2899
3430
|
end
|
@@ -2943,6 +3474,14 @@ module SyntaxTree
|
|
2943
3474
|
[:opt_getconstant_path, names]
|
2944
3475
|
end
|
2945
3476
|
|
3477
|
+
def deconstruct_keys(_keys)
|
3478
|
+
{ names: names }
|
3479
|
+
end
|
3480
|
+
|
3481
|
+
def ==(other)
|
3482
|
+
other.is_a?(OptGetConstantPath) && other.names == names
|
3483
|
+
end
|
3484
|
+
|
2946
3485
|
def length
|
2947
3486
|
2
|
2948
3487
|
end
|
@@ -2960,7 +3499,7 @@ module SyntaxTree
|
|
2960
3499
|
end
|
2961
3500
|
|
2962
3501
|
def call(vm)
|
2963
|
-
current = vm._self
|
3502
|
+
current = vm.frame._self
|
2964
3503
|
current = current.class unless current.is_a?(Class)
|
2965
3504
|
|
2966
3505
|
names.each do |name|
|
@@ -2999,6 +3538,14 @@ module SyntaxTree
|
|
2999
3538
|
[:opt_gt, calldata.to_h]
|
3000
3539
|
end
|
3001
3540
|
|
3541
|
+
def deconstruct_keys(_keys)
|
3542
|
+
{ calldata: calldata }
|
3543
|
+
end
|
3544
|
+
|
3545
|
+
def ==(other)
|
3546
|
+
other.is_a?(OptGT) && other.calldata == calldata
|
3547
|
+
end
|
3548
|
+
|
3002
3549
|
def length
|
3003
3550
|
2
|
3004
3551
|
end
|
@@ -3048,6 +3595,14 @@ module SyntaxTree
|
|
3048
3595
|
[:opt_le, calldata.to_h]
|
3049
3596
|
end
|
3050
3597
|
|
3598
|
+
def deconstruct_keys(_keys)
|
3599
|
+
{ calldata: calldata }
|
3600
|
+
end
|
3601
|
+
|
3602
|
+
def ==(other)
|
3603
|
+
other.is_a?(OptLE) && other.calldata == calldata
|
3604
|
+
end
|
3605
|
+
|
3051
3606
|
def length
|
3052
3607
|
2
|
3053
3608
|
end
|
@@ -3097,6 +3652,14 @@ module SyntaxTree
|
|
3097
3652
|
[:opt_length, calldata.to_h]
|
3098
3653
|
end
|
3099
3654
|
|
3655
|
+
def deconstruct_keys(_keys)
|
3656
|
+
{ calldata: calldata }
|
3657
|
+
end
|
3658
|
+
|
3659
|
+
def ==(other)
|
3660
|
+
other.is_a?(OptLength) && other.calldata == calldata
|
3661
|
+
end
|
3662
|
+
|
3100
3663
|
def length
|
3101
3664
|
2
|
3102
3665
|
end
|
@@ -3146,6 +3709,14 @@ module SyntaxTree
|
|
3146
3709
|
[:opt_lt, calldata.to_h]
|
3147
3710
|
end
|
3148
3711
|
|
3712
|
+
def deconstruct_keys(_keys)
|
3713
|
+
{ calldata: calldata }
|
3714
|
+
end
|
3715
|
+
|
3716
|
+
def ==(other)
|
3717
|
+
other.is_a?(OptLT) && other.calldata == calldata
|
3718
|
+
end
|
3719
|
+
|
3149
3720
|
def length
|
3150
3721
|
2
|
3151
3722
|
end
|
@@ -3195,6 +3766,14 @@ module SyntaxTree
|
|
3195
3766
|
[:opt_ltlt, calldata.to_h]
|
3196
3767
|
end
|
3197
3768
|
|
3769
|
+
def deconstruct_keys(_keys)
|
3770
|
+
{ calldata: calldata }
|
3771
|
+
end
|
3772
|
+
|
3773
|
+
def ==(other)
|
3774
|
+
other.is_a?(OptLTLT) && other.calldata == calldata
|
3775
|
+
end
|
3776
|
+
|
3198
3777
|
def length
|
3199
3778
|
2
|
3200
3779
|
end
|
@@ -3245,6 +3824,14 @@ module SyntaxTree
|
|
3245
3824
|
[:opt_minus, calldata.to_h]
|
3246
3825
|
end
|
3247
3826
|
|
3827
|
+
def deconstruct_keys(_keys)
|
3828
|
+
{ calldata: calldata }
|
3829
|
+
end
|
3830
|
+
|
3831
|
+
def ==(other)
|
3832
|
+
other.is_a?(OptMinus) && other.calldata == calldata
|
3833
|
+
end
|
3834
|
+
|
3248
3835
|
def length
|
3249
3836
|
2
|
3250
3837
|
end
|
@@ -3294,6 +3881,14 @@ module SyntaxTree
|
|
3294
3881
|
[:opt_mod, calldata.to_h]
|
3295
3882
|
end
|
3296
3883
|
|
3884
|
+
def deconstruct_keys(_keys)
|
3885
|
+
{ calldata: calldata }
|
3886
|
+
end
|
3887
|
+
|
3888
|
+
def ==(other)
|
3889
|
+
other.is_a?(OptMod) && other.calldata == calldata
|
3890
|
+
end
|
3891
|
+
|
3297
3892
|
def length
|
3298
3893
|
2
|
3299
3894
|
end
|
@@ -3343,6 +3938,14 @@ module SyntaxTree
|
|
3343
3938
|
[:opt_mult, calldata.to_h]
|
3344
3939
|
end
|
3345
3940
|
|
3941
|
+
def deconstruct_keys(_keys)
|
3942
|
+
{ calldata: calldata }
|
3943
|
+
end
|
3944
|
+
|
3945
|
+
def ==(other)
|
3946
|
+
other.is_a?(OptMult) && other.calldata == calldata
|
3947
|
+
end
|
3948
|
+
|
3346
3949
|
def length
|
3347
3950
|
2
|
3348
3951
|
end
|
@@ -3398,6 +4001,15 @@ module SyntaxTree
|
|
3398
4001
|
[:opt_neq, eq_calldata.to_h, neq_calldata.to_h]
|
3399
4002
|
end
|
3400
4003
|
|
4004
|
+
def deconstruct_keys(_keys)
|
4005
|
+
{ eq_calldata: eq_calldata, neq_calldata: neq_calldata }
|
4006
|
+
end
|
4007
|
+
|
4008
|
+
def ==(other)
|
4009
|
+
other.is_a?(OptNEq) && other.eq_calldata == eq_calldata &&
|
4010
|
+
other.neq_calldata == neq_calldata
|
4011
|
+
end
|
4012
|
+
|
3401
4013
|
def length
|
3402
4014
|
3
|
3403
4015
|
end
|
@@ -3447,6 +4059,14 @@ module SyntaxTree
|
|
3447
4059
|
[:opt_newarray_max, number]
|
3448
4060
|
end
|
3449
4061
|
|
4062
|
+
def deconstruct_keys(_keys)
|
4063
|
+
{ number: number }
|
4064
|
+
end
|
4065
|
+
|
4066
|
+
def ==(other)
|
4067
|
+
other.is_a?(OptNewArrayMax) && other.number == number
|
4068
|
+
end
|
4069
|
+
|
3450
4070
|
def length
|
3451
4071
|
2
|
3452
4072
|
end
|
@@ -3495,6 +4115,14 @@ module SyntaxTree
|
|
3495
4115
|
[:opt_newarray_min, number]
|
3496
4116
|
end
|
3497
4117
|
|
4118
|
+
def deconstruct_keys(_keys)
|
4119
|
+
{ number: number }
|
4120
|
+
end
|
4121
|
+
|
4122
|
+
def ==(other)
|
4123
|
+
other.is_a?(OptNewArrayMin) && other.number == number
|
4124
|
+
end
|
4125
|
+
|
3498
4126
|
def length
|
3499
4127
|
2
|
3500
4128
|
end
|
@@ -3544,6 +4172,14 @@ module SyntaxTree
|
|
3544
4172
|
[:opt_nil_p, calldata.to_h]
|
3545
4173
|
end
|
3546
4174
|
|
4175
|
+
def deconstruct_keys(_keys)
|
4176
|
+
{ calldata: calldata }
|
4177
|
+
end
|
4178
|
+
|
4179
|
+
def ==(other)
|
4180
|
+
other.is_a?(OptNilP) && other.calldata == calldata
|
4181
|
+
end
|
4182
|
+
|
3547
4183
|
def length
|
3548
4184
|
2
|
3549
4185
|
end
|
@@ -3591,6 +4227,14 @@ module SyntaxTree
|
|
3591
4227
|
[:opt_not, calldata.to_h]
|
3592
4228
|
end
|
3593
4229
|
|
4230
|
+
def deconstruct_keys(_keys)
|
4231
|
+
{ calldata: calldata }
|
4232
|
+
end
|
4233
|
+
|
4234
|
+
def ==(other)
|
4235
|
+
other.is_a?(OptNot) && other.calldata == calldata
|
4236
|
+
end
|
4237
|
+
|
3594
4238
|
def length
|
3595
4239
|
2
|
3596
4240
|
end
|
@@ -3640,6 +4284,14 @@ module SyntaxTree
|
|
3640
4284
|
[:opt_or, calldata.to_h]
|
3641
4285
|
end
|
3642
4286
|
|
4287
|
+
def deconstruct_keys(_keys)
|
4288
|
+
{ calldata: calldata }
|
4289
|
+
end
|
4290
|
+
|
4291
|
+
def ==(other)
|
4292
|
+
other.is_a?(OptOr) && other.calldata == calldata
|
4293
|
+
end
|
4294
|
+
|
3643
4295
|
def length
|
3644
4296
|
2
|
3645
4297
|
end
|
@@ -3689,6 +4341,14 @@ module SyntaxTree
|
|
3689
4341
|
[:opt_plus, calldata.to_h]
|
3690
4342
|
end
|
3691
4343
|
|
4344
|
+
def deconstruct_keys(_keys)
|
4345
|
+
{ calldata: calldata }
|
4346
|
+
end
|
4347
|
+
|
4348
|
+
def ==(other)
|
4349
|
+
other.is_a?(OptPlus) && other.calldata == calldata
|
4350
|
+
end
|
4351
|
+
|
3692
4352
|
def length
|
3693
4353
|
2
|
3694
4354
|
end
|
@@ -3737,6 +4397,14 @@ module SyntaxTree
|
|
3737
4397
|
[:opt_regexpmatch2, calldata.to_h]
|
3738
4398
|
end
|
3739
4399
|
|
4400
|
+
def deconstruct_keys(_keys)
|
4401
|
+
{ calldata: calldata }
|
4402
|
+
end
|
4403
|
+
|
4404
|
+
def ==(other)
|
4405
|
+
other.is_a?(OptRegExpMatch2) && other.calldata == calldata
|
4406
|
+
end
|
4407
|
+
|
3740
4408
|
def length
|
3741
4409
|
2
|
3742
4410
|
end
|
@@ -3785,6 +4453,14 @@ module SyntaxTree
|
|
3785
4453
|
[:opt_send_without_block, calldata.to_h]
|
3786
4454
|
end
|
3787
4455
|
|
4456
|
+
def deconstruct_keys(_keys)
|
4457
|
+
{ calldata: calldata }
|
4458
|
+
end
|
4459
|
+
|
4460
|
+
def ==(other)
|
4461
|
+
other.is_a?(OptSendWithoutBlock) && other.calldata == calldata
|
4462
|
+
end
|
4463
|
+
|
3788
4464
|
def length
|
3789
4465
|
2
|
3790
4466
|
end
|
@@ -3834,6 +4510,14 @@ module SyntaxTree
|
|
3834
4510
|
[:opt_size, calldata.to_h]
|
3835
4511
|
end
|
3836
4512
|
|
4513
|
+
def deconstruct_keys(_keys)
|
4514
|
+
{ calldata: calldata }
|
4515
|
+
end
|
4516
|
+
|
4517
|
+
def ==(other)
|
4518
|
+
other.is_a?(OptSize) && other.calldata == calldata
|
4519
|
+
end
|
4520
|
+
|
3837
4521
|
def length
|
3838
4522
|
2
|
3839
4523
|
end
|
@@ -3886,6 +4570,15 @@ module SyntaxTree
|
|
3886
4570
|
[:opt_str_freeze, object, calldata.to_h]
|
3887
4571
|
end
|
3888
4572
|
|
4573
|
+
def deconstruct_keys(_keys)
|
4574
|
+
{ object: object, calldata: calldata }
|
4575
|
+
end
|
4576
|
+
|
4577
|
+
def ==(other)
|
4578
|
+
other.is_a?(OptStrFreeze) && other.object == object &&
|
4579
|
+
other.calldata == calldata
|
4580
|
+
end
|
4581
|
+
|
3889
4582
|
def length
|
3890
4583
|
3
|
3891
4584
|
end
|
@@ -3938,6 +4631,15 @@ module SyntaxTree
|
|
3938
4631
|
[:opt_str_uminus, object, calldata.to_h]
|
3939
4632
|
end
|
3940
4633
|
|
4634
|
+
def deconstruct_keys(_keys)
|
4635
|
+
{ object: object, calldata: calldata }
|
4636
|
+
end
|
4637
|
+
|
4638
|
+
def ==(other)
|
4639
|
+
other.is_a?(OptStrUMinus) && other.object == object &&
|
4640
|
+
other.calldata == calldata
|
4641
|
+
end
|
4642
|
+
|
3941
4643
|
def length
|
3942
4644
|
3
|
3943
4645
|
end
|
@@ -3987,6 +4689,14 @@ module SyntaxTree
|
|
3987
4689
|
[:opt_succ, calldata.to_h]
|
3988
4690
|
end
|
3989
4691
|
|
4692
|
+
def deconstruct_keys(_keys)
|
4693
|
+
{ calldata: calldata }
|
4694
|
+
end
|
4695
|
+
|
4696
|
+
def ==(other)
|
4697
|
+
other.is_a?(OptSucc) && other.calldata == calldata
|
4698
|
+
end
|
4699
|
+
|
3990
4700
|
def length
|
3991
4701
|
2
|
3992
4702
|
end
|
@@ -4027,6 +4737,14 @@ module SyntaxTree
|
|
4027
4737
|
[:pop]
|
4028
4738
|
end
|
4029
4739
|
|
4740
|
+
def deconstruct_keys(_keys)
|
4741
|
+
{}
|
4742
|
+
end
|
4743
|
+
|
4744
|
+
def ==(other)
|
4745
|
+
other.is_a?(Pop)
|
4746
|
+
end
|
4747
|
+
|
4030
4748
|
def length
|
4031
4749
|
1
|
4032
4750
|
end
|
@@ -4067,6 +4785,14 @@ module SyntaxTree
|
|
4067
4785
|
[:putnil]
|
4068
4786
|
end
|
4069
4787
|
|
4788
|
+
def deconstruct_keys(_keys)
|
4789
|
+
{}
|
4790
|
+
end
|
4791
|
+
|
4792
|
+
def ==(other)
|
4793
|
+
other.is_a?(PutNil)
|
4794
|
+
end
|
4795
|
+
|
4070
4796
|
def length
|
4071
4797
|
1
|
4072
4798
|
end
|
@@ -4113,6 +4839,14 @@ module SyntaxTree
|
|
4113
4839
|
[:putobject, object]
|
4114
4840
|
end
|
4115
4841
|
|
4842
|
+
def deconstruct_keys(_keys)
|
4843
|
+
{ object: object }
|
4844
|
+
end
|
4845
|
+
|
4846
|
+
def ==(other)
|
4847
|
+
other.is_a?(PutObject) && other.object == object
|
4848
|
+
end
|
4849
|
+
|
4116
4850
|
def length
|
4117
4851
|
2
|
4118
4852
|
end
|
@@ -4155,6 +4889,14 @@ module SyntaxTree
|
|
4155
4889
|
[:putobject_INT2FIX_0_]
|
4156
4890
|
end
|
4157
4891
|
|
4892
|
+
def deconstruct_keys(_keys)
|
4893
|
+
{}
|
4894
|
+
end
|
4895
|
+
|
4896
|
+
def ==(other)
|
4897
|
+
other.is_a?(PutObjectInt2Fix0)
|
4898
|
+
end
|
4899
|
+
|
4158
4900
|
def length
|
4159
4901
|
1
|
4160
4902
|
end
|
@@ -4197,6 +4939,14 @@ module SyntaxTree
|
|
4197
4939
|
[:putobject_INT2FIX_1_]
|
4198
4940
|
end
|
4199
4941
|
|
4942
|
+
def deconstruct_keys(_keys)
|
4943
|
+
{}
|
4944
|
+
end
|
4945
|
+
|
4946
|
+
def ==(other)
|
4947
|
+
other.is_a?(PutObjectInt2Fix1)
|
4948
|
+
end
|
4949
|
+
|
4200
4950
|
def length
|
4201
4951
|
1
|
4202
4952
|
end
|
@@ -4237,6 +4987,14 @@ module SyntaxTree
|
|
4237
4987
|
[:putself]
|
4238
4988
|
end
|
4239
4989
|
|
4990
|
+
def deconstruct_keys(_keys)
|
4991
|
+
{}
|
4992
|
+
end
|
4993
|
+
|
4994
|
+
def ==(other)
|
4995
|
+
other.is_a?(PutSelf)
|
4996
|
+
end
|
4997
|
+
|
4240
4998
|
def length
|
4241
4999
|
1
|
4242
5000
|
end
|
@@ -4254,7 +5012,7 @@ module SyntaxTree
|
|
4254
5012
|
end
|
4255
5013
|
|
4256
5014
|
def call(vm)
|
4257
|
-
vm.push(vm._self)
|
5015
|
+
vm.push(vm.frame._self)
|
4258
5016
|
end
|
4259
5017
|
end
|
4260
5018
|
|
@@ -4289,6 +5047,14 @@ module SyntaxTree
|
|
4289
5047
|
[:putspecialobject, object]
|
4290
5048
|
end
|
4291
5049
|
|
5050
|
+
def deconstruct_keys(_keys)
|
5051
|
+
{ object: object }
|
5052
|
+
end
|
5053
|
+
|
5054
|
+
def ==(other)
|
5055
|
+
other.is_a?(PutSpecialObject) && other.object == object
|
5056
|
+
end
|
5057
|
+
|
4292
5058
|
def length
|
4293
5059
|
2
|
4294
5060
|
end
|
@@ -4310,7 +5076,7 @@ module SyntaxTree
|
|
4310
5076
|
when OBJECT_VMCORE
|
4311
5077
|
vm.push(vm.frozen_core)
|
4312
5078
|
when OBJECT_CBASE
|
4313
|
-
value = vm._self
|
5079
|
+
value = vm.frame._self
|
4314
5080
|
value = value.singleton_class unless value.is_a?(Class)
|
4315
5081
|
vm.push(value)
|
4316
5082
|
when OBJECT_CONST_BASE
|
@@ -4344,6 +5110,14 @@ module SyntaxTree
|
|
4344
5110
|
[:putstring, object]
|
4345
5111
|
end
|
4346
5112
|
|
5113
|
+
def deconstruct_keys(_keys)
|
5114
|
+
{ object: object }
|
5115
|
+
end
|
5116
|
+
|
5117
|
+
def ==(other)
|
5118
|
+
other.is_a?(PutString) && other.object == object
|
5119
|
+
end
|
5120
|
+
|
4347
5121
|
def length
|
4348
5122
|
2
|
4349
5123
|
end
|
@@ -4398,6 +5172,15 @@ module SyntaxTree
|
|
4398
5172
|
[:send, calldata.to_h, block_iseq&.to_a]
|
4399
5173
|
end
|
4400
5174
|
|
5175
|
+
def deconstruct_keys(_keys)
|
5176
|
+
{ calldata: calldata, block_iseq: block_iseq }
|
5177
|
+
end
|
5178
|
+
|
5179
|
+
def ==(other)
|
5180
|
+
other.is_a?(Send) && other.calldata == calldata &&
|
5181
|
+
other.block_iseq == block_iseq
|
5182
|
+
end
|
5183
|
+
|
4401
5184
|
def length
|
4402
5185
|
3
|
4403
5186
|
end
|
@@ -4418,9 +5201,12 @@ module SyntaxTree
|
|
4418
5201
|
def call(vm)
|
4419
5202
|
block =
|
4420
5203
|
if (iseq = block_iseq)
|
5204
|
+
frame = vm.frame
|
4421
5205
|
->(*args, **kwargs, &blk) do
|
4422
|
-
vm.run_block_frame(iseq, *args, **kwargs, &blk)
|
5206
|
+
vm.run_block_frame(iseq, frame, *args, **kwargs, &blk)
|
4423
5207
|
end
|
5208
|
+
elsif calldata.flag?(CallData::CALL_ARGS_BLOCKARG)
|
5209
|
+
vm.pop
|
4424
5210
|
end
|
4425
5211
|
|
4426
5212
|
keywords =
|
@@ -4472,6 +5258,15 @@ module SyntaxTree
|
|
4472
5258
|
[:setblockparam, current.local_table.offset(index), level]
|
4473
5259
|
end
|
4474
5260
|
|
5261
|
+
def deconstruct_keys(_keys)
|
5262
|
+
{ index: index, level: level }
|
5263
|
+
end
|
5264
|
+
|
5265
|
+
def ==(other)
|
5266
|
+
other.is_a?(SetBlockParam) && other.index == index &&
|
5267
|
+
other.level == level
|
5268
|
+
end
|
5269
|
+
|
4475
5270
|
def length
|
4476
5271
|
3
|
4477
5272
|
end
|
@@ -4525,6 +5320,15 @@ module SyntaxTree
|
|
4525
5320
|
[:setclassvariable, name, cache]
|
4526
5321
|
end
|
4527
5322
|
|
5323
|
+
def deconstruct_keys(_keys)
|
5324
|
+
{ name: name, cache: cache }
|
5325
|
+
end
|
5326
|
+
|
5327
|
+
def ==(other)
|
5328
|
+
other.is_a?(SetClassVariable) && other.name == name &&
|
5329
|
+
other.cache == cache
|
5330
|
+
end
|
5331
|
+
|
4528
5332
|
def length
|
4529
5333
|
3
|
4530
5334
|
end
|
@@ -4542,7 +5346,7 @@ module SyntaxTree
|
|
4542
5346
|
end
|
4543
5347
|
|
4544
5348
|
def call(vm)
|
4545
|
-
clazz = vm._self
|
5349
|
+
clazz = vm.frame._self
|
4546
5350
|
clazz = clazz.class unless clazz.is_a?(Class)
|
4547
5351
|
clazz.class_variable_set(name, vm.pop)
|
4548
5352
|
end
|
@@ -4574,6 +5378,14 @@ module SyntaxTree
|
|
4574
5378
|
[:setconstant, name]
|
4575
5379
|
end
|
4576
5380
|
|
5381
|
+
def deconstruct_keys(_keys)
|
5382
|
+
{ name: name }
|
5383
|
+
end
|
5384
|
+
|
5385
|
+
def ==(other)
|
5386
|
+
other.is_a?(SetConstant) && other.name == name
|
5387
|
+
end
|
5388
|
+
|
4577
5389
|
def length
|
4578
5390
|
2
|
4579
5391
|
end
|
@@ -4622,6 +5434,14 @@ module SyntaxTree
|
|
4622
5434
|
[:setglobal, name]
|
4623
5435
|
end
|
4624
5436
|
|
5437
|
+
def deconstruct_keys(_keys)
|
5438
|
+
{ name: name }
|
5439
|
+
end
|
5440
|
+
|
5441
|
+
def ==(other)
|
5442
|
+
other.is_a?(SetGlobal) && other.name == name
|
5443
|
+
end
|
5444
|
+
|
4625
5445
|
def length
|
4626
5446
|
2
|
4627
5447
|
end
|
@@ -4680,6 +5500,15 @@ module SyntaxTree
|
|
4680
5500
|
[:setinstancevariable, name, cache]
|
4681
5501
|
end
|
4682
5502
|
|
5503
|
+
def deconstruct_keys(_keys)
|
5504
|
+
{ name: name, cache: cache }
|
5505
|
+
end
|
5506
|
+
|
5507
|
+
def ==(other)
|
5508
|
+
other.is_a?(SetInstanceVariable) && other.name == name &&
|
5509
|
+
other.cache == cache
|
5510
|
+
end
|
5511
|
+
|
4683
5512
|
def length
|
4684
5513
|
3
|
4685
5514
|
end
|
@@ -4698,7 +5527,7 @@ module SyntaxTree
|
|
4698
5527
|
|
4699
5528
|
def call(vm)
|
4700
5529
|
method = Object.instance_method(:instance_variable_set)
|
4701
|
-
method.bind(vm._self).call(name, vm.pop)
|
5530
|
+
method.bind(vm.frame._self).call(name, vm.pop)
|
4702
5531
|
end
|
4703
5532
|
end
|
4704
5533
|
|
@@ -4734,6 +5563,14 @@ module SyntaxTree
|
|
4734
5563
|
[:setlocal, current.local_table.offset(index), level]
|
4735
5564
|
end
|
4736
5565
|
|
5566
|
+
def deconstruct_keys(_keys)
|
5567
|
+
{ index: index, level: level }
|
5568
|
+
end
|
5569
|
+
|
5570
|
+
def ==(other)
|
5571
|
+
other.is_a?(SetLocal) && other.index == index && other.level == level
|
5572
|
+
end
|
5573
|
+
|
4737
5574
|
def length
|
4738
5575
|
3
|
4739
5576
|
end
|
@@ -4783,6 +5620,14 @@ module SyntaxTree
|
|
4783
5620
|
[:setlocal_WC_0, iseq.local_table.offset(index)]
|
4784
5621
|
end
|
4785
5622
|
|
5623
|
+
def deconstruct_keys(_keys)
|
5624
|
+
{ index: index }
|
5625
|
+
end
|
5626
|
+
|
5627
|
+
def ==(other)
|
5628
|
+
other.is_a?(SetLocalWC0) && other.index == index
|
5629
|
+
end
|
5630
|
+
|
4786
5631
|
def length
|
4787
5632
|
2
|
4788
5633
|
end
|
@@ -4832,6 +5677,14 @@ module SyntaxTree
|
|
4832
5677
|
[:setlocal_WC_1, iseq.parent_iseq.local_table.offset(index)]
|
4833
5678
|
end
|
4834
5679
|
|
5680
|
+
def deconstruct_keys(_keys)
|
5681
|
+
{ index: index }
|
5682
|
+
end
|
5683
|
+
|
5684
|
+
def ==(other)
|
5685
|
+
other.is_a?(SetLocalWC1) && other.index == index
|
5686
|
+
end
|
5687
|
+
|
4835
5688
|
def length
|
4836
5689
|
2
|
4837
5690
|
end
|
@@ -4879,6 +5732,14 @@ module SyntaxTree
|
|
4879
5732
|
[:setn, number]
|
4880
5733
|
end
|
4881
5734
|
|
5735
|
+
def deconstruct_keys(_keys)
|
5736
|
+
{ number: number }
|
5737
|
+
end
|
5738
|
+
|
5739
|
+
def ==(other)
|
5740
|
+
other.is_a?(SetN) && other.number == number
|
5741
|
+
end
|
5742
|
+
|
4882
5743
|
def length
|
4883
5744
|
2
|
4884
5745
|
end
|
@@ -4927,6 +5788,14 @@ module SyntaxTree
|
|
4927
5788
|
[:setspecial, key]
|
4928
5789
|
end
|
4929
5790
|
|
5791
|
+
def deconstruct_keys(_keys)
|
5792
|
+
{ key: key }
|
5793
|
+
end
|
5794
|
+
|
5795
|
+
def ==(other)
|
5796
|
+
other.is_a?(SetSpecial) && other.key == key
|
5797
|
+
end
|
5798
|
+
|
4930
5799
|
def length
|
4931
5800
|
2
|
4932
5801
|
end
|
@@ -4946,7 +5815,7 @@ module SyntaxTree
|
|
4946
5815
|
def call(vm)
|
4947
5816
|
case key
|
4948
5817
|
when GetSpecial::SVAR_LASTLINE
|
4949
|
-
raise NotImplementedError, "
|
5818
|
+
raise NotImplementedError, "setspecial SVAR_LASTLINE"
|
4950
5819
|
when GetSpecial::SVAR_BACKREF
|
4951
5820
|
raise NotImplementedError, "setspecial SVAR_BACKREF"
|
4952
5821
|
when GetSpecial::SVAR_FLIPFLOP_START
|
@@ -4982,6 +5851,14 @@ module SyntaxTree
|
|
4982
5851
|
[:splatarray, flag]
|
4983
5852
|
end
|
4984
5853
|
|
5854
|
+
def deconstruct_keys(_keys)
|
5855
|
+
{ flag: flag }
|
5856
|
+
end
|
5857
|
+
|
5858
|
+
def ==(other)
|
5859
|
+
other.is_a?(SplatArray) && other.flag == flag
|
5860
|
+
end
|
5861
|
+
|
4985
5862
|
def length
|
4986
5863
|
2
|
4987
5864
|
end
|
@@ -4999,7 +5876,27 @@ module SyntaxTree
|
|
4999
5876
|
end
|
5000
5877
|
|
5001
5878
|
def call(vm)
|
5002
|
-
vm.
|
5879
|
+
value = vm.pop
|
5880
|
+
|
5881
|
+
vm.push(
|
5882
|
+
if Array === value
|
5883
|
+
value.instance_of?(Array) ? value.dup : Array[*value]
|
5884
|
+
elsif value.nil?
|
5885
|
+
value.to_a
|
5886
|
+
else
|
5887
|
+
if value.respond_to?(:to_a, true)
|
5888
|
+
result = value.to_a
|
5889
|
+
|
5890
|
+
if result.nil?
|
5891
|
+
[value]
|
5892
|
+
elsif !result.is_a?(Array)
|
5893
|
+
raise TypeError, "expected to_a to return an Array"
|
5894
|
+
end
|
5895
|
+
else
|
5896
|
+
[value]
|
5897
|
+
end
|
5898
|
+
end
|
5899
|
+
)
|
5003
5900
|
end
|
5004
5901
|
end
|
5005
5902
|
|
@@ -5026,6 +5923,14 @@ module SyntaxTree
|
|
5026
5923
|
[:swap]
|
5027
5924
|
end
|
5028
5925
|
|
5926
|
+
def deconstruct_keys(_keys)
|
5927
|
+
{}
|
5928
|
+
end
|
5929
|
+
|
5930
|
+
def ==(other)
|
5931
|
+
other.is_a?(Swap)
|
5932
|
+
end
|
5933
|
+
|
5029
5934
|
def length
|
5030
5935
|
1
|
5031
5936
|
end
|
@@ -5061,15 +5966,18 @@ module SyntaxTree
|
|
5061
5966
|
# ~~~
|
5062
5967
|
#
|
5063
5968
|
class Throw
|
5064
|
-
|
5065
|
-
|
5066
|
-
|
5067
|
-
|
5068
|
-
|
5069
|
-
|
5070
|
-
|
5071
|
-
|
5072
|
-
|
5969
|
+
RUBY_TAG_NONE = 0x0
|
5970
|
+
RUBY_TAG_RETURN = 0x1
|
5971
|
+
RUBY_TAG_BREAK = 0x2
|
5972
|
+
RUBY_TAG_NEXT = 0x3
|
5973
|
+
RUBY_TAG_RETRY = 0x4
|
5974
|
+
RUBY_TAG_REDO = 0x5
|
5975
|
+
RUBY_TAG_RAISE = 0x6
|
5976
|
+
RUBY_TAG_THROW = 0x7
|
5977
|
+
RUBY_TAG_FATAL = 0x8
|
5978
|
+
|
5979
|
+
VM_THROW_NO_ESCAPE_FLAG = 0x8000
|
5980
|
+
VM_THROW_STATE_MASK = 0xff
|
5073
5981
|
|
5074
5982
|
attr_reader :type
|
5075
5983
|
|
@@ -5085,6 +5993,14 @@ module SyntaxTree
|
|
5085
5993
|
[:throw, type]
|
5086
5994
|
end
|
5087
5995
|
|
5996
|
+
def deconstruct_keys(_keys)
|
5997
|
+
{ type: type }
|
5998
|
+
end
|
5999
|
+
|
6000
|
+
def ==(other)
|
6001
|
+
other.is_a?(Throw) && other.type == type
|
6002
|
+
end
|
6003
|
+
|
5088
6004
|
def length
|
5089
6005
|
2
|
5090
6006
|
end
|
@@ -5102,7 +6018,43 @@ module SyntaxTree
|
|
5102
6018
|
end
|
5103
6019
|
|
5104
6020
|
def call(vm)
|
5105
|
-
|
6021
|
+
state = type & VM_THROW_STATE_MASK
|
6022
|
+
value = vm.pop
|
6023
|
+
|
6024
|
+
case state
|
6025
|
+
when RUBY_TAG_NONE
|
6026
|
+
case value
|
6027
|
+
when nil
|
6028
|
+
# do nothing
|
6029
|
+
when Exception
|
6030
|
+
raise value
|
6031
|
+
else
|
6032
|
+
raise NotImplementedError
|
6033
|
+
end
|
6034
|
+
when RUBY_TAG_RETURN
|
6035
|
+
raise VM::ReturnError.new(value, error_backtrace(vm))
|
6036
|
+
when RUBY_TAG_BREAK
|
6037
|
+
raise VM::BreakError.new(value, error_backtrace(vm))
|
6038
|
+
when RUBY_TAG_NEXT
|
6039
|
+
raise VM::NextError.new(value, error_backtrace(vm))
|
6040
|
+
else
|
6041
|
+
raise NotImplementedError, "Unknown throw kind #{state}"
|
6042
|
+
end
|
6043
|
+
end
|
6044
|
+
|
6045
|
+
private
|
6046
|
+
|
6047
|
+
def error_backtrace(vm)
|
6048
|
+
backtrace = []
|
6049
|
+
current = vm.frame
|
6050
|
+
|
6051
|
+
while current
|
6052
|
+
backtrace << "#{current.iseq.file}:#{current.line}:in" \
|
6053
|
+
"`#{current.iseq.name}'"
|
6054
|
+
current = current.parent
|
6055
|
+
end
|
6056
|
+
|
6057
|
+
[*backtrace, *caller]
|
5106
6058
|
end
|
5107
6059
|
end
|
5108
6060
|
|
@@ -5135,6 +6087,14 @@ module SyntaxTree
|
|
5135
6087
|
[:topn, number]
|
5136
6088
|
end
|
5137
6089
|
|
6090
|
+
def deconstruct_keys(_keys)
|
6091
|
+
{ number: number }
|
6092
|
+
end
|
6093
|
+
|
6094
|
+
def ==(other)
|
6095
|
+
other.is_a?(TopN) && other.number == number
|
6096
|
+
end
|
6097
|
+
|
5138
6098
|
def length
|
5139
6099
|
2
|
5140
6100
|
end
|
@@ -5183,6 +6143,15 @@ module SyntaxTree
|
|
5183
6143
|
[:toregexp, options, length]
|
5184
6144
|
end
|
5185
6145
|
|
6146
|
+
def deconstruct_keys(_keys)
|
6147
|
+
{ options: options, length: length }
|
6148
|
+
end
|
6149
|
+
|
6150
|
+
def ==(other)
|
6151
|
+
other.is_a?(ToRegExp) && other.options == options &&
|
6152
|
+
other.length == length
|
6153
|
+
end
|
6154
|
+
|
5186
6155
|
def pops
|
5187
6156
|
length
|
5188
6157
|
end
|