Skip to content

Commit c9db96b

Browse files
committed
opt_mult, Float, and Rational
1 parent 6c6b88b commit c9db96b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/syntax_tree/yarv.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,20 @@ def to_ruby
290290
case insn[0]
291291
when :leave
292292
stack << ReturnNode.new(arguments: Args.new(parts: [stack.pop], location: Location.default), location: Location.default)
293+
when :opt_mult
294+
left, right = stack.pop(2)
295+
stack << Binary.new(left: left, operator: :*, right: right, location: Location.default)
293296
when :opt_plus
294297
left, right = stack.pop(2)
295298
stack << Binary.new(left: left, operator: :+, right: right, location: Location.default)
296299
when :putobject
297300
case insn[1]
301+
when Float
302+
stack << FloatLiteral.new(value: insn[1].inspect, location: Location.default)
298303
when Integer
299304
stack << Int.new(value: insn[1].inspect, location: Location.default)
305+
when Rational
306+
stack << RationalLiteral.new(value: insn[1].inspect, location: Location.default)
300307
else
301308
raise "Unknown object type: #{insn[1].class.name}"
302309
end

0 commit comments

Comments
 (0)