From 08762b6631ed812ebbaac5c62cd077c070f3978b Mon Sep 17 00:00:00 2001 From: erlingrj Date: Wed, 25 Sep 2024 07:56:01 -0700 Subject: [PATCH] Trial and error... --- .../org/lflang/generator/c/CGenerator.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) 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 ac3dd54c42..30ffe08bec 100644 --- a/core/src/main/java/org/lflang/generator/c/CGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CGenerator.java @@ -1375,10 +1375,6 @@ private void recordBuiltinTriggers(ReactorInstance instance) { } } - /** - * Generate code to set up the tables used in _lf_start_time_step to decrement reference counts - * and mark outputs absent between time steps. This function puts the code into startTimeStep. - */ /** * Generate code to set up the tables used in _lf_start_time_step to decrement reference counts * and mark outputs absent between time steps. This function puts the code into startTimeStep. @@ -1465,11 +1461,17 @@ private void generateStartTimeStep(ReactorInstance instance) { for (ActionInstance action : instance.actions) { foundOne = true; + temp.startScopedBlock(); + temp.pr("int count = 0; SUPPRESS_UNUSED_WARNING(count);"); + temp.startScopedBlock(instance); temp.pr( String.join( "\n", "// Add action " + action.getFullName() + " to array of is_present fields.", - enclaveStruct + ".is_present_fields[" + CUtil.bankIndex(instance) + " + " + enclaveInfo.numIsPresentFields + "] ", + enclaveStruct + + ".is_present_fields[" + + enclaveInfo.numIsPresentFields + + " + count] ", " = (bool *) &" + containerSelfStructName + "->_lf__" @@ -1485,17 +1487,18 @@ private void generateStartTimeStep(ReactorInstance instance) { "// Add action " + action.getFullName() + " to array of intended_tag fields.", enclaveStruct + "._lf_intended_tag_fields[" - + CUtil.bankIndex(instance) - + " + " + enclaveInfo.numIsPresentFields - + "]", + + " + count]", " = &" + containerSelfStructName + "->_lf_" + action.getName() + ".intended_tag;"))); - enclaveInfo.numIsPresentFields += action.getParent().getTotalWidth(); + temp.pr("count++;"); + temp.endScopedBlock(); + temp.endScopedBlock(); + enclaveInfo.numIsPresentFields += action.getParent().getTotalWidth(); } if (foundOne) startTimeStep.pr(temp.toString()); temp = new CodeBuilder(); @@ -1518,8 +1521,6 @@ private void generateStartTimeStep(ReactorInstance instance) { temp.pr( enclaveStruct + ".is_present_fields[" - + CUtil.bankIndex(instance) - + " + " + enclaveInfo.numIsPresentFields + " + count] = &" + CUtil.portRef(output) @@ -1534,8 +1535,6 @@ private void generateStartTimeStep(ReactorInstance instance) { "// Add port " + output.getFullName() + " to array of intended_tag fields.", enclaveStruct + "._lf_intended_tag_fields[" - + CUtil.bankIndex(instance) - + " + " + enclaveInfo.numIsPresentFields + " + count] = &" + CUtil.portRef(output)