Skip to content

Commit

Permalink
Added functions to dae and flatmodelica
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1171 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
levsa committed May 6, 2004
1 parent b817185 commit 1a0e285
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 27 deletions.
48 changes: 36 additions & 12 deletions modeq/dae.rml
Expand Up @@ -316,14 +316,14 @@ end
** This relation prints the DAE to a string.
**)
relation dump_str : DAElist => string =

rule dump_comp_element_str d => str &
dump_str(DAE(dl)) => str2 &
string_append(str,str2) => str3
-------------------------------
dump_str DAE((d as COMP(_,_))::dl) => str3

axiom dump_str DAE([]) => ""
rule Util.list_map(daelist,dump_function_str) => flist &
Util.list_map(daelist,dump_comp_element_str) => clist &
list_append(flist,clist) => slist &
Util.string_append_list(slist) => str
-------------------------------------
dump_str DAE(daelist) => str

end


Expand All @@ -338,17 +338,25 @@ relation dump_list : ('a list, 'a => ()) => () =

end

relation dump_list_str : (Element list, Element => string) => string =

rule Util.list_map (daelist, func) => slist &
Util.string_append_list(slist) => str
-------------------------------------
dump_list_str (daelist,func) => str
end

relation dump_comp_element : Element => () =

rule RTOpts.modelica_output => false &
Print.print_buf "class " & Print.print_buf n & Print.print_buf "\n" &
Print.print_buf "fclass " & Print.print_buf n & Print.print_buf "\n" &
dump_elements(l) &
Print.print_buf "end " & Print.print_buf n & Print.print_buf ";\n"
-----------------------------------
dump_comp_element COMP(n,DAE(l))

rule RTOpts.modelica_output => true &
Print.print_buf "class " & Print.print_buf n & Print.print_buf "\n" &
Print.print_buf "fclass " & Print.print_buf n & Print.print_buf "\n" &
dump_elements(l) &
Print.print_buf "end " & Print.print_buf n & Print.print_buf ";\n"
-----------------------------------
Expand All @@ -362,7 +370,7 @@ end
relation dump_comp_element_str : Element => string =

rule RTOpts.modelica_output => false &
string_append("class ",n) => s1 &
string_append("fclass ",n) => s1 &
string_append(s1,"\n") => s2 &
dump_elements_str(l) => s3 &
string_append(s2,s3) => s4 &
Expand Down Expand Up @@ -812,7 +820,7 @@ relation dump_function: Element => () =
Absyn.path_string fpath => fstr &
Print.print_buf fstr & Print.print_buf "\n" &
dump_elements(dae) &
Print.print_buf "end " & Print.print_buf fstr & Print.print_buf ";\n\n\n"
Print.print_buf "end " & Print.print_buf fstr & Print.print_buf ";\n\n"
------------------------------------
dump_function FUNCTION(fpath,DAE(dae),t)

Expand All @@ -821,6 +829,22 @@ relation dump_function: Element => () =

end

(* LS *)
relation dump_function_str: Element => string =


rule Absyn.path_string fpath => fstr &
dump_elements_str(dae) => daestr &
Util.string_append_list(["function ", fstr, "\n",
daestr,
"end ", fstr, ";\n\n"]) => str
------------------------------------
dump_function_str FUNCTION(fpath,DAE(dae),t) => str

axiom dump_function_str _ => ""

end


(** relation: pp_statement
**
Expand Down Expand Up @@ -1577,4 +1601,4 @@ rule Ceval.ceval([],rhs,false,NONE,NONE) => (value,_) &
--------------------------------------------------
dae_to_record_value(_::rest) => res

end
end
24 changes: 11 additions & 13 deletions modeq/inst.rml
Expand Up @@ -2662,37 +2662,35 @@ correct?
(* LS: removed prefix because function elements shouldn't have
one. They will contain the elements locally *)

(* rule
inst_class(cache, env, mod, pre, csets, c, inst_dims, true,INNER_CALL)
=> (cache', dae, _, csets', ty, st) &
rule inst_class(env, mod, pre, csets, c, inst_dims, true,INNER_CALL)
=> (dae, _, csets', ty, st) &
Env.extend_frame_t(env, n, ty) => env' &
package_prefix (env, Absyn.IDENT(n)) => fpath
--------------------------------------
implicit_instantiation(cache, env, mod, pre, csets,
implicit_instantiation(env, mod, pre, csets,
c as SCode.CLASS(n,_,_,SCode.R_FUNCTION,_),
inst_dims, false)
=> (cache', env', [DAE.FUNCTION(fpath, DAE.DAE(dae), ty)])
=> (env', [DAE.FUNCTION(fpath, DAE.DAE(dae), ty)])


rule
inst_class(cache, env, mod, pre, csets, c, inst_dims, true,INNER_CALL)
=> (cache', dae, _, csets', ty, st) &
rule inst_class(env, mod, pre, csets, c, inst_dims, true,INNER_CALL)
=> (dae, _, csets', ty, st) &

Env.extend_frame_t(env, n, ty) => env' &
package_prefix (env, Absyn.IDENT(n)) => fpath &
let prot = false &
inst_classdef (cache', env, mod, pre, csets, ClassInf.UNKNOWN(n), parts, restr,
inst_classdef (env, mod, pre, csets, ClassInf.UNKNOWN(n), parts, restr,
prot, inst_dims, true, false)
=>(cache'', _, tempenv,_,_,_) &
=>(_, tempenv,_,_,_) &

inst_ext_decl(tempenv, n, parts) => extdecl
--------------------------------------
implicit_instantiation(cache, env, mod, pre, csets,
implicit_instantiation(env, mod, pre, csets,
c as SCode.CLASS(n,_,_, restr as SCode.R_EXT_FUNCTION,
parts as SCode.PARTS(els,_,_,_,_,_)),
inst_dims, false)
=> (cache'', env', [DAE.EXTFUNCTION(fpath,DAE.DAE(dae), ty, extdecl)])
*)
=> (env', [DAE.EXTFUNCTION(fpath,DAE.DAE(dae), ty, extdecl)])


rule (*let ty = Types.T_ENUMERATION(l) &
Env.extend_frame_t(env,n,ty) => env' & *)
Expand Down
2 changes: 0 additions & 2 deletions modeq/main.rml
Expand Up @@ -241,10 +241,8 @@ relation translate_file : string list => () =
(* & Debug. print "\nJust instantiated" *)
& Debug.fprint ("info", "---dumping\n")
& Debug.fcallret ("flatmodelica", DAE.dump_str, d, "") => s
& Debug.fcall ("flatmodelica", Print.print_buf, "f")
& Debug.fcall ("flatmodelica", Print.print_buf, s)
& Debug.fcallret ("none", DAE.dump_str, d, "") => s
& Debug.fcall ("none", Print.print_buf, "f")
& Debug.fcall ("none", Print.print_buf, s)
& Debug.fcall ("daedump", DAE.dump, d)
& Debug.fcall ("daedump2", DAE.dump2, d)
Expand Down

0 comments on commit 1a0e285

Please sign in to comment.