Skip to content

Commit

Permalink
[NB] correctly lower array records (#10686)
Browse files Browse the repository at this point in the history
  • Loading branch information
kabdelhak committed May 12, 2023
1 parent 997b5e0 commit 9d08b82
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions OMCompiler/Compiler/NBackEnd/Classes/NBackendDAE.mo
Expand Up @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions OMCompiler/Compiler/NFFrontEnd/NFType.mo
Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions OMCompiler/Compiler/NFFrontEnd/NFVariable.mo
Expand Up @@ -186,17 +186,21 @@ public
input Variable var;
output list<Variable> 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
input Variable var;
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 =
Expand Down

0 comments on commit 9d08b82

Please sign in to comment.