Skip to content

Commit

Permalink
[NF] Fix flattening of bindings.
Browse files Browse the repository at this point in the history
- Use flattenExp when flattening bindings, so any crefs in the binding
  gets the correct subscripts.

Belonging to [master]:
  - OpenModelica/OMCompiler#2455
  - OpenModelica/OpenModelica-testsuite#957
  • Loading branch information
perost authored and OpenModelica-Hudson committed May 22, 2018
1 parent 4f6e4cd commit 2d96bc2
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Compiler/NFFrontEnd/NFFlatten.mo
Expand Up @@ -454,15 +454,12 @@ algorithm

case Binding.TYPED_BINDING()
algorithm
bind_exp := binding.bindingExp;
pars := listRest(binding.parents);

// TODO: Optimize this, making a list of all subscripts in the prefix
// when only a few are needed is unnecessary.
if not binding.isEach then
pars := listRest(binding.parents);

if listEmpty(pars) then
return;
end if;

if not (binding.isEach or listEmpty(pars)) then
if isTypeAttribute then
pars := listRest(pars);
end if;
Expand All @@ -473,7 +470,6 @@ algorithm
end for;

if binding_level > 0 then
bind_exp := binding.bindingExp;
subs := listAppend(listReverse(s) for s in ComponentRef.subscriptsAll(prefix));
accum_subs := {};

Expand All @@ -487,9 +483,10 @@ algorithm
end for;

bind_exp := Expression.applySubscripts(accum_subs, bind_exp);
binding.bindingExp := bind_exp;
end if;
end if;

binding.bindingExp := flattenExp(bind_exp, prefix);
then
binding;

Expand Down

0 comments on commit 2d96bc2

Please sign in to comment.