Skip to content

Commit

Permalink
naming banked reactors
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerMajNition committed Jun 14, 2024
1 parent 345df42 commit 10aacaa
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions core/src/main/java/org/lflang/generator/c/CGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ";");
}
}
}
}
Expand Down

0 comments on commit 10aacaa

Please sign in to comment.