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

some fixes to variable lowering (ticket:5148) #2742

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Compiler/BackEnd/BackendDAECreate.mo
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ algorithm
comment = comment,
innerOuter = io)
equation
kind_1 = lowerKnownVarkind(kind, name, dir, ct);
kind_1 = lowerKnownVarkind(kind, t, name, dir, ct);
// bind = fixParameterStartBinding(bind, t, dae_var_attr, kind_1);
tp = lowerType(t);
b = DAEUtil.boolVarVisibility(protection);
Expand Down Expand Up @@ -1094,6 +1094,7 @@ algorithm
match (inVarKind, inType)
case (DAE.VARIABLE(), DAE.T_BOOL()) then BackendDAE.DISCRETE();
case (DAE.VARIABLE(), DAE.T_INTEGER()) then BackendDAE.DISCRETE();
case (DAE.VARIABLE(), DAE.T_STRING()) then BackendDAE.DISCRETE();
case (DAE.VARIABLE(), DAE.T_ENUMERATION()) then BackendDAE.DISCRETE();
case (DAE.VARIABLE(), _) then BackendDAE.VARIABLE();
case (DAE.DISCRETE(), _) then BackendDAE.DISCRETE();
Expand All @@ -1105,6 +1106,7 @@ protected function lowerKnownVarkind
"Helper function to lowerKnownVar.
NOTE: Fails for everything but parameters and constants and top level inputs"
input DAE.VarKind inVarKind;
input DAE.Type inType;
input DAE.ComponentRef inComponentRef;
input DAE.VarDirection inVarDirection;
input DAE.ConnectorType inConnectorType;
Expand All @@ -1118,7 +1120,15 @@ algorithm
equation
true = DAEUtil.topLevelInput(inComponentRef, inVarDirection, inConnectorType);
then
BackendDAE.VARIABLE();
match (inVarKind, inType)
case (DAE.VARIABLE(), DAE.T_BOOL()) then BackendDAE.DISCRETE();
case (DAE.VARIABLE(), DAE.T_INTEGER()) then BackendDAE.DISCRETE();
case (DAE.VARIABLE(), DAE.T_STRING()) then BackendDAE.DISCRETE();
case (DAE.VARIABLE(), DAE.T_ENUMERATION()) then BackendDAE.DISCRETE();
case (DAE.VARIABLE(), _) then BackendDAE.VARIABLE();
case (DAE.DISCRETE(), _) then BackendDAE.DISCRETE();
end match;

// adrpo: topLevelInput might fail!
// case (DAE.VARIABLE(), cr, dir, flowPrefix)
// then
Expand Down