From c398cad0596b1d8bee62a1ade2cb7c1499833023 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Sun, 29 Aug 2021 12:46:39 +0200 Subject: show procedure parameters in dot graph --- .../functions/intern/multi_function_procedure.cc | 40 ++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/source/blender/functions/intern/multi_function_procedure.cc b/source/blender/functions/intern/multi_function_procedure.cc index 1782d50371f..7d96491f5e0 100644 --- a/source/blender/functions/intern/multi_function_procedure.cc +++ b/source/blender/functions/intern/multi_function_procedure.cc @@ -615,8 +615,7 @@ class MFProcedureDotExport { } } - dot::Node &entry_node = digraph_.new_node("Entry"); - entry_node.set_shape(dot::Attr_shape::Circle); + dot::Node &entry_node = this->create_entry_node(); create_edge(entry_node, procedure_.entry()); } @@ -754,6 +753,20 @@ class MFProcedureDotExport { void instruction_to_string(const MFReturnInstruction &UNUSED(instruction), std::stringstream &ss) { instruction_name_format("Return ", ss); + + Vector outgoing_parameters; + for (const ConstMFParameter ¶m : procedure_.params()) { + if (ELEM(param.type, MFParamType::Mutable, MFParamType::Output)) { + outgoing_parameters.append(param); + } + } + for (const int param_index : outgoing_parameters.index_range()) { + const ConstMFParameter ¶m = outgoing_parameters[param_index]; + variable_to_string(param.variable, ss); + if (param_index < outgoing_parameters.size() - 1) { + ss << ", "; + } + } } void instruction_to_string(const MFBranchInstruction &instruction, std::stringstream &ss) @@ -761,6 +774,29 @@ class MFProcedureDotExport { instruction_name_format("Branch ", ss); variable_to_string(instruction.condition(), ss); } + + dot::Node &create_entry_node() + { + std::stringstream ss; + ss << "Entry: "; + Vector incoming_parameters; + for (const ConstMFParameter ¶m : procedure_.params()) { + if (ELEM(param.type, MFParamType::Input, MFParamType::Mutable)) { + incoming_parameters.append(param); + } + } + for (const int param_index : incoming_parameters.index_range()) { + const ConstMFParameter ¶m = incoming_parameters[param_index]; + variable_to_string(param.variable, ss); + if (param_index < incoming_parameters.size() - 1) { + ss << ", "; + } + } + + dot::Node &node = digraph_.new_node(ss.str()); + node.set_shape(dot::Attr_shape::Ellipse); + return node; + } }; std::string MFProcedure::to_dot() const -- cgit v1.2.3