@@ -233,7 +233,7 @@ algorithm
233233 (outExp, outPrevVars) := Expression . traverseExpBottomUp(inExp, collectPrevVars1, inPrevVars);
234234end collectPrevVars;
235235
236- public function collectPrevVars1
236+ protected function collectPrevVars1
237237 input DAE . Exp inExp;
238238 input list< DAE . ComponentRef > inPrevCompRefs;
239239 output DAE . Exp outExp = inExp;
@@ -1278,29 +1278,21 @@ protected function substitutePartitionOpExps
12781278 Also when clauses are created for boolean clocks."
12791279 input BackendDAE . EqSystem inSyst;
12801280 input BackendDAE . Shared inShared;
1281- output BackendDAE . EqSystem outSyst;
1281+ output BackendDAE . EqSystem outSyst = inSyst;
1282+ protected
1283+ list< BackendDAE . Equation > newEqs = {};
1284+ list< BackendDAE . Var > newVars = {};
1285+ Integer cnt = 1 ;
1286+ BackendDAE . Equation eq;
12821287algorithm
1283- outSyst := match inSyst
1284- local
1285- BackendDAE . Variables vars;
1286- BackendDAE . EquationArray eqs;
1287- BackendDAE . EqSystem syst;
1288- list< BackendDAE . Equation > newEqs = {};
1289- list< BackendDAE . Var > newVars = {};
1290- Integer cnt = 1 ;
1291- BackendDAE . Equation eq;
1292- case syst as BackendDAE . EQSYSTEM (orderedVars= vars, orderedEqs= eqs)
1293- algorithm
1294- for i in 1 :BackendDAEUtil . equationArraySize(eqs) loop
1295- eq := BackendEquation . equationNth1(eqs, i);
1296- (eq, (newEqs, newVars, cnt, _)) :=
1297- BackendEquation . traverseExpsOfEquation(eq, substitutePartitionOpExp, (newEqs, newVars, cnt, inShared));
1298- newEqs := eq::newEqs;
1299- end for ;
1300- syst. orderedEqs := BackendEquation . listEquation(listReverse(newEqs));
1301- syst. orderedVars := BackendVariable . addVars(newVars, vars);
1302- then BackendDAEUtil . clearEqSyst(syst);
1303- end match;
1288+ for i in 1 :BackendDAEUtil . equationArraySize(inSyst. orderedEqs) loop
1289+ eq := BackendEquation . equationNth1(inSyst. orderedEqs, i);
1290+ (eq, (newEqs, newVars, cnt, _)) := BackendEquation . traverseExpsOfEquation(eq, substitutePartitionOpExp, (newEqs, newVars, cnt, inShared));
1291+ newEqs := eq::newEqs;
1292+ end for ;
1293+ outSyst. orderedEqs := BackendEquation . listEquation(listReverse(newEqs));
1294+ outSyst. orderedVars := BackendVariable . addVars(newVars, inSyst. orderedVars);
1295+ outSyst := BackendDAEUtil . clearEqSyst(outSyst);
13041296end substitutePartitionOpExps;
13051297
13061298protected function substitutePartitionOpExp
@@ -1318,28 +1310,25 @@ protected function substitutePartitionOpExp1
13181310 output DAE . Exp outExp;
13191311 output tuple< list< BackendDAE . Equation > ,list< BackendDAE . Var > , Integer , BackendDAE . Shared > outTpl;
13201312protected
1313+ Absyn . Path path;
1314+ BackendDAE . Shared shared ;
1315+ DAE . CallAttributes attr;
1316+ DAE . ClockKind clk;
1317+ Integer cnt;
13211318 list< BackendDAE . Equation > newEqs;
13221319 list< BackendDAE . Var > newVars;
1323- Integer cnt;
1324- BackendDAE . Shared shared ;
1320+ list< DAE . Exp > exps;
13251321algorithm
13261322 (newEqs, newVars, cnt, shared ) := inTpl;
13271323 (outExp, outTpl) := match inExp
1328- local
1329- Absyn . Path path;
1330- list< DAE . Exp > exps;
1331- DAE . CallAttributes attr;
1332- DAE . ClockKind clk;
1333- case DAE . CLKCONST (clk)
1334- equation
1335- (clk, newEqs, newVars, cnt) = substClock(clk, newEqs, newVars, cnt, shared );
1336- then
1337- (DAE . CLKCONST (clk), (newEqs, newVars, cnt, shared ));
1338- case DAE . CALL (path = path, expLst = exps, attr = attr)
1339- then
1340- substituteExpsCall(path, exps, attr, newEqs, newVars, cnt, shared );
1341- else
1342- (inExp, inTpl);
1324+ case DAE . CLKCONST (clk) equation
1325+ (clk, newEqs, newVars, cnt) = substClock(clk, newEqs, newVars, cnt, shared );
1326+ then (DAE . CLKCONST (clk), (newEqs, newVars, cnt, shared ));
1327+
1328+ case DAE . CALL (path= path, expLst= exps, attr= attr)
1329+ then substituteExpsCall(path, exps, attr, newEqs, newVars, cnt, shared );
1330+
1331+ else (inExp, inTpl);
13431332 end match;
13441333end substitutePartitionOpExp1;
13451334
@@ -1353,32 +1342,28 @@ protected function substClock
13531342 output list< BackendDAE . Equation > outNewEqs;
13541343 output list< BackendDAE . Var > outNewVars;
13551344 output Integer outCnt;
1345+ protected
1346+ DAE . Exp e;
1347+ Integer cnt;
1348+ Integer i;
1349+ Real f;
1350+ list< BackendDAE . Equation > eqs;
1351+ list< BackendDAE . Var > vars;
13561352algorithm
13571353 (outClk, outNewEqs, outNewVars, outCnt) := match inClk
1358- local
1359- DAE . Exp e;
1360- Integer i;
1361- Real f;
1362- list< BackendDAE . Equation > eqs;
1363- list< BackendDAE . Var > vars;
1364- Integer cnt;
1365- case DAE . BOOLEAN_CLOCK (e, f)
1366- equation
1367- ({e}, eqs, vars, cnt) = substExp({e}, inNewEqs, inNewVars, inCnt);
1368- then
1369- (DAE . BOOLEAN_CLOCK (e, f), eqs, vars, cnt);
1370- case DAE . REAL_CLOCK (e)
1371- equation
1372- (e, eqs, vars, cnt) = substClockExp(e, inNewEqs, inNewVars, inCnt, inShared);
1373- then
1374- (DAE . REAL_CLOCK (e), eqs, vars, cnt);
1375- case DAE . INTEGER_CLOCK (e, i)
1376- equation
1377- (e, eqs, vars, cnt) = substClockExp(e, inNewEqs, inNewVars, inCnt, inShared);
1378- then
1379- (DAE . INTEGER_CLOCK (e, i), eqs, vars, cnt);
1380- else
1381- (inClk, inNewEqs, inNewVars, inCnt);
1354+ case DAE . BOOLEAN_CLOCK (e, f) equation
1355+ ({e}, eqs, vars, cnt) = substExp({e}, inNewEqs, inNewVars, inCnt);
1356+ then (DAE . BOOLEAN_CLOCK (e, f), eqs, vars, cnt);
1357+
1358+ case DAE . REAL_CLOCK (e) equation
1359+ (e, eqs, vars, cnt) = substClockExp(e, inNewEqs, inNewVars, inCnt, inShared);
1360+ then (DAE . REAL_CLOCK (e), eqs, vars, cnt);
1361+
1362+ case DAE . INTEGER_CLOCK (e, i) equation
1363+ (e, eqs, vars, cnt) = substClockExp(e, inNewEqs, inNewVars, inCnt, inShared);
1364+ then (DAE . INTEGER_CLOCK (e, i), eqs, vars, cnt);
1365+
1366+ else (inClk, inNewEqs, inNewVars, inCnt);
13821367 end match;
13831368end substClock;
13841369
@@ -1561,23 +1546,6 @@ algorithm
15611546 end matchcontinue;
15621547end getVarIxs;
15631548
1564- protected function getVars
1565- input DAE . ComponentRef inComp;
1566- input BackendDAE . Variables inVariables;
1567- output list< BackendDAE . Var > outIntegerLst;
1568- algorithm
1569- outIntegerLst := matchcontinue inComp
1570- local
1571- list< BackendDAE . Var > vars;
1572- case _
1573- equation
1574- (vars, _) = BackendVariable . getVar(inComp, inVariables);
1575- then vars;
1576- else
1577- then {};
1578- end matchcontinue;
1579- end getVars;
1580-
15811549protected function baseClockPartitioning
15821550"Do base clock partitioning and detect kind of new partitions(clocked or continuous)."
15831551 input BackendDAE . EqSystem inSyst;
@@ -1762,18 +1730,6 @@ algorithm
17621730 else partitionType;
17631731end detectEqPartition;
17641732
1765- protected function reverseBoolOption
1766- input Option < Boolean > inp;
1767- output Option < Boolean > out;
1768- algorithm
1769- out := match inp
1770- local
1771- Boolean v;
1772- case SOME (v) then SOME (not v);
1773- else inp;
1774- end match;
1775- end reverseBoolOption;
1776-
17771733protected function printPartitionType
17781734 input Option < Boolean > isClockedPartition;
17791735 output String out;
@@ -1947,7 +1903,7 @@ algorithm
19471903 end for ;
19481904end partitionIndependentBlocks0;
19491905
1950- public function partitionIndependentBlocksMasked
1906+ protected function partitionIndependentBlocksMasked
19511907 input BackendDAE . IncidenceMatrix m;
19521908 input BackendDAE . IncidenceMatrixT mT;
19531909 input BackendDAE . IncidenceMatrix rm;
0 commit comments