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

Commit a0d3cc1

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Reuse pointer when redeclaring component.
Belonging to [master]: - #2967 - OpenModelica/OpenModelica-testsuite#1133
1 parent 1cc697e commit a0d3cc1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Compiler/NFFrontEnd/NFInst.mo

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,10 +1480,12 @@ algorithm
14801480
fail();
14811481
end if;
14821482

1483+
orig_comp := InstNode.component(originalNode);
14831484
rdcl_type := InstNodeType.REDECLARED_COMP(InstNode.parent(originalNode));
14841485
rdcl_node := InstNode.setNodeType(rdcl_type, redeclareNode);
1486+
rdcl_node := InstNode.copyInstancePtr(originalNode, rdcl_node);
1487+
rdcl_node := InstNode.updateComponent(InstNode.component(redeclareNode), rdcl_node);
14851488
instComponent(rdcl_node, outerAttr, constrainingMod, true);
1486-
orig_comp := InstNode.component(originalNode);
14871489
rdcl_comp := InstNode.component(rdcl_node);
14881490

14891491
new_comp := match (orig_comp, rdcl_comp)

Compiler/NFFrontEnd/NFInstNode.mo

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,26 @@ uniontype InstNode
15521552
else accumCmts;
15531553
end match;
15541554
end getComments;
1555+
1556+
function copyInstancePtr
1557+
input InstNode srcNode;
1558+
input output InstNode dstNode;
1559+
algorithm
1560+
() := match (srcNode, dstNode)
1561+
case (COMPONENT_NODE(), COMPONENT_NODE())
1562+
algorithm
1563+
dstNode.component := srcNode.component;
1564+
then
1565+
();
1566+
1567+
case (CLASS_NODE(), CLASS_NODE())
1568+
algorithm
1569+
dstNode.cls := srcNode.cls;
1570+
then
1571+
();
1572+
1573+
end match;
1574+
end copyInstancePtr;
15551575
end InstNode;
15561576

15571577
annotation(__OpenModelica_Interface="frontend");

0 commit comments

Comments
 (0)