Skip to content

Commit

Permalink
corrected some errors in code-gen for tornado
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1455 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x02lucpo committed Feb 2, 2005
1 parent 5019b46 commit 85282dc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
22 changes: 20 additions & 2 deletions modeq/simcodegen.rml
Expand Up @@ -371,6 +371,21 @@ end
------------------------
print_exp2_str (Exp.BINARY(e1, op as Exp.SUB(ty), e2 as Exp.BINARY(e21, Exp.SUB(ty2), e22)),pri1) => s'''

rule
Exp.binop_priority op => pri2 &
Exp.print_leftpar_str (pri1,pri2) => (s1, pri3) &
print_exp2_str (e1,pri3) => s2 &
print_exp2_str (e2,pri2) => s3 &
Exp.print_rightpar_str (pri1,pri2) => s4 &
string_append (s1, s2) => s &
string_append("pow(",s) => s' &
string_append(s',",") => s'' &
string_append(s'',s3) => s''' &
string_append(s''',")") => res &
string_append (res, s4) => res'
------------------------
print_exp2_str (Exp.BINARY(e1, (op as Exp.POW(_)), e2),pri1) => res'

rule Exp.binop_symbol(op) => sym &
Exp.binop_priority op => pri2 &
Exp.print_leftpar_str (pri1,pri2) => (s1, pri3) &
Expand Down Expand Up @@ -561,10 +576,13 @@ end
end

relation cref_modelica_str : Exp.ComponentRef => string =
rule Util.string_replace_char(s,#".",#"_") => res'

rule Util.string_replace_char(s,#".",#"_") => res' &
Util.string_replace_char(res',#"[",#"_") => res'' &
Util.string_replace_char(res'',#"]",#"_") => res'''
(* & Util.string_append_list(["_",res,"_"]) => res'*)
------------------------------
cref_modelica_str(Exp.CREF_IDENT(s,_)) => res'
cref_modelica_str(Exp.CREF_IDENT(s,_)) => res'''

rule cref_modelica_str(n) => ns &
(* string_append(s,"_") => s1 & *)
Expand Down
6 changes: 3 additions & 3 deletions modeq/tornado.rml
Expand Up @@ -2250,10 +2250,10 @@ relation generate_compute_initial2:(DAELow.Variables,

rule generate_compute_initial2(vars,es) => str_lst &
DAELow.get_var(cr,vars)
=> (DAELow.VAR(_,_,_,_,_,_,_,_,_,_,_),_) &
Exp.print_component_ref_str(cr) => crstr &
=> (DAELow.VAR(cr',_,_,_,_,_,_,_,_,_,_),_) &
SimCodegen.cref_modelica_str(cr') => crstr &
SimCodegen.print_exp_cpp_str(e2) => rhs_str &
Util.string_append_list([crstr, " = ",rhs_str, ";"]) => str
Util.string_append_list([" ",crstr, " = ",rhs_str, ";"]) => str
------------------------------
generate_compute_initial2(vars,DAELow.EQUATION(Exp.CREF(cr,_),e2)::es)
=> str::str_lst
Expand Down

0 comments on commit 85282dc

Please sign in to comment.