diff options
3 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/functions/FN_multi_function_procedure.hh b/source/blender/functions/FN_multi_function_procedure.hh index 7b6102efe67..7da121816b6 100644 --- a/source/blender/functions/FN_multi_function_procedure.hh +++ b/source/blender/functions/FN_multi_function_procedure.hh @@ -146,7 +146,7 @@ class MFProcedure : NonCopyable, NonMovable { MFCallInstruction &new_call_instruction(const MultiFunction &fn, Span<MFVariable *> param_variables); MFBranchInstruction &new_branch_instruction(MFVariable *condition_variable = nullptr); - MFDestructInstruction &new_destruct_instruction(); + MFDestructInstruction &new_destruct_instruction(MFVariable *variable = nullptr); void add_parameter(MFParamType::InterfaceType interface_type, MFVariable &variable); diff --git a/source/blender/functions/intern/multi_function_procedure.cc b/source/blender/functions/intern/multi_function_procedure.cc index b5b7585e5b1..4732275fb7f 100644 --- a/source/blender/functions/intern/multi_function_procedure.cc +++ b/source/blender/functions/intern/multi_function_procedure.cc @@ -148,11 +148,12 @@ MFBranchInstruction &MFProcedure::new_branch_instruction(MFVariable *condition_v return instruction; } -MFDestructInstruction &MFProcedure::new_destruct_instruction() +MFDestructInstruction &MFProcedure::new_destruct_instruction(MFVariable *variable) { MFDestructInstruction &instruction = *allocator_.construct<MFDestructInstruction>().release(); instruction.type_ = MFInstructionType::Destruct; destruct_instructions_.append(&instruction); + instruction.set_variable(variable); return instruction; } @@ -222,7 +223,7 @@ std::string MFProcedure::to_dot() const } MFVariable *variable = instruction->params()[param_index]; if (variable == nullptr) { - ss << "null"; + ss << "<null>"; } else { ss << variable->name(); @@ -237,18 +238,18 @@ std::string MFProcedure::to_dot() const dot_nodes.add_new(instruction, &dot_node); } for (MFBranchInstruction *instruction : branch_instructions_) { - std::stringstream ss; - ss << "Branch"; MFVariable *variable = instruction->condition(); - if (variable != nullptr) { - ss << ": " << variable->name(); - } + std::stringstream ss; + ss << "Branch: " << (variable == nullptr ? "<null>" : variable->name().c_str()); dot::Node &dot_node = digraph.new_node(ss.str()); dot_node.set_shape(dot::Attr_shape::Rectangle); dot_nodes.add_new(instruction, &dot_node); } for (MFDestructInstruction *instruction : destruct_instructions_) { - dot::Node &dot_node = digraph.new_node("Destruct"); + MFVariable *variable = instruction->variable(); + std::stringstream ss; + ss << "Destruct: " << (variable == nullptr ? "<null>" : variable->name().c_str()); + dot::Node &dot_node = digraph.new_node(ss.str()); dot_node.set_shape(dot::Attr_shape::Rectangle); dot_nodes.add_new(instruction, &dot_node); } diff --git a/source/blender/functions/tests/FN_multi_function_procedure_test.cc b/source/blender/functions/tests/FN_multi_function_procedure_test.cc index 4ecad05e07b..cb30501a001 100644 --- a/source/blender/functions/tests/FN_multi_function_procedure_test.cc +++ b/source/blender/functions/tests/FN_multi_function_procedure_test.cc @@ -22,10 +22,12 @@ TEST(multi_function_procedure, SimpleTest) MFCallInstruction &add1_instr = procedure.new_call_instruction(add_fn, {&var1, &var2, &var3}); MFCallInstruction &add2_instr = procedure.new_call_instruction(add_fn, {&var2, &var3, &var4}); MFCallInstruction &add3_instr = procedure.new_call_instruction(add_10_fn, {&var4}); + MFDestructInstruction &destruct_instr = procedure.new_destruct_instruction(&var3); procedure.set_entry(add1_instr); add1_instr.set_next(&add2_instr); add2_instr.set_next(&add3_instr); + add3_instr.set_next(&destruct_instr); procedure.add_parameter(MFParamType::Input, var1); procedure.add_parameter(MFParamType::Input, var2); |