diff --git a/lib/mom/instruction/simple_call.rb b/lib/mom/instruction/simple_call.rb index e3f9b5c3..b6a517ee 100644 --- a/lib/mom/instruction/simple_call.rb +++ b/lib/mom/instruction/simple_call.rb @@ -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 diff --git a/lib/mom/instruction/truth_check.rb b/lib/mom/instruction/truth_check.rb index 0e8bcbd3..8f5af60d 100644 --- a/lib/mom/instruction/truth_check.rb +++ b/lib/mom/instruction/truth_check.rb @@ -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