Skip to content

Commit

Permalink
- fix count of equations, Expression.sizeof, add a fiew more types
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12227 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jun 28, 2012
1 parent c7fede3 commit 721f3b0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 20 deletions.
30 changes: 19 additions & 11 deletions Compiler/FrontEnd/CheckModel.mo
Expand Up @@ -95,6 +95,8 @@ algorithm
list<DAE.ComponentRef> crlst;
DAE.Algorithm alg;
HashSet.HashSet hs;
DAE.Type tp;
DAE.Dimensions dims;

case ({},_,_,_,_) then (ivarSize,ieqnSize,ieqnslst,ihs);

Expand Down Expand Up @@ -186,16 +188,20 @@ algorithm
(varSize,eqnSize,eqns,hs);

// effort variable equality equations
case ((elem as DAE.EQUEQUATION(cr1 = _))::rest,_,_,_,_)
case ((elem as DAE.EQUEQUATION(cr1 = cr))::rest,_,_,_,_)
equation
(varSize,eqnSize,eqns,hs) = countVarEqnSize(rest,ivarSize,ieqnSize+1,elem::ieqnslst,ihs);
tp = ComponentReference.crefTypeConsiderSubs(cr);
size = Expression.sizeOf(tp);
(varSize,eqnSize,eqns,hs) = countVarEqnSize(rest,ivarSize,ieqnSize+size,elem::ieqnslst,ihs);
then
(varSize,eqnSize,eqns,hs);

// a solved equation
case ((elem as DAE.DEFINE(componentRef = _))::rest,_,_,_,_)
case ((elem as DAE.DEFINE(componentRef = cr))::rest,_,_,_,_)
equation
(varSize,eqnSize,eqns,hs) = countVarEqnSize(rest,ivarSize,ieqnSize+1,elem::ieqnslst,ihs);
tp = ComponentReference.crefTypeConsiderSubs(cr);
size = Expression.sizeOf(tp);
(varSize,eqnSize,eqns,hs) = countVarEqnSize(rest,ivarSize,ieqnSize+size,elem::ieqnslst,ihs);
then
(varSize,eqnSize,eqns,hs);

Expand All @@ -215,9 +221,9 @@ algorithm
(varSize,eqnSize,eqns,hs);

// array equations
case ((elem as DAE.ARRAY_EQUATION(exp = e1))::rest,_,_,_,_)
case ((elem as DAE.ARRAY_EQUATION(dimension=dims))::rest,_,_,_,_)
equation
size = Expression.sizeOf(Expression.typeof(e1));
size = List.fold(Expression.dimensionsSizes(dims),intMul,1);
(varSize,eqnSize,eqns,hs) = countVarEqnSize(rest,ivarSize,ieqnSize+size,elem::ieqnslst,ihs);
then
(varSize,eqnSize,eqns,hs);
Expand All @@ -232,8 +238,8 @@ algorithm
// when equations
case (DAE.WHEN_EQUATION(equations = daeElts)::rest,_,_,_,_)
equation
(varSize,eqnSize,_,_) = countVarEqnSize(daeElts,ivarSize,ieqnSize,{},ihs);
(varSize,eqnSize,eqns,hs) = countVarEqnSize(rest,varSize,eqnSize,ieqnslst,ihs);
(_,size,_,_) = countVarEqnSize(daeElts,0,0,{},ihs);
(varSize,eqnSize,eqns,hs) = countVarEqnSize(rest,ivarSize,ieqnSize+size,ieqnslst,ihs);
then
(varSize,eqnSize,eqns,hs);

Expand All @@ -247,8 +253,8 @@ algorithm
// if equation
case (DAE.IF_EQUATION(equations2 = daeElts::_)::rest,_,_,_,_)
equation
(varSize,eqnSize,_,_) = countVarEqnSize(daeElts,ivarSize,ieqnSize,{},ihs);
(varSize,eqnSize,eqns,hs) = countVarEqnSize(rest,varSize,eqnSize,ieqnslst,ihs);
(_,size,_,_) = countVarEqnSize(daeElts,0,0,{},ihs);
(varSize,eqnSize,eqns,hs) = countVarEqnSize(rest,ivarSize,ieqnSize+size,ieqnslst,ihs);
then
(varSize,eqnSize,eqns,hs);
// initial if equation
Expand Down Expand Up @@ -565,6 +571,8 @@ algorithm
DAE.ComponentRef cr;
DAE.Type tp;
Integer size;
DAE.Dimensions dims;

case ({},_,_) then isimpleEqnSize;

// equations
Expand Down Expand Up @@ -600,7 +608,7 @@ algorithm
countSympleEqnSize(rest,isimpleEqnSize+size,ihs);

// array equations
case ((elem as DAE.ARRAY_EQUATION(exp = e1, array = e2))::rest,_,_)
case ((elem as DAE.ARRAY_EQUATION(dimension=dims,exp = e1, array = e2))::rest,_,_)
equation
size = simpleEquation(e1,e2,ihs);
then
Expand Down
31 changes: 22 additions & 9 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -1599,7 +1599,9 @@ algorithm
Integer nr;
list<Integer> lstInt;
list<Var> varLst;
list<DAE.Type> typs;
list<DAE.Type> typs;
Type ty;
list<String> strlst;

// count the variables in array
case DAE.T_ARRAY(dims = ad)
Expand All @@ -1622,8 +1624,19 @@ algorithm
nr = List.reduce(lstInt, intAdd);
then
nr;



case DAE.T_ENUMERATION(index=NONE(),names=strlst)
then
listLength(strlst);

case DAE.T_FUNCTION(funcResultType=ty)
then
sizeOf(ty);

case DAE.T_METATYPE(ty=ty)
then
sizeOf(ty);

// for all other consider it just 1 variable
case _ then 1;
end matchcontinue;
Expand Down Expand Up @@ -6343,11 +6356,11 @@ returns true if expression is an array.
input DAE.Exp inExp;
output Boolean outB;
algorithm
outB := matchcontinue(inExp)
outB := match(inExp)
case(DAE.ARRAY(array = _ )) then true;
case(DAE.UNARY(operator=DAE.UMINUS_ARR(ty=_),exp=DAE.ARRAY(array=_))) then true;
case(_) then false;
end matchcontinue;
else then false;
end match;
end isArray;

public function isMatrix " function: isMatrix
Expand All @@ -6356,11 +6369,11 @@ returns true if expression is an matrix.
input DAE.Exp inExp;
output Boolean outB;
algorithm
outB := matchcontinue(inExp)
outB := match(inExp)
case(DAE.MATRIX(ty = _ )) then true;
case(DAE.UNARY(operator=DAE.UMINUS_ARR(ty=_),exp=DAE.MATRIX(ty=_))) then true;
case(_) then false;
end matchcontinue;
else then false;
end match;
end isMatrix;

public function isUnary " function: isUnary
Expand Down

0 comments on commit 721f3b0

Please sign in to comment.