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

Commit 7ad3a17

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Make record constructors work again.
Belonging to [master]: - #2506
1 parent dc81059 commit 7ad3a17

File tree

1 file changed

+37
-25
lines changed

1 file changed

+37
-25
lines changed

Compiler/NFFrontEnd/NFInst.mo

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ algorithm
18091809
inst_cls := Class.INSTANCED_CLASS(ty, cls.elements, sections, cls.restriction);
18101810
InstNode.updateClass(inst_cls, node);
18111811

1812-
instRecordConstructor(cls.restriction, node);
1812+
instComplexType(ty);
18131813
then
18141814
();
18151815

@@ -1824,7 +1824,9 @@ algorithm
18241824
dims[i] := instDimension(dims[i], dim_scope, info);
18251825
end for;
18261826

1827-
instRecordConstructor(cls.restriction, node);
1827+
if Restriction.isRecord(cls.restriction) then
1828+
instRecordConstructor(node);
1829+
end if;
18281830
then
18291831
();
18301832

@@ -1872,44 +1874,54 @@ protected
18721874
InstNode cls_node;
18731875
list<String> fields;
18741876
algorithm
1875-
cls_node := InstNode.classScope(InstNode.getDerivedNode(node));
1877+
cls_node := if SCode.isOperatorRecord(InstNode.definition(node))
1878+
then InstNode.classScope(node) else InstNode.classScope(InstNode.getDerivedNode(node));
18761879
fields := list(InstNode.name(c) for c guard not InstNode.isEmpty(c) in
18771880
ClassTree.getComponents(Class.classTree(cls)));
18781881
ty := ComplexType.RECORD(cls_node, fields);
18791882
end makeRecordComplexType;
18801883

1884+
function instComplexType
1885+
input Type ty;
1886+
algorithm
1887+
() := match ty
1888+
local
1889+
InstNode node;
1890+
CachedData cache;
1891+
1892+
case Type.COMPLEX(complexTy = ComplexType.RECORD(node))
1893+
algorithm
1894+
instRecordConstructor(node);
1895+
then
1896+
();
1897+
1898+
else ();
1899+
end match;
1900+
end instComplexType;
1901+
18811902
function instRecordConstructor
1882-
input Restriction restriction;
18831903
input InstNode node;
18841904
protected
18851905
CachedData cache;
1886-
Absyn.Path path;
18871906
algorithm
1888-
() := match restriction
1889-
case Restriction.RECORD()
1890-
algorithm
1891-
cache := InstNode.getFuncCache(node);
1907+
cache := InstNode.getFuncCache(node);
18921908

1893-
() := match cache
1894-
case CachedData.FUNCTION() then ();
1895-
else
1896-
algorithm
1897-
InstNode.cacheInitFunc(node);
1898-
path := InstNode.scopePath(node, includeRoot = true);
1899-
1900-
if SCode.isOperatorRecord(InstNode.definition(node)) then
1901-
OperatorOverloading.instConstructor(path, node, InstNode.info(node));
1902-
else
1903-
Record.instDefaultConstructor(path, node, InstNode.info(node));
1904-
end if;
1905-
then
1906-
();
1909+
() := match cache
1910+
case CachedData.FUNCTION() then ();
1911+
else
1912+
algorithm
1913+
InstNode.cacheInitFunc(node);
19071914

1908-
end match;
1915+
if SCode.isOperatorRecord(InstNode.definition(node)) then
1916+
OperatorOverloading.instConstructor(
1917+
InstNode.scopePath(node, includeRoot = true), node, InstNode.info(node));
1918+
else
1919+
Record.instDefaultConstructor(
1920+
InstNode.scopePath(node, includeRoot = true), node, InstNode.info(node));
1921+
end if;
19091922
then
19101923
();
19111924

1912-
else ();
19131925
end match;
19141926
end instRecordConstructor;
19151927

0 commit comments

Comments
 (0)