2019-10-03 20:07:55 +02:00
|
|
|
module SlotMachine
|
2019-09-11 19:17:43 +02:00
|
|
|
class MethodMissing < Macro
|
2019-09-17 19:18:00 +02:00
|
|
|
attr_reader :name
|
|
|
|
|
|
|
|
def initialize( source , name )
|
|
|
|
super(source)
|
|
|
|
name = name.value if name.is_a?(Vool::SymbolConstant)
|
|
|
|
raise "No reg #{name.class}" unless name.class == Symbol
|
|
|
|
@name = name
|
|
|
|
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
|
|
|
from = Risc::RegisterValue.new(@name , :Word)
|
|
|
|
to = Risc::RegisterValue.new(:r1 , :Word)
|
|
|
|
builder.add_code Risc::Transfer.new(self , from , to)
|
|
|
|
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
|