From 1eb643088076ac3341e622a92bb6d877a25ea60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20R=C3=BCger?= Date: Fri, 23 Aug 2019 19:22:27 +0300 Subject: [PATCH] last fixes for cc seems like setup had just worked by chance and change broke that. --- lib/mom/builtin/init.rb | 2 +- lib/mom/builtin/object.rb | 4 ++-- lib/mom/callable_compiler.rb | 8 +++++++- lib/mom/instruction/message_setup.rb | 6 +++++- lib/mom/instruction/return_sequence.rb | 2 +- lib/risc/builder.rb | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/mom/builtin/init.rb b/lib/mom/builtin/init.rb index ea1e2204..0165bc2a 100644 --- a/lib/mom/builtin/init.rb +++ b/lib/mom/builtin/init.rb @@ -9,7 +9,7 @@ module Mom next_message! << message[:next_message] factory[:next_object] << next_message end - + builder.reset_names Mom::MessageSetup.new(Parfait.object_space.get_main).build_with( builder ) builder.build do diff --git a/lib/mom/builtin/object.rb b/lib/mom/builtin/object.rb index 401541e4..e7420b0a 100644 --- a/lib/mom/builtin/object.rb +++ b/lib/mom/builtin/object.rb @@ -40,8 +40,8 @@ module Mom # - call main, ie set up message for that etc # - exit (exit_sequence) which passes a machine int out to c def __init__( context ) - compiler = Mom::MethodCompiler.compiler_for_class(:Object,:__init__ , - Parfait::NamedList.type_for({}) , Parfait::NamedList.type_for({})) + compiler = compiler_for(:Object,:__init__ ,{}) + compiler._reset_for_init # no return, just for init compiler.add_code Init.new("missing") return compiler end diff --git a/lib/mom/callable_compiler.rb b/lib/mom/callable_compiler.rb index fe014724..fbad0df2 100644 --- a/lib/mom/callable_compiler.rb +++ b/lib/mom/callable_compiler.rb @@ -28,6 +28,12 @@ module Mom end end + # Only for init, as init has no return + def _reset_for_init + @mom_instructions = Label.new(source_name, source_name) + @current = @mom_instructions + end + # add a constant (which get created during compilation and need to be linked) def add_constant(const) raise "Must be Parfait #{const}" unless const.is_a?(Parfait::Object) @@ -64,8 +70,8 @@ module Mom while( instruction ) raise "whats this a #{instruction}" unless instruction.is_a?(Mom::Instruction) #puts "adding mom #{instruction.to_s}:#{instruction.next.to_s}" - instruction.to_risc( risc_compiler ) risc_compiler.reset_regs + instruction.to_risc( risc_compiler ) #puts "adding risc #{risc.to_s}:#{risc.next.to_s}" instruction = instruction.next end diff --git a/lib/mom/instruction/message_setup.rb b/lib/mom/instruction/message_setup.rb index efd30e14..1b5af7c7 100644 --- a/lib/mom/instruction/message_setup.rb +++ b/lib/mom/instruction/message_setup.rb @@ -61,8 +61,12 @@ module Mom # set the method into the message def build_message_data( builder ) + if(reg = builder.names["next_message"]) + raise "NEXT = #{reg}" + end builder.build do - next_message?[:method] << callable + next_message! << message[:next_message] + next_message[:method] << callable end end end diff --git a/lib/mom/instruction/return_sequence.rb b/lib/mom/instruction/return_sequence.rb index c78f68cb..63c43926 100644 --- a/lib/mom/instruction/return_sequence.rb +++ b/lib/mom/instruction/return_sequence.rb @@ -31,7 +31,7 @@ module Mom return_address! << message[:return_address] return_address << return_address[ Parfait::Integer.integer_index] message << message[:caller] - add_code Risc.function_return("return", return_address) + add_code Risc.function_return("return #{compiler.callable.name}", return_address) end end diff --git a/lib/risc/builder.rb b/lib/risc/builder.rb index 45726432..1c8a0062 100644 --- a/lib/risc/builder.rb +++ b/lib/risc/builder.rb @@ -12,7 +12,7 @@ module Risc # class Builder - attr_reader :built , :compiler + attr_reader :built , :compiler , :names # pass a compiler, to which instruction are added (usually) # second arg determines weather instructions are added (default true)