diff --git a/core/src/main/java/org/lflang/generator/c/CGenerator.java b/core/src/main/java/org/lflang/generator/c/CGenerator.java index 298a637098..6238f5b1ed 100644 --- a/core/src/main/java/org/lflang/generator/c/CGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CGenerator.java @@ -1923,8 +1923,42 @@ protected void generateParameterInitialization(ReactorInstance instance) { + ";", selfRef + "->" + parameter.getName() + " = " + temporaryVariableName + ";")); } else { - initializeTriggerObjects.pr( - selfRef + "->" + parameter.getName() + " = " + initializer + ";"); + if (parameter.getName().equals("name")) { + ReactorInstance parent = instance.getParent(); + boolean parent_name_found = false; + if (parent != null) { + for (ParameterInstance p_parameter : parent.parameters) { + if (p_parameter.getName().equals("name")) { + parent_name_found = true; + break; + } + } + } + if (parent_name_found) { + initializeTriggerObjects.pr( + selfRef + "->" + parameter.getName() + " = " + + "calloc (1 + snprintf (NULL, 0, \"%s.%s%d\", " + + "self->name, " + initializer + ", " + + CUtil.bankIndex(instance) + "), sizeof (char));"); + initializeTriggerObjects.pr( + "sprintf (" + selfRef + "->" + parameter.getName() + ", \"%s.%s%d\", " + + "self->name, " + initializer + ", " + + CUtil.bankIndex(instance) + ");"); + } else { + initializeTriggerObjects.pr( + selfRef + "->" + parameter.getName() + " = " + + "calloc (1 + snprintf (NULL, 0, \"%s%d\", " + + initializer + ", " + + CUtil.bankIndex(instance) + "), sizeof (char));"); + initializeTriggerObjects.pr( + "sprintf (" + selfRef + "->" + parameter.getName() + ", \"%s%d\", " + + initializer + ", " + + CUtil.bankIndex(instance) + ");"); + } + } else { + initializeTriggerObjects.pr( + selfRef + "->" + parameter.getName() + " = " + initializer + ";"); + } } } }