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
# return_address of the next_message, for the ReturnSequence to pick it up.
def to_risc(compiler)
method = @method
return_label = Risc.label(self,"continue_#{object_id}")
save_return = SlotLoad.new([:message,:next_message,:return_address],[return_label],self)
moves = save_return.to_risc(compiler)
moves << Risc.slot_to_reg(self, Risc.message_reg , :next_message , Risc.message_reg)
moves << Risc::FunctionCall.new(self, method )
moves << return_label
compiler.build("SimpleCall") do
return_address! << return_label
next_message! << message[:next_message]
next_message[:return_address] << return_address
message << message[:next_message]
add_code Risc::FunctionCall.new("SimpleCall", method )
add_code return_label
end
end
end

View File

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