Skip to content

Commit

Permalink
- rewrite some set functions
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12312 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jul 9, 2012
1 parent 8b7c5e5 commit 58657c1
Showing 1 changed file with 134 additions and 122 deletions.
256 changes: 134 additions & 122 deletions Compiler/BackEnd/BackendVariable.mo
Expand Up @@ -176,26 +176,7 @@ algorithm
varKind = b,
varDirection = c,
varParallelism = prl,
varType = DAE.T_REAL(source = _),
bindExp = e,
bindValue = f,
arryDim = g,
index = i,
source = source,
values = NONE(),
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),fixed)
then
BackendDAE.VAR(a,b,c,prl,DAE.T_REAL_DEFAULT,e,f,g,i,source,
SOME(DAE.VAR_ATTR_REAL(NONE(),NONE(),NONE(),(NONE(),NONE()),NONE(),SOME(DAE.BCONST(fixed)),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE())),
s,t,streamPrefix);

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
varParallelism = prl,
varType = DAE.T_INTEGER(source = _),
varType = d,
bindExp = e,
bindValue = f,
arryDim = g,
Expand All @@ -205,48 +186,12 @@ algorithm
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),fixed)
then
BackendDAE.VAR(a,b,c,prl,DAE.T_REAL_DEFAULT,e,f,g,i,source,
SOME(DAE.VAR_ATTR_INT(NONE(),(NONE(),NONE()),NONE(),SOME(DAE.BCONST(fixed)),NONE(),NONE(),NONE(),NONE(),NONE())),
s,t,streamPrefix);
equation
attr = getVariableAttributefromType(d);
oattr = DAEUtil.setFixedAttr(SOME(attr),SOME(DAE.BCONST(fixed)));
then BackendDAE.VAR(a,b,c,prl,d,e,f,g,i,source,oattr,s,t,streamPrefix);

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
varParallelism = prl,
varType = DAE.T_BOOL(source = _),
bindExp = e,
bindValue = f,
arryDim = g,
index = i,
source = source,
values = NONE(),
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),fixed)
then
BackendDAE.VAR(a,b,c,prl,DAE.T_REAL_DEFAULT,e,f,g,i,source,
SOME(DAE.VAR_ATTR_BOOL(NONE(),NONE(),SOME(DAE.BCONST(fixed)),NONE(),NONE(),NONE())),
s,t,streamPrefix);

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
varParallelism = prl,
varType = DAE.T_ENUMERATION(source = _),
bindExp = e,
bindValue = f,
arryDim = g,
index = i,
source = source,
values = NONE(),
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),fixed)
then
BackendDAE.VAR(a,b,c,prl,DAE.T_REAL_DEFAULT,e,f,g,i,source,
SOME(DAE.VAR_ATTR_ENUMERATION(NONE(),(NONE(),NONE()),NONE(),SOME(DAE.BCONST(fixed)),NONE(),NONE(),NONE())),
s,t,streamPrefix);
end match;
end setVarFixed;

Expand Down Expand Up @@ -335,64 +280,7 @@ algorithm
varKind = b,
varDirection = c,
varParallelism = prl,
varType = DAE.T_REAL(source = _),
bindExp = e,
bindValue = f,
arryDim = g,
index = i,
source = source,
values = NONE(),
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),inExp)
then
BackendDAE.VAR(a,b,c,prl,DAE.T_REAL_DEFAULT,e,f,g,i,source,
SOME(DAE.VAR_ATTR_REAL(NONE(),NONE(),NONE(),(NONE(),NONE()),SOME(inExp),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE())),
s,t,streamPrefix);

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
varParallelism = prl,
varType = DAE.T_INTEGER(source = _),
bindExp = e,
bindValue = f,
arryDim = g,
index = i,
source = source,
values = NONE(),
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),inExp)
then
BackendDAE.VAR(a,b,c,prl,DAE.T_REAL_DEFAULT,e,f,g,i,source,
SOME(DAE.VAR_ATTR_INT(NONE(),(NONE(),NONE()),SOME(inExp),NONE(),NONE(),NONE(),NONE(),NONE(),NONE())),
s,t,streamPrefix);

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
varParallelism = prl,
varType = DAE.T_BOOL(source = _),
bindExp = e,
bindValue = f,
arryDim = g,
index = i,
source = source,
values = NONE(),
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),inExp)
then
BackendDAE.VAR(a,b,c,prl,DAE.T_REAL_DEFAULT,e,f,g,i,source,
SOME(DAE.VAR_ATTR_BOOL(NONE(),SOME(inExp),NONE(),NONE(),NONE(),NONE())),
s,t,streamPrefix);

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
varParallelism = prl,
varType = DAE.T_ENUMERATION(source = _),
varType = d,
bindExp = e,
bindValue = f,
arryDim = g,
Expand All @@ -402,10 +290,11 @@ algorithm
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),inExp)
then
BackendDAE.VAR(a,b,c,prl,DAE.T_REAL_DEFAULT,e,f,g,i,source,
SOME(DAE.VAR_ATTR_ENUMERATION(NONE(),(NONE(),NONE()),SOME(inExp),NONE(),NONE(),NONE(),NONE())),
s,t,streamPrefix);
equation
attr = getVariableAttributefromType(d);
oattr1 = DAEUtil.setStartAttr(SOME(attr),inExp);
then BackendDAE.VAR(a,b,c,prl,d,e,f,g,i,source,oattr1,s,t,streamPrefix);

end match;
end setVarStartValue;

Expand Down Expand Up @@ -524,6 +413,91 @@ algorithm
end matchcontinue;
end varStateSelect;

protected function getVariableAttributefromType
input DAE.Type inType;
output DAE.VariableAttributes attr;
algorithm
attr := match(inType)
case DAE.T_REAL(source=_) then DAE.VAR_ATTR_REAL(NONE(),NONE(),NONE(),(NONE(),NONE()),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE());
case DAE.T_INTEGER(source=_) then DAE.VAR_ATTR_INT(NONE(),(NONE(),NONE()),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE());
case DAE.T_INTEGER(source=_) then DAE.VAR_ATTR_INT(NONE(),(NONE(),NONE()),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE());
case DAE.T_BOOL(source=_) then DAE.VAR_ATTR_BOOL(NONE(),NONE(),NONE(),NONE(),NONE(),NONE());
case DAE.T_STRING(source=_) then DAE.VAR_ATTR_STRING(NONE(),NONE(),NONE(),NONE(),NONE());
case DAE.T_ENUMERATION(source=_) then DAE.VAR_ATTR_ENUMERATION(NONE(),(NONE(),NONE()),NONE(),NONE(),NONE(),NONE(),NONE());
else
equation
// repord a warning on failtrace
Debug.fprint(Flags.FAILTRACE,"BackendVariable.getVariableAttributefromType called with unsopported Type!\n");
then
DAE.VAR_ATTR_REAL(NONE(),NONE(),NONE(),(NONE(),NONE()),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE(),NONE());
end match;
end getVariableAttributefromType;

public function setVarFinal
"function: setVarFinal
author: Frenkel TUD
Sets the final attribute of a variable."
input BackendDAE.Var inVar;
input Boolean finalPrefix;
output BackendDAE.Var outVar;
algorithm
outVar := match (inVar,finalPrefix)
local
DAE.ComponentRef a;
BackendDAE.VarKind b;
DAE.VarDirection c;
DAE.VarParallelism prl;
BackendDAE.Type d;
Option<DAE.Exp> e;
Option<Values.Value> f;
list<DAE.Subscript> g;
BackendDAE.Value i;
DAE.ElementSource source;
DAE.VariableAttributes attr;
Option<DAE.VariableAttributes> oattr,oattr1;
Option<SCode.Comment> s;
DAE.Flow t;
DAE.Stream streamPrefix;

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
varParallelism = prl,
varType = d,
bindExp = e,
bindValue = f,
arryDim = g,
index = i,
source = source,
values = NONE(),
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),finalPrefix)
equation
attr = getVariableAttributefromType(d);
oattr1 = DAEUtil.setFinalAttr(SOME(attr),finalPrefix);
then BackendDAE.VAR(a,b,c,prl,d,e,f,g,i,source,oattr1,s,t,streamPrefix);

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
varParallelism = prl,
varType = d,
bindExp = e,
bindValue = f,
arryDim = g,
index = i,
source = source,
values = SOME(attr),
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),finalPrefix)
equation
oattr1 = DAEUtil.setFinalAttr(SOME(attr),finalPrefix);
then BackendDAE.VAR(a,b,c,prl,d,e,f,g,i,source,oattr1,s,t,streamPrefix);
end match;
end setVarFinal;

public function setVarMinMax
"function: setVarMinMax
author: Frenkel TUD
Expand All @@ -550,6 +524,25 @@ algorithm
DAE.Flow t;
DAE.Stream streamPrefix;

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
varParallelism = prl,
varType = d,
bindExp = e,
bindValue = f,
arryDim = g,
index = i,
source = source,
values = NONE(),
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),minMax)
equation
attr = getVariableAttributefromType(d);
oattr1 = DAEUtil.setMinMax(SOME(attr),minMax);
then BackendDAE.VAR(a,b,c,prl,d,e,f,g,i,source,oattr1,s,t,streamPrefix);

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
Expand Down Expand Up @@ -610,6 +603,25 @@ algorithm
DAE.Flow t;
DAE.Stream streamPrefix;

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
varParallelism = prl,
varType = d,
bindExp = e,
bindValue = f,
arryDim = g,
index = i,
source = source,
values = NONE(),
comment = s,
flowPrefix = t,
streamPrefix = streamPrefix),inExp)
equation
attr = getVariableAttributefromType(d);
oattr1 = DAEUtil.setNominalAttr(SOME(attr),inExp);
then BackendDAE.VAR(a,b,c,prl,d,e,f,g,i,source,oattr1,s,t,streamPrefix);

case (BackendDAE.VAR(varName = a,
varKind = b,
varDirection = c,
Expand Down

0 comments on commit 58657c1

Please sign in to comment.