Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0e4f6d0

Browse files
committed
Enhance and test the interface for YARV instructions
1 parent e789ead commit 0e4f6d0

File tree

3 files changed

+39
-62
lines changed

3 files changed

+39
-62
lines changed

lib/syntax_tree/yarv/instructions.rb

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -858,10 +858,8 @@ def deconstruct_keys(keys)
858858
end
859859

860860
def ==(other)
861-
other.is_a?(DefineClass) &&
862-
other.name == name &&
863-
other.class_iseq == class_iseq &&
864-
other.flags == flags
861+
other.is_a?(DefineClass) && other.name == name &&
862+
other.class_iseq == class_iseq && other.flags == flags
865863
end
866864

867865
def length
@@ -997,9 +995,7 @@ def deconstruct_keys(keys)
997995
end
998996

999997
def ==(other)
1000-
other.is_a?(Defined) &&
1001-
other.type == type &&
1002-
other.name == name &&
998+
other.is_a?(Defined) && other.type == type && other.name == name &&
1003999
other.message == message
10041000
end
10051001

@@ -1098,8 +1094,7 @@ def deconstruct_keys(keys)
10981094
end
10991095

11001096
def ==(other)
1101-
other.is_a?(DefineMethod) &&
1102-
other.method_name == method_name &&
1097+
other.is_a?(DefineMethod) && other.method_name == method_name &&
11031098
other.method_iseq == method_iseq
11041099
end
11051100

@@ -1180,8 +1175,7 @@ def deconstruct_keys(keys)
11801175
end
11811176

11821177
def ==(other)
1183-
other.is_a?(DefineSMethod) &&
1184-
other.method_name == method_name &&
1178+
other.is_a?(DefineSMethod) && other.method_name == method_name &&
11851179
other.method_iseq == method_iseq
11861180
end
11871181

@@ -1468,8 +1462,7 @@ def deconstruct_keys(keys)
14681462
end
14691463

14701464
def ==(other)
1471-
other.is_a?(ExpandArray) &&
1472-
other.number == number &&
1465+
other.is_a?(ExpandArray) && other.number == number &&
14731466
other.flags == flags
14741467
end
14751468

@@ -1569,8 +1562,7 @@ def deconstruct_keys(keys)
15691562
end
15701563

15711564
def ==(other)
1572-
other.is_a?(GetBlockParam) &&
1573-
other.index == index &&
1565+
other.is_a?(GetBlockParam) && other.index == index &&
15741566
other.level == level
15751567
end
15761568

@@ -1636,8 +1628,7 @@ def deconstruct_keys(keys)
16361628
end
16371629

16381630
def ==(other)
1639-
other.is_a?(GetBlockParamProxy) &&
1640-
other.index == index &&
1631+
other.is_a?(GetBlockParamProxy) && other.index == index &&
16411632
other.level == level
16421633
end
16431634

@@ -1698,8 +1689,7 @@ def deconstruct_keys(keys)
16981689
end
16991690

17001691
def ==(other)
1701-
other.is_a?(GetClassVariable) &&
1702-
other.name == name &&
1692+
other.is_a?(GetClassVariable) && other.name == name &&
17031693
other.cache == cache
17041694
end
17051695

@@ -1895,8 +1885,7 @@ def deconstruct_keys(keys)
18951885
end
18961886

18971887
def ==(other)
1898-
other.is_a?(GetInstanceVariable) &&
1899-
other.name == name &&
1888+
other.is_a?(GetInstanceVariable) && other.name == name &&
19001889
other.cache == cache
19011890
end
19021891

@@ -2309,8 +2298,7 @@ def deconstruct_keys(keys)
23092298
end
23102299

23112300
def ==(other)
2312-
other.is_a?(InvokeSuper) &&
2313-
other.calldata == calldata &&
2301+
other.is_a?(InvokeSuper) && other.calldata == calldata &&
23142302
other.block_iseq == block_iseq
23152303
end
23162304

@@ -3010,8 +2998,7 @@ def deconstruct_keys(keys)
30102998
end
30112999

30123000
def ==(other)
3013-
other.is_a?(OptArefWith) &&
3014-
other.object == object &&
3001+
other.is_a?(OptArefWith) && other.object == object &&
30153002
other.calldata == calldata
30163003
end
30173004

@@ -3129,8 +3116,7 @@ def deconstruct_keys(keys)
31293116
end
31303117

31313118
def ==(other)
3132-
other.is_a?(OptAsetWith) &&
3133-
other.object == object &&
3119+
other.is_a?(OptAsetWith) && other.object == object &&
31343120
other.calldata == calldata
31353121
end
31363122

@@ -4020,8 +4006,7 @@ def deconstruct_keys(keys)
40204006
end
40214007

40224008
def ==(other)
4023-
other.is_a?(OptNEq) &&
4024-
other.eq_calldata == eq_calldata &&
4009+
other.is_a?(OptNEq) && other.eq_calldata == eq_calldata &&
40254010
other.neq_calldata == neq_calldata
40264011
end
40274012

@@ -4590,8 +4575,7 @@ def deconstruct_keys(keys)
45904575
end
45914576

45924577
def ==(other)
4593-
other.is_a?(OptStrFreeze) &&
4594-
other.object == object &&
4578+
other.is_a?(OptStrFreeze) && other.object == object &&
45954579
other.calldata == calldata
45964580
end
45974581

@@ -4652,8 +4636,7 @@ def deconstruct_keys(keys)
46524636
end
46534637

46544638
def ==(other)
4655-
other.is_a?(OptStrUMinus) &&
4656-
other.object == object &&
4639+
other.is_a?(OptStrUMinus) && other.object == object &&
46574640
other.calldata == calldata
46584641
end
46594642

@@ -5194,8 +5177,7 @@ def deconstruct_keys(keys)
51945177
end
51955178

51965179
def ==(other)
5197-
other.is_a?(Send) &&
5198-
other.calldata == calldata &&
5180+
other.is_a?(Send) && other.calldata == calldata &&
51995181
other.block_iseq == block_iseq
52005182
end
52015183

@@ -5281,8 +5263,7 @@ def deconstruct_keys(keys)
52815263
end
52825264

52835265
def ==(other)
5284-
other.is_a?(SetBlockParam) &&
5285-
other.index == index &&
5266+
other.is_a?(SetBlockParam) && other.index == index &&
52865267
other.level == level
52875268
end
52885269

@@ -5344,8 +5325,7 @@ def deconstruct_keys(keys)
53445325
end
53455326

53465327
def ==(other)
5347-
other.is_a?(SetClassVariable) &&
5348-
other.name == name &&
5328+
other.is_a?(SetClassVariable) && other.name == name &&
53495329
other.cache == cache
53505330
end
53515331

@@ -5525,8 +5505,7 @@ def deconstruct_keys(keys)
55255505
end
55265506

55275507
def ==(other)
5528-
other.is_a?(SetInstanceVariable) &&
5529-
other.name == name &&
5508+
other.is_a?(SetInstanceVariable) && other.name == name &&
55305509
other.cache == cache
55315510
end
55325511

@@ -6169,8 +6148,7 @@ def deconstruct_keys(keys)
61696148
end
61706149

61716150
def ==(other)
6172-
other.is_a?(ToRegExp) &&
6173-
other.options == options &&
6151+
other.is_a?(ToRegExp) && other.options == options &&
61746152
other.length == length
61756153
end
61766154

lib/syntax_tree/yarv/legacy.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def to_a(_iseq)
3737
def deconstruct_keys(keys)
3838
{ name: name }
3939
end
40-
40+
4141
def ==(other)
4242
other.is_a?(GetClassVariable) && other.name == name
4343
end
@@ -101,10 +101,9 @@ def to_a(_iseq)
101101
def deconstruct_keys(keys)
102102
{ label: label, cache: cache }
103103
end
104-
104+
105105
def ==(other)
106-
other.is_a?(OptGetInlineCache) &&
107-
other.label == label &&
106+
other.is_a?(OptGetInlineCache) && other.label == label &&
108107
other.cache == cache
109108
end
110109

@@ -162,7 +161,7 @@ def to_a(_iseq)
162161
def deconstruct_keys(keys)
163162
{ cache: cache }
164163
end
165-
164+
166165
def ==(other)
167166
other.is_a?(OptSetInlineCache) && other.cache == cache
168167
end
@@ -219,7 +218,7 @@ def to_a(_iseq)
219218
def deconstruct_keys(keys)
220219
{ name: name }
221220
end
222-
221+
223222
def ==(other)
224223
other.is_a?(SetClassVariable) && other.name == name
225224
end

test/yarv_test.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,19 @@ def value
290290

291291
instructions =
292292
YARV.constants.map { YARV.const_get(_1) } +
293-
YARV::Legacy.constants.map { YARV::Legacy.const_get(_1) } -
294-
[
295-
YARV::Assembler,
296-
YARV::Bf,
297-
YARV::CallData,
298-
YARV::Compiler,
299-
YARV::Decompiler,
300-
YARV::Disassembler,
301-
YARV::InstructionSequence,
302-
YARV::Legacy,
303-
YARV::LocalTable,
304-
YARV::VM
305-
]
293+
YARV::Legacy.constants.map { YARV::Legacy.const_get(_1) } -
294+
[
295+
YARV::Assembler,
296+
YARV::Bf,
297+
YARV::CallData,
298+
YARV::Compiler,
299+
YARV::Decompiler,
300+
YARV::Disassembler,
301+
YARV::InstructionSequence,
302+
YARV::Legacy,
303+
YARV::LocalTable,
304+
YARV::VM
305+
]
306306

307307
interface = %i[
308308
disasm

0 commit comments

Comments
 (0)