Changeset 11454
 Timestamp:
 Aug 13, 2018 1:41:02 PM (16 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/Compiler/ModelicaMiddleEnd/src/jastadd/TransformCanonical.jrag
r11452 r11454 1203 1203 public void perform() { 1204 1204 genAlias(); 1205 eliminateAliasVariables(); 1205 propagateDerivativeBindings(); 1206 sortAliasVariables(false); 1207 sortAliasEquations(); 1208 enableAliasRewrite(); 1209 change(); 1206 1210 removeUnusedTemporaries(); 1207 1211 mergeEquivalentRecords(); … … 1209 1213 remoteRedundantInitialEquations(); 1210 1214 change(); 1215 } 1216 1217 public void propagateDerivativeBindings() { 1218 // Collect derivative binding equations, however only if we are going 1219 // to perform index reduction! 1220 if (myOptions().getBooleanOption("propagate_derivatives")) { 1221 for (FAbstractEquation equation : getFAbstractEquations()) { 1222 if (!equation.isAliasEquation()) { 1223 equation.propagateDerivativeBindings(); 1224 } 1225 } 1226 } 1211 1227 } 1212 1228 } … … 1381 1397 } 1382 1398 } 1383 aliasManager.reportAliasErrors(this); 1384 //flush(); 1385 root().flushAllRecursive(); // TODO: is this really needed? the tree isn't changed 1399 aliasManager.reportAliasErrors(this); 1386 1400 } 1387 1401 … … 1401 1415 } 1402 1416 1403 /** 1404 * Eliminate alias variables from the flat model. 1405 * 1406 * The nonalias variables are kept in the list FClass.FVariableList but the 1407 * alias variables are moved to FClass.AliasVariablesList. 1408 */ 1409 public void FClass.eliminateAliasVariables() { 1410 ArrayList<FAbstractEquation> eqns = new ArrayList<FAbstractEquation>(); 1417 /** 1418 * Eliminate alias variables from the flat model. 1419 * 1420 * The nonalias variables are kept in the list FClass.FVariableList but the 1421 * alias variables are moved to FClass.AliasVariablesList. 1422 */ 1423 public void FClass.sortAliasVariables(boolean recompute) { 1424 ArrayList<FVariable> nonAliasVars = new ArrayList<FVariable>(); 1425 ArrayList<FVariable> aliasVars = new ArrayList<FVariable>(); 1426 if (recompute) { 1427 for (FVariable fv : getAliasVariables()) { 1428 fv.aliasSort(nonAliasVars, aliasVars); 1429 } 1430 } else { 1431 for (FVariable fv : getAliasVariables()) { 1432 aliasVars.add(fv); 1433 } 1434 } 1435 for (FVariable fv : getFVariables()) { 1436 fv.aliasSort(nonAliasVars, aliasVars); 1437 } 1438 setFVariableList(new List(nonAliasVars)); 1439 setAliasVariableList(new List(aliasVars)); 1440 } 1441 1442 /** 1443 * Eliminate alias equation from the flat model. 1444 */ 1445 public void FClass.sortAliasEquations() { 1446 ArrayList<FAbstractEquation> eqns = new ArrayList<FAbstractEquation>(); 1411 1447 ArrayList<FAbstractEquation> pEqns = new ArrayList<FAbstractEquation>(); 1412 1413 //log.debug("FClass.eliminateAliasVariables(): l1 " + nonAliasVars + " l2 " + aliasVars); 1414 1415 // Remove alias equations. 1416 for (FAbstractEquation equation : getFAbstractEquations()) 1417 if (!equation.isAliasEquation()) 1418 eqns.add(equation); 1448 for (FAbstractEquation equation : getFAbstractEquations()) { 1449 if (!equation.isAliasEquation()) { 1450 eqns.add(equation); 1451 } 1452 } 1419 1453 if (myOptions().getBooleanOption("eliminate_alias_parameters")) { 1420 1454 for (FAbstractEquation equation : getParameterEquations()) { … … 1423 1457 } 1424 1458 } 1425 }1426 1427 // Collect derivative binding equations, however only if we are going1428 // to perform index reduction!1429 if (myOptions().getBooleanOption("propagate_derivatives")) {1430 for (FAbstractEquation eqn : eqns) {1431 eqn.propagateDerivativeBindings();1432 }1433 }1434 1435 setFAbstractEquationList(new List(eqns));1436 if (myOptions().getBooleanOption("eliminate_alias_parameters")) {1437 1459 setParameterEquationList(new List(pEqns)); 1438 1460 } 1439 1440 sortAliasvariables(false); 1441 1442 flush(); 1443 } 1444 1445 public void FClass.sortAliasvariables(boolean recompute) { 1446 ArrayList<FVariable> nonAliasVars = new ArrayList<FVariable>(); 1447 ArrayList<FVariable> aliasVars = new ArrayList<FVariable>(); 1448 if (recompute) { 1449 for (FVariable fv : getAliasVariables()) { 1450 fv.aliasSort(nonAliasVars, aliasVars); 1451 } 1452 } else { 1453 for (FVariable fv : getAliasVariables()) { 1454 aliasVars.add(fv); 1455 } 1456 } 1457 for (FVariable fv : getFVariables()) { 1458 fv.aliasSort(nonAliasVars, aliasVars); 1459 } 1460 setFVariableList(new List(nonAliasVars)); 1461 setAliasVariableList(new List(aliasVars)); 1462 enableAliasRewrite(); 1461 setFAbstractEquationList(new List(eqns)); 1463 1462 } 1464 1463
Note: See TracChangeset
for help on using the changeset viewer.