From 4ba7588dcfc6d7644cf3f148d6e7f03f70b6b061 Mon Sep 17 00:00:00 2001 From: Lennart Ochel Date: Wed, 29 Mar 2017 11:40:22 +0200 Subject: [PATCH] Remove obsolete start value call cases --- Compiler/BackEnd/BackendDAEUtil.mo | 9 --------- Compiler/BackEnd/CommonSubExpression.mo | 2 -- Compiler/BackEnd/Differentiate.mo | 5 ----- Compiler/BackEnd/Initialization.mo | 14 +++++++------- Compiler/FrontEnd/Expression.mo | 3 --- Compiler/Template/CodegenCFunctions.tpl | 4 ---- Compiler/Template/CodegenCSharp.tpl | 23 ++++------------------- Compiler/Template/CodegenCppCommon.tpl | 3 --- Compiler/Template/CodegenXML.tpl | 3 --- 9 files changed, 11 insertions(+), 55 deletions(-) diff --git a/Compiler/BackEnd/BackendDAEUtil.mo b/Compiler/BackEnd/BackendDAEUtil.mo index 2a8afc1e3d3..49df4b13bf3 100644 --- a/Compiler/BackEnd/BackendDAEUtil.mo +++ b/Compiler/BackEnd/BackendDAEUtil.mo @@ -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); @@ -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); diff --git a/Compiler/BackEnd/CommonSubExpression.mo b/Compiler/BackEnd/CommonSubExpression.mo index a8f871033e5..c6c7b886a53 100644 --- a/Compiler/BackEnd/CommonSubExpression.mo +++ b/Compiler/BackEnd/CommonSubExpression.mo @@ -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; diff --git a/Compiler/BackEnd/Differentiate.mo b/Compiler/BackEnd/Differentiate.mo index e6a09c3de43..124f393ce46 100644 --- a/Compiler/BackEnd/Differentiate.mo +++ b/Compiler/BackEnd/Differentiate.mo @@ -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); diff --git a/Compiler/BackEnd/Initialization.mo b/Compiler/BackEnd/Initialization.mo index adee779f7d9..f1821712d70 100644 --- a/Compiler/BackEnd/Initialization.mo +++ b/Compiler/BackEnd/Initialization.mo @@ -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; diff --git a/Compiler/FrontEnd/Expression.mo b/Compiler/FrontEnd/Expression.mo index 7521649b0f8..9fbf8122c63 100644 --- a/Compiler/FrontEnd/Expression.mo +++ b/Compiler/FrontEnd/Expression.mo @@ -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")), _) diff --git a/Compiler/Template/CodegenCFunctions.tpl b/Compiler/Template/CodegenCFunctions.tpl index 06b6679c106..b4fc04528f9 100644 --- a/Compiler/Template/CodegenCFunctions.tpl +++ b/Compiler/Template/CodegenCFunctions.tpl @@ -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) diff --git a/Compiler/Template/CodegenCSharp.tpl b/Compiler/Template/CodegenCSharp.tpl index 360f5619606..9e0a18cd758 100644 --- a/Compiler/Template/CodegenCSharp.tpl +++ b/Compiler/Template/CodegenCSharp.tpl @@ -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 => @@ -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 << diff --git a/Compiler/Template/CodegenCppCommon.tpl b/Compiler/Template/CodegenCppCommon.tpl index 363bef8f9f0..4ba7b646d62 100644 --- a/Compiler/Template/CodegenCppCommon.tpl +++ b/Compiler/Template/CodegenCppCommon.tpl @@ -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) diff --git a/Compiler/Template/CodegenXML.tpl b/Compiler/Template/CodegenXML.tpl index 486deb74bf6..6167fb6c1ea 100644 --- a/Compiler/Template/CodegenXML.tpl +++ b/Compiler/Template/CodegenXML.tpl @@ -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)%>