2019-10-03 20:07:55 +02:00
|
|
|
module SlotMachine
|
2019-09-11 19:17:43 +02:00
|
|
|
class MethodMissing < Macro
|
2020-03-22 14:58:19 +01:00
|
|
|
attr_reader :name_reg
|
2019-09-17 19:18:00 +02:00
|
|
|
|
2020-03-22 14:58:19 +01:00
|
|
|
def initialize( source , name_reg )
|
2019-09-17 19:18:00 +02:00
|
|
|
super(source)
|
2020-03-22 14:58:19 +01:00
|
|
|
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
|
2019-09-17 19:18:00 +02:00
|
|
|
end
|
|
|
|
|
2019-09-11 17:43:20 +02:00
|
|
|
def to_risc(compiler)
|
2019-09-15 14:13:11 +02:00
|
|
|
builder = compiler.builder(compiler.source_name)
|
2019-09-17 19:18:00 +02:00
|
|
|
to = Risc::RegisterValue.new(:r1 , :Word)
|
2020-03-22 14:58:19 +01:00
|
|
|
builder.add_code Risc::Transfer.new(self , name_reg , to)
|
2019-09-17 19:18:00 +02:00
|
|
|
builder.add_code Risc::Syscall.new(self, :died )
|
2019-09-11 17:43:20 +02:00
|
|
|
return compiler
|
|
|
|
end
|
|
|
|
end
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|