diff --git a/lib/parfait/message.rb b/lib/parfait/message.rb index a58dce1c..49e02066 100644 --- a/lib/parfait/message.rb +++ b/lib/parfait/message.rb @@ -20,7 +20,7 @@ module Parfait attr_reader :return_address, :return_value attr_reader :caller , :name , :arguments - def initialize next_m + def initialize( next_m ) @next_message = next_m @frame = NamedList.new() @arguments = NamedList.new() diff --git a/lib/risc/builtin/kernel.rb b/lib/risc/builtin/kernel.rb index 7b9444ea..b05429fa 100644 --- a/lib/risc/builtin/kernel.rb +++ b/lib/risc/builtin/kernel.rb @@ -11,20 +11,23 @@ module Risc Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({})) new_start = Risc.label("__init__ start" , "__init__" ) 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_reg = compiler.use_reg(:Space) #Set up the Space as self upon init compiler.add_load_constant("__init__ load Space", space , space_reg) 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) + # 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) #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}" ) ret_tmp = compiler.use_reg(:Label) 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_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 emit_syscall( compiler , :exit ) return compiler.method diff --git a/lib/risc/instruction.rb b/lib/risc/instruction.rb index 364771fd..b842fc53 100644 --- a/lib/risc/instruction.rb +++ b/lib/risc/instruction.rb @@ -77,7 +77,7 @@ module Risc end def source_mini 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})" end end diff --git a/lib/risc/method_compiler.rb b/lib/risc/method_compiler.rb index ab20365e..fc341314 100644 --- a/lib/risc/method_compiler.rb +++ b/lib/risc/method_compiler.rb @@ -103,7 +103,7 @@ module Risc # for computationally building code (ie writing assembler) these short cuts # 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| define_method("add_#{method}".to_sym) do |*args| add_code Risc.send( method , *args ) diff --git a/test/support/risc.rb b/test/support/risc.rb index 1b218de4..b6a9674a 100644 --- a/test/support/risc.rb +++ b/test/support/risc.rb @@ -9,12 +9,12 @@ module Risc end end - def check_return val + def check_return( val ) assert_equal Parfait::Message , @interpreter.get_register(:r0).class assert_equal val , @interpreter.get_register(:r0).return_value end - def ticks num + def ticks( num ) last = nil num.times do last = @interpreter.instruction