From 834266e11e2a53e4aac97ff10e01a40dce44206b Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 1 Nov 2015 19:13:40 +0200 Subject: [PATCH] improve label names a bit --- lib/register/builtin/kernel.rb | 16 +++++++++------- lib/soml/compiler.rb | 2 +- lib/soml/compiler/function_definition.rb | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/register/builtin/kernel.rb b/lib/register/builtin/kernel.rb index 93e0b6ec..88bfd4df 100644 --- a/lib/register/builtin/kernel.rb +++ b/lib/register/builtin/kernel.rb @@ -6,7 +6,7 @@ module Register # 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 def __init__ context - source = "Kernel.__init__" + source = "__init__" compiler = Soml::Compiler.new.create_method(:Kernel,:__init__ , []) # no method enter or return (automatically added), remove new_start = Label.new(source , source ) @@ -27,18 +27,19 @@ module Register emit_syscall( compiler , :exit ) return compiler.method end + def exit context compiler = Soml::Compiler.new.create_method(:Kernel,:exit , []).init_method + emit_syscall( compiler , :exit ) return compiler.method - ret = RegisterMachine.instance.exit(function) - function.set_return ret - function end def emit_syscall compiler , name save_message( compiler ) compiler.add_code Syscall.new("emit_syscall(#{name})", name ) restore_message(compiler) + return unless (@clazz and @method) + compiler.add_code Label.new( "#{@clazz.name}.#{@message.name}" , "return_syscall" ) end # save the current message, as the syscall destroys all context @@ -53,12 +54,13 @@ module Register def restore_message(compiler) r8 = RegisterValue.new( :r8 , :Message) return_tmp = Register.tmp_reg :Integer + source = "_restore_message" # 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 - 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 - 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 end end diff --git a/lib/soml/compiler.rb b/lib/soml/compiler.rb index 6ae21169..2377567a 100644 --- a/lib/soml/compiler.rb +++ b/lib/soml/compiler.rb @@ -82,7 +82,7 @@ module Soml # message shuffle and FunctionReturn for the return # return self for chaining def init_method - source = "Complier.init_method" + source = "_init_method" @method.instructions = Register::Label.new(source, "#{method.for_class.name}.#{method.name}") @current = method.instructions add_code enter = Register.save_return(source, :message , :return_address) diff --git a/lib/soml/compiler/function_definition.rb b/lib/soml/compiler/function_definition.rb index 6f2ecabd..05cbeb10 100644 --- a/lib/soml/compiler/function_definition.rb +++ b/lib/soml/compiler/function_definition.rb @@ -33,6 +33,7 @@ module Soml create_method_for(@clazz, name , args ).init_method @clazz.add_instance_method @method end + @method.source = statement #puts "compile method #{@method.name}" kids.to_a.each do |ex|