Skip to content

Commit

Permalink
Remove obsolete start value call cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel authored and OpenModelica-Hudson committed Mar 29, 2017
1 parent bca32a3 commit 4ba7588
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 55 deletions.
9 changes: 0 additions & 9 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -2711,11 +2711,6 @@ algorithm
pa = incidenceRowExp1(varslst, p, pa, diffindx);
then (inExp, false,(vars, pa, ofunctionTree));

// lochel: internally generated call start(v) depends not on v
// TODO: REMOVE THIS CASE
case (DAE.CALL(path=Absyn.IDENT(name="$_start")), tpl)
then (inExp, false, tpl);

/* pre(v) is considered a known variable */
case (DAE.CALL(path=Absyn.IDENT(name="pre")), tpl)
then (inExp, false, tpl);
Expand Down Expand Up @@ -2889,10 +2884,6 @@ algorithm
(_,(_,res)) = Expression.traverseExpTopDownCrefHelper(cr, traversingincidenceRowExpFinder, (vars,res));
then (e,false,(vars,res));

// lochel: internally generated call start(v) depends not on v
// TODO: REMOVE THIS CASE
case (DAE.CALL(path = Absyn.IDENT(name = "$_start")), _) then (inExp, false, inTpl);

/* pre(v) is considered a known variable */
case (DAE.CALL(path = Absyn.IDENT(name = "pre"),expLst = {DAE.CREF()}),_) then (inExp,false,inTpl);

Expand Down
2 changes: 0 additions & 2 deletions Compiler/BackEnd/CommonSubExpression.mo
Expand Up @@ -874,8 +874,6 @@ algorithm
case DAE.CALL(path=Absyn.IDENT("$_initialGuess")) then true;
case DAE.CALL(path=Absyn.IDENT("$_old")) then true;
case DAE.CALL(path=Absyn.IDENT("$_round")) then true;
// TODO: REMOVE THIS CASE
case DAE.CALL(path=Absyn.IDENT("$_start")) then true;
case DAE.CALL(path=Absyn.IDENT("$getPart")) then true;
case DAE.CALL(path=Absyn.IDENT("abs")) then true;
case DAE.CALL(path=Absyn.IDENT("actualStream")) then true;
Expand Down
5 changes: 0 additions & 5 deletions Compiler/BackEnd/Differentiate.mo
Expand Up @@ -594,11 +594,6 @@ algorithm
//print("\nresults to exp: " + se1);
then (res, functionTree);

// differentiate start value
// TODO: REMOVE THIS CASE
case DAE.CALL(path=Absyn.IDENT(name="$_start"), attr=DAE.CALL_ATTR(ty=tp))
then (Expression.makeConstZero(tp), inFunctionTree);

// differentiate homotopy
case DAE.CALL(path=p as Absyn.IDENT(name="homotopy"), expLst={actual, simplified}, attr=attr) equation
(e1, functionTree) = differentiateExp(actual, inDiffwrtCref, inInputData, inDiffType, inFunctionTree, maxIter, inExpStack);
Expand Down
14 changes: 7 additions & 7 deletions Compiler/BackEnd/Initialization.mo
Expand Up @@ -1911,13 +1911,13 @@ protected
algorithm
(parameters, anyStartValue) := inParams;
(outParams, outContinue) := match inExp
case DAE.CREF(componentRef=componentRef) equation
parameters = ComponentReference.crefStr(componentRef)::parameters;
then ((parameters, anyStartValue), true);

// TODO: REMOVE THIS CASE
case DAE.CALL(path=Absyn.IDENT(name="$_start"))
then ((parameters, true), false);
case DAE.CREF(componentRef=componentRef) algorithm
if ComponentReference.isStartCref(componentRef) then
anyStartValue := true;
else
parameters := ComponentReference.crefStr(componentRef)::parameters;
end if;
then ((parameters, anyStartValue), not anyStartValue);

else ((parameters, anyStartValue), true);
end match;
Expand Down
3 changes: 0 additions & 3 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -6636,9 +6636,6 @@ algorithm
then (inExp,false,inTpl);
case (DAE.CALL(path = Absyn.IDENT(name = "edge")), _)
then (inExp,false,inTpl);
// TODO: REMOVE THIS CASE
case (DAE.CALL(path = Absyn.IDENT(name = "$_start")), _)
then (inExp,false,inTpl);
case (DAE.CALL(path = Absyn.IDENT(name = "$_initialGuess")), _)
then (inExp,false,inTpl);
case (DAE.CALL(path = Absyn.IDENT(name = "$_round")), _)
Expand Down
4 changes: 0 additions & 4 deletions Compiler/Template/CodegenCFunctions.tpl
Expand Up @@ -5544,10 +5544,6 @@ template daeExpCall(Exp call, Context context, Text &preExp, Text &varDecls, Tex
'(data->simulationInfo->clocksData[clockIndex].cnt == 0)'
case CALL(path=IDENT(name="$_clkfire"), expLst={arg as ICONST(__)}) then
'fireClock(data, threadData, <%intSub(arg.integer,1)%>, data->localData[0]->timeValue)'

// a $_start is used to get get start value of a variable
case CALL(path=IDENT(name="$_start"), expLst={arg}) then
daeExpCallStart(arg, context, preExp, varDecls, &auxFunction)
// a $_initialGuess is used to get initial guess for nonlinear solver
case CALL(path=IDENT(name="$_initialGuess"), expLst={arg as CREF(__)}) then
let namestr = cref(arg.componentRef)
Expand Down
23 changes: 4 additions & 19 deletions Compiler/Template/CodegenCSharp.tpl
Expand Up @@ -1215,22 +1215,10 @@ match eq
case SES_SIMPLE_ASSIGN(__) then
let &preExp = buffer ""
let expPart = daeExp(exp, context, &preExp, simCode) //was daeExpToReal
//a hack - start values should be never on the right side of an equation,
//specially in FunInitialEquations()
let codeTxt =
<<
<%preExp%>
<%cref(cref, simCode)%> = <%expPart%>;
>>
match exp
case CALL(path=IDENT(name="$_start"), expLst={arg as CREF(__)}) then
<<
//### useless start value assignment ??
//<%codeTxt%>
//###
>>
else
codeTxt
<<
<%preExp%>
<%cref(cref, simCode)%> = <%expPart%>;
>>
case SES_ARRAY_CALL_ASSIGN(__) then "SES_ARRAY_CALL_ASSIGN"
case SES_ALGORITHM(__) then
(statements |> stmt =>
Expand Down Expand Up @@ -2655,9 +2643,6 @@ template daeExpCall(Exp inExp, Context context, Text &preExp, SimCode simCode) :
let castedVar = daeExp(toBeCasted, context, &preExp, simCode)
'((int)<%castedVar%>)'

case CALL(path=IDENT(name="$_start"), expLst={arg as CREF(__)}) then
startCref(arg.componentRef, simCode)

//'(/*edge(h[<%idx%>])*/H[<%idx%>]!=0.0 && preH[<%idx%>]==0.0)'
case CALL(path=IDENT(name="edge"), expLst={arg as CREF(__)}) then
<<
Expand Down
3 changes: 0 additions & 3 deletions Compiler/Template/CodegenCppCommon.tpl
Expand Up @@ -1971,9 +1971,6 @@ template daeExpCall(Exp call, Context context, Text &preExp /*BUFP*/, Text &varD

let &preExp += 'fill_array<<%ty_str%>>(<%tvar%>, <%valExp%>);<%\n%>'
'<%tvar%>'
case CALL(path=IDENT(name="$_start"), expLst={arg}) then
daeExpCallStart(arg, context, preExp, varDecls,simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)


case CALL(path=IDENT(name="cat"), expLst=dim::a0::arrays, attr=attr as CALL_ATTR(__)) then
let dim_exp = daeExp(dim, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
Expand Down
3 changes: 0 additions & 3 deletions Compiler/Template/CodegenXML.tpl
Expand Up @@ -3055,9 +3055,6 @@ template daeExpCallXml(Exp call, Context context, Text &preExp /*BUFP*/,
error(sourceInfo(), 'Code generation does not support der(<%ExpressionDumpTpl.dumpExp(exp,"\"")%>)')
case CALL(path=IDENT(name="pre"), expLst={arg}) then
daeExpCallPreXml(arg, context, preExp, varDecls)
// a $_start is used to get get start value of a variable
case CALL(path=IDENT(name="$_start"), expLst={arg}) then
daeExpCallPreXml(arg, context, preExp, varDecls)
case CALL(path=IDENT(name="edge"), expLst={arg as CREF(__)}) then
<<
<%crefXml(arg.componentRef)%>
Expand Down

0 comments on commit 4ba7588

Please sign in to comment.