Skip to content

Commit a21e167

Browse files
author
Jens Frenkel
committed
- DAELow.mo
move DelayExpression stuff to SimCode.mo and delete duplicatet functions git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/sjoelund-functiontree@6662 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 9a9c149 commit a21e167

File tree

3 files changed

+26
-78
lines changed

3 files changed

+26
-78
lines changed

Compiler/BackendDAECreate.mo

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3353,5 +3353,4 @@ algorithm
33533353
end matchcontinue;
33543354
end whenEquationsIndices2;
33553355

3356-
33573356
end BackendDAECreate;

Compiler/DAELow.mo

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -6037,82 +6037,6 @@ algorithm
60376037
end matchcontinue;
60386038
end generateDaeType;
60396039

6040-
protected function transformDelayExpression
6041-
"Insert a unique index into the arguments of a delay() expression.
6042-
Repeat delay as maxDelay if not present."
6043-
input tuple<DAE.Exp, Integer> inTuple;
6044-
output tuple<DAE.Exp, Integer> outTuple;
6045-
algorithm
6046-
outTuple := matchcontinue(inTuple)
6047-
local
6048-
DAE.Exp e, e1, e2, e3;
6049-
Integer i;
6050-
list<DAE.Exp> l;
6051-
Boolean t, b;
6052-
DAE.ExpType ty;
6053-
DAE.InlineType it;
6054-
case ((DAE.CALL(Absyn.IDENT("delay"), {e1, e2}, t, b, ty, it), i))
6055-
then ((DAE.CALL(Absyn.IDENT("delay"), {DAE.ICONST(i), e1, e2, e2}, t, b, ty, it), i + 1));
6056-
case ((DAE.CALL(Absyn.IDENT("delay"), {e1, e2, e3}, t, b, ty, it), i))
6057-
then ((DAE.CALL(Absyn.IDENT("delay"), {DAE.ICONST(i), e1, e2, e3}, t, b, ty, it), i + 1));
6058-
case ((e, i)) then ((e, i));
6059-
end matchcontinue;
6060-
end transformDelayExpression;
6061-
6062-
protected function transformDelayExpressions
6063-
"Helper for processDelayExpressions()"
6064-
input DAE.Exp inExp;
6065-
input Integer inInteger;
6066-
output DAE.Exp outExp;
6067-
output Integer outInteger;
6068-
algorithm
6069-
((outExp, outInteger)) := Expression.traverseExp(inExp, transformDelayExpression, inInteger);
6070-
end transformDelayExpressions;
6071-
6072-
public function processDelayExpressions
6073-
"Assign each call to delay() with a unique id argument"
6074-
input DAE.DAElist inDAE;
6075-
input DAE.FunctionTree functionTree;
6076-
output DAE.DAElist outDAE;
6077-
output DAE.FunctionTree outTree;
6078-
algorithm
6079-
(outDAE,outTree) := matchcontinue(inDAE,functionTree)
6080-
local
6081-
DAE.DAElist dae, dae2;
6082-
case (dae,functionTree)
6083-
equation
6084-
(dae,functionTree,_) = DAEUtil.traverseDAE(dae, functionTree, transformDelayExpressions, 0);
6085-
then
6086-
(dae,functionTree);
6087-
end matchcontinue;
6088-
end processDelayExpressions;
6089-
6090-
protected function collectDelayExpressions
6091-
"Put expression into a list if it is a call to delay().
6092-
Useable as a function parameter for Expression.traverseExpression."
6093-
input tuple<DAE.Exp, list<DAE.Exp>> inTuple;
6094-
output tuple<DAE.Exp, list<DAE.Exp>> outTuple;
6095-
algorithm
6096-
outTuple := matchcontinue(inTuple)
6097-
local
6098-
DAE.Exp e;
6099-
list<DAE.Exp> l;
6100-
case ((e as DAE.CALL(path = Absyn.IDENT("delay")), l))
6101-
then ((e, e :: l));
6102-
case ((e, l)) then ((e, l));
6103-
end matchcontinue;
6104-
end collectDelayExpressions;
6105-
6106-
public function findDelaySubExpressions
6107-
"Return all subexpressions of inExp that are calls to delay()"
6108-
input DAE.Exp inExp;
6109-
input list<Integer> inDummy "this is a dummy for traverseDAELowExps";
6110-
output list<DAE.Exp> outExps;
6111-
algorithm
6112-
((_, outExps)) := Expression.traverseExp(inExp, collectDelayExpressions, {});
6113-
end findDelaySubExpressions;
6114-
6115-
61166040
public function generateCrefsExpFromType "
61176041
Author: Frenkel TUD 2010-05"
61186042
input DAE.ExpVar inVar;

Compiler/SimCode.mo

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,31 @@ algorithm
18311831
end matchcontinue;
18321832
end createLinearModelMatrixes;
18331833

1834+
protected function collectDelayExpressions
1835+
"Put expression into a list if it is a call to delay().
1836+
Useable as a function parameter for Expression.traverseExpression."
1837+
input tuple<DAE.Exp, list<DAE.Exp>> inTuple;
1838+
output tuple<DAE.Exp, list<DAE.Exp>> outTuple;
1839+
algorithm
1840+
outTuple := matchcontinue(inTuple)
1841+
local
1842+
DAE.Exp e;
1843+
list<DAE.Exp> l;
1844+
case ((e as DAE.CALL(path = Absyn.IDENT("delay")), l))
1845+
then ((e, e :: l));
1846+
case ((e, l)) then ((e, l));
1847+
end matchcontinue;
1848+
end collectDelayExpressions;
1849+
1850+
protected function findDelaySubExpressions
1851+
"Return all subexpressions of inExp that are calls to delay()"
1852+
input DAE.Exp inExp;
1853+
input list<Integer> inDummy "this is a dummy for traverseDAELowExps";
1854+
output list<DAE.Exp> outExps;
1855+
algorithm
1856+
((_, outExps)) := Expression.traverseExp(inExp, collectDelayExpressions, {});
1857+
end findDelaySubExpressions;
1858+
18341859
protected function extractDelayedExpressions
18351860
input BackendDAE.DAELow dlow;
18361861
output list<tuple<Integer, DAE.Exp>> delayedExps;
@@ -1841,7 +1866,7 @@ algorithm
18411866
list<DAE.Exp> exps;
18421867
case (dlow)
18431868
equation
1844-
exps = DAELow.traverseDAELowExps(dlow,true,DAELow.findDelaySubExpressions,{});
1869+
exps = DAELow.traverseDAELowExps(dlow,true,findDelaySubExpressions,{});
18451870
delayedExps = Util.listMap(exps, extractIdAndExpFromDelayExp);
18461871
maxDelayedExpIndex = Util.listFold(Util.listMap(delayedExps, Util.tuple21), intMax, -1);
18471872
then

0 commit comments

Comments
 (0)