Skip to content

Commit ce4bc83

Browse files
committed
Update yarv compiler and decompiler to stop using Elsif node
1 parent f325ee4 commit ce4bc83

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

lib/syntax_tree/yarv/compiler.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -916,17 +916,6 @@ def visit_else(node)
916916
iseq.pop unless last_statement?
917917
end
918918

919-
def visit_elsif(node)
920-
visit_if(
921-
IfNode.new(
922-
predicate: node.predicate,
923-
statements: node.statements,
924-
consequent: node.consequent,
925-
location: node.location
926-
)
927-
)
928-
end
929-
930919
def visit_ensure(node)
931920
end
932921

@@ -1054,6 +1043,7 @@ def visit_if(node)
10541043
def visit_if_op(node)
10551044
visit_if(
10561045
IfNode.new(
1046+
keyword: Kw.new(value: "if", location: Location.default),
10571047
predicate: node.predicate,
10581048
statements:
10591049
Statements.new(body: [node.truthy], location: Location.default),

lib/syntax_tree/yarv/decompiler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def decompile(iseq)
7777
Next(Args([]))
7878
]
7979

80-
clause << IfNode(clause.pop, Statements(body), nil)
80+
clause << IfNode(Kw("if"), clause.pop, Statements(body), nil)
8181
when Dup
8282
clause << clause.last
8383
when DupHash

0 commit comments

Comments
 (0)