Skip to content

Commit

Permalink
- rename Exp to Expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Frenkel committed Oct 26, 2010
1 parent 5c64b6e commit c250c9c
Show file tree
Hide file tree
Showing 61 changed files with 9,155 additions and 3,501 deletions.
2 changes: 1 addition & 1 deletion Compiler/Absyn.mo
Expand Up @@ -1451,7 +1451,7 @@ end traverseExpAlgItemTupleList;
public function traverseExp
" Traverses all subexpressions of an Exp expression.
Takes a function and an extra argument passed through the traversal.
NOTE:This function was copied from Exp.traverseExp."
NOTE:This function was copied from Expression.traverseExpression."
input Exp inExp;
input FuncTypeTplExpType_aToTplExpType_a inFuncTypeTplExpTypeAToTplExpTypeA;
input Type_a inTypeA;
Expand Down
8 changes: 4 additions & 4 deletions Compiler/Algorithm.mo
Expand Up @@ -49,7 +49,6 @@ package Algorithm
"

public import Absyn;
public import ComponentReference;
public import DAE;
public import SCode;

Expand All @@ -60,11 +59,12 @@ public type Algorithm = DAE.Algorithm;
public type Statement = DAE.Statement;
public type Else = DAE.Else;

protected import ComponentReference;
protected import DAEUtil;
protected import Debug;
protected import Error;
protected import Expression;
protected import ExpressionDump;
protected import Exp;
protected import Print;
protected import RTOpts;
protected import System;
Expand Down Expand Up @@ -660,7 +660,7 @@ public function getCrefFromAlg "Returns all crefs from an algorithm"
input Algorithm alg;
output list<DAE.ComponentRef> crs;
algorithm
crs := Util.listListUnionOnTrue(Util.listMap(getAllExps(alg),Exp.extractCrefsFromExp),ComponentReference.crefEqual);
crs := Util.listListUnionOnTrue(Util.listMap(getAllExps(alg),Expression.extractCrefsFromExp),ComponentReference.crefEqual);
end getCrefFromAlg;


Expand Down Expand Up @@ -828,7 +828,7 @@ protected function crefToExp "function: crefToExp
input DAE.ComponentRef inComponentRef;
output DAE.Exp outExp;
algorithm
outExp:= Exp.makeCrefExp(inComponentRef,DAE.ET_OTHER());
outExp:= Expression.makeCrefExp(inComponentRef,DAE.ET_OTHER());
end crefToExp;


Expand Down
114 changes: 57 additions & 57 deletions Compiler/BackendDAETransform.mo

Large diffs are not rendered by default.

51 changes: 26 additions & 25 deletions Compiler/BackendDAEUtil.mo
Expand Up @@ -48,24 +48,25 @@ package BackendDAEUtil
in the BLT sorting."

public import BackendDAE;
public import ComponentReference;
public import DAE;
public import Exp;
public import ExpressionSimplify;
public import Util;

protected import Absyn;
protected import BackendVariable;
protected import ComponentReference;
protected import Ceval;
protected import DAELow;
protected import Debug;
protected import Error;
protected import Expression;
protected import ExpressionSimplify;
protected import ExpressionDump;
protected import HashTable2;
protected import Values;
protected import ValuesUtil;
protected import RTOpts;
protected import System;
protected import Util;


public function checkBackendDAEWithErrorMsg"function: checkBackendDAEWithErrorMsg
author: Frenkel TUD
Expand Down Expand Up @@ -158,7 +159,7 @@ algorithm
list<tuple<DAE.Exp,list<DAE.ComponentRef>>> lstExpCrefs;
case (exp,vars)
equation
((_,(_,crefs))) = Exp.traverseExpTopDown(exp,traversecheckBackendDAEExp,((vars,{})));
((_,(_,crefs))) = Expression.traverseExpTopDown(exp,traversecheckBackendDAEExp,((vars,{})));
lstExpCrefs = Util.if_(listLength(crefs)>0,{(exp,crefs)},{});
then
lstExpCrefs;
Expand Down Expand Up @@ -372,7 +373,7 @@ algorithm
bt;
case (DAE.CALL(path = Absyn.IDENT(name = "der"),expLst = {DAE.CREF(componentRef = cr)}),bt)
equation
//cr_1 = Exp.stringifyComponentRef(cr) "value irrelevant, give zero" ;
//cr_1 = Expression.stringifyComponentRef(cr) "value irrelevant, give zero" ;
bt = DAELow.treeAdd(bt, cr, 0);
then
bt;
Expand Down Expand Up @@ -419,7 +420,7 @@ end statesExp;
protected function statesExpMatrix
"function: statesExpMatrix
author: PA
Helper function to statesExp. Deals with matrix exp list."
Helper function to statesExpression. Deals with matrix exp list."
input list<list<tuple<DAE.Exp, Boolean>>> inTplExpExpBooleanLstLst;
input BackendDAE.BinTree inBinTree;
output BackendDAE.BinTree outBinTree;
Expand Down Expand Up @@ -1082,7 +1083,7 @@ algorithm
DAE.ET_COMPLEX(varLst=varLst) = ComponentReference.crefLastType(cr);
expl = Util.listMap1(varLst,DAELow.generateCrefsExpFromType,e);
lst = Util.listMap1(expl, statesAndVarsExp, vars);
res = Util.listListUnionOnTrue(lst, Exp.expEqual);
res = Util.listListUnionOnTrue(lst, Expression.expEqual);
then
res;
/* Special Case for unextended arrays */
Expand All @@ -1101,7 +1102,7 @@ algorithm
equation
s1 = statesAndVarsExp(e1, vars);
s2 = statesAndVarsExp(e2, vars);
res = Util.listUnionOnTrue(s1, s2, Exp.expEqual);
res = Util.listUnionOnTrue(s1, s2, Expression.expEqual);
then
res;
case (DAE.UNARY(exp = e),vars)
Expand All @@ -1113,7 +1114,7 @@ algorithm
equation
s1 = statesAndVarsExp(e1, vars);
s2 = statesAndVarsExp(e2, vars);
res = Util.listUnionOnTrue(s1, s2, Exp.expEqual);
res = Util.listUnionOnTrue(s1, s2, Expression.expEqual);
then
res;
case (DAE.LUNARY(exp = e),vars)
Expand All @@ -1133,7 +1134,7 @@ algorithm
s1 = statesAndVarsExp(e1, vars);
s2 = statesAndVarsExp(e2, vars);
s3 = statesAndVarsExp(e3, vars);
res = Util.listListUnionOnTrue({s1,s2,s3}, Exp.expEqual);
res = Util.listListUnionOnTrue({s1,s2,s3}, Expression.expEqual);
then
res;
case ((e as DAE.CALL(path = Absyn.IDENT(name = "der"),expLst = {DAE.CREF(componentRef = cr)})),vars)
Expand All @@ -1149,19 +1150,19 @@ algorithm
case (DAE.CALL(expLst = expl),vars)
equation
lst = Util.listMap1(expl, statesAndVarsExp, vars);
res = Util.listListUnionOnTrue(lst, Exp.expEqual);
res = Util.listListUnionOnTrue(lst, Expression.expEqual);
then
res;
case (DAE.PARTEVALFUNCTION(expList = expl),vars)
equation
lst = Util.listMap1(expl, statesAndVarsExp, vars);
res = Util.listListUnionOnTrue(lst, Exp.expEqual);
res = Util.listListUnionOnTrue(lst, Expression.expEqual);
then
res;
case (DAE.ARRAY(array = expl),vars)
equation
lst = Util.listMap1(expl, statesAndVarsExp, vars);
res = Util.listListUnionOnTrue(lst, Exp.expEqual);
res = Util.listListUnionOnTrue(lst, Expression.expEqual);
then
res;
case (DAE.MATRIX(scalar = mexp),vars)
Expand All @@ -1172,7 +1173,7 @@ algorithm
case (DAE.TUPLE(PR = expl),vars)
equation
lst = Util.listMap1(expl, statesAndVarsExp, vars);
res = Util.listListUnionOnTrue(lst, Exp.expEqual);
res = Util.listListUnionOnTrue(lst, Expression.expEqual);
then
res;
case (DAE.CAST(exp = e),vars)
Expand All @@ -1189,7 +1190,7 @@ algorithm
equation
s1 = statesAndVarsExp(e1, vars);
s2 = statesAndVarsExp(e2, vars);
res = Util.listUnionOnTrue(s1, s2, Exp.expEqual);
res = Util.listUnionOnTrue(s1, s2, Expression.expEqual);
then
res;
// ignore constants!
Expand Down Expand Up @@ -1228,7 +1229,7 @@ algorithm
expl_1 = Util.listMap(expl, Util.tuple21);
lst = Util.listMap1(expl_1, statesAndVarsExp, vars);
ms_1 = statesAndVarsMatrixExp(ms, vars);
res = Util.listListUnionOnTrue((ms_1 :: lst), Exp.expEqual);
res = Util.listListUnionOnTrue((ms_1 :: lst), Expression.expEqual);
then
res;
end matchcontinue;
Expand All @@ -1252,7 +1253,7 @@ algorithm
case (DAE.CREF(componentRef = cr), _)
equation
subscripts = ComponentReference.crefSubs(cr);
subscript_exprs = Util.listMap(subscripts, Exp.subscriptExp);
subscript_exprs = Util.listMap(subscripts, Expression.subscriptExp);
true = isLoopDependentHelper(subscript_exprs, iteratorExp);
then true;
case (DAE.ASUB(sub = subscript_exprs), _)
Expand All @@ -1278,7 +1279,7 @@ algorithm
case ({}, _) then false;
case (subscript :: rest, _)
equation
true = Exp.expContains(subscript, iteratorExp);
true = Expression.expContains(subscript, iteratorExp);
then true;
case (subscript :: rest, _)
equation
Expand Down Expand Up @@ -1351,7 +1352,7 @@ algorithm
equation
(arrayElements, _) = BackendVariable.getVar(cref, vars);
varCrefs = Util.listMap(arrayElements, BackendVariable.varCref);
varExprs = Util.listMap(varCrefs, Exp.crefExp);
varExprs = Util.listMap(varCrefs, Expression.crefExp);
then varExprs;

case (DAE.ASUB(exp = DAE.CREF(componentRef = cref)), _, _, _)
Expand All @@ -1360,13 +1361,13 @@ algorithm
// of the array.
(arrayElements, _) = BackendVariable.getVar(cref, vars);
varCrefs = Util.listMap(arrayElements, BackendVariable.varCref);
varExprs = Util.listMap(varCrefs, Exp.crefExp);
varExprs = Util.listMap(varCrefs, Expression.crefExp);
then varExprs;

case (DAE.ASUB(exp = e), _, _, _)
local DAE.Exp e;
equation
varExprs = Exp.flattenArrayExpToList(e);
varExprs = Expression.flattenArrayExpToList(e);
then
varExprs;
end matchcontinue;
Expand Down Expand Up @@ -1467,7 +1468,7 @@ algorithm
case ({}, {}, _) then {};
case (clone :: restClones, index :: restIndices, _)
equation
(newElement, _) = Exp.replaceExp(clone, iteratorExp, index);
(newElement, _) = Expression.replaceExp(clone, iteratorExp, index);
newElement2 = simplifySubscripts(newElement);
elements = generateArrayElements(restClones, restIndices, iteratorExp);
then (newElement2 :: elements);
Expand Down Expand Up @@ -1500,13 +1501,13 @@ algorithm
// An ASUB => convert to CREF if only constant subscripts.
case (DAE.ASUB(DAE.CREF(DAE.CREF_IDENT(varIdent, arrayType, _), varType), subExprs))
equation
{} = Util.listSelect(subExprs, Exp.isNotConst);
{} = Util.listSelect(subExprs, Expression.isNotConst);
// If a subscript is not a single constant value it needs to be
// simplified, e.g. cref[3+4] => cref[7], otherwise some subscripts
// might be counted twice, such as cref[3+4] and cref[2+5], even though
// they reference the same element.
subExprsSimplified = Util.listMap(subExprs, ExpressionSimplify.simplify);
subscripts = Util.listMap(subExprsSimplified, Exp.makeIndexSubscript);
subscripts = Util.listMap(subExprsSimplified, Expression.makeIndexSubscript);
cref_ = ComponentReference.makeCrefIdent(varIdent, arrayType, subscripts);
then DAE.CREF(cref_, varType);
case (_) then asub;
Expand Down
10 changes: 5 additions & 5 deletions Compiler/BackendDump.mo
Expand Up @@ -38,21 +38,21 @@ package BackendDump
"

public import BackendDAE;
public import BackendDAEUtil;
public import ComponentReference;
public import DAE;

protected import Absyn;
protected import Algorithm;
protected import BackendDAEUtil;
protected import BackendVarTransform;
protected import BackendVariable;
protected import ComponentReference;
protected import DAEEXT;
protected import DAEDump;
protected import DAELow;
protected import DAEUtil;
protected import Debug;
protected import Error;
protected import Exp;
protected import Expression;
protected import ExpressionDump;
protected import IOStream;
protected import SCode;
Expand Down Expand Up @@ -98,11 +98,11 @@ public function printCallFunction2StrDIVISION
algorithm
outString := matchcontinue (inExp,stringDelimiter,opcreffunc)
local
Exp.Ident s,s_1,s_2,fs,argstr;
Expression.Ident s,s_1,s_2,fs,argstr;
Absyn.Path fcn;
list<DAE.Exp> args;
DAE.Exp e,e1,e2;
Exp.Type ty;
Expression.Type ty;
case( DAE.CALL(path = Absyn.IDENT("DIVISION"), expLst = {e1,e2,DAE.SCONST(_)}, tuple_ = false,builtin = true,ty = ty,inlineType = DAE.NO_INLINE()), _, _)
equation
s = ExpressionDump.printExp2Str(DAE.BINARY(e1,DAE.DIV(ty),e2),stringDelimiter,opcreffunc, SOME(printCallFunction2StrDIVISION));
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackendVarTransform.mo
Expand Up @@ -41,11 +41,11 @@ package BackendVarTransform

public import BackendDAE;
public import DAE;
public import ExpressionSimplify;
public import VarTransform;

protected import Absyn;
protected import Exp;
protected import Expression;
protected import ExpressionSimplify;
protected import Util;

public function replaceEquations
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackendVarTransform_stub.mo
Expand Up @@ -39,7 +39,7 @@ package BackendVarTransform
This file is a stub!"

public import VarTransform;
protected import Exp;
protected import Expression;
protected import Util;

end BackendVarTransform;
10 changes: 5 additions & 5 deletions Compiler/BackendVariable.mo
Expand Up @@ -46,7 +46,7 @@ protected import ComponentReference;
protected import DAELow;
protected import DAEUtil;
protected import Debug;
protected import Exp;
protected import Expression;
protected import HashTable2;
protected import SCode;
protected import System;
Expand Down Expand Up @@ -1332,7 +1332,7 @@ algorithm
equation
indx_lst = Util.listIntRange(i1);
indx_lstlst = Util.listMap(indx_lst, Util.listCreate);
subscripts_lstlst = Util.listMap(indx_lstlst, Exp.intSubscripts);
subscripts_lstlst = Util.listMap(indx_lstlst, Expression.intSubscripts);
scalar_crs = Util.listMap1r(subscripts_lstlst, ComponentReference.subscriptCref, arr_cr);
(vs,indxs) = Util.listMap12(scalar_crs, getVar, vars);
vs_1 = Util.listFlatten(vs);
Expand All @@ -1343,10 +1343,10 @@ algorithm
equation
indx_lst1 = Util.listIntRange(i1);
indx_lstlst1 = Util.listMap(indx_lst1, Util.listCreate);
subscripts_lstlst1 = Util.listMap(indx_lstlst1, Exp.intSubscripts);
subscripts_lstlst1 = Util.listMap(indx_lstlst1, Expression.intSubscripts);
indx_lst2 = Util.listIntRange(i2);
indx_lstlst2 = Util.listMap(indx_lst2, Util.listCreate);
subscripts_lstlst2 = Util.listMap(indx_lstlst2, Exp.intSubscripts);
subscripts_lstlst2 = Util.listMap(indx_lstlst2, Expression.intSubscripts);
subscripts = BackendDAEUtil.subscript2dCombinations(subscripts_lstlst1, subscripts_lstlst2) "make all possbible combinations to get all 2d indexes" ;
scalar_crs = Util.listMap1r(subscripts, ComponentReference.subscriptCref, arr_cr);
(vs,indxs) = Util.listMap12(scalar_crs, getVar, vars);
Expand All @@ -1361,7 +1361,7 @@ algorithm
true = ComponentReference.crefHaveSubs(arr_cr);
indx_lst = Util.listIntRange(i1);
indx_lstlst = Util.listMap(indx_lst, Util.listCreate);
subscripts_lstlst = Util.listMap(indx_lstlst, Exp.intSubscripts);
subscripts_lstlst = Util.listMap(indx_lstlst, Expression.intSubscripts);
scalar_crs = Util.listMap1r(subscripts_lstlst, ComponentReference.subscriptCref, arr_cr);
(vs,indxs) = Util.listMap12(scalar_crs, getVar, vars);
vs_1 = Util.listFlatten(vs);
Expand Down

0 comments on commit c250c9c

Please sign in to comment.