fix most of mom from calling changes

This commit is contained in:
2019-08-22 22:56:44 +03:00
parent 0c49612e5e
commit 017e7e2971
17 changed files with 106 additions and 84 deletions

View File

@ -27,12 +27,12 @@ module Mom
# For blocks the options are args or frame
# or then the methods arg or frame
def slot_type_for(name)
if @callable.arguments_type.variable_index(name)
slot_def = [:arguments]
if index = @callable.arguments_type.variable_index(name)
return ["arg#{index}".to_sym]
elsif @callable.frame_type.variable_index(name)
slot_def = [:frame]
elsif @method.arguments_type.variable_index(name)
slot_def = [:caller , :caller ,:arguments ]
elsif index = @method.arguments_type.variable_index(name)
return [:caller , :caller , "arg#{index}".to_sym]
elsif @method.frame_type.variable_index(name)
slot_def = [:caller ,:caller , :frame ]
elsif

View File

@ -37,6 +37,7 @@ module Mom
# delegates to SlotLoad for receiver and to the actual args.to_risc
def to_risc(compiler)
transfer = SlotLoad.new(self.source ,[:message , :next_message , :receiver] , @receiver, self).to_risc(compiler)
#TODO transfer the Number of arguments to :arguments_given (to be checked on entry)
compiler.reset_regs
@arguments.each do |arg|
arg.to_risc(compiler)

View File

@ -26,8 +26,7 @@ module Mom
return_address! << return_label
next_message[:return_address] << return_address
block_reg! << message[:arguments]
block_reg << block_reg[index]
block_reg! << message["arg#{index}".to_sym]
message << message[:next_message]
add_code Risc::DynamicJump.new("block_yield", block_reg )

View File

@ -45,8 +45,7 @@ module Mom
end
when Integer
builder.build do
arguments! << message[:arguments]
callable! << arguments[ from ]
callable! << message[ "arg#{from}".to_sym ]
end
else
raise "unknown source #{method_source.class}:#{method_source}"

View File

@ -13,6 +13,7 @@ module Mom
def initialize(left, right , label)
super(label)
raise right.to_s if right.to_s.include?("arguments")
@left , @right = left , right
end

View File

@ -68,12 +68,10 @@ module Mom
# determine how given name need to be accsessed.
# For methods the options are args or frame
def slot_type_for(name)
if @callable.arguments_type.variable_index(name)
type = :arguments
else
type = :frame
if index = @callable.arguments_type.variable_index(name)
return ["arg#{index}".to_sym]
end
[type , name]
[:frame , name]
end
def add_block_compiler(compiler)