Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16763 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Aug 8, 2013
1 parent fa87cc5 commit d265de4
Show file tree
Hide file tree
Showing 18 changed files with 267 additions and 275 deletions.
10 changes: 6 additions & 4 deletions Compiler/BackEnd/BackendDAECreate.mo
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ protected import SCode;
protected import System;
protected import Util;

protected type Functiontuple = tuple<Option<DAE.FunctionTree>,list<DAE.InlineType>>;

public function lower "function: lower
This function translates a DAE, which is the result from instantiating a
class, into a more precise form, called BackendDAE.BackendDAE defined in this module.
Expand Down Expand Up @@ -675,7 +677,7 @@ algorithm
DAE.VarVisibility protection;
Boolean b;
String str;
Inline.Functiontuple fnstpl;
Functiontuple fnstpl;
HashTableExpToExp.HashTable inlineHT;
case (DAE.VAR(componentRef = name,
kind = kind,
Expand Down Expand Up @@ -716,7 +718,7 @@ protected function inlineExpOpt
"function inlineExpOpt
author Frenkel TUD 2013-02"
input Option<DAE.Exp> iOptExp;
input Inline.Functiontuple fnstpl;
input Functiontuple fnstpl;
input DAE.ElementSource iSource;
input HashTableExpToExp.HashTable iInlineHT "workaround to speed up inlining of array parameters";
output Option<DAE.Exp> oOptExp;
Expand All @@ -740,7 +742,7 @@ protected function inlineExpOpt1
"function inlineExpOpt
author Frenkel TUD 2013-02"
input DAE.Exp iExp;
input Inline.Functiontuple fnstpl;
input Functiontuple fnstpl;
input DAE.ElementSource iSource;
input HashTableExpToExp.HashTable iInlineHT "workaround to speed up inlining of array parameters";
output DAE.Exp oExp;
Expand Down Expand Up @@ -1544,7 +1546,7 @@ protected function lowerextendedRecordEqn "function lowerextendedRecordEqn
algorithm
outEqns := matchcontinue(inExp1, inExp2, source, functionTree, inEqns)
local
Expression.Type tp;
DAE.Type tp;
Integer size;
DAE.Dimensions dims;
list<DAE.Exp> explst1, explst2;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAEOptimize.mo
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ protected function generateScalarArrayEqns2 "function generateScalarArrayEqns2
algorithm
oEqns := matchcontinue(inExp1,inExp2,inSource,diffed,eqExp,iEqns)
local
Expression.Type tp;
DAE.Type tp;
Integer size,i;
DAE.Dimensions dims;
list<Integer> ds;
Expand Down
7 changes: 4 additions & 3 deletions Compiler/BackEnd/BackendDAETransform.mo
Original file line number Diff line number Diff line change
Expand Up @@ -556,13 +556,13 @@ protected function transformXToXd "function transformXToXd
algorithm
outVar := match (inVar)
local
Expression.ComponentRef cr;
DAE.ComponentRef cr;
DAE.VarDirection dir;
DAE.VarParallelism prl;
BackendDAE.Type tp;
Option<DAE.Exp> exp;
Option<Values.Value> v;
list<Expression.Subscript> dim;
list<DAE.Subscript> dim;
Option<DAE.VariableAttributes> attr;
Option<SCode.Comment> comment;
DAE.ConnectorType ct;
Expand Down Expand Up @@ -1002,7 +1002,8 @@ on the form v = expr for solving variable v"
output tuple<BackendDAE.Equation,Integer> eqnindx;
algorithm
eqnindx := matchcontinue(v,eqnIndxLst)
local Expression.ComponentRef cr1,cr;
local
DAE.ComponentRef cr1,cr;
DAE.Exp e2;
Integer i;
BackendDAE.Equation eqn;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAEUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6186,7 +6186,7 @@ algorithm
list<tuple<Integer, Integer, BackendDAE.Equation>> eqns;
DAE.Exp e,e1,e2;
list<DAE.Exp> expl;
Expression.Type t;
DAE.Type t;
list<list<DAE.Subscript>> subslst;
DAE.ElementSource source;
DAE.ComponentRef cr;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/BackendDump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1725,11 +1725,11 @@ public function printCallFunction2StrDIVISION
algorithm
outString := matchcontinue (inExp,stringDelimiter,opcreffunc)
local
Expression.Ident s,s_1,s_2,fs,argstr;
String s,s_1,s_2,fs,argstr;
Absyn.Path fcn;
list<DAE.Exp> args;
DAE.Exp e1,e2;
Expression.Type ty;
DAE.Type ty;
case( DAE.CALL(path = Absyn.IDENT("DIVISION"), expLst = {e1,e2,DAE.SCONST(_)}, attr = DAE.CALL_ATTR(ty = ty)), _, _)
equation
s = ExpressionDump.printExp2Str(DAE.BINARY(e1,DAE.DIV(ty),e2),stringDelimiter,opcreffunc, SOME(printCallFunction2StrDIVISION));
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/HpcOmScheduler.mo
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ protected function convertNodeToGraphNode
input Real iTimeOffset;
output GraphNode oNode;
protected
Integer weighting, nodeMark, primalComp;
Integer nodeMark, primalComp;
array<Integer> nodeMarks;
array<list<Integer>> inComps;
list<Integer> components;
array<tuple<Integer,Real>> exeCosts;
Real exeCost, weighting;
algorithm
iTaskGraphMeta := matchcontinue(iNodeIdx, iTaskGraphMeta,iTimeOffset)
oNode := matchcontinue(iNodeIdx, iTaskGraphMeta,iTimeOffset)
case(_,HpcOmTaskGraph.TASKGRAPHMETA(inComps=inComps, exeCosts=exeCosts, nodeMark=nodeMarks),_)
equation
components = arrayGet(inComps,iNodeIdx);
Expand All @@ -130,4 +130,4 @@ algorithm
GRAPHNODE(weighting=weightingNode2) := iGraphNode2;
oResult := intGt(weightingNode1,weightingNode2);
end compareGraphNodes;
end HpcOmScheduler;
end HpcOmScheduler;
4 changes: 2 additions & 2 deletions Compiler/BackEnd/HpcOmTaskGraph.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3847,7 +3847,7 @@ protected function countOperations "function countOperations
output tuple<Integer,Integer,Integer> operations; //<add,mul,trig>

protected
Expression.ComponentRef cr;
DAE.ComponentRef cr;
Integer eqnIdx,varIdx;
Integer op1,op2,op3;
BackendDAE.Variables vars;
Expand Down Expand Up @@ -5046,4 +5046,4 @@ end transposeTaskGraph1;
// end getRootNodes;


end HpcOmTaskGraph;
end HpcOmTaskGraph;
2 changes: 1 addition & 1 deletion Compiler/BackEnd/MathematicaDump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ algorithm
outString:=
matchcontinue (inExp,vars,knvars)
local
Expression.Ident s,s_1,s1_1,s_2,s2_1,sym,s2,s3,s3_1,s4,s_3,ifstr,thenstr,elsestr,res,fs,argstr,s_4,s_5,res2,str,crstr,dimstr,expstr,iterstr,id;
String s,s_1,s1_1,s_2,s2_1,sym,s2,s3,s3_1,s4,s_3,ifstr,thenstr,elsestr,res,fs,argstr,s_4,s_5,res2,str,crstr,dimstr,expstr,iterstr,id;
Integer p,p1,p2,ival,i,pstart,pstop,pe1;
DAE.ComponentRef cr;
DAE.Type tp;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/ResidualCmp.mo
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ algorithm
DAE.ComponentRef cr;
DAE.VarKind daekind;
BackendDAE.VarKind kind;
list<Expression.Subscript> inst_dims;
list<DAE.Subscript> inst_dims;
list<String> numArrayElement;
Option<DAE.VariableAttributes> dae_var_attr;
Option<SCode.Comment> comment;
Expand Down
42 changes: 21 additions & 21 deletions Compiler/BackEnd/SimCodeUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -927,9 +927,9 @@ algorithm
local
String name;
DAE.Type daeType;
Expression.ComponentRef id;
DAE.ComponentRef id;
DAE.VarParallelism prl;
list<Expression.Subscript> inst_dims;
list<DAE.Subscript> inst_dims;
list<DAE.Exp> inst_dims_exp;
Option<DAE.Exp> binding;
SimCode.Variable var;
Expand Down Expand Up @@ -2498,7 +2498,7 @@ protected function createEquation
algorithm
(equation_, ouniqueEqIndex, otempvars) := matchcontinue (eqNum, varNum, syst, shared, linearSystem, skipDiscInAlgorithm, iuniqueEqIndex, itempvars)
local
Expression.ComponentRef cr;
DAE.ComponentRef cr;
BackendDAE.VarKind kind;
Option<DAE.VariableAttributes> values;
BackendDAE.Var v;
Expand Down Expand Up @@ -6338,7 +6338,7 @@ algorithm
(equations_, ouniqueEqIndex) := matchcontinue (eqns, vars, skipDiscinAlgorithm, iuniqueEqIndex)
local
DAE.Algorithm alg;
list<Expression.ComponentRef> solvedVars, algOutVars;
list<DAE.ComponentRef> solvedVars, algOutVars;
String message, algStr;
list<DAE.Statement> algStatements;
DAE.ElementSource source;
Expand Down Expand Up @@ -8251,7 +8251,7 @@ end isMixedSystem;

protected function solveTrivialArrayEquation "function solveTrivialArrayEquation
Solves some trivial array equations, like v+v2=foo(...), w.r.t. v is v=foo(...)-v2"
input Expression.ComponentRef v;
input DAE.ComponentRef v;
input DAE.Exp e1;
input DAE.Exp e2;
output DAE.Exp outE1;
Expand Down Expand Up @@ -8332,12 +8332,12 @@ protected function getVectorizedCrefFromExp "function getVectorizedCrefFromExp
{v{1}, v{2}, ...v{n}} for some n.
TODO: implement for 2D as well."
input DAE.Exp inExp;
output Expression.ComponentRef outComponentRef;
output DAE.ComponentRef outComponentRef;
algorithm
outComponentRef := match (inExp)
local
list<Expression.ComponentRef> crefs, crefs_1;
Expression.ComponentRef cr;
list<DAE.ComponentRef> crefs, crefs_1;
DAE.ComponentRef cr;
list<DAE.Exp> expl;
list<list<DAE.Exp>> column;

Expand Down Expand Up @@ -8369,13 +8369,13 @@ protected function transformXToXd "function transformXToXd
algorithm
outVar := matchcontinue (inVar)
local
Expression.ComponentRef cr;
DAE.ComponentRef cr;
DAE.VarDirection dir;
DAE.VarParallelism prl;
BackendDAE.Type tp;
Option<DAE.Exp> exp;
Option<Values.Value> v;
list<Expression.Subscript> dim;
list<DAE.Subscript> dim;
Option<DAE.VariableAttributes> attr;
Option<SCode.Comment> comment;
DAE.ConnectorType ct;
Expand Down Expand Up @@ -8631,7 +8631,7 @@ protected function getCrefFromExp "function getCrefFromExp
algorithm
c := match (e)
local
Expression.ComponentRef crefe;
DAE.ComponentRef crefe;
Absyn.ComponentRef crefa;

case(DAE.CREF(componentRef = crefe))
Expand Down Expand Up @@ -8728,7 +8728,7 @@ algorithm
DAE.ComponentRef cr;
BackendDAE.VarKind kind;
DAE.VarDirection dir;
list<Expression.Subscript> inst_dims;
list<DAE.Subscript> inst_dims;
list<String> numArrayElement;
Option<DAE.VariableAttributes> dae_var_attr;
Option<SCode.Comment> comment;
Expand Down Expand Up @@ -9361,7 +9361,7 @@ algorithm
outExp := matchcontinue(inExp)
local
DAE.Exp e, e1, e2;
Expression.Type ty;
DAE.Type ty;
String se;
DAE.ElementSource source;
case( (e as DAE.BINARY(exp1 = e1, operator = DAE.DIV(ty), exp2 = e2), source))
Expand Down Expand Up @@ -10454,7 +10454,7 @@ algorithm outOrder := matchcontinue(inDlow, syst)
BackendDAE.EquationArray deqns;
list<BackendDAE.Equation> eqns;
list<BackendDAE.Var> vars;
list<Expression.Exp> derExps;
list<DAE.Exp> derExps;
list<tuple<DAE.ComponentRef, Integer>> variableIndex;
list<list<DAE.ComponentRef>> firstOrderVars;
list<DAE.ComponentRef> firstOrderVarsFiltered;
Expand Down Expand Up @@ -10549,12 +10549,12 @@ Author bz 2008-06
For all state-variables, generate an der(var) expression.
"
input list<BackendDAE.Var> inVars;
output list<Expression.Exp> outDerExps;
output list<DAE.Exp> outDerExps;
algorithm outDerExps := matchcontinue(inVars)
local
BackendDAE.Var v;
list<BackendDAE.Var> vars;
list<Expression.Exp> rec;
list<DAE.Exp> rec;
DAE.ComponentRef cr;
case({}) then {};
case((v as BackendDAE.VAR(varKind = BackendDAE.STATE(index=_), varName = cr))::vars)
Expand Down Expand Up @@ -10582,14 +10582,14 @@ Author bz 2008-06
helper function for setVariableDerIndex, locates the equation(/s) containing the current derivate.
From there search for the variable beeing derived, exclude 'current equation'
"
input Expression.Exp derExp;
input DAE.Exp derExp;
input list<BackendDAE.Equation> inEqns;
input list<BackendDAE.Equation> inEqnsOrg;
output tuple<DAE.ComponentRef, Integer> out;
output list<DAE.ComponentRef> sysOrdOneVars;
algorithm (out, sysOrdOneVars) := matchcontinue(derExp, inEqns, inEqnsOrg)
local
Expression.Exp e1, e2, deriveVar;
DAE.Exp e1, e2, deriveVar;
list<BackendDAE.Equation> eqs, eqsOrg;
BackendDAE.Equation eq;
list<DAE.ComponentRef> crefs;
Expand Down Expand Up @@ -10662,7 +10662,7 @@ end locateDerAndSerachOtherSide;
protected function locateDerAndSerachOtherSide2 "
Author bz 2008-06
helper function for locateDerAndSerachOtherSide"
input Expression.Exp inDer;
input DAE.Exp inDer;
input list<BackendDAE.Equation> inEqns;
output Integer oi;
output list<DAE.ComponentRef> firstOrderDers;
Expand All @@ -10682,13 +10682,13 @@ recursivly search equations for der(..) expressions.
When found, return 1... this since we are only interested in second order system, at most.
If we do not find any more derivative, 0 is returned.
"
input Expression.Exp inDer;
input DAE.Exp inDer;
input list<BackendDAE.Equation> inEqns;
output Integer oi;
output list<DAE.ComponentRef> firstOrderDers;
algorithm (oi, firstOrderDers) := matchcontinue(inDer, inEqns)
local
Expression.Exp e1, e2;
DAE.Exp e1, e2;
DAE.ComponentRef cr;
list<BackendDAE.Equation> rest;
case(_, {}) then (0, {});
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/ConnectionGraph.mo
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ algorithm
outOrderedConnections := matchcontinue(inConnections, inUserSelectedBreaking)
local
String sc1,sc2;
Expression.ComponentRef c1, c2;
DAE.ComponentRef c1, c2;
DaeEdge e;
list<DAE.Element> els;
DaeEdges rest, ordered;
Expand Down

0 comments on commit d265de4

Please sign in to comment.