Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
fix ticket:5249
Browse files Browse the repository at this point in the history
- add a flag to typed binding to signal if it was flattened
- do not flatten again already flattened typed binding

Belonging to [master]:
  - #2836
  - OpenModelica/OpenModelica-testsuite#1094
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Dec 14, 2018
1 parent 83d5105 commit 7a31ea6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Compiler/NFFrontEnd/NFBinding.mo
Expand Up @@ -80,6 +80,7 @@ uniontype Binding
list<InstNode> parents;
Boolean isEach;
Boolean evaluated;
Boolean isFlattened;
SourceInfo info;
end TYPED_BINDING;

Expand Down Expand Up @@ -193,6 +194,8 @@ public
function setTypedExp
input Expression exp;
input output Binding binding;
protected
Type ty1, ty2;
algorithm
() := match binding
case TYPED_BINDING()
Expand Down Expand Up @@ -278,7 +281,7 @@ public
ty := Expression.typeOf(exp);
var := Expression.variability(exp);
then
TYPED_BINDING(exp, ty, var, fieldBinding.parents, fieldBinding.isEach, fieldBinding.evaluated, fieldBinding.info);
TYPED_BINDING(exp, ty, var, fieldBinding.parents, fieldBinding.isEach, fieldBinding.evaluated, fieldBinding.isFlattened, fieldBinding.info);

case FLAT_BINDING()
algorithm
Expand Down
4 changes: 4 additions & 0 deletions Compiler/NFFrontEnd/NFFlatten.mo
Expand Up @@ -762,6 +762,9 @@ algorithm

case Binding.TYPED_BINDING()
algorithm
if binding.isFlattened then
return;
end if;
bind_exp := binding.bindingExp;
pars := listRest(binding.parents);

Expand Down Expand Up @@ -795,6 +798,7 @@ algorithm
end if;

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

Expand Down
2 changes: 1 addition & 1 deletion Compiler/NFFrontEnd/NFTypeCheck.mo
Expand Up @@ -2616,7 +2616,7 @@ algorithm
Type.toString(binding.bindingType)}, {Binding.getInfo(binding), InstNode.info(component)});
fail();
elseif isCastMatch(ty_match) then
binding := Binding.TYPED_BINDING(exp, ty, binding.variability, binding.parents, binding.isEach, binding.evaluated, binding.info);
binding := Binding.TYPED_BINDING(exp, ty, binding.variability, binding.parents, binding.isEach, binding.evaluated, binding.isFlattened, binding.info);
end if;
then
();
Expand Down
4 changes: 2 additions & 2 deletions Compiler/NFFrontEnd/NFTyping.mo
Expand Up @@ -866,7 +866,7 @@ algorithm
info := Binding.getInfo(binding);
(exp, ty, var) := typeExp(exp, origin, info);
then
Binding.TYPED_BINDING(exp, ty, var, binding.parents, binding.isEach, false, binding.info);
Binding.TYPED_BINDING(exp, ty, var, binding.parents, binding.isEach, false, false, binding.info);

case Binding.TYPED_BINDING() then binding;
case Binding.UNBOUND() then binding;
Expand Down Expand Up @@ -929,7 +929,7 @@ algorithm
fail();
end if;
then
Binding.TYPED_BINDING(exp, ty, var, condition.parents, false, false, info);
Binding.TYPED_BINDING(exp, ty, var, condition.parents, false, false, false, info);

end match;
end typeComponentCondition;
Expand Down

0 comments on commit 7a31ea6

Please sign in to comment.