NodeRef Synth::instantiate(NodeDefinition *nodedef) { /*------------------------------------------------------------------------ * Recursively instantiate the subgraph specified in NodeDefinition. * Does not currently support graphs that route one node to multiple * inputs. *-----------------------------------------------------------------------*/ NodeRegistry *registry = NodeRegistry::global(); Node *node = registry->create(nodedef->name); NodeRef noderef = NodeRef(node); /*------------------------------------------------------------------------ * Update the synth's internal collection of node refs. *-----------------------------------------------------------------------*/ this->nodes.insert(noderef); for (auto param : nodedef->params) { std::string param_name = param.first; NodeRef param_node = this->instantiate(param.second); noderef->set_input(param_name, param_node); } if (nodedef->is_constant) { Constant *constant = (Constant *) node; constant->value = nodedef->value; } if (!nodedef->input_name.empty()) { this->inputs[nodedef->input_name] = noderef; } return noderef; }