last two to_risc converted to builder

no change of tests, good sign
This commit is contained in:
Torsten Ruger 2018-08-16 20:28:42 +03:00
parent da9dc30c20
commit 176b12d896
2 changed files with 21 additions and 18 deletions

View File

@ -23,14 +23,16 @@ module Mom
# For returning, we add a label after the call, and load it's address into the # For returning, we add a label after the call, and load it's address into the
# return_address of the next_message, for the ReturnSequence to pick it up. # return_address of the next_message, for the ReturnSequence to pick it up.
def to_risc(compiler) def to_risc(compiler)
method = @method
return_label = Risc.label(self,"continue_#{object_id}") return_label = Risc.label(self,"continue_#{object_id}")
save_return = SlotLoad.new([:message,:next_message,:return_address],[return_label],self) compiler.build("SimpleCall") do
moves = save_return.to_risc(compiler) return_address! << return_label
moves << Risc.slot_to_reg(self, Risc.message_reg , :next_message , Risc.message_reg) next_message! << message[:next_message]
next_message[:return_address] << return_address
moves << Risc::FunctionCall.new(self, method ) message << message[:next_message]
add_code Risc::FunctionCall.new("SimpleCall", method )
moves << return_label add_code return_label
end
end end
end end

View File

@ -20,17 +20,18 @@ module Mom
def to_risc(compiler) def to_risc(compiler)
false_label = @false_jump.to_risc(compiler) false_label = @false_jump.to_risc(compiler)
left = @condition.to_register(compiler,self) builder = compiler.code_builder("TruthCheck")
false_load = SlotDefinition.new( FalseConstant.new , [] ).to_register(compiler,self) condition_code = @condition.to_register(compiler,self)
left << false_load condition = condition_code.register#.set_builder(builder)
left << Risc.op( self , :- , left.register , false_load.register) built = builder.build do
left << Risc::IsZero.new( self, false_label) object! << Parfait.object_space.false_object
nil_load = SlotDefinition.new( NilConstant.new , [] ).to_register(compiler,self) object.op :- , condition
left << nil_load if_zero false_label
left << Risc.op( self , :- , left.register , nil_load.register) object << Parfait.object_space.nil_object
left << Risc::IsZero.new( self, false_label) object.op :- , condition
if_zero false_label
left end
condition_code << built
end end
end end