Skip to content

Commit

Permalink
[NF] Improve evaluation of record fields.
Browse files Browse the repository at this point in the history
- Change the check in Ceval.evalCref that checked that the cref had a
  cref origin to instead check that it doesn't have an iterator origin.
  The cref might have a scope origin when evaluating the parent of a
  record field, and the intent was only to make sure that iterators are
  not evaluated by mistake.
- Add a flag to Typing.typeComponentBinding to make it possible to skip
  typing the component's children, otherwise we might get loops when
  calling it from Ceval.evalComponentBinding.

Belonging to [master]:
  - OpenModelica/OMCompiler#2817
  • Loading branch information
perost authored and OpenModelica-Hudson committed Dec 6, 2018
1 parent 8ffc95a commit 9fc7ba2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Compiler/NFFrontEnd/NFCeval.mo
Expand Up @@ -325,8 +325,8 @@ protected
list<Subscript> subs;
algorithm
exp := match cref
case ComponentRef.CREF(node = c as InstNode.COMPONENT_NODE(),
origin = NFComponentRef.Origin.CREF)
case ComponentRef.CREF(node = c as InstNode.COMPONENT_NODE())
guard not ComponentRef.isIterator(cref)
then evalComponentBinding(c, cref, defaultExp, target, evalSubscripts);

else defaultExp;
Expand All @@ -353,7 +353,7 @@ algorithm
exp_origin := if InstNode.isFunction(InstNode.explicitParent(node))
then ExpOrigin.FUNCTION else ExpOrigin.CLASS;

Typing.typeComponentBinding(node, exp_origin);
Typing.typeComponentBinding(node, exp_origin, typeChildren = false);
comp := InstNode.component(node);
binding := Component.getBinding(comp);

Expand Down
10 changes: 8 additions & 2 deletions Compiler/NFFrontEnd/NFTyping.mo
Expand Up @@ -753,6 +753,7 @@ end typeBindings;
function typeComponentBinding
input InstNode component;
input ExpOrigin.Type origin;
input Boolean typeChildren = true;
protected
InstNode node = InstNode.resolveOuter(component);
Component c;
Expand Down Expand Up @@ -807,7 +808,10 @@ algorithm
end if;

InstNode.updateComponent(c, node);
typeBindings(c.classInst, component, origin);

if typeChildren then
typeBindings(c.classInst, component, origin);
end if;
then
();

Expand All @@ -821,7 +825,9 @@ algorithm
InstNode.updateComponent(c, node);
end if;

typeBindings(c.classInst, component, origin);
if typeChildren then
typeBindings(c.classInst, component, origin);
end if;
then
();

Expand Down

0 comments on commit 9fc7ba2

Please sign in to comment.