get method name out from method_missing

This commit is contained in:
2019-09-17 20:18:00 +03:00
parent d58ed8e5e8
commit e56db0a3ac
9 changed files with 31 additions and 16 deletions

View File

@ -62,7 +62,7 @@ module Mom
branch while_start_label
add_code exit_label
MethodMissing.new(compiler.source_name).to_risc(compiler)
MethodMissing.new(compiler.source_name , word.symbol).to_risc(compiler)
add_code ok_label
cache_entry[:cached_method] << callable_method

View File

@ -1,8 +1,20 @@
module Mom
class MethodMissing < Macro
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
def to_risc(compiler)
builder = compiler.builder(compiler.source_name)
builder.add_code Risc::Syscall.new("Method_missing_died", :died )
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 )
return compiler
end
end

View File

@ -54,7 +54,7 @@ module Mom
def self.create_mm_compiler
compiler = compiler_for(:Object,:__method_missing__ ,{})
compiler.add_code MethodMissing.new("missing")
compiler.add_code MethodMissing.new("missing" , :r1)
return compiler
end

View File

@ -250,7 +250,7 @@ module Risc
set_instruction(nil)
return false
when :died
raise "Method not found #{@registers[:r0]}"
raise "Method #{@registers[:r1]} not found for #{@registers[:r0].receiver}"
else
raise "un-implemented syscall #{name}"
end

View File

@ -13,7 +13,7 @@ module Vool
def self.builtin
{
"Object.get" => "def get_internal_word(at); X.get_internal_word;end",
"Object.missing" => "def method_missing(at); X.method_missing;end",
"Object.missing" => "def method_missing(at); X.method_missing(:r1);end",
"Object.exit" => "def exit; X.exit;end",
"Integer.div4" => "def div4; X.div4;end",
"Integer.div10" => "def div10; X.div10;end",