mostly brackets and formatting
This commit is contained in:
parent
c51e593335
commit
b4a18bc59b
@ -20,7 +20,7 @@ module Parfait
|
|||||||
attr_reader :return_address, :return_value
|
attr_reader :return_address, :return_value
|
||||||
attr_reader :caller , :name , :arguments
|
attr_reader :caller , :name , :arguments
|
||||||
|
|
||||||
def initialize next_m
|
def initialize( next_m )
|
||||||
@next_message = next_m
|
@next_message = next_m
|
||||||
@frame = NamedList.new()
|
@frame = NamedList.new()
|
||||||
@arguments = NamedList.new()
|
@arguments = NamedList.new()
|
||||||
|
@ -11,20 +11,23 @@ module Risc
|
|||||||
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({}))
|
||||||
new_start = Risc.label("__init__ start" , "__init__" )
|
new_start = Risc.label("__init__ start" , "__init__" )
|
||||||
compiler.method.set_instructions( new_start)
|
compiler.method.set_instructions( new_start)
|
||||||
compiler.set_current new_start
|
compiler.set_current( new_start ) #thus abandoning standard method setup
|
||||||
|
|
||||||
space = Parfait.object_space
|
space = Parfait.object_space
|
||||||
space_reg = compiler.use_reg(:Space) #Set up the Space as self upon init
|
space_reg = compiler.use_reg(:Space) #Set up the Space as self upon init
|
||||||
compiler.add_load_constant("__init__ load Space", space , space_reg)
|
compiler.add_load_constant("__init__ load Space", space , space_reg)
|
||||||
message_ind = Risc.resolve_to_index( :space , :first_message )
|
message_ind = Risc.resolve_to_index( :space , :first_message )
|
||||||
|
#load the first_message (instance of space)
|
||||||
compiler.add_slot_to_reg( "__init__ load 1st message" , space_reg , message_ind , :message)
|
compiler.add_slot_to_reg( "__init__ load 1st message" , space_reg , message_ind , :message)
|
||||||
|
# but use it's next message, so main can return normally
|
||||||
|
compiler.add_slot_to_reg( "__init__ load 2nd message" , :message , :next_message , :message)
|
||||||
compiler.add_reg_to_slot( "__init__ store Space in message", space_reg , :message , :receiver)
|
compiler.add_reg_to_slot( "__init__ store Space in message", space_reg , :message , :receiver)
|
||||||
#fixme: should add arg type here, as done in call_site (which this sort of is)
|
#fixme: should add arg type here, as done in call_site (which this sort of is)
|
||||||
exit_label = Risc.label("_exit_label for __init__" , "#{compiler.type.object_class.name}.#{compiler.method.name}" )
|
exit_label = Risc.label("_exit_label for __init__" , "#{compiler.type.object_class.name}.#{compiler.method.name}" )
|
||||||
ret_tmp = compiler.use_reg(:Label)
|
ret_tmp = compiler.use_reg(:Label)
|
||||||
compiler.add_load_constant("__init__ load return", exit_label , ret_tmp)
|
compiler.add_load_constant("__init__ load return", exit_label , ret_tmp)
|
||||||
compiler.add_reg_to_slot("__init__ store return", ret_tmp , :message , :return_address)
|
compiler.add_reg_to_slot("__init__ store return", ret_tmp , :message , :return_address)
|
||||||
compiler.add_code Risc.function_call( "__init__ issue call" , Parfait.object_space.get_main , ret_tmp)
|
compiler.add_function_call( "__init__ issue call" , Parfait.object_space.get_main , ret_tmp)
|
||||||
compiler.add_code exit_label
|
compiler.add_code exit_label
|
||||||
emit_syscall( compiler , :exit )
|
emit_syscall( compiler , :exit )
|
||||||
return compiler.method
|
return compiler.method
|
||||||
|
@ -77,7 +77,7 @@ module Risc
|
|||||||
end
|
end
|
||||||
def source_mini
|
def source_mini
|
||||||
return "(no source)" unless source
|
return "(no source)" unless source
|
||||||
return "(from: #{source[0..15]})" if source.is_a?(String)
|
return "(from: #{source[0..25]})" if source.is_a?(String)
|
||||||
"(from: #{source.class.name.split("::").last})"
|
"(from: #{source.class.name.split("::").last})"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -103,7 +103,7 @@ module Risc
|
|||||||
|
|
||||||
# for computationally building code (ie writing assembler) these short cuts
|
# for computationally building code (ie writing assembler) these short cuts
|
||||||
# help to instantiate risc instructions and add them immediately
|
# help to instantiate risc instructions and add them immediately
|
||||||
[:label, :reg_to_slot , :slot_to_reg , :load_constant, :function_return ,
|
[:label, :reg_to_slot , :slot_to_reg , :load_constant, :function_return , :function_call,
|
||||||
:transfer , :reg_to_slot , :byte_to_reg , :reg_to_byte].each do |method|
|
:transfer , :reg_to_slot , :byte_to_reg , :reg_to_byte].each do |method|
|
||||||
define_method("add_#{method}".to_sym) do |*args|
|
define_method("add_#{method}".to_sym) do |*args|
|
||||||
add_code Risc.send( method , *args )
|
add_code Risc.send( method , *args )
|
||||||
|
@ -9,12 +9,12 @@ module Risc
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_return val
|
def check_return( val )
|
||||||
assert_equal Parfait::Message , @interpreter.get_register(:r0).class
|
assert_equal Parfait::Message , @interpreter.get_register(:r0).class
|
||||||
assert_equal val , @interpreter.get_register(:r0).return_value
|
assert_equal val , @interpreter.get_register(:r0).return_value
|
||||||
end
|
end
|
||||||
|
|
||||||
def ticks num
|
def ticks( num )
|
||||||
last = nil
|
last = nil
|
||||||
num.times do
|
num.times do
|
||||||
last = @interpreter.instruction
|
last = @interpreter.instruction
|
||||||
|
Loading…
Reference in New Issue
Block a user