Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further cleanup #2210

Merged
merged 18 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static String generateConstructor(TypeParameterizedReactor tpr, String co
code.pr(structType + "* new_" + CUtil.getName(tpr) + "() {");
code.indent();
code.pr(
structType + "* self = (" + structType + "*)_lf_new_reactor(sizeof(" + structType + "));");
structType + "* self = (" + structType + "*)lf_new_reactor(sizeof(" + structType + "));");
code.pr(constructorCode);
code.pr("return self;");
code.unindent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private String generateEnvironmentEnum() {
private String generateCreateEnvironments() {
CodeBuilder code = new CodeBuilder();
code.pr("// 'Create' and initialize the environments in the program");
code.pr("void _lf_create_environments() {");
code.pr("void lf_create_environments() {");
code.indent();
for (ReactorInstance enclave : enclaves) {
// Decide the number of workers to use. If this is the top-level
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/lflang/generator/c/CGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ private void generateCodeFor(String lfModuleName) throws IOException {
code.pr(
"""
#ifndef FEDERATED
void terminate_execution(environment_t* env) {}
void lf_terminate_execution(environment_t* env) {}
#endif""");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ private String generateSetDefaultCliOption() {
+ StringUtil.addDoubleQuotes(
StringUtil.joinObjects(runCommand, StringUtil.addDoubleQuotes(", ")))
+ " };",
"void _lf_set_default_command_line_options() {",
"void lf_set_default_command_line_options() {",
" default_argc = " + runCommand.size() + ";",
" default_argv = _lf_default_argv;",
"}")
: "void _lf_set_default_command_line_options() {}";
: "void lf_set_default_command_line_options() {}";
}

/** Parse the target parameters and set flags to the runCommand accordingly. */
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/org/lflang/generator/c/CPortGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static String initializeInputMultiport(PortInstance input, String reactor
"\n",
portRefName + "_width = " + input.getWidth() + ";",
"// Allocate memory for multiport inputs.",
portRefName + " = (" + variableStructType(input) + "**)_lf_allocate(",
portRefName + " = (" + variableStructType(input) + "**)lf_allocate(",
" " + input.getWidth() + ", sizeof(" + variableStructType(input) + "*),",
" &" + reactorSelfStruct + "->base.allocations); ",
"// Set inputs by default to an always absent default input.",
Expand All @@ -119,7 +119,7 @@ public static String initializeInputMultiport(PortInstance input, String reactor
"\n",
result,
"if (" + input.getWidth() + " >= LF_SPARSE_WIDTH_THRESHOLD) {",
" " + portRefName + "__sparse = (lf_sparse_io_record_t*)_lf_allocate(1,",
" " + portRefName + "__sparse = (lf_sparse_io_record_t*)lf_allocate(1,",
" sizeof(lf_sparse_io_record_t) + sizeof(size_t) * "
+ input.getWidth()
+ "/LF_SPARSE_CAPACITY_DIVIDER,",
Expand Down Expand Up @@ -158,10 +158,10 @@ public static String initializeOutputMultiport(PortInstance output, String react
"\n",
portRefName + "_width = " + output.getWidth() + ";",
"// Allocate memory for multiport output.",
portRefName + " = (" + portStructType + "*)_lf_allocate(",
portRefName + " = (" + portStructType + "*)lf_allocate(",
" " + output.getWidth() + ", sizeof(" + portStructType + "),",
" &" + reactorSelfStruct + "->base.allocations); ",
portRefName + "_pointers = (" + portStructType + "**)_lf_allocate(",
portRefName + "_pointers = (" + portStructType + "**)lf_allocate(",
" " + output.getWidth() + ", sizeof(" + portStructType + "*),",
" &" + reactorSelfStruct + "->base.allocations); ",
"// Assign each output port pointer to be used in",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ private static String deferredFillTriggerTable(Iterable<ReactionInstance> reacti
"// For reaction " + reaction.index + " of " + name + ", allocate an",
"// array of trigger pointers for downstream reactions through port "
+ port.getFullName(),
"trigger_t** trigger_array = (trigger_t**)_lf_allocate(",
"trigger_t** trigger_array = (trigger_t**)lf_allocate(",
" " + srcRange.destinations.size() + ", sizeof(trigger_t*),",
" &" + reactorSelfStruct + "->base.allocations); ",
triggerArray + " = trigger_array;"));
Expand Down Expand Up @@ -967,13 +967,13 @@ private static String deferredReactionOutputs(
"\n",
"// Allocate memory for triggers[] and triggered_sizes[] on the reaction_t",
"// struct for this reaction.",
CUtil.reactionRef(reaction) + ".triggers = (trigger_t***)_lf_allocate(",
CUtil.reactionRef(reaction) + ".triggers = (trigger_t***)lf_allocate(",
" " + outputCount + ", sizeof(trigger_t**),",
" &" + reactorSelfStruct + "->base.allocations);",
CUtil.reactionRef(reaction) + ".triggered_sizes = (int*)_lf_allocate(",
CUtil.reactionRef(reaction) + ".triggered_sizes = (int*)lf_allocate(",
" " + outputCount + ", sizeof(int),",
" &" + reactorSelfStruct + "->base.allocations);",
CUtil.reactionRef(reaction) + ".output_produced = (bool**)_lf_allocate(",
CUtil.reactionRef(reaction) + ".output_produced = (bool**)lf_allocate(",
" " + outputCount + ", sizeof(bool*),",
" &" + reactorSelfStruct + "->base.allocations);"));
}
Expand Down Expand Up @@ -1029,7 +1029,7 @@ private static String deferredReactionMemory(
+ width
+ ";",
CUtil.reactorRefNested(trigger.getParent()) + "." + trigger.getName(),
" = (" + portStructType + "**)_lf_allocate(",
" = (" + portStructType + "**)lf_allocate(",
" " + width + ", sizeof(" + portStructType + "*),",
" &" + reactorSelfStruct + "->base.allocations); "));

Expand Down Expand Up @@ -1071,11 +1071,11 @@ private static String deferredAllocationForEffectsOnInputs(ReactorInstance react
effectRef + "_width = " + effect.getWidth() + ";",
"// Allocate memory to store output of reaction feeding ",
"// a multiport input of a contained reactor.",
effectRef + " = (" + portStructType + "**)_lf_allocate(",
effectRef + " = (" + portStructType + "**)lf_allocate(",
" " + effect.getWidth() + ", sizeof(" + portStructType + "*),",
" &" + reactorSelfStruct + "->base.allocations); ",
"for (int i = 0; i < " + effect.getWidth() + "; i++) {",
" " + effectRef + "[i] = (" + portStructType + "*)_lf_allocate(",
" " + effectRef + "[i] = (" + portStructType + "*)lf_allocate(",
" 1, sizeof(" + portStructType + "),",
" &" + reactorSelfStruct + "->base.allocations); ",
"}"));
Expand Down
Loading