Skip to content

Commit

Permalink
[NF] Set correct restriction for complex types.
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#2351
  • Loading branch information
perost authored and OpenModelica-Hudson committed Apr 10, 2018
1 parent bd785a4 commit 65d57a5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
9 changes: 5 additions & 4 deletions Compiler/NFFrontEnd/NFInstNode.mo
Expand Up @@ -48,6 +48,7 @@ import DAE;
protected
import List;
import ConvertDAE = NFConvertDAE;
import Restriction = NFRestriction;

public
uniontype InstNodeType
Expand Down Expand Up @@ -1233,10 +1234,10 @@ uniontype InstNode
case Class.DAE_TYPE() then cls.ty;
else
algorithm
// TODO: Use proper ClassInf.State here.
outType := DAE.Type.T_COMPLEX(ClassInf.MODEL(scopePath(clsNode)),
ConvertDAE.makeTypesVars(clsNode),
NONE());
outType := DAE.Type.T_COMPLEX(
Restriction.toDAE(Class.restriction(cls), scopePath(clsNode)),
ConvertDAE.makeTypesVars(clsNode),
NONE());
Pointer.update(clsNode.cls, Class.DAE_TYPE(outType));
then
outType;
Expand Down
20 changes: 20 additions & 0 deletions Compiler/NFFrontEnd/NFRestriction.mo
Expand Up @@ -31,6 +31,7 @@

encapsulated uniontype NFRestriction
import NFInstNode.InstNode;
import ClassInf;

protected
import Restriction = NFRestriction;
Expand Down Expand Up @@ -68,6 +69,25 @@ public
end match;
end fromSCode;

function toDAE
input Restriction res;
input Absyn.Path path;
output ClassInf.State state;
algorithm
state := match res
case CLASS() then ClassInf.State.UNKNOWN(path);
case CONNECTOR() then ClassInf.State.CONNECTOR(path, res.isExpandable);
case ENUMERATION() then ClassInf.State.ENUMERATION(path);
case EXTERNAL_OBJECT() then ClassInf.State.EXTERNAL_OBJ(path);
case FUNCTION() then ClassInf.State.FUNCTION(path, false);
case MODEL() then ClassInf.State.MODEL(path);
case OPERATOR() then ClassInf.State.FUNCTION(path, false);
case RECORD() then ClassInf.State.RECORD(path);
case TYPE() then ClassInf.State.TYPE(path);
else ClassInf.State.UNKNOWN(path);
end match;
end toDAE;

function isConnector
input Restriction res;
output Boolean isConnector;
Expand Down
9 changes: 6 additions & 3 deletions Compiler/NFFrontEnd/NFTyping.mo
Expand Up @@ -1390,9 +1390,6 @@ algorithm
list<Subscript> subs;
Variability subs_var, rest_var;

case ComponentRef.CREF(origin = Origin.SCOPE)
then (cref, Variability.CONSTANT);

case ComponentRef.CREF(node = InstNode.COMPONENT_NODE())
algorithm
node_ty := typeComponent(cref.node, origin);
Expand All @@ -1402,6 +1399,12 @@ algorithm
then
(ComponentRef.CREF(cref.node, subs, node_ty, cref.origin, rest_cr), subsVariability);

case ComponentRef.CREF(node = InstNode.CLASS_NODE())
algorithm
cref.ty := InstNode.getType(cref.node);
then
(cref, Variability.CONSTANT);

else (cref, Variability.CONSTANT);
end match;
end typeCref2;
Expand Down

0 comments on commit 65d57a5

Please sign in to comment.