fix function call and simple call logic
Before creating DynamicJump, the FunctionCall got a register for a possible jump address. Now that is handled by DynamicJump and FunctionCall just needs the method, from which it determines the binaryCode address
This commit is contained in:
@ -67,7 +67,7 @@ module Risc
|
||||
builder.build do
|
||||
add_load_constant("__init__ load return", exit_label , ret_tmp)
|
||||
add_reg_to_slot("__init__ store return", ret_tmp , :message , :return_address)
|
||||
add_function_call( "__init__ issue call" , Parfait.object_space.get_main , ret_tmp)
|
||||
add_function_call( "__init__ issue call" , Parfait.object_space.get_main)
|
||||
add_code exit_label
|
||||
end
|
||||
compiler.reset_regs
|
||||
|
@ -4,32 +4,19 @@ module Risc
|
||||
# assembly takes care of the rest (ie getting the address)
|
||||
|
||||
class FunctionCall < Instruction
|
||||
def initialize( source , method , register)
|
||||
def initialize( source , method)
|
||||
super(source)
|
||||
@method = method
|
||||
@register = register
|
||||
end
|
||||
attr_reader :method , :register
|
||||
attr_reader :method
|
||||
|
||||
def to_s
|
||||
class_source method.name
|
||||
end
|
||||
end
|
||||
|
||||
def self.function_call( source , method , register)
|
||||
Risc::FunctionCall.new( source , method , register)
|
||||
def self.function_call( source , method )
|
||||
Risc::FunctionCall.new( source , method )
|
||||
end
|
||||
|
||||
# def self.issue_call( compiler , callee )
|
||||
# callee_name = callee.name
|
||||
# return_label = Risc.label("_return_label #{callee_name}" , "#{compiler.type.object_class.name}.#{compiler.method.name}" )
|
||||
# ret_tmp = compiler.use_reg(:Label)
|
||||
# compiler.add_load_constant("#{callee_name} load ret", return_label , ret_tmp)
|
||||
# compiler.add_reg_to_slot("#{callee_name} store ret", ret_tmp , :new_message , :return_address)
|
||||
# compiler.add_transfer("#{callee_name} move new message", Risc.new_message_reg , Risc.message_reg )
|
||||
# compiler.add_function_call( "#{callee_name} call" , callee )
|
||||
# compiler.add_code return_label
|
||||
# compiler.add_transfer("#{callee_name} remove new message", Risc.message_reg , Risc.new_message_reg )
|
||||
# compiler.add_slot_to_reg("#{callee_name} restore message" , :new_message , :caller , :message )
|
||||
# end
|
||||
end
|
||||
|
@ -49,6 +49,9 @@ module Risc
|
||||
raise "Not int #{pos}" unless pos.is_a? Numeric
|
||||
position = Position.at(pos)
|
||||
log.debug "Setting Position #{pos}"
|
||||
if position.is_a?(Position::CodePosition)
|
||||
return set_pc(position.at + 12)
|
||||
end
|
||||
raise "not instruction position #{position}-#{position.class}-#{position.object.class}" unless position.is_a?(Position::InstructionPosition)
|
||||
set_instruction( position.instruction)
|
||||
@clock = position.at
|
||||
@ -207,7 +210,11 @@ module Risc
|
||||
end
|
||||
|
||||
def execute_FunctionCall
|
||||
set_instruction @instruction.method.risc_instructions
|
||||
meth = @instruction.method
|
||||
at = Position.get(meth.binary).at
|
||||
log.debug "Call to #{meth.name} at:#{at}"
|
||||
set_pc(at + 12)
|
||||
#set_instruction @instruction.method.risc_instructions
|
||||
false
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user