rubyx/lib/slot_machine/macro/method_missing.rb

21 lines
630 B
Ruby
Raw Normal View History

2019-10-03 20:07:55 +02:00
module SlotMachine
2019-09-11 19:17:43 +02:00
class MethodMissing < Macro
attr_reader :name_reg
def initialize( source , name_reg )
super(source)
name_reg = Risc::RegisterValue.new(name_reg , :Word) if name_reg.class == Symbol
raise "No reg #{name_reg.class}" unless name_reg.is_a? Risc::RegisterValue
@name_reg = name_reg
end
def to_risc(compiler)
builder = compiler.builder(compiler.source_name)
to = Risc::RegisterValue.new(:r1 , :Word)
builder.add_code Risc::Transfer.new(self , name_reg , to)
builder.add_code Risc::Syscall.new(self, :died )
return compiler
end
end
end