Skip to content

Commit

Permalink
- Added min of array to code generator.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5677 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Jun 16, 2010
1 parent 601156d commit d41f891
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Compiler/SimCodeC.mo
Expand Up @@ -20282,6 +20282,32 @@ algorithm
txt = Tpl.writeText(txt, i_tvar);
then (txt, i_preExp, i_varDecls);

case ( txt,
DAE.CALL(tuple_ = false, builtin = true, path = Absyn.IDENT(name = "min"), expLst = {i_array}),
i_context,
i_preExp,
i_varDecls )
local
DAE.Exp i_array;
Tpl.Text txt_3;
Tpl.Text i_tvar;
Tpl.Text i_arr__tp__str;
Tpl.Text i_expVar;
equation
(i_expVar, i_preExp, i_varDecls) = daeExp(emptyTxt, i_array, i_context, i_preExp, i_varDecls);
i_arr__tp__str = expTypeFromExpArray(emptyTxt, i_array);
txt_3 = expTypeFromExpModelica(emptyTxt, i_array);
(i_tvar, i_varDecls) = tempDecl(emptyTxt, Tpl.textString(txt_3), i_varDecls);
i_preExp = Tpl.writeText(i_preExp, i_tvar);
i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING(" = min_"));
i_preExp = Tpl.writeText(i_preExp, i_arr__tp__str);
i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING("(&"));
i_preExp = Tpl.writeText(i_preExp, i_expVar);
i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_STRING(");"));
i_preExp = Tpl.writeTok(i_preExp, Tpl.ST_NEW_LINE());
txt = Tpl.writeText(txt, i_tvar);
then (txt, i_preExp, i_varDecls);

case ( txt,
DAE.CALL(tuple_ = false, builtin = true, path = Absyn.IDENT(name = "promote"), expLst = {i_A, i_n}),
i_context,
Expand Down
8 changes: 8 additions & 0 deletions Compiler/susan_codegen/SimCode/SimCodeC.tpl
Expand Up @@ -3691,6 +3691,14 @@ template daeExpCall(Exp call, Context context, Text &preExp /*BUFP*/,
let tvar = tempDecl(expTypeFromExpModelica(array), &varDecls /*BUFC*/)
let &preExp += '<%tvar%> = max_<%arr_tp_str%>(&<%expVar%>);<%\n%>'
tvar
case CALL(tuple_=false, builtin=true,
path=IDENT(name="min"), expLst={array}) then
let expVar = daeExp(array, context, &preExp /*BUFC*/, &varDecls /*BUFC*/)
let arr_tp_str = '<%expTypeFromExpArray(array)%>'
let tvar = tempDecl(expTypeFromExpModelica(array), &varDecls /*BUFC*/)
let &preExp += '<%tvar%> = min_<%arr_tp_str%>(&<%expVar%>);<%\n%>'
tvar

case CALL(tuple_=false, builtin=true,
path=IDENT(name="promote"), expLst={A, n}) then
let var1 = daeExp(A, context, &preExp /*BUFC*/, &varDecls /*BUFC*/)
Expand Down

0 comments on commit d41f891

Please sign in to comment.