mor on sys call implementation
This commit is contained in:
parent
2aba926f1f
commit
1a82ebcd69
@ -4,7 +4,7 @@ module Arm
|
|||||||
def run block
|
def run block
|
||||||
block.codes.dup.each do |code|
|
block.codes.dup.each do |code|
|
||||||
next unless code.is_a? Register::GetSlot
|
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 )
|
block.replace(code , load )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ module Arm
|
|||||||
def run block
|
def run block
|
||||||
block.codes.dup.each do |code|
|
block.codes.dup.each do |code|
|
||||||
next unless code.is_a? Register::SetSlot
|
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 )
|
block.replace(code , store )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
16
lib/arm/passes/syscall_implementation.rb
Normal file
16
lib/arm/passes/syscall_implementation.rb
Normal file
@ -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
|
@ -18,8 +18,6 @@ module Builtin
|
|||||||
def putstring context
|
def putstring context
|
||||||
function = Virtual::CompiledMethodInfo.create_method(:Kernel , :putstring , [] )
|
function = Virtual::CompiledMethodInfo.create_method(:Kernel , :putstring , [] )
|
||||||
emit_syscall( function , :putstring )
|
emit_syscall( function , :putstring )
|
||||||
ret = Virtual::RegisterMachine.instance.write_stdout(function)
|
|
||||||
function.set_return ret
|
|
||||||
function
|
function
|
||||||
end
|
end
|
||||||
def exit context
|
def exit context
|
||||||
@ -51,22 +49,23 @@ module Builtin
|
|||||||
space_tmp = Register::RegisterReference.tmp_reg
|
space_tmp = Register::RegisterReference.tmp_reg
|
||||||
ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message )
|
ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message )
|
||||||
raise "index not found for :syscall_message" unless ind
|
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 Register::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::SetSlot.new( Virtual::Slot::MESSAGE_REGISTER , space_tmp , ind)
|
||||||
end
|
end
|
||||||
def restore_message(function)
|
def restore_message(function)
|
||||||
# get the sys return out of the way
|
# get the sys return out of the way
|
||||||
return_tmp = Register::RegisterReference.tmp_reg
|
return_tmp = Register::RegisterReference.tmp_reg
|
||||||
# load the space into the base register
|
# 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
|
# find the stored message
|
||||||
ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message )
|
ind = Parfait::Space.object_space.get_layout().index_of( :syscall_message )
|
||||||
raise "index not found for #{kind}.#{kind.class}" unless ind
|
raise "index not found for #{kind}.#{kind.class}" unless ind
|
||||||
# and load it into the base RegisterMachine
|
# 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
|
# and "unroll" self and frame
|
||||||
function.info.add_code GetSlot.new( slot::MESSAGE_REGISTER , Virtual::SELF_INDEX, slot::SELF_REGISTER )
|
function.info.add_code Register::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::FRAME_INDEX, slot::FRAME_REGISTER )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
extend ClassMethods
|
extend ClassMethods
|
||||||
|
@ -28,7 +28,7 @@ module Virtual
|
|||||||
:Message => [],
|
:Message => [],
|
||||||
:MetaClass => [],
|
:MetaClass => [],
|
||||||
:BinaryCode => [],
|
:BinaryCode => [],
|
||||||
:Space => [:classes ,:frames ,:messages ,:next_message ,:next_frame],
|
:Space => [:classes ,:frames ,:messages ,:next_message ,:next_frame, :syscall_message],
|
||||||
:Frame => [:locals , :tmps ],
|
:Frame => [:locals , :tmps ],
|
||||||
:Layout => [:object_class] ,
|
:Layout => [:object_class] ,
|
||||||
:Class => [:object_layout ],
|
:Class => [:object_layout ],
|
||||||
|
Loading…
Reference in New Issue
Block a user