2019-10-03 21:07:55 +03:00
|
|
|
module SlotMachine
|
2019-09-11 20:17:43 +03:00
|
|
|
class MethodMissing < Macro
|
2019-09-17 20:18:00 +03:00
|
|
|
attr_reader :name
|
|
|
|
|
|
|
|
def initialize( source , name )
|
|
|
|
super(source)
|
2019-10-04 00:36:49 +03:00
|
|
|
name = name.value if name.is_a?(Sol::SymbolConstant)
|
2019-09-17 20:18:00 +03:00
|
|
|
raise "No reg #{name.class}" unless name.class == Symbol
|
|
|
|
@name = name
|
|
|
|
end
|
|
|
|
|
2019-09-11 18:43:20 +03:00
|
|
|
def to_risc(compiler)
|
2019-09-15 15:13:11 +03:00
|
|
|
builder = compiler.builder(compiler.source_name)
|
2019-09-17 20:18:00 +03: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 18:43:20 +03:00
|
|
|
return compiler
|
|
|
|
end
|
|
|
|
end
|
2019-08-12 13:16:15 +03:00
|
|
|
end
|