From 00b44917fe0295b2b9b82284bc35f96f2e4f44e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Mon, 4 Apr 2011 09:57:50 +0000 Subject: [PATCH] - Started removing assert(true, ...) from algorithm sections (functions) git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8478 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- Compiler/BackEnd/SimCode.mo | 1 + Compiler/FrontEnd/Algorithm.mo | 20 ++++- Compiler/FrontEnd/ConnectUtil.mo | 7 +- Compiler/FrontEnd/DAE.mo | 14 ++- Compiler/FrontEnd/DAEUtil.mo | 33 ++++--- Compiler/FrontEnd/InstSection.mo | 39 +-------- Compiler/Template/Unparsing.mo | 59 ++++++------- .../susan_codegen/SimCode/SimCodeDump.tpl | 85 ++++++++++++++++++- Compiler/susan_codegen/SimCode/SimCodeTV.mo | 39 +++++++++ 9 files changed, 211 insertions(+), 86 deletions(-) diff --git a/Compiler/BackEnd/SimCode.mo b/Compiler/BackEnd/SimCode.mo index 7b1eef2fc76..4fe2da290a7 100644 --- a/Compiler/BackEnd/SimCode.mo +++ b/Compiler/BackEnd/SimCode.mo @@ -3017,6 +3017,7 @@ algorithm equation // Yes, do this better later on... print(Tpl.tplString(SimCodeDump.dumpSimCode, simCode)); + print("\n"); then (); case (_,target) equation diff --git a/Compiler/FrontEnd/Algorithm.mo b/Compiler/FrontEnd/Algorithm.mo index 3aaa0d536f1..8480290d35c 100644 --- a/Compiler/FrontEnd/Algorithm.mo +++ b/Compiler/FrontEnd/Algorithm.mo @@ -643,10 +643,26 @@ public function makeAssert "function: makeAssert input DAE.Properties inProperties3; input DAE.Properties inProperties4; input DAE.ElementSource source; - output Statement outStatement; + output list outStatement; algorithm outStatement := match (cond,msg,inProperties3,inProperties4,source) - case (cond,msg,DAE.PROP(type_ = (DAE.T_BOOL(varLstBool = _),_)),DAE.PROP(type_ = (DAE.T_STRING(varLstString = _),_)),source) then DAE.STMT_ASSERT(cond,msg,source); + local + String str; + Absyn.Info info; + case (DAE.BCONST(true),_,_,_,source) + then {}; + /* Do not evaluate all assertions. These may or may not be evaluated during runtime... + case (DAE.BCONST(false),DAE.SCONST(str),_,_,DAE.SOURCE(info=info)) + equation + Error.addSourceMessage(Error.ASSERT_CONSTANT_FALSE_ERROR,{str},info); + then fail(); + case (DAE.BCONST(false),_,_,_,DAE.SOURCE(info=info)) + equation + Error.addSourceMessage(Error.ASSERT_CONSTANT_FALSE_ERROR,{"Message was not constant and could not be evaluated"},info); + then fail(); + */ + case (cond,msg,DAE.PROP(type_ = (DAE.T_BOOL(varLstBool = _),_)),DAE.PROP(type_ = (DAE.T_STRING(varLstString = _),_)),source) + then {DAE.STMT_ASSERT(cond,msg,source)}; end match; end makeAssert; diff --git a/Compiler/FrontEnd/ConnectUtil.mo b/Compiler/FrontEnd/ConnectUtil.mo index cf0ad5a61d1..23496d2d641 100644 --- a/Compiler/FrontEnd/ConnectUtil.mo +++ b/Compiler/FrontEnd/ConnectUtil.mo @@ -1059,7 +1059,8 @@ algorithm list partOfLst; list> instanceOptLst; list>> connectEquationOptLst; - list typeLst; + list typeLst; + list operations; case {_} then DAEUtil.emptyDae; @@ -1067,9 +1068,9 @@ algorithm equation ee1 = Util.if_(RTOpts.orderConnections(), ee1, ee2); DAE.DAE(eq) = equEquations(ee1 :: cs); - DAE.SOURCE(info, partOfLst, instanceOptLst, connectEquationOptLst, typeLst) = DAEUtil.mergeSources(src1,src2); + DAE.SOURCE(info, partOfLst, instanceOptLst, connectEquationOptLst, typeLst, operations) = DAEUtil.mergeSources(src1,src2); // do not propagate connects from different sources! use the crefs directly! - src = DAE.SOURCE(info, partOfLst, instanceOptLst, {SOME((x,y))}, typeLst); + src = DAE.SOURCE(info, partOfLst, instanceOptLst, {SOME((x,y))}, typeLst, operations); then (DAE.DAE(DAE.EQUEQUATION(x,y,src) :: eq)); diff --git a/Compiler/FrontEnd/DAE.mo b/Compiler/FrontEnd/DAE.mo index d655bd289e8..d8bbf183b2f 100644 --- a/Compiler/FrontEnd/DAE.mo +++ b/Compiler/FrontEnd/DAE.mo @@ -97,10 +97,22 @@ uniontype ElementSource "gives information about the origin of the element" list> instanceOptLst "the instance(s) this element is part of"; list>> connectEquationOptLst "this element came from this connect(s)"; list typeLst "the classes where the type(s) of the element is defined"; + list operations "the symbolic operations used to end up with the final state of the element"; end SOURCE; end ElementSource; -public constant ElementSource emptyElementSource = SOURCE(Absyn.dummyInfo,{},{},{},{}); +public uniontype SymbolicOperation + record SIMPLIFY + Exp before; + Exp after; + end SIMPLIFY; + record SUBSTITUTION + Exp source; + Exp target; + end SUBSTITUTION; +end SymbolicOperation; + +public constant ElementSource emptyElementSource = SOURCE(Absyn.dummyInfo,{},{},{},{},{}); public uniontype Element record VAR diff --git a/Compiler/FrontEnd/DAEUtil.mo b/Compiler/FrontEnd/DAEUtil.mo index 1c4a7d51572..f5dea1ff982 100644 --- a/Compiler/FrontEnd/DAEUtil.mo +++ b/Compiler/FrontEnd/DAEUtil.mo @@ -4273,9 +4273,10 @@ algorithm list partOfLst "the models this element came from" ; list> instanceOptLst "the instance this element is part of" ; list>> connectEquationOptLst "this element came from this connect" ; + list operations; - case (DAE.SOURCE(info, partOfLst, instanceOptLst, connectEquationOptLst, typeLst), classPath) - then DAE.SOURCE(info, partOfLst, instanceOptLst, connectEquationOptLst, classPath::typeLst); + case (DAE.SOURCE(info, partOfLst, instanceOptLst, connectEquationOptLst, typeLst, operations), classPath) + then DAE.SOURCE(info, partOfLst, instanceOptLst, connectEquationOptLst, classPath::typeLst, operations); end match; end addElementSourceType; @@ -4308,9 +4309,10 @@ algorithm list partOfLst "the models this element came from" ; list> instanceOptLst "the instance this element is part of" ; list>> connectEquationOptLst "this element came from this connect" ; + list operations; - case (DAE.SOURCE(info,partOfLst, instanceOptLst, connectEquationOptLst, typeLst), withinPath) - then DAE.SOURCE(info,withinPath::partOfLst, instanceOptLst, connectEquationOptLst, typeLst); + case (DAE.SOURCE(info,partOfLst, instanceOptLst, connectEquationOptLst, typeLst, operations), withinPath) + then DAE.SOURCE(info,withinPath::partOfLst, instanceOptLst, connectEquationOptLst, typeLst, operations); end match; end addElementSourcePartOf; @@ -4347,8 +4349,9 @@ algorithm list> instanceOptLst "the instance this element is part of" ; list>> connectEquationOptLst "this element came from this connect" ; Absyn.Info info; - case (DAE.SOURCE(_,partOfLst,instanceOptLst,connectEquationOptLst,typeLst), info) - then DAE.SOURCE(info,partOfLst,instanceOptLst,connectEquationOptLst,typeLst); + list operations; + case (DAE.SOURCE(_,partOfLst,instanceOptLst,connectEquationOptLst,typeLst,operations), info) + then DAE.SOURCE(info,partOfLst,instanceOptLst,connectEquationOptLst,typeLst,operations); end match; end addElementSourceFileInfo; @@ -4364,10 +4367,11 @@ algorithm list> instanceOptLst "the instance this element is part of" ; list>> connectEquationOptLst "this element came from this connect" ; list typeLst "the classes where the type of the element is defined" ; + list operations; // a NONE() means top level (equivalent to NO_PRE, SOME(cref) means subcomponent - case (DAE.SOURCE(info,partOfLst,instanceOptLst,connectEquationOptLst,typeLst), instanceOpt) - then DAE.SOURCE(info,partOfLst,instanceOpt::instanceOptLst,connectEquationOptLst,typeLst); + case (DAE.SOURCE(info,partOfLst,instanceOptLst,connectEquationOptLst,typeLst,operations), instanceOpt) + then DAE.SOURCE(info,partOfLst,instanceOpt::instanceOptLst,connectEquationOptLst,typeLst,operations); end match; end addElementSourceInstanceOpt; @@ -4383,11 +4387,12 @@ algorithm list> instanceOptLst "the instance this element is part of" ; list>> connectEquationOptLst "this element came from this connect" ; list typeLst "the classes where the type of the element is defined" ; + list operations; // a top level case (inSource, NONE()) then inSource; - case (inSource as DAE.SOURCE(info,partOfLst,instanceOptLst,connectEquationOptLst,typeLst), connectEquationOpt) - then DAE.SOURCE(info,partOfLst,instanceOptLst,connectEquationOpt::connectEquationOptLst,typeLst); + case (inSource as DAE.SOURCE(info,partOfLst,instanceOptLst,connectEquationOptLst,typeLst,operations), connectEquationOpt) + then DAE.SOURCE(info,partOfLst,instanceOptLst,connectEquationOpt::connectEquationOptLst,typeLst,operations); end matchcontinue; end addElementSourceConnectOpt; @@ -4424,14 +4429,16 @@ algorithm list> instanceOptLst1,instanceOptLst2,i; list>> connectEquationOptLst1,connectEquationOptLst2,c; list typeLst1,typeLst2,t; - case (DAE.SOURCE(info, partOfLst1, instanceOptLst1, connectEquationOptLst1, typeLst1), - DAE.SOURCE(_ /* Discard */, partOfLst2, instanceOptLst2, connectEquationOptLst2, typeLst2)) + list o,operations1,operations2; + case (DAE.SOURCE(info, partOfLst1, instanceOptLst1, connectEquationOptLst1, typeLst1, operations1), + DAE.SOURCE(_ /* Discard */, partOfLst2, instanceOptLst2, connectEquationOptLst2, typeLst2, operations2)) equation p = listAppend(partOfLst1, partOfLst2); i = listAppend(instanceOptLst1, instanceOptLst2); c = listAppend(connectEquationOptLst1, connectEquationOptLst1); t = listAppend(typeLst1, typeLst2); - then DAE.SOURCE(info,p,i,c,t); + o = listAppend(operations1, operations2); + then DAE.SOURCE(info,p,i,c,t, o); end match; end mergeSources; diff --git a/Compiler/FrontEnd/InstSection.mo b/Compiler/FrontEnd/InstSection.mo index 1d172484efa..74ee792f544 100644 --- a/Compiler/FrontEnd/InstSection.mo +++ b/Compiler/FrontEnd/InstSection.mo @@ -462,41 +462,6 @@ algorithm then (cache,env,ih,dae,csets_1,ci_state_1,graph); - //------------------------------------------------------ - // Part of the MetaModelica extension - /* equality equations cref = array(...) */ - // Should be removed?? - // case (cache,env,ih,mods,pre,csets,ci_state,SCode.EQ_EQUALS(e1 as Absyn.CREF(cr),Absyn.ARRAY(expList)),initial_,impl) - // local Option c1,c2; - // list expList; - // Absyn.ComponentRef cr; - // DAE.Properties cprop; - // equation - // true = RTOpts.acceptMetaModelicaGrammar(); - // If this is a list assignment, then the Absyn.ARRAY expression should - // be evaluated to DAE.LIST - // (cache,_,cprop,_) = Static.elabCref(cache,env, cr, impl,false); - // true = MetaUtil.isList(cprop); - // Do static analysis and constant evaluation of expressions. - // Gives expression and properties - // (Type bool | (Type Const as (bool | Const list))). - // For a function, it checks the funtion name. - // Also the function call\'s in parameters are type checked with - // the functions definition\'s inparameters. This is done with - // regard to the position of the input arguments. - // Returns the output parameters from the function. - // (cache,e1_1,prop1,c1) = Static.elabExp(cache,env, e1, impl,NONE(),true /*do vectorization*/); - // (cache,e2_1,prop2,c2) = Static.elabListExp(cache,env, expList, cprop, impl,NONE(),true/* do vectorization*/); - // (cache,e1_1,e2_1) = condenseArrayEquation(cache,env,e1,e2,e1_1,e2_1,prop1,impl); - // (cache,e1_2) = PrefixUtil.prefixExp(cache, env, ih, e1_1, pre); - // (cache,e2_2) = PrefixUtil.prefixExp(cache, env, ih, e2_1, pre); - // Check that the lefthandside and the righthandside get along. - // dae = instEqEquation(e1_2, prop1, e2_2, prop2, initial_, impl); - // ci_state_1 = instEquationCommonCiTrans(ci_state, initial_); - // then - // (cache,env,ih,dae,csets,ci_state_1); - //------------------------------------------------------ - /* equality equations e1 = e2 */ case (cache,env,ih,mods,pre,csets,ci_state,SCode.EQ_EQUALS(expLeft = e1,expRight = e2,info = info),initial_,impl,graph) equation @@ -2473,9 +2438,9 @@ algorithm (cache, msg_1, msgprop) = Ceval.cevalIfConstant(cache, env, msg_1, msgprop, impl); (cache,msg_2) = PrefixUtil.prefixExp(cache, env, ih, msg_1, pre); source = DAEUtil.addElementSourceFileInfo(source, info); - stmt = Algorithm.makeAssert(cond_2, msg_2, cprop, msgprop, source); + stmts = Algorithm.makeAssert(cond_2, msg_2, cprop, msgprop, source); then - (cache,{stmt}); + (cache,stmts); /* terminate(msg) */ case (cache,env,ih,pre,SCode.ALG_NORETCALL(functionCall = Absyn.CREF_IDENT(name = "terminate"), diff --git a/Compiler/Template/Unparsing.mo b/Compiler/Template/Unparsing.mo index 3ea5943e0b1..bafba385fae 100644 --- a/Compiler/Template/Unparsing.mo +++ b/Compiler/Template/Unparsing.mo @@ -20,8 +20,9 @@ public import Error; public import Values; public import ValuesUtil; public import BackendQSS; +public import DAEDump; -protected function lm_20 +protected function lm_21 input Tpl.Text in_txt; input SCode.Program in_items; @@ -42,16 +43,16 @@ algorithm i_cl :: rest ) equation txt = classExternalHeader(txt, i_cl, ""); - txt = lm_20(txt, rest); + txt = lm_21(txt, rest); then txt; case ( txt, _ :: rest ) equation - txt = lm_20(txt, rest); + txt = lm_21(txt, rest); then txt; end matchcontinue; -end lm_20; +end lm_21; public function programExternalHeader input Tpl.Text txt; @@ -65,7 +66,7 @@ algorithm "extern \"C\" {\n", "#endif\n" }, true)); - out_txt := lm_20(out_txt, a_program); + out_txt := lm_21(out_txt, a_program); out_txt := Tpl.softNewLine(out_txt); out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({ "#ifdef __cplusplus\n", @@ -75,7 +76,7 @@ algorithm }, true)); end programExternalHeader; -protected function lm_22 +protected function lm_23 input Tpl.Text in_txt; input list in_items; input SCode.Ident in_a_c_name; @@ -100,19 +101,19 @@ algorithm a_c_name ) equation txt = elementExternalHeader(txt, i_elt, a_c_name); - txt = lm_22(txt, rest, a_c_name); + txt = lm_23(txt, rest, a_c_name); then txt; case ( txt, _ :: rest, a_c_name ) equation - txt = lm_22(txt, rest, a_c_name); + txt = lm_23(txt, rest, a_c_name); then txt; end matchcontinue; -end lm_22; +end lm_23; -protected function fun_23 +protected function fun_24 input Tpl.Text in_txt; input SCode.Class in_a_cl; @@ -128,14 +129,14 @@ algorithm case ( txt, SCode.CLASS(classDef = SCode.PARTS(elementLst = i_p_elementLst), name = i_c_name) ) equation - txt = lm_22(txt, i_p_elementLst, i_c_name); + txt = lm_23(txt, i_p_elementLst, i_c_name); then txt; case ( txt, _ ) then txt; end matchcontinue; -end fun_23; +end fun_24; public function classExternalHeader input Tpl.Text txt; @@ -144,7 +145,7 @@ public function classExternalHeader output Tpl.Text out_txt; algorithm - out_txt := fun_23(txt, a_cl); + out_txt := fun_24(txt, a_cl); end classExternalHeader; public function pathString @@ -187,7 +188,7 @@ algorithm end matchcontinue; end pathString; -protected function lm_26 +protected function lm_27 input Tpl.Text in_txt; input list in_items; @@ -209,18 +210,18 @@ algorithm equation txt = Tpl.writeStr(txt, i_component); txt = Tpl.nextIter(txt); - txt = lm_26(txt, rest); + txt = lm_27(txt, rest); then txt; case ( txt, _ :: rest ) equation - txt = lm_26(txt, rest); + txt = lm_27(txt, rest); then txt; end matchcontinue; -end lm_26; +end lm_27; -protected function lm_27 +protected function lm_28 input Tpl.Text in_txt; input list in_items; @@ -244,18 +245,18 @@ algorithm txt = Tpl.writeStr(txt, i_component); txt = Tpl.writeTok(txt, Tpl.ST_STRING("\"")); txt = Tpl.nextIter(txt); - txt = lm_27(txt, rest); + txt = lm_28(txt, rest); then txt; case ( txt, _ :: rest ) equation - txt = lm_27(txt, rest); + txt = lm_28(txt, rest); then txt; end matchcontinue; -end lm_27; +end lm_28; -protected function fun_28 +protected function fun_29 input Tpl.Text in_txt; input String in_mArg; input Tpl.Text in_a_fieldsStr; @@ -298,9 +299,9 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING("};")); then txt; end matchcontinue; -end fun_28; +end fun_29; -protected function fun_29 +protected function fun_30 input Tpl.Text in_txt; input list in_a_p_elementLst; input Tpl.Text in_a_fields; @@ -371,7 +372,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_NEW_LINE()); then txt; end matchcontinue; -end fun_29; +end fun_30; public function elementExternalHeader input Tpl.Text in_txt; @@ -408,10 +409,10 @@ algorithm a_pack ) equation l_fields = Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - l_fields = lm_26(l_fields, i_p_elementLst); + l_fields = lm_27(l_fields, i_p_elementLst); l_fields = Tpl.popIter(l_fields); l_fieldsStr = Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); - l_fieldsStr = lm_27(l_fieldsStr, i_p_elementLst); + l_fieldsStr = lm_28(l_fieldsStr, i_p_elementLst); l_fieldsStr = Tpl.popIter(l_fieldsStr); l_omcname = Tpl.writeStr(Tpl.emptyTxt, a_pack); l_omcname = Tpl.writeTok(l_omcname, Tpl.ST_STRING("_")); @@ -428,7 +429,7 @@ algorithm ret_9 = intAdd(3, i_r_index); l_ctor = Tpl.writeStr(Tpl.emptyTxt, intString(ret_9)); str_11 = Tpl.textString(l_nElts); - l_fieldsDescription = fun_28(Tpl.emptyTxt, str_11, l_fieldsStr, l_nElts, l_omcname); + l_fieldsDescription = fun_29(Tpl.emptyTxt, str_11, l_fieldsStr, l_nElts, l_omcname); txt = Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ "#ifdef ADD_METARECORD_DEFINTIONS\n", "#ifndef " @@ -479,7 +480,7 @@ algorithm txt = Tpl.writeTok(txt, Tpl.ST_STRING(" ")); txt = Tpl.writeText(txt, l_ctor); txt = Tpl.softNewLine(txt); - txt = fun_29(txt, i_p_elementLst, l_fields, l_omcname, l_ctor, l_fullname); + txt = fun_30(txt, i_p_elementLst, l_fields, l_omcname, l_ctor, l_fullname); then txt; case ( txt, diff --git a/Compiler/susan_codegen/SimCode/SimCodeDump.tpl b/Compiler/susan_codegen/SimCode/SimCodeDump.tpl index eafd9725138..1e4194599ed 100644 --- a/Compiler/susan_codegen/SimCode/SimCodeDump.tpl +++ b/Compiler/susan_codegen/SimCode/SimCodeDump.tpl @@ -6,12 +6,95 @@ import SimCodeC.*; template dumpSimCode(SimCode code) ::= match code - case sc as SIMCODE(modelInfo=mi as MODELINFO(__)) then + case sc as SIMCODE(modelInfo=mi as MODELINFO(vars=vars as SIMVARS(__))) then << SimCode: <%dotPath(mi.name)%> + <%dumpVars(vars.stateVars)%> + <%dumpVars(vars.derivativeVars)%> + <%dumpVars(vars.algVars)%> + <%dumpVars(vars.intAlgVars)%> + <%dumpVars(vars.boolAlgVars)%> + <%dumpVars(vars.inputVars)%> + <%dumpVars(vars.outputVars)%> + <%dumpVars(vars.aliasVars)%> + <%dumpVars(vars.intAliasVars)%> + <%dumpVars(vars.boolAliasVars)%> + <%dumpVars(vars.paramVars)%> + <%dumpVars(vars.intParamVars)%> + <%dumpVars(vars.boolParamVars)%> + <%dumpVars(vars.stringAlgVars)%> + <%dumpVars(vars.stringParamVars)%> + <%dumpVars(vars.stringAliasVars)%> + <%dumpVars(vars.extObjVars)%> + <%dumpVars(vars.jacobianVars)%> + <%dumpVars(vars.constVars)%> + <%dumpEqs(sc.allEquations)%> >> end dumpSimCode; +template dumpVars(list vars) +::= + vars |> v as SIMVAR(__) => + << + <%crefStr(v.name)%> <%v.comment%> <%dumpAlias(v.aliasvar)%><%\n%> + >> +end dumpVars; + +template dumpAlias(AliasVariable alias) +::= + match alias + case ALIAS(__) then 'alias of <%crefStr(varName)%>' + case NEGATEDALIAS(__) then 'alias of -<%crefStr(varName)%>' +end dumpAlias; + +template dumpEqs(list eqs) +::= eqs |> eq => + match eq + case e as SES_RESIDUAL(__) then "RESIDUAL" + case e as SES_SIMPLE_ASSIGN(__) then + << + eq: <%crefStr(e.cref)%> = <%printExpStr(e.exp)%>; + <%dumpElementSource(e.source)%><%\n%> + >> + case e as SES_ARRAY_CALL_ASSIGN(__) then "SES_ARRAY_CALL_ASSIGN" + case e as SES_ALGORITHM(statements={}) then 'empty algorithm<%\n%>' + case e as SES_ALGORITHM(__) + then (e.statements |> stmt => ppStmtStr(stmt,2)) + case e as SES_LINEAR(__) then "SES_LINEAR" + case e as SES_NONLINEAR(__) then "SES_NONLINEAR" + case e as SES_MIXED(__) then "SES_MIXED" + case e as SES_WHEN(__) then "SES_WHEN" + else "UNKNOWN" +end dumpEqs; + +template dumpWithin(Within w) +::= + match w + case TOP(__) then "within ;" + case WITHIN(__) then 'within <%dotPath(path)%>;' +end dumpWithin; + +template dumpElementSource(ElementSource source) +::= + match source + case s as SOURCE(__) then + << + <%infoStr(s.info)%> + partOfLst: <%s.partOfLst |> w => dumpWithin(w)%> + instanceOptLst: <%s.instanceOptLst |> SOME(cr) => crefStr(cr)%> + connectEquationOptLst: <%s.connectEquationOptLst |> p => "w"%> + typeLst: <%s.typeLst |> p => "w"%> + operations: <%s.operations |> op => dumpOperation(op,s.info) %> + >> +end dumpElementSource; + +template dumpOperation(SymbolicOperation op, Info info) +::= + match op + case SIMPLIFY(__) then "SIMPLIFY!" + else Tpl.addSourceTemplateError("Unknown operation",info) +end dumpOperation; + end SimCodeDump; // vim: filetype=susan sw=2 sts=2 diff --git a/Compiler/susan_codegen/SimCode/SimCodeTV.mo b/Compiler/susan_codegen/SimCode/SimCodeTV.mo index 110a8ea75ea..09602e22b7e 100644 --- a/Compiler/susan_codegen/SimCode/SimCodeTV.mo +++ b/Compiler/susan_codegen/SimCode/SimCodeTV.mo @@ -158,14 +158,17 @@ package SimCode uniontype SimEqSystem record SES_RESIDUAL DAE.Exp exp; + DAE.ElementSource source; end SES_RESIDUAL; record SES_SIMPLE_ASSIGN DAE.ComponentRef cref; DAE.Exp exp; + DAE.ElementSource source; end SES_SIMPLE_ASSIGN; record SES_ARRAY_CALL_ASSIGN DAE.ComponentRef componentRef; DAE.Exp exp; + DAE.ElementSource source; end SES_ARRAY_CALL_ASSIGN; record SES_ALGORITHM list statements; @@ -195,6 +198,7 @@ package SimCode DAE.Exp right; list> conditions; Option elseWhen; + DAE.ElementSource source; end SES_WHEN; end SimEqSystem; @@ -648,6 +652,15 @@ package Absyn end INFO; end Info; + uniontype Within "Within Clauses" + record WITHIN "the within clause" + Path path "the path for within"; + end WITHIN; + + record TOP end TOP; + + end Within; + constant Info dummyInfo; end Absyn; @@ -1201,8 +1214,24 @@ package DAE uniontype ElementSource record SOURCE Absyn.Info info; + list partOfLst; + list> instanceOptLst; + list>> connectEquationOptLst; + list typeLst; + list operations; end SOURCE; end ElementSource; + + uniontype SymbolicOperation + record SIMPLIFY + Exp before; + Exp after; + end SIMPLIFY; + record SUBSTITUTION + Exp source; + Exp target; + end SUBSTITUTION; + end SymbolicOperation; end DAE; @@ -1815,4 +1844,14 @@ package BackendQSS end replaceZC; end BackendQSS; +package DAEDump + + function ppStmtStr + input DAE.Statement stmt; + input Integer inInteger; + output String outString; + end ppStmtStr; + +end DAEDump; + end SimCodeTV;