rubyx/lib/soml/compiler/operator_value.rb

19 lines
726 B
Ruby
Raw Normal View History

2015-10-23 13:22:55 +02:00
module Soml
Compiler.class_eval do
def on_operator_value statement
2015-10-15 08:47:11 +02:00
#puts "operator #{statement.inspect}"
operator , left_e , right_e = *statement
2015-10-15 08:32:47 +02:00
# left and right must be expressions. Expressions return a register when compiled
left_reg = process(left_e)
right_reg = process(right_e)
raise "Not register #{left_reg}" unless left_reg.is_a?(Register::RegisterValue)
raise "Not register #{right_reg}" unless right_reg.is_a?(Register::RegisterValue)
2015-10-15 08:47:11 +02:00
#puts "left #{left_reg}"
#puts "right #{right_reg}"
add_code Register::OperatorInstruction.new(statement,operator,left_reg,right_reg)
2015-10-15 08:32:47 +02:00
return left_reg # though this has wrong value attached
end
end
end