last fixes for cc

seems like setup had just worked by chance and change broke that.
This commit is contained in:
Torsten Rüger 2019-08-23 19:22:27 +03:00
parent 4ca16e5f9a
commit 1eb6430880
6 changed files with 17 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)