Changeset fc625e4 in OpenModelica


Ignore:
Timestamp:
2014-05-26T16:32:51+02:00 (10 years ago)
Author:
Per Östlund <per.ostlund@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
768e0be4
Parents:
6166857e
Message:
  • Added output of parentheses for if-expressions on the LHS in dumpers.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20840 f25d12d1-65f4-0310-ae8a-bbce733d8d8e

Location:
Compiler/Template
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Compiler/Template/AbsynDumpTpl.mo

    r52852791 rfc625e4  
    37213721           Absyn.EQ_EQUALS(leftSide = i_leftSide, rightSide = i_rightSide) )
    37223722      equation
    3723         l_lhs = dumpExp(Tpl.emptyTxt, i_leftSide);
     3723        l_lhs = dumpLhsExp(Tpl.emptyTxt, i_leftSide);
    37243724        l_rhs = dumpExp(Tpl.emptyTxt, i_rightSide);
    37253725        txt = Tpl.writeText(txt, l_lhs);
     
    40774077           Absyn.ALG_ASSIGN(assignComponent = i_assignComponent, value = i_value) )
    40784078      equation
    4079         l_lhs__str = dumpExp(Tpl.emptyTxt, i_assignComponent);
     4079        l_lhs__str = dumpLhsExp(Tpl.emptyTxt, i_assignComponent);
    40804080        l_rhs__str = dumpExp(Tpl.emptyTxt, i_value);
    40814081        txt = Tpl.writeText(txt, l_lhs__str);
     
    49424942end dumpExp;
    49434943
    4944 protected function fun_142
     4944public function dumpLhsExp
     4945  input Tpl.Text in_txt;
     4946  input Absyn.Exp in_a_lhs;
     4947
     4948  output Tpl.Text out_txt;
     4949algorithm
     4950  out_txt :=
     4951  match(in_txt, in_a_lhs)
     4952    local
     4953      Tpl.Text txt;
     4954      Absyn.Exp i_lhs;
     4955
     4956    case ( txt,
     4957           (i_lhs as Absyn.IFEXP(ifExp = _)) )
     4958      equation
     4959        txt = Tpl.writeTok(txt, Tpl.ST_STRING("("));
     4960        txt = dumpExp(txt, i_lhs);
     4961        txt = Tpl.writeTok(txt, Tpl.ST_STRING(")"));
     4962      then txt;
     4963
     4964    case ( txt,
     4965           i_lhs )
     4966      equation
     4967        txt = dumpExp(txt, i_lhs);
     4968      then txt;
     4969  end match;
     4970end dumpLhsExp;
     4971
     4972protected function fun_143
    49454973  input Tpl.Text in_txt;
    49464974  input Boolean in_mArg;
     
    49714999      then txt;
    49725000  end match;
    4973 end fun_142;
     5001end fun_143;
    49745002
    49755003public function dumpOperand
     
    49865014  l_op__str := dumpExp(Tpl.emptyTxt, a_operand);
    49875015  ret_1 := Dump.shouldParenthesize(a_operand, a_operation, a_lhs);
    4988   out_txt := fun_142(txt, ret_1, l_op__str);
     5016  out_txt := fun_143(txt, ret_1, l_op__str);
    49895017end dumpOperand;
    49905018
     
    50305058end dumpIfExp;
    50315059
    5032 protected function lm_145
     5060protected function lm_146
    50335061  input Tpl.Text in_txt;
    50345062  input list<tuple<Absyn.Exp, Absyn.Exp>> in_items;
     
    50625090        txt = Tpl.popBlock(txt);
    50635091        txt = Tpl.nextIter(txt);
    5064         txt = lm_145(txt, rest);
    5065       then txt;
    5066   end match;
    5067 end lm_145;
     5092        txt = lm_146(txt, rest);
     5093      then txt;
     5094  end match;
     5095end lm_146;
    50685096
    50695097public function dumpElseIfExp
     
    50745102algorithm
    50755103  out_txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
    5076   out_txt := lm_145(out_txt, a_else__if);
     5104  out_txt := lm_146(out_txt, a_else__if);
    50775105  out_txt := Tpl.popIter(out_txt);
    50785106end dumpElseIfExp;
    50795107
    5080 protected function fun_147
     5108protected function fun_148
    50815109  input Tpl.Text in_txt;
    50825110  input Boolean in_a_boolean;
     
    50995127      then txt;
    51005128  end match;
    5101 end fun_147;
    5102 
    5103 protected function fun_148
     5129end fun_148;
     5130
     5131protected function fun_149
    51045132  input Tpl.Text in_txt;
    51055133  input Boolean in_a_boolean;
     
    51225150      then txt;
    51235151  end match;
    5124 end fun_148;
    5125 
    5126 protected function fun_149
     5152end fun_149;
     5153
     5154protected function fun_150
    51275155  input Tpl.Text in_txt;
    51285156  input Boolean in_a_boolean;
     
    51455173      then txt;
    51465174  end match;
    5147 end fun_149;
     5175end fun_150;
    51485176
    51495177public function dumpCodeNode
     
    51845212           Absyn.C_CONSTRAINTSECTION(boolean = i_boolean, equationItemLst = i_equationItemLst) )
    51855213      equation
    5186         l_initial__str = fun_147(Tpl.emptyTxt, i_boolean);
     5214        l_initial__str = fun_148(Tpl.emptyTxt, i_boolean);
    51875215        l_eql__str = dumpEquationItems(Tpl.emptyTxt, i_equationItemLst);
    51885216        txt = Tpl.writeText(txt, l_initial__str);
     
    51965224           Absyn.C_EQUATIONSECTION(boolean = i_boolean, equationItemLst = i_equationItemLst) )
    51975225      equation
    5198         l_initial__str = fun_148(Tpl.emptyTxt, i_boolean);
     5226        l_initial__str = fun_149(Tpl.emptyTxt, i_boolean);
    51995227        l_eql__str = dumpEquationItems(Tpl.emptyTxt, i_equationItemLst);
    52005228        txt = Tpl.writeText(txt, l_initial__str);
     
    52085236           Absyn.C_ALGORITHMSECTION(boolean = i_boolean, algorithmItemLst = i_algorithmItemLst) )
    52095237      equation
    5210         l_initial__str = fun_149(Tpl.emptyTxt, i_boolean);
     5238        l_initial__str = fun_150(Tpl.emptyTxt, i_boolean);
    52115239        l_algs__str = dumpAlgorithmItems(Tpl.emptyTxt, i_algorithmItemLst);
    52125240        txt = Tpl.writeText(txt, l_initial__str);
     
    52415269end dumpCodeNode;
    52425270
    5243 protected function lm_151
     5271protected function lm_152
    52445272  input Tpl.Text in_txt;
    52455273  input list<Absyn.Case> in_items;
     
    52635291        txt = dumpMatchCase(txt, i_c);
    52645292        txt = Tpl.nextIter(txt);
    5265         txt = lm_151(txt, rest);
    5266       then txt;
    5267   end match;
    5268 end lm_151;
     5293        txt = lm_152(txt, rest);
     5294      then txt;
     5295  end match;
     5296end lm_152;
    52695297
    52705298public function dumpMatchExp
     
    52995327                                                                                       "\n"
    53005328                                                                                   }, true)), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
    5301         l_cases__str = lm_151(l_cases__str, i_cases);
     5329        l_cases__str = lm_152(l_cases__str, i_cases);
    53025330        l_cases__str = Tpl.popIter(l_cases__str);
    53035331        l_cmt__str = dumpStringCommentOption(Tpl.emptyTxt, i_comment);
     
    53525380end dumpMatchType;
    53535381
    5354 protected function lm_154
     5382protected function lm_155
    53555383  input Tpl.Text in_txt;
    53565384  input list<Absyn.ElementItem> in_items;
     
    53745402        txt = dumpElementItem(txt, i_decl);
    53755403        txt = Tpl.nextIter(txt);
    5376         txt = lm_154(txt, rest);
    5377       then txt;
    5378   end match;
    5379 end lm_154;
     5404        txt = lm_155(txt, rest);
     5405      then txt;
     5406  end match;
     5407end lm_155;
    53805408
    53815409public function dumpMatchLocals
     
    54015429        txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
    54025430        txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
    5403         txt = lm_154(txt, i_locals);
     5431        txt = lm_155(txt, i_locals);
    54045432        txt = Tpl.popIter(txt);
    54055433        txt = Tpl.softNewLine(txt);
     
    54105438end dumpMatchLocals;
    54115439
    5412 protected function lm_156
     5440protected function lm_157
    54135441  input Tpl.Text in_txt;
    54145442  input list<Absyn.EquationItem> in_items;
     
    54325460        txt = dumpEquationItem(txt, i_eq);
    54335461        txt = Tpl.nextIter(txt);
    5434         txt = lm_156(txt, rest);
    5435       then txt;
    5436   end match;
    5437 end lm_156;
     5462        txt = lm_157(txt, rest);
     5463      then txt;
     5464  end match;
     5465end lm_157;
    54385466
    54395467public function dumpMatchEquations
     
    54625490        txt = Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
    54635491        txt = Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
    5464         txt = lm_156(txt, i_eql);
     5492        txt = lm_157(txt, i_eql);
    54655493        txt = Tpl.popIter(txt);
    54665494        txt = Tpl.popBlock(txt);
     
    54695497end dumpMatchEquations;
    54705498
    5471 protected function fun_158
     5499protected function fun_159
    54725500  input Tpl.Text in_txt;
    54735501  input Option<Absyn.Exp> in_a_patternGuard;
     
    54935521      then txt;
    54945522  end match;
    5495 end fun_158;
    5496 
    5497 protected function fun_159
     5523end fun_159;
     5524
     5525protected function fun_160
    54985526  input Tpl.Text in_txt;
    54995527  input Tpl.Text in_a_eql__str;
     
    55295557      then txt;
    55305558  end match;
    5531 end fun_159;
     5559end fun_160;
    55325560
    55335561public function dumpMatchCase
     
    55575585      equation
    55585586        l_pattern__str = dumpExp(Tpl.emptyTxt, i_pattern);
    5559         l_guard__str = fun_158(Tpl.emptyTxt, i_patternGuard);
     5587        l_guard__str = fun_159(Tpl.emptyTxt, i_patternGuard);
    55605588        l_eql__str = dumpMatchEquations(Tpl.emptyTxt, i_equations);
    55615589        l_result__str = dumpExp(Tpl.emptyTxt, i_result);
    5562         l_then__str = fun_159(Tpl.emptyTxt, l_eql__str, l_result__str);
     5590        l_then__str = fun_160(Tpl.emptyTxt, l_eql__str, l_result__str);
    55635591        l_cmt__str = dumpStringCommentOption(Tpl.emptyTxt, i_comment);
    55645592        txt = Tpl.writeTok(txt, Tpl.ST_STRING("case "));
     
    57325760end dumpOperator;
    57335761
    5734 protected function fun_162
     5762protected function fun_163
    57355763  input Tpl.Text in_txt;
    57365764  input Boolean in_mArg;
     
    57535781      then txt;
    57545782  end match;
    5755 end fun_162;
     5783end fun_163;
    57565784
    57575785public function dumpCref
     
    57975825      equation
    57985826        ret_0 = Config.acceptMetaModelicaGrammar();
    5799         txt = fun_162(txt, ret_0);
     5827        txt = fun_163(txt, ret_0);
    58005828      then txt;
    58015829
     
    58125840end dumpCref;
    58135841
    5814 protected function lm_164
     5842protected function lm_165
    58155843  input Tpl.Text in_txt;
    58165844  input list<Absyn.Exp> in_items;
     
    58345862        txt = dumpExp(txt, i_arg);
    58355863        txt = Tpl.nextIter(txt);
    5836         txt = lm_164(txt, rest);
    5837       then txt;
    5838   end match;
    5839 end lm_164;
    5840 
    5841 protected function lm_165
     5864        txt = lm_165(txt, rest);
     5865      then txt;
     5866  end match;
     5867end lm_165;
     5868
     5869protected function lm_166
    58425870  input Tpl.Text in_txt;
    58435871  input list<Absyn.NamedArg> in_items;
     
    58615889        txt = dumpNamedArg(txt, i_narg);
    58625890        txt = Tpl.nextIter(txt);
    5863         txt = lm_165(txt, rest);
    5864       then txt;
    5865   end match;
    5866 end lm_165;
    5867 
    5868 protected function fun_166
     5891        txt = lm_166(txt, rest);
     5892      then txt;
     5893  end match;
     5894end lm_166;
     5895
     5896protected function fun_167
    58695897  input Tpl.Text in_txt;
    58705898  input list<Absyn.NamedArg> in_a_argNames;
     
    58875915      then txt;
    58885916  end match;
    5889 end fun_166;
    5890 
    5891 protected function fun_167
     5917end fun_167;
     5918
     5919protected function fun_168
    58925920  input Tpl.Text in_txt;
    58935921  input Tpl.Text in_a_args__str;
     
    59115939           a_argNames )
    59125940      equation
    5913         txt = fun_166(txt, a_argNames);
    5914       then txt;
    5915   end match;
    5916 end fun_167;
    5917 
    5918 protected function lm_168
     5941        txt = fun_167(txt, a_argNames);
     5942      then txt;
     5943  end match;
     5944end fun_168;
     5945
     5946protected function lm_169
    59195947  input Tpl.Text in_txt;
    59205948  input Absyn.ForIterators in_items;
     
    59385966        txt = dumpForIterator(txt, i_i);
    59395967        txt = Tpl.nextIter(txt);
    5940         txt = lm_168(txt, rest);
    5941       then txt;
    5942   end match;
    5943 end lm_168;
     5968        txt = lm_169(txt, rest);
     5969      then txt;
     5970  end match;
     5971end lm_169;
    59445972
    59455973public function dumpFunctionArgs
     
    59675995      equation
    59685996        l_args__str = Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
    5969         l_args__str = lm_164(l_args__str, i_args);
     5997        l_args__str = lm_165(l_args__str, i_args);
    59705998        l_args__str = Tpl.popIter(l_args__str);
    59715999        l_namedargs__str = Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
    5972         l_namedargs__str = lm_165(l_namedargs__str, i_argNames);
     6000        l_namedargs__str = lm_166(l_namedargs__str, i_argNames);
    59736001        l_namedargs__str = Tpl.popIter(l_namedargs__str);
    5974         l_separator = fun_167(Tpl.emptyTxt, l_args__str, i_argNames);
     6002        l_separator = fun_168(Tpl.emptyTxt, l_args__str, i_argNames);
    59756003        txt = Tpl.writeText(txt, l_args__str);
    59766004        txt = Tpl.writeText(txt, l_separator);
     
    59836011        l_exp__str = dumpExp(Tpl.emptyTxt, i_exp);
    59846012        l_iter__str = Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
    5985         l_iter__str = lm_168(l_iter__str, i_iterators);
     6013        l_iter__str = lm_169(l_iter__str, i_iterators);
    59866014        l_iter__str = Tpl.popIter(l_iter__str);
    59876015        txt = Tpl.writeText(txt, l_exp__str);
     
    60236051end dumpNamedArg;
    60246052
    6025 protected function lm_171
     6053protected function lm_172
    60266054  input Tpl.Text in_txt;
    60276055  input Absyn.ForIterators in_items;
     
    60456073        txt = dumpForIterator(txt, i_i);
    60466074        txt = Tpl.nextIter(txt);
    6047         txt = lm_171(txt, rest);
    6048       then txt;
    6049   end match;
    6050 end lm_171;
     6075        txt = lm_172(txt, rest);
     6076      then txt;
     6077  end match;
     6078end lm_172;
    60516079
    60526080public function dumpForIterators
     
    60576085algorithm
    60586086  out_txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
    6059   out_txt := lm_171(out_txt, a_iters);
     6087  out_txt := lm_172(out_txt, a_iters);
    60606088  out_txt := Tpl.popIter(out_txt);
    60616089end dumpForIterators;
    60626090
    6063 protected function fun_173
     6091protected function fun_174
    60646092  input Tpl.Text in_txt;
    60656093  input Option<Absyn.Exp> in_a_range;
     
    60866114      then txt;
    60876115  end match;
    6088 end fun_173;
    6089 
    6090 protected function fun_174
     6116end fun_174;
     6117
     6118protected function fun_175
    60916119  input Tpl.Text in_txt;
    60926120  input Option<Absyn.Exp> in_a_guardExp;
     
    61136141      then txt;
    61146142  end match;
    6115 end fun_174;
     6143end fun_175;
    61166144
    61176145public function dumpForIterator
     
    61346162           Absyn.ITERATOR(range = i_range, guardExp = i_guardExp, name = i_name) )
    61356163      equation
    6136         l_range__str = fun_173(Tpl.emptyTxt, i_range);
    6137         l_guard__str = fun_174(Tpl.emptyTxt, i_guardExp);
     6164        l_range__str = fun_174(Tpl.emptyTxt, i_range);
     6165        l_guard__str = fun_175(Tpl.emptyTxt, i_guardExp);
    61386166        txt = Tpl.writeStr(txt, i_name);
    61396167        txt = Tpl.writeText(txt, l_guard__str);
  • Compiler/Template/AbsynDumpTpl.tpl

    rf30c28d rfc625e4  
    539539    >>
    540540  case EQ_EQUALS(__) then
    541     let lhs = dumpExp(leftSide)
     541    let lhs = dumpLhsExp(leftSide)
    542542    let rhs = dumpExp(rightSide)
    543543    '<%lhs%> = <%rhs%>'
     
    600600match alg
    601601  case ALG_ASSIGN(__) then
    602     let lhs_str = dumpExp(assignComponent)
     602    let lhs_str = dumpLhsExp(assignComponent)
    603603    let rhs_str = dumpExp(value)
    604604    '<%lhs_str%> := <%rhs_str%>'
     
    803803end dumpExp;
    804804
     805template dumpLhsExp(Absyn.Exp lhs)
     806::=
     807match lhs
     808  case IFEXP(__) then '(<%dumpExp(lhs)%>)'
     809  else dumpExp(lhs)
     810end dumpLhsExp;
     811
    805812template dumpOperand(Absyn.Exp operand, Absyn.Exp operation, Boolean lhs)
    806813::=
  • Compiler/Template/DAEDumpTpl.tpl

    rffd0ca1 rfc625e4  
    612612template dumpEquation(DAE.Exp lhs, DAE.Exp rhs, DAE.ElementSource src)
    613613::=
    614   let lhs_str = dumpExp(lhs)
     614  let lhs_str = match lhs case IFEXP(__) then '(<%dumpExp(lhs)%>)' else dumpExp(lhs)
    615615  let rhs_str = dumpExp(rhs)
    616616  let src_str = dumpSource(src)
     
    813813template dumpAssignment(DAE.Exp lhs, DAE.Exp rhs, DAE.ElementSource src)
    814814::=
    815   let lhs_str = dumpExp(lhs)
     815  let lhs_str = match lhs case IFEXP(__) then '(<%dumpExp(lhs)%>)' else dumpExp(lhs)
    816816  let rhs_str = dumpExp(rhs)
    817817  let src_str = dumpSource(src)
  • Compiler/Template/SCodeDumpTpl.tpl

    rf30c28d rfc625e4  
    279279  case EQ_IF(__) then dumpIfEEquation(equation, options)
    280280  case EQ_EQUALS(__) then
    281     let lhs_str = AbsynDumpTpl.dumpExp(expLeft)
     281    let lhs_str = AbsynDumpTpl.dumpLhsExp(expLeft)
    282282    let rhs_str = AbsynDumpTpl.dumpExp(expRight)
    283283    let cmt_str = dumpComment(comment, options)
     
    416416match statement
    417417  case ALG_ASSIGN(__) then
    418     let lhs_str = AbsynDumpTpl.dumpExp(assignComponent)
     418    let lhs_str = AbsynDumpTpl.dumpLhsExp(assignComponent)
    419419    let rhs_str = AbsynDumpTpl.dumpExp(value)
    420420    let cmt_str = dumpComment(comment, options)
Note: See TracChangeset for help on using the changeset viewer.