diff --git a/lib/arm/passes/get_implementation.rb b/lib/arm/passes/get_implementation.rb index fb065789..a36067eb 100644 --- a/lib/arm/passes/get_implementation.rb +++ b/lib/arm/passes/get_implementation.rb @@ -4,7 +4,7 @@ module Arm def run block block.codes.dup.each do |code| next unless code.is_a? Register::GetSlot - load = ArmMachine.ldr( code.value , code.reference , code.index ) + load = ArmMachine.ldr( code.register , code.array , code.index ) block.replace(code , load ) end end diff --git a/lib/arm/passes/set_implementation.rb b/lib/arm/passes/set_implementation.rb index fca646c2..163a8e4e 100644 --- a/lib/arm/passes/set_implementation.rb +++ b/lib/arm/passes/set_implementation.rb @@ -4,7 +4,7 @@ module Arm def run block block.codes.dup.each do |code| next unless code.is_a? Register::SetSlot - store = ArmMachine.str( code.value , code.reference , code.index ) + store = ArmMachine.str( code.register , code.array , code.index ) block.replace(code , store ) end end diff --git a/lib/arm/passes/syscall_implementation.rb b/lib/arm/passes/syscall_implementation.rb new file mode 100644 index 00000000..854af86c --- /dev/null +++ b/lib/arm/passes/syscall_implementation.rb @@ -0,0 +1,16 @@ +module Arm + + class SyscallImplementation + def run block + block.codes.dup.each do |code| + next unless code.is_a? Register::Syscall + new_codes = [] + load = ArmMachine.ldr( :r1 , code.constant ) + + store = ArmMachine.str( code.register , code.array , code.index ) + block.replace(code , new_codes ) + end + end + end + Virtual.machine.add_pass "Arm::SetImplementation" +end diff --git a/lib/register/builtin/kernel.rb b/lib/register/builtin/kernel.rb index 69858853..a78febea 100644 --- a/lib/register/builtin/kernel.rb +++ b/lib/register/builtin/kernel.rb @@ -18,8 +18,6 @@ module Builtin def putstring context function = Virtual::CompiledMethodInfo.create_method(:Kernel , :putstring , [] ) emit_syscall( function , :putstring ) - ret = Virtual::RegisterMachine.instance.write_stdout(function) - function.set_return ret function end def exit context @@ -51,22 +49,23 @@ module Builtin space_tmp = Register::RegisterReference.tmp_reg ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message ) raise "index not found for :syscall_message" unless ind - function.info.add_code LoadConstant.new( space_tmp , Parfait::Space.object_space ) - function.info.add_code << SetSlot.new( Virtual::Slot::MESSAGE_REGISTER , space_tmp , ind) + function.info.add_code Register::LoadConstant.new( space_tmp , Parfait::Space.object_space ) + function.info.add_code Register::SetSlot.new( Virtual::Slot::MESSAGE_REGISTER , space_tmp , ind) end def restore_message(function) # get the sys return out of the way return_tmp = Register::RegisterReference.tmp_reg # load the space into the base register - function.info.add_code RegisterTransfer.new( Virtual::Slot::MESSAGE_REGISTER , return_tmp ) + function.info.add_code Register::RegisterTransfer.new( Virtual::Slot::MESSAGE_REGISTER , return_tmp ) + slot = Virtual::Slot # find the stored message ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message ) raise "index not found for #{kind}.#{kind.class}" unless ind # and load it into the base RegisterMachine - function.info.add_code GetSlot.new( Virtual::Slot::MESSAGE_REGISTER , ind , Virtual::Slot::MESSAGE_REGISTER ) + function.info.add_code Register::GetSlot.new( slot::MESSAGE_REGISTER , ind , slot::MESSAGE_REGISTER ) # and "unroll" self and frame - function.info.add_code GetSlot.new( slot::MESSAGE_REGISTER , Virtual::SELF_INDEX, slot::SELF_REGISTER ) - function.info.add_code GetSlot.new( slot::MESSAGE_REGISTER , Virtual::FRAME_INDEX, slot::FRAME_REGISTER ) + function.info.add_code Register::GetSlot.new( slot::MESSAGE_REGISTER , Virtual::SELF_INDEX, slot::SELF_REGISTER ) + function.info.add_code Register::GetSlot.new( slot::MESSAGE_REGISTER , Virtual::FRAME_INDEX, slot::FRAME_REGISTER ) end end extend ClassMethods diff --git a/lib/virtual/boot.rb b/lib/virtual/boot.rb index 6f02e00b..2da33f95 100644 --- a/lib/virtual/boot.rb +++ b/lib/virtual/boot.rb @@ -28,7 +28,7 @@ module Virtual :Message => [], :MetaClass => [], :BinaryCode => [], - :Space => [:classes ,:frames ,:messages ,:next_message ,:next_frame], + :Space => [:classes ,:frames ,:messages ,:next_message ,:next_frame, :syscall_message], :Frame => [:locals , :tmps ], :Layout => [:object_class] , :Class => [:object_layout ],