From 9d08b8228bfb5b449b9643d6f3d016c59b6b908c Mon Sep 17 00:00:00 2001 From: kabdelhak <38032125+kabdelhak@users.noreply.github.com> Date: Fri, 12 May 2023 12:04:47 +0200 Subject: [PATCH] [NB] correctly lower array records (#10686) --- OMCompiler/Compiler/NBackEnd/Classes/NBackendDAE.mo | 1 + OMCompiler/Compiler/NFFrontEnd/NFType.mo | 11 +++++++++++ OMCompiler/Compiler/NFFrontEnd/NFVariable.mo | 10 +++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/OMCompiler/Compiler/NBackEnd/Classes/NBackendDAE.mo b/OMCompiler/Compiler/NBackEnd/Classes/NBackendDAE.mo index ed58c34e778..17c500ee550 100644 --- a/OMCompiler/Compiler/NBackEnd/Classes/NBackendDAE.mo +++ b/OMCompiler/Compiler/NBackEnd/Classes/NBackendDAE.mo @@ -539,6 +539,7 @@ protected // add children pointers for records afterwards case (_, _, Type.COMPLEX()) then BackendExtension.RECORD({}); + case (_, _, _) guard(Type.isComplexArray(ty)) then BackendExtension.RECORD({}); case (NFPrefixes.Variability.CONTINUOUS, _, Type.BOOLEAN()) then BackendExtension.DISCRETE(); case (NFPrefixes.Variability.CONTINUOUS, _, Type.INTEGER()) then BackendExtension.DISCRETE(); diff --git a/OMCompiler/Compiler/NFFrontEnd/NFType.mo b/OMCompiler/Compiler/NFFrontEnd/NFType.mo index ea1aecca239..e41bc1c1dd0 100644 --- a/OMCompiler/Compiler/NFFrontEnd/NFType.mo +++ b/OMCompiler/Compiler/NFFrontEnd/NFType.mo @@ -462,6 +462,17 @@ public end match; end isComplex; + function isComplexArray + input Type ty; + output Boolean isComplex; + algorithm + isComplex := match ty + case ARRAY() guard(isComplex(ty.elementType)) then true; + case ARRAY() then isComplexArray(ty.elementType); + else false; + end match; + end isComplexArray; + function complexNode input Type ty; output InstNode node; diff --git a/OMCompiler/Compiler/NFFrontEnd/NFVariable.mo b/OMCompiler/Compiler/NFFrontEnd/NFVariable.mo index e67935bf8a0..4dc4ff3ce5d 100644 --- a/OMCompiler/Compiler/NFFrontEnd/NFVariable.mo +++ b/OMCompiler/Compiler/NFFrontEnd/NFVariable.mo @@ -186,10 +186,9 @@ public input Variable var; output list children; algorithm - children := match var.ty - case Type.COMPLEX() then var :: List.flatten(list(expandChildren(v) for v in var.children)); + children := if (isComplex(var) or isComplexArray(var)) + then var :: List.flatten(list(expandChildren(v) for v in var.children)) else {var}; - end match; end expandChildren; function isComplex @@ -197,6 +196,11 @@ public output Boolean b = Type.isComplex(var.ty); end isComplex; + function isComplexArray + input Variable var; + output Boolean b = Type.isComplexArray(var.ty); + end isComplexArray; + function isStructural input Variable variable; output Boolean structural =