Skip to content

Commit

Permalink
Improved handling of non-scalarized bindings (#9685)
Browse files Browse the repository at this point in the history
- Introduce the concept of an indexed prefix that can be used to flatten
  and vectorize non-scalarized bindings where they occur, instead of
  delaying it until `Flatten.vectorizeArray` where we don't know the
  correct prefix for each variable.
- Fix various minor issues with the non-scalarized flattening.
  • Loading branch information
perost committed Nov 10, 2022
1 parent 2c2d711 commit acb73a1
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 101 deletions.
1 change: 1 addition & 0 deletions OMCompiler/Compiler/NFFrontEnd/NFCeval.mo
Expand Up @@ -334,6 +334,7 @@ algorithm
else
// Crefs can be evaluated even if they have non-evaluated subscripts.
outExp := evalCref(e.cref, e, target, evalSubscripts = false);
outEvaluated := Expression.isLiteral(outExp);
end if;
then
outExp;
Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFConvertDAE.mo
Expand Up @@ -1288,7 +1288,7 @@ algorithm

binding := Component.getBinding(comp);
binding := Binding.mapExp(binding, stripScopePrefixExp);
binding := Flatten.flattenBinding(binding, ComponentRef.EMPTY());
binding := Flatten.flattenBinding(binding, NFFlatten.EMPTY_PREFIX);
bind_from_outside := Binding.source(binding) == NFBinding.Source.MODIFIER;

ty := Component.getType(comp);
Expand Down
4 changes: 2 additions & 2 deletions OMCompiler/Compiler/NFFrontEnd/NFEvalConstants.mo
Expand Up @@ -110,7 +110,7 @@ algorithm
eexp := Ceval.evalExp(exp, Ceval.EvalTarget.ATTRIBUTE(binding));
end if;

eexp := Flatten.flattenExp(eexp, prefix);
eexp := Flatten.flattenExp(eexp, Flatten.PREFIX(prefix));
else
info := Binding.getInfo(binding);
eexp := evaluateExp(exp, info);
Expand Down Expand Up @@ -183,7 +183,7 @@ algorithm
if ComponentRef.nodeVariability(cref) <= Variability.STRUCTURAL_PARAMETER then
// Evaluate all constants and structural parameters.
outExp := Ceval.evalCref(cref, outExp, Ceval.EvalTarget.IGNORE_ERRORS(), evalSubscripts = false);
outExp := Flatten.flattenExp(outExp, cref);
outExp := Flatten.flattenExp(outExp, Flatten.Prefix.PREFIX(cref));
outChanged := true;
elseif outChanged then
ty := ComponentRef.getSubscriptedType(cref);
Expand Down

0 comments on commit acb73a1

Please sign in to comment.