From fb3f6d42a6b503a020b67000910cce2c12e5e041 Mon Sep 17 00:00:00 2001 From: kabdelhak <38032125+kabdelhak@users.noreply.github.com> Date: Mon, 29 Jan 2024 11:34:34 +0100 Subject: [PATCH] [NB] update function alias in when and if (#11896) * [NB] update function alias in when and if - for now skip function alias creation inside when and if - future plans: collect conditions and create them * [testsuite] model runs by hand but not on server - the model CombiTimeTable.mos runs and verifies if executed by hand, but not using rtest. are dependencies missing? --- .../NBackEnd/Modules/2_Pre/NBFunctionAlias.mo | 22 +++++++++++++++---- .../NBackend/ScalableTestsuite/Makefile | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBFunctionAlias.mo b/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBFunctionAlias.mo index 012fecfbd8d..4455ccfacc0 100644 --- a/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBFunctionAlias.mo +++ b/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBFunctionAlias.mo @@ -119,6 +119,12 @@ protected record CALL_ID Expression call; Iterator iter; + // ToDo: instead of skipping when and if, one could collect these conditions + // and create the function call equations with them. + // Note: update hashing, isEqual and take into account that there can be + // elseif/elsewhen which need to be chained + // Option when_condition + // Option if_condition end CALL_ID; function toString @@ -316,12 +322,20 @@ protected input Boolean init; protected Iterator iter; + Boolean stop; algorithm - iter := match eq - case Equation.FOR_EQUATION() then eq.iter; - else Iterator.EMPTY(); + (iter, stop) := match eq + local + Equation body; + case Equation.FOR_EQUATION(body = {body}) then (eq.iter, Equation.isWhenEquation(Pointer.create(body)) + or Equation.isIfEquation(Pointer.create(body))); + case Equation.WHEN_EQUATION() then (Iterator.EMPTY(), true); + case Equation.IF_EQUATION() then (Iterator.EMPTY(), true); + else (Iterator.EMPTY(), false); end match; - eq := Equation.map(eq, function introduceFunctionAlias(map = map, index = index, iter = iter, init = init)); + if not stop then + eq := Equation.map(eq, function introduceFunctionAlias(map = map, index = index, iter = iter, init = init)); + end if; end introduceFunctionAliasEquation; function introduceFunctionAlias diff --git a/testsuite/simulation/modelica/NBackend/ScalableTestsuite/Makefile b/testsuite/simulation/modelica/NBackend/ScalableTestsuite/Makefile index 5a6d24322fa..6fbe2d10a96 100644 --- a/testsuite/simulation/modelica/NBackend/ScalableTestsuite/Makefile +++ b/testsuite/simulation/modelica/NBackend/ScalableTestsuite/Makefile @@ -29,6 +29,7 @@ SimpleAdvection.mos \ FAILINGTESTFILES = \ CombiTimeTable.mos \ TransmissionLineEquations.mos \ +CombiTimeTable.mos \ # Dependency files that are not .mo .mos or Makefile # Add them here or they will be cleaned.