Skip to content

Commit

Permalink
Applied the refactoring script
Browse files Browse the repository at this point in the history
This removes some dead code and makes it easier to read the code to
figure out what is happening.
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Oct 6, 2017
1 parent ec7206f commit ec69d30
Show file tree
Hide file tree
Showing 30 changed files with 90 additions and 98 deletions.
12 changes: 6 additions & 6 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -1004,13 +1004,13 @@ algorithm
nameen = Absyn.joinPaths(inPath, Absyn.IDENT(sn));
then
DAEUtil.setMinMax(inVarAttr, SOME(DAE.ENUM_LITERAL(namee1, 1)), SOME(DAE.ENUM_LITERAL(nameen, i)));
case (NONE(), SOME(e), _, _, _)
case (NONE(), SOME(_), _, _, _)
equation
s1 = listHead(inNames);
namee1 = Absyn.joinPaths(inPath, Absyn.IDENT(s1));
then
DAEUtil.setMinMax(inVarAttr, SOME(DAE.ENUM_LITERAL(namee1, 1)), inMax);
case (SOME(e), NONE(), _, _, _)
case (SOME(_), NONE(), _, _, _)
equation
i = listLength(inNames);
sn = listGet(inNames, i);
Expand Down Expand Up @@ -1962,7 +1962,7 @@ algorithm
(eqnl, reqnl);

// if a function call includes external functions, it is not allowed to expand the left hand side since the call will be evaluated multiple times. That's an unintended behaviour.
case DAE.EQUATION(exp = lhs as DAE.TUPLE(PR=_), scalar = e as DAE.CALL(_), source = source)::xs
case DAE.EQUATION(exp = lhs as DAE.TUPLE(), scalar = e as DAE.CALL(_), source = source)::xs
equation
//print("Do not lower equations with function calls that solve tuples "+DAEDump.dumpEquationStr(listHead(inDAEElementLst))+"\n");
ty = Expression.typeof(lhs);
Expand All @@ -1980,7 +1980,7 @@ algorithm
then
(eqnl, reqnl);

case (el as DAE.EQUATION(exp = (cre as DAE.CREF(componentRef = _)), scalar = e, source = source))::xs algorithm
case (el as DAE.EQUATION(exp = (cre as DAE.CREF()), scalar = e, source = source))::xs algorithm
try
e := ExpressionSolve.solve(cre, e, cre);
else
Expand All @@ -1994,7 +1994,7 @@ algorithm
(eqnl, reqnl) := lowerWhenEqn2(xs, inCond, functionTree, eq::iEquationLst, iREquationLst);
then (eqnl, reqnl);

case DAE.COMPLEX_EQUATION(lhs = (cre as DAE.CREF(componentRef = _)), rhs = e, source = source)::xs
case DAE.COMPLEX_EQUATION(lhs = (cre as DAE.CREF()), rhs = e, source = source)::xs
equation
(DAE.EQUALITY_EXPS(_,e), source) = ExpressionSimplify.simplifyAddSymbolicOperation(DAE.EQUALITY_EXPS(cre,e),source);
size = Expression.sizeOf(Expression.typeof(cre));
Expand Down Expand Up @@ -2029,7 +2029,7 @@ algorithm
then
(eqnl, reqnl);

case DAE.ARRAY_EQUATION(dimension=ds, exp = (cre as DAE.CREF(componentRef = _)), array = e, source = source)::xs
case DAE.ARRAY_EQUATION(dimension=ds, exp = (cre as DAE.CREF()), array = e, source = source)::xs
equation
(DAE.EQUALITY_EXPS(_,e), source) = ExpressionSimplify.simplifyAddSymbolicOperation(DAE.EQUALITY_EXPS(cre,e),source);
size = List.fold(Expression.dimensionsSizes(ds), intMul, 1);
Expand Down
20 changes: 10 additions & 10 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -503,7 +503,7 @@ algorithm
equation
(_::_,_::_)= BackendVariable.getVar(cr, vars);
then (e,false,(true,vars,globalKnownVars,b1,true));
case (e,(b,vars,globalKnownVars,b1,b2)) then (e,not b,inTpl);
case (e,(b,_,_,_,_)) then (e,not b,inTpl);

end matchcontinue;
end traversingTimeEqnsFinder;
Expand Down Expand Up @@ -5909,7 +5909,7 @@ algorithm
list<BackendDAE.Equation> eqnLst;
Boolean hasHomotopy;

case(BackendDAE.SINGLEEQUATION(eqn=eqnIndex, var=varIndex))
case(BackendDAE.SINGLEEQUATION(eqn=eqnIndex))
equation
eqn = BackendEquation.get(system.orderedEqs, eqnIndex);
(_, hasHomotopy) = BackendEquation.traverseExpsOfEquation(eqn, BackendDAEUtil.containsHomotopyCall, false);
Expand All @@ -5921,7 +5921,7 @@ algorithm
end if;
then();

case(BackendDAE.EQUATIONSYSTEM(eqns=eqnIndexes, vars=varIndexes))
case(BackendDAE.EQUATIONSYSTEM(eqns=eqnIndexes))
equation
if (homotopyLoopBeginning == 0) then
eqnLst = BackendEquation.getList(eqnIndexes, system.orderedEqs);
Expand All @@ -5936,7 +5936,7 @@ algorithm
end if;
then();

case(BackendDAE.SINGLEARRAY(eqn=eqnIndex, vars=varIndexes))
case(BackendDAE.SINGLEARRAY(eqn=eqnIndex))
equation
eqn = BackendEquation.get(system.orderedEqs, eqnIndex);
(_, hasHomotopy) = BackendEquation.traverseExpsOfEquation(eqn, BackendDAEUtil.containsHomotopyCall, false);
Expand All @@ -5949,7 +5949,7 @@ algorithm
end if;
then();

case(BackendDAE.SINGLEALGORITHM(eqn=eqnIndex, vars=varIndexes))
case(BackendDAE.SINGLEALGORITHM(eqn=eqnIndex))
equation
eqn = BackendEquation.get(system.orderedEqs, eqnIndex);
(_, hasHomotopy) = BackendEquation.traverseExpsOfEquation(eqn, BackendDAEUtil.containsHomotopyCall, false);
Expand All @@ -5962,7 +5962,7 @@ algorithm
end if;
then();

case(BackendDAE.SINGLECOMPLEXEQUATION(eqn=eqnIndex, vars=varIndexes))
case(BackendDAE.SINGLECOMPLEXEQUATION(eqn=eqnIndex))
equation
eqn = BackendEquation.get(system.orderedEqs, eqnIndex);
(_, hasHomotopy) = BackendEquation.traverseExpsOfEquation(eqn, BackendDAEUtil.containsHomotopyCall, false);
Expand All @@ -5975,7 +5975,7 @@ algorithm
end if;
then();

case(BackendDAE.SINGLEWHENEQUATION(eqn=eqnIndex, vars=varIndexes))
case(BackendDAE.SINGLEWHENEQUATION(eqn=eqnIndex))
equation
eqn = BackendEquation.get(system.orderedEqs, eqnIndex);
(_, hasHomotopy) = BackendEquation.traverseExpsOfEquation(eqn, BackendDAEUtil.containsHomotopyCall, false);
Expand All @@ -5988,7 +5988,7 @@ algorithm
end if;
then();

case(BackendDAE.SINGLEIFEQUATION(eqn=eqnIndex, vars=varIndexes))
case(BackendDAE.SINGLEIFEQUATION(eqn=eqnIndex))
equation
eqn = BackendEquation.get(system.orderedEqs, eqnIndex);
(_, hasHomotopy) = BackendEquation.traverseExpsOfEquation(eqn, BackendDAEUtil.containsHomotopyCall, false);
Expand All @@ -6001,14 +6001,14 @@ algorithm
end if;
then();

case(BackendDAE.TORNSYSTEM(strictTearingSet=BackendDAE.TEARINGSET(residualequations=resEqnIndexes, tearingvars=tVarIndexes, innerEquations=innerEquations)))
case(BackendDAE.TORNSYSTEM(strictTearingSet=BackendDAE.TEARINGSET(residualequations=resEqnIndexes, innerEquations=innerEquations)))
equation
if (homotopyLoopBeginning == 0) then
eqnLst = BackendEquation.getList(resEqnIndexes, system.orderedEqs);
(_, hasHomotopy) = BackendEquation.traverseExpsOfEquationList(eqnLst, BackendDAEUtil.containsHomotopyCall, false);

if not hasHomotopy then
(innerEqnIndexes, innerVarIndexesLst,_) = List.map_3(innerEquations, BackendDAEUtil.getEqnAndVarsFromInnerEquation);
(innerEqnIndexes,_,_) = List.map_3(innerEquations, BackendDAEUtil.getEqnAndVarsFromInnerEquation);
eqnLst = BackendEquation.getList(innerEqnIndexes, system.orderedEqs);
(_, hasHomotopy) = BackendEquation.traverseExpsOfEquationList(eqnLst, BackendDAEUtil.containsHomotopyCall, false);
end if;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -159,7 +159,7 @@ algorithm
BackendDAE.EqSystem syst;
DAE.FunctionTree functionTree;

case BackendDAE.DAE(eqs=(syst as BackendDAE.EQSYSTEM(orderedVars=vars, orderedEqs=orderedEqs))::{}, shared=BackendDAE.SHARED(functionTree=functionTree)) equation
case BackendDAE.DAE(eqs=(BackendDAE.EQSYSTEM(orderedVars=vars, orderedEqs=orderedEqs))::{}, shared=BackendDAE.SHARED(functionTree=_)) equation
//true = Flags.isSet(Flags.CHECK_BACKEND_DAE);
//Check for correct size
nVars = BackendVariable.varsSize(vars);
Expand Down Expand Up @@ -4354,7 +4354,7 @@ algorithm
arrayUpdate(rowmark,i,-mark);
then
adjacencyRowAlgorithmInputs1(rest,mark,rowmark,(i,BackendDAE.SOLVABILITY_UNSOLVABLE(),{})::iRow);
case (i::rest,_,_,_)
case (_::rest,_,_,_)
then
adjacencyRowAlgorithmInputs1(rest,mark,rowmark,iRow);
end match;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/CommonSubExpression.mo
Expand Up @@ -853,7 +853,7 @@ algorithm
guard isSkipCase(inExp, functionTree)
then false;

case tsub as DAE.TSUB(exp=call as DAE.CALL(attr=DAE.CALL_ATTR(ty=DAE.T_TUPLE(types=types)), expLst=expLst), ix=ix, ty=ty) algorithm
case tsub as DAE.TSUB(exp=call as DAE.CALL(attr=DAE.CALL_ATTR(ty=DAE.T_TUPLE(types=types))), ix=ix, ty=ty) algorithm
if not BaseHashTable.hasKey(call, HT) then
index := index + 1;
HT := BaseHashTable.add((call, index), HT);
Expand All @@ -879,7 +879,7 @@ algorithm
end if;
then true;

case DAE.CALL(attr=DAE.CALL_ATTR(ty=ty), expLst=expLst) algorithm
case DAE.CALL(attr=DAE.CALL_ATTR(ty=ty)) algorithm
if not BaseHashTable.hasKey(inExp, HT) then
index := index + 1;
HT := BaseHashTable.add((inExp, index), HT);
Expand Down Expand Up @@ -2239,7 +2239,7 @@ algorithm
DAE.Type ty;
DAE.ComponentRef cref;
list<BackendDAE.Equation> eqLst;
case({}, _, _, syst as BackendDAE.EQSYSTEM(orderedEqs=_))
case({}, _, _, syst as BackendDAE.EQSYSTEM())
equation
then (BackendDAEUtil.clearEqSyst(syst));

Expand Down
10 changes: 5 additions & 5 deletions Compiler/BackEnd/Initialization.mo
Expand Up @@ -533,13 +533,13 @@ algorithm
then (stmts, inLeftCrs);

// inactive when equation during initialization
case DAE.STMT_WHEN(exp=condition, statementLst=stmts, elseWhen=NONE()) equation
case DAE.STMT_WHEN(exp=_, statementLst=stmts, elseWhen=NONE()) equation
crefLst = CheckModel.algorithmStatementListOutputs(stmts, DAE.EXPAND()); // expand as we're in an algorithm
leftCrs = List.fold(crefLst, BaseHashSet.add, inLeftCrs);
then (inAcc, leftCrs);

// inactive when equation during initialization with elsewhen part
case DAE.STMT_WHEN(exp=condition, statementLst=stmts, elseWhen=SOME(stmt)) equation
case DAE.STMT_WHEN(exp=_, statementLst=stmts, elseWhen=SOME(stmt)) equation
crefLst = CheckModel.algorithmStatementListOutputs(stmts, DAE.EXPAND()); // expand as we're in an algorithm
leftCrs = List.fold(crefLst, BaseHashSet.add, inLeftCrs);
(stmts, leftCrs) = inlineWhenForInitializationWhenStmt(stmt, leftCrs, inAcc);
Expand Down Expand Up @@ -1857,7 +1857,7 @@ algorithm
true = Expression.isZero(exp);
//listParameter = parameterCheck(exp);
//true = listEmpty(listParameter);
eqn = BackendEquation.get(inEqnsOrig, inUnassignedEqn);
_ = BackendEquation.get(inEqnsOrig, inUnassignedEqn);
// Error.addCompilerNotification("The following equation is consistent and got removed from the initialization problem: " + BackendDump.equationString(eqn));
then ({inUnassignedEqn}, true, {});

Expand Down Expand Up @@ -2294,7 +2294,7 @@ algorithm
isInput = BackendVariable.isVarOnTopLevelAndInput(var);
preUsed = BaseHashSet.has(cr, hs);

crefExp = Expression.crefExp(cr);
_ = Expression.crefExp(cr);

startCR = ComponentReference.crefPrefixStart(cr);
startVar = BackendVariable.copyVarNewName(startCR, var);
Expand Down Expand Up @@ -2340,7 +2340,7 @@ algorithm
isInput = BackendVariable.isVarOnTopLevelAndInput(var);
preUsed = BaseHashSet.has(cr, hs);

crefExp = Expression.crefExp(cr);
_ = Expression.crefExp(cr);

startCR = ComponentReference.crefPrefixStart(cr);
startVar = BackendVariable.copyVarNewName(startCR, var);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/SymbolicImplicitSolver.mo
Expand Up @@ -273,7 +273,7 @@ algorithm
cont = false;
then (DAE.BINARY(DAE.BINARY(e1, DAE.SUB(tp), e2), DAE.DIV(tp), e3), (List.unionElt(cr,cr_lst), orderedVars));

case (cr_lst, DAE.CREF(ty=tp, componentRef=cr))
case (cr_lst, DAE.CREF(ty=_, componentRef=cr))
equation
(e, cr_lst) = symSolverAppendStringToStates(cr, cr_lst, orderedVars);
then (e, (cr_lst, orderedVars));
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/SymbolicJacobian.mo
Expand Up @@ -1869,7 +1869,7 @@ algorithm
seedlst = List.map1(comref_vars, createSeedVars, inName);

// Differentiate the ODE system w.r.t states for jacobian
(backendDAE as BackendDAE.DAE(shared=shared), funcs) = generateSymbolicJacobian(reducedDAE, inDiffVars, inDifferentiatedVars, BackendVariable.listVar1(seedlst), inStateVars, inInputVars, inParameterVars, inName);
(backendDAE as BackendDAE.DAE(shared=_), funcs) = generateSymbolicJacobian(reducedDAE, inDiffVars, inDifferentiatedVars, BackendVariable.listVar1(seedlst), inStateVars, inInputVars, inParameterVars, inName);
if Flags.isSet(Flags.JAC_DUMP2) then
print("analytical Jacobians -> generated equations for Jacobian " + inName + " time: " + realString(clock()) + "\n");
end if;
Expand Down
12 changes: 6 additions & 6 deletions Compiler/BackEnd/SynchronousFeatures.mo
Expand Up @@ -822,7 +822,7 @@ algorithm
algorithm
solver1 := mergeSolver(solver1,solver2);
then BackendDAE.SUBCLOCK(MMath.divRational(f1, f2), MMath.addRational(MMath.multRational(s1, f2), s2), solver1);
case(BackendDAE.SUBCLOCK(f1,s1,solver1),BackendDAE.INFERED_SUBCLOCK())
case(BackendDAE.SUBCLOCK(_,_,_),BackendDAE.INFERED_SUBCLOCK())
then subSeqClock;
else
algorithm
Expand Down Expand Up @@ -909,7 +909,7 @@ algorithm
local
MMath.Rational shift;
Option<String> solver;
case(BackendDAE.SUBCLOCK(factor,shift,solver))
case(BackendDAE.SUBCLOCK(factor,_,_))
then factor;
else
then MMath.RAT1;
Expand All @@ -926,7 +926,7 @@ algorithm
local
MMath.Rational factor;
Option<String> solver;
case(BackendDAE.SUBCLOCK(factor,shift,solver))
case(BackendDAE.SUBCLOCK(_,shift,_))
then shift;
else
then MMath.RAT1;
Expand All @@ -942,7 +942,7 @@ algorithm
solver := match(subClk)
local
MMath.Rational factor,shift;
case(BackendDAE.SUBCLOCK(factor,shift,solver))
case(BackendDAE.SUBCLOCK(_,_,solver))
then solver;
else
then NONE();
Expand Down Expand Up @@ -1104,7 +1104,7 @@ algorithm
case(BackendDAE.EQUATION(exp=DAE.CREF(),scalar=DAE.CLKCONST(clk=DAE.INFERRED_CLOCK())))
algorithm
then false;
case(BackendDAE.EQUATION(exp=DAE.CREF(),scalar=DAE.CLKCONST(clk=clk)))
case(BackendDAE.EQUATION(exp=DAE.CREF(),scalar=DAE.CLKCONST()))
algorithm
then true;
else
Expand Down Expand Up @@ -1256,7 +1256,7 @@ algorithm
removeEdge(eqIdx,varIdx,m,mT);
then (clockEqsIn, eqIdx::subClockInterfaceEqIdxsIn, eq::subClockInterfaceEqsIn);

case(BackendDAE.EQUATION(scalar=e1, exp=e2))
case(BackendDAE.EQUATION(scalar=_))
algorithm
//print("Thats also not a base clock "+BackendDump.equationString(eq)+"\n");
then (clockEqsIn, subClockInterfaceEqIdxsIn, subClockInterfaceEqsIn);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/UnitCheck.mo
Expand Up @@ -790,7 +790,7 @@ algorithm
then (Unit.MASTER({}), (HtCr2U, HtS2U, HtU2S), expListList);

//IFEXP
case (DAE.IFEXP(exp1, exp2, exp3), (HtCr2U, HtS2U, HtU2S), _) equation
case (DAE.IFEXP(_, exp2, exp3), (HtCr2U, HtS2U, HtU2S), _) equation
//(_, (HtCr2U, HtS2U, HtU2S), expListList) = insertUnitInEquation(exp1, (HtCr2U, HtS2U, HtU2S), Unit.MASTER({}));
(ut, (HtCr2U, HtS2U, HtU2S), expListList2) = insertUnitInEquation(exp2, (HtCr2U, HtS2U, HtU2S), inUt);
(ut2, (HtCr2U, HtS2U, HtU2S), expListList3) = insertUnitInEquation(exp3, (HtCr2U, HtS2U, HtU2S), ut);
Expand All @@ -800,7 +800,7 @@ algorithm
expListList = listAppend(expListList2, expListList3);
then (ut, (HtCr2U, HtS2U, HtU2S), expListList);

case (DAE.IFEXP(exp1, exp2, exp3), (HtCr2U, HtS2U, HtU2S), _) equation
case (DAE.IFEXP(_, exp2, exp3), (HtCr2U, HtS2U, HtU2S), _) equation
//(_, (HtCr2U, HtS2U, HtU2S), expListList) = insertUnitInEquation(exp1, (HtCr2U, HtS2U, HtU2S), Unit.MASTER({}));
(ut, (HtCr2U, HtS2U, HtU2S), expListList2) = insertUnitInEquation(exp2, (HtCr2U, HtS2U, HtU2S), inUt);
(ut2, (HtCr2U, HtS2U, HtU2S), expListList3) = insertUnitInEquation(exp3, (HtCr2U, HtS2U, HtU2S), ut);
Expand Down
10 changes: 1 addition & 9 deletions Compiler/BackEnd/VisualXML.mo
Expand Up @@ -506,15 +506,7 @@ algorithm
end if;
then (SHAPE(ident, shapeType, T, r, r_shape, lengthDir, widthDir, length, width, height, extra, color, exp));

else
algorithm
BackendDAE.VAR(bindExp=bind) := var;
if isSome(bind) then
_ := if not Expression.isConstValue(Util.getOption(bind)) and storeProtectedCrefs then BackendVariable.varExp(var) else Util.getOption(bind);
else _ := DAE.SCONST("NO_BINDING");
end if;
//print("whats this? :"+ComponentReference.printComponentRefStr(cref)+" with binding: "+ExpressionDump.printExpStr(exp)+"\n");
then visIn;
else visIn;
end matchcontinue;
end fillShapeObject;

Expand Down
6 changes: 3 additions & 3 deletions Compiler/FFrontEnd/FCore.mo
Expand Up @@ -595,7 +595,7 @@ algorithm
// print("Func quard [there]: " + Absyn.pathString(func) + "\n");
then cache;

case (CACHE(igraph,ef,ht,p,program),Absyn.FULLYQUALIFIED(_))
case (CACHE(_,ef,_,_,_),Absyn.FULLYQUALIFIED(_))
equation
Mutable.update(ef,DAE.AvlTreePathFunction.add(Mutable.access(ef),func,NONE()));
// print("Func quard [new]: " + Absyn.pathString(func) + "\n");
Expand Down Expand Up @@ -624,7 +624,7 @@ algorithm
Absyn.Path p;
Absyn.Program program;

case (CACHE(igraph,ef,ht,p,program),_)
case (CACHE(_,ef,_,_,_),_)
equation
Mutable.update(ef,DAEUtil.addDaeFunction(funcs, Mutable.access(ef)));
then inCache;
Expand All @@ -647,7 +647,7 @@ algorithm
Absyn.Path p;
Absyn.Program program;

case (CACHE(igraph,ef,ht,p,program),_)
case (CACHE(_,ef,_,_,_),_)
equation
Mutable.update(ef,DAEUtil.addDaeExtFunction(funcs, Mutable.access(ef)));
then inCache;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/FrontEnd/Algorithm.mo
Expand Up @@ -381,7 +381,7 @@ protected
String c, l, r;
algorithm
for p in props loop
_ := matchcontinue p
_ := match p
// variables is fine
case DAE.PROP(constFlag = DAE.C_VAR()) then ();
// constant
Expand All @@ -407,7 +407,7 @@ algorithm
();
// tuples? TODO! FIXME! can we get tuple here? maybe only for MetaModelica
case DAE.PROP_TUPLE(_, _) then ();
end matchcontinue;
end match;
i := i + 1;
end for;
end checkLHSWritable;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Ceval.mo
Expand Up @@ -862,7 +862,7 @@ algorithm
then
(inCache, Values.EMPTY(inExp.scope, s, v, inExp.tyStr), inST);

case (_,env,e,_,_,_,_) guard Config.getGraphicsExpMode()
case (_,_,_,_,_,_,_) guard Config.getGraphicsExpMode()
algorithm
ty := Expression.typeof(inExp);
v := Types.typeToValue(ty);
Expand Down

0 comments on commit ec69d30

Please sign in to comment.