Skip to content

Commit

Permalink
[NF] Reuse pointer when redeclaring component.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Mar 6, 2019
1 parent 1cc697e commit a0d3cc1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Compiler/NFFrontEnd/NFInst.mo
Expand Up @@ -1480,10 +1480,12 @@ algorithm
fail();
end if;

orig_comp := InstNode.component(originalNode);
rdcl_type := InstNodeType.REDECLARED_COMP(InstNode.parent(originalNode));
rdcl_node := InstNode.setNodeType(rdcl_type, redeclareNode);
rdcl_node := InstNode.copyInstancePtr(originalNode, rdcl_node);
rdcl_node := InstNode.updateComponent(InstNode.component(redeclareNode), rdcl_node);
instComponent(rdcl_node, outerAttr, constrainingMod, true);
orig_comp := InstNode.component(originalNode);
rdcl_comp := InstNode.component(rdcl_node);

new_comp := match (orig_comp, rdcl_comp)
Expand Down
20 changes: 20 additions & 0 deletions Compiler/NFFrontEnd/NFInstNode.mo
Expand Up @@ -1552,6 +1552,26 @@ uniontype InstNode
else accumCmts;
end match;
end getComments;

function copyInstancePtr
input InstNode srcNode;
input output InstNode dstNode;
algorithm
() := match (srcNode, dstNode)
case (COMPONENT_NODE(), COMPONENT_NODE())
algorithm
dstNode.component := srcNode.component;
then
();

case (CLASS_NODE(), CLASS_NODE())
algorithm
dstNode.cls := srcNode.cls;
then
();

end match;
end copyInstancePtr;
end InstNode;

annotation(__OpenModelica_Interface="frontend");
Expand Down

0 comments on commit a0d3cc1

Please sign in to comment.