improve label names a bit
This commit is contained in:
parent
d3a7809746
commit
834266e11e
@ -6,7 +6,7 @@ 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__"
|
source = "__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(source , source )
|
new_start = Label.new(source , source )
|
||||||
@ -27,18 +27,19 @@ module Register
|
|||||||
emit_syscall( compiler , :exit )
|
emit_syscall( compiler , :exit )
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
|
|
||||||
def exit context
|
def exit context
|
||||||
compiler = Soml::Compiler.new.create_method(:Kernel,:exit , []).init_method
|
compiler = Soml::Compiler.new.create_method(:Kernel,:exit , []).init_method
|
||||||
|
emit_syscall( compiler , :exit )
|
||||||
return compiler.method
|
return compiler.method
|
||||||
ret = RegisterMachine.instance.exit(function)
|
|
||||||
function.set_return ret
|
|
||||||
function
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def emit_syscall compiler , name
|
def emit_syscall compiler , name
|
||||||
save_message( compiler )
|
save_message( compiler )
|
||||||
compiler.add_code Syscall.new("emit_syscall(#{name})", name )
|
compiler.add_code Syscall.new("emit_syscall(#{name})", name )
|
||||||
restore_message(compiler)
|
restore_message(compiler)
|
||||||
|
return unless (@clazz and @method)
|
||||||
|
compiler.add_code Label.new( "#{@clazz.name}.#{@message.name}" , "return_syscall" )
|
||||||
end
|
end
|
||||||
|
|
||||||
# save the current message, as the syscall destroys all context
|
# save the current message, as the syscall destroys all context
|
||||||
@ -53,12 +54,13 @@ module Register
|
|||||||
def restore_message(compiler)
|
def restore_message(compiler)
|
||||||
r8 = RegisterValue.new( :r8 , :Message)
|
r8 = RegisterValue.new( :r8 , :Message)
|
||||||
return_tmp = Register.tmp_reg :Integer
|
return_tmp = Register.tmp_reg :Integer
|
||||||
|
source = "_restore_message"
|
||||||
# get the sys return out of the way
|
# get the sys return out of the way
|
||||||
compiler.add_code RegisterTransfer.new("restore_message", Register.message_reg , return_tmp )
|
compiler.add_code RegisterTransfer.new(source, Register.message_reg , return_tmp )
|
||||||
# load the stored message into the base RegisterMachine
|
# load the stored message into the base RegisterMachine
|
||||||
compiler.add_code RegisterTransfer.new("restore_message", r8 , Register.message_reg )
|
compiler.add_code RegisterTransfer.new(source, r8 , Register.message_reg )
|
||||||
# save the return value into the message
|
# save the return value into the message
|
||||||
compiler.add_code Register.set_slot( "restore_message" , return_tmp , :message , :return_value )
|
compiler.add_code Register.set_slot( source , return_tmp , :message , :return_value )
|
||||||
# and "unroll" self and frame
|
# and "unroll" self and frame
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -82,7 +82,7 @@ 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
|
||||||
source = "Complier.init_method"
|
source = "_init_method"
|
||||||
@method.instructions = Register::Label.new(source, "#{method.for_class.name}.#{method.name}")
|
@method.instructions = Register::Label.new(source, "#{method.for_class.name}.#{method.name}")
|
||||||
@current = method.instructions
|
@current = method.instructions
|
||||||
add_code enter = Register.save_return(source, :message , :return_address)
|
add_code enter = Register.save_return(source, :message , :return_address)
|
||||||
|
@ -33,6 +33,7 @@ module Soml
|
|||||||
create_method_for(@clazz, name , args ).init_method
|
create_method_for(@clazz, name , args ).init_method
|
||||||
@clazz.add_instance_method @method
|
@clazz.add_instance_method @method
|
||||||
end
|
end
|
||||||
|
@method.source = statement
|
||||||
#puts "compile method #{@method.name}"
|
#puts "compile method #{@method.name}"
|
||||||
|
|
||||||
kids.to_a.each do |ex|
|
kids.to_a.each do |ex|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user