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

Commit 65d57a5

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Set correct restriction for complex types.
Belonging to [master]: - #2351
1 parent bd785a4 commit 65d57a5

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

Compiler/NFFrontEnd/NFInstNode.mo

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import DAE;
4848
protected
4949
import List;
5050
import ConvertDAE = NFConvertDAE;
51+
import Restriction = NFRestriction;
5152

5253
public
5354
uniontype InstNodeType
@@ -1233,10 +1234,10 @@ uniontype InstNode
12331234
case Class.DAE_TYPE() then cls.ty;
12341235
else
12351236
algorithm
1236-
// TODO: Use proper ClassInf.State here.
1237-
outType := DAE.Type.T_COMPLEX(ClassInf.MODEL(scopePath(clsNode)),
1238-
ConvertDAE.makeTypesVars(clsNode),
1239-
NONE());
1237+
outType := DAE.Type.T_COMPLEX(
1238+
Restriction.toDAE(Class.restriction(cls), scopePath(clsNode)),
1239+
ConvertDAE.makeTypesVars(clsNode),
1240+
NONE());
12401241
Pointer.update(clsNode.cls, Class.DAE_TYPE(outType));
12411242
then
12421243
outType;

Compiler/NFFrontEnd/NFRestriction.mo

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
encapsulated uniontype NFRestriction
3333
import NFInstNode.InstNode;
34+
import ClassInf;
3435

3536
protected
3637
import Restriction = NFRestriction;
@@ -68,6 +69,25 @@ public
6869
end match;
6970
end fromSCode;
7071

72+
function toDAE
73+
input Restriction res;
74+
input Absyn.Path path;
75+
output ClassInf.State state;
76+
algorithm
77+
state := match res
78+
case CLASS() then ClassInf.State.UNKNOWN(path);
79+
case CONNECTOR() then ClassInf.State.CONNECTOR(path, res.isExpandable);
80+
case ENUMERATION() then ClassInf.State.ENUMERATION(path);
81+
case EXTERNAL_OBJECT() then ClassInf.State.EXTERNAL_OBJ(path);
82+
case FUNCTION() then ClassInf.State.FUNCTION(path, false);
83+
case MODEL() then ClassInf.State.MODEL(path);
84+
case OPERATOR() then ClassInf.State.FUNCTION(path, false);
85+
case RECORD() then ClassInf.State.RECORD(path);
86+
case TYPE() then ClassInf.State.TYPE(path);
87+
else ClassInf.State.UNKNOWN(path);
88+
end match;
89+
end toDAE;
90+
7191
function isConnector
7292
input Restriction res;
7393
output Boolean isConnector;

Compiler/NFFrontEnd/NFTyping.mo

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,9 +1390,6 @@ algorithm
13901390
list<Subscript> subs;
13911391
Variability subs_var, rest_var;
13921392

1393-
case ComponentRef.CREF(origin = Origin.SCOPE)
1394-
then (cref, Variability.CONSTANT);
1395-
13961393
case ComponentRef.CREF(node = InstNode.COMPONENT_NODE())
13971394
algorithm
13981395
node_ty := typeComponent(cref.node, origin);
@@ -1402,6 +1399,12 @@ algorithm
14021399
then
14031400
(ComponentRef.CREF(cref.node, subs, node_ty, cref.origin, rest_cr), subsVariability);
14041401

1402+
case ComponentRef.CREF(node = InstNode.CLASS_NODE())
1403+
algorithm
1404+
cref.ty := InstNode.getType(cref.node);
1405+
then
1406+
(cref, Variability.CONSTANT);
1407+
14051408
else (cref, Variability.CONSTANT);
14061409
end match;
14071410
end typeCref2;

0 commit comments

Comments
 (0)