polish sources
This commit is contained in:
parent
7d7b7ca995
commit
7e24f63327
@ -6,21 +6,22 @@ module Register
|
|||||||
# it isn't really a function, ie it is jumped to (not called), exits and may not return
|
# it isn't really a function, ie it is jumped to (not called), exits and may not return
|
||||||
# so it is responsible for initial setup
|
# so it is responsible for initial setup
|
||||||
def __init__ context
|
def __init__ context
|
||||||
|
source = "Kernel.__init__"
|
||||||
compiler = Soml::Compiler.new.create_method(:Kernel,:__init__ , [])
|
compiler = Soml::Compiler.new.create_method(:Kernel,:__init__ , [])
|
||||||
# no method enter or return (automatically added), remove
|
# no method enter or return (automatically added), remove
|
||||||
new_start = Label.new("__init__" , "__init__" )
|
new_start = Label.new(source , source )
|
||||||
compiler.method.instructions = new_start
|
compiler.method.instructions = new_start
|
||||||
compiler.set_current new_start
|
compiler.set_current new_start
|
||||||
|
|
||||||
#Set up the Space as self upon init
|
#Set up the Space as self upon init
|
||||||
space = Parfait::Space.object_space
|
space = Parfait::Space.object_space
|
||||||
space_reg = Register.tmp_reg(:Space)
|
space_reg = Register.tmp_reg(:Space)
|
||||||
compiler.add_code LoadConstant.new("__init__", space , space_reg)
|
compiler.add_code LoadConstant.new(source, space , space_reg)
|
||||||
message_ind = Register.resolve_index( :space , :first_message )
|
message_ind = Register.resolve_index( :space , :first_message )
|
||||||
# Load the message to new message register (r1)
|
# Load the message to new message register (r1)
|
||||||
compiler.add_code Register.get_slot( "__init__" , space_reg , message_ind , :new_message)
|
compiler.add_code Register.get_slot( source , space_reg , message_ind , :new_message)
|
||||||
# And store the space as the new self (so the call can move it back as self)
|
# And store the space as the new self (so the call can move it back as self)
|
||||||
compiler.add_code Register.set_slot( "__init__", space_reg , :new_message , :receiver)
|
compiler.add_code Register.set_slot( source, space_reg , :new_message , :receiver)
|
||||||
# now we are set up to issue a call to the main
|
# now we are set up to issue a call to the main
|
||||||
Register.issue_call( compiler , Register.machine.space.get_main)
|
Register.issue_call( compiler , Register.machine.space.get_main)
|
||||||
emit_syscall( compiler , :exit )
|
emit_syscall( compiler , :exit )
|
||||||
@ -36,7 +37,7 @@ module Register
|
|||||||
|
|
||||||
def emit_syscall compiler , name
|
def emit_syscall compiler , name
|
||||||
save_message( compiler )
|
save_message( compiler )
|
||||||
compiler.add_code Syscall.new("emit_syscall", name )
|
compiler.add_code Syscall.new("emit_syscall(#{name})", name )
|
||||||
restore_message(compiler)
|
restore_message(compiler)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ module Register
|
|||||||
# collect anything that is in the space but and reachable from init
|
# collect anything that is in the space but and reachable from init
|
||||||
module Collector
|
module Collector
|
||||||
def collect
|
def collect
|
||||||
# init= Parfait::Space.object_space.get_class_by_name("Kernel").get_instance_method "__init__"
|
|
||||||
self.objects.clear
|
self.objects.clear
|
||||||
keep Parfait::Space.object_space , 0
|
keep Parfait::Space.object_space , 0
|
||||||
constants.each {|o| keep(o,0)}
|
constants.each {|o| keep(o,0)}
|
||||||
|
@ -16,9 +16,10 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.issue_call compiler , callee
|
def self.issue_call compiler , callee
|
||||||
|
source = "_issue_call(#{callee.name})"
|
||||||
# move the current new_message to message
|
# move the current new_message to message
|
||||||
compiler.add_code RegisterTransfer.new("__call__", Register.new_message_reg , Register.message_reg )
|
compiler.add_code RegisterTransfer.new(source, Register.new_message_reg , Register.message_reg )
|
||||||
# do the register call
|
# do the register call
|
||||||
compiler.add_code FunctionCall.new( "__call__" , callee )
|
compiler.add_code FunctionCall.new( source , callee )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -63,7 +63,7 @@ module Register
|
|||||||
|
|
||||||
def boot
|
def boot
|
||||||
boot_parfait!
|
boot_parfait!
|
||||||
@init = Branch.new( "__init__" , self.space.get_init.instructions )
|
@init = Branch.new( "__initial_branch__" , self.space.get_init.instructions )
|
||||||
@booted = true
|
@booted = true
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
@ -82,16 +82,17 @@ module Soml
|
|||||||
# message shuffle and FunctionReturn for the return
|
# message shuffle and FunctionReturn for the return
|
||||||
# return self for chaining
|
# return self for chaining
|
||||||
def init_method
|
def init_method
|
||||||
@method.instructions = Register::Label.new("_init_method_", "#{method.for_class.name}_#{method.name}")
|
source = "Complier.init_method"
|
||||||
|
@method.instructions = Register::Label.new(source, "#{method.for_class.name}_#{method.name}")
|
||||||
@current = method.instructions
|
@current = method.instructions
|
||||||
add_code enter = Register.save_return("_init_method_", :message , :return_address)
|
add_code enter = Register.save_return(source, :message , :return_address)
|
||||||
add_code Register::Label.new( "_init_method_", "return")
|
add_code Register::Label.new( source, "return")
|
||||||
# move the current message to new_message
|
# move the current message to new_message
|
||||||
add_code Register::RegisterTransfer.new("_init_method_", Register.message_reg , Register.new_message_reg )
|
add_code Register::RegisterTransfer.new(source, Register.message_reg , Register.new_message_reg )
|
||||||
# and restore the message from saved value in new_message
|
# and restore the message from saved value in new_message
|
||||||
add_code Register.get_slot("_init_method_",:new_message , :caller , :message )
|
add_code Register.get_slot("_init_method_",:new_message , :caller , :message )
|
||||||
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
|
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
|
||||||
add_code Register::FunctionReturn.new( "_init_method_" , Register.new_message_reg , Register.resolve_index(:message , :return_address) )
|
add_code Register::FunctionReturn.new( source , Register.new_message_reg , Register.resolve_index(:message , :return_address) )
|
||||||
@current = enter
|
@current = enter
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user