Skip to content

Commit

Permalink
Fixed so parameters are split in DAE x becomes {x[1],x[2],...} for an…
Browse files Browse the repository at this point in the history
… parameter array.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1303 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Oct 7, 2004
1 parent d4c64ad commit 49a3b15
Show file tree
Hide file tree
Showing 20 changed files with 657 additions and 224 deletions.
26 changes: 17 additions & 9 deletions modeq/ceval.rml
Expand Up @@ -424,8 +424,7 @@ relation ceval : (Env.Env, Exp.Exp, bool, Interactive.InteractiveSymbolTable opt
ceval (env, Exp.RANGE(Exp.REAL,start, NONE, stop),impl,st,dim)
=> (Values.ARRAY(arr),st'')

rule
ceval (env,start,impl,st,dim) => (Values.REAL(start'),st') &
rule ceval (env,start,impl,st,dim) => (Values.REAL(start'),st') &
ceval (env,step,impl,st',dim) => (Values.REAL(step'),st'') &
ceval (env,stop,impl,st'',dim) => (Values.REAL(stop'),st''') &
ceval_range_real(start', step', stop') => arr
Expand Down Expand Up @@ -474,18 +473,27 @@ relation ceval : (Env.Env, Exp.Exp, bool, Interactive.InteractiveSymbolTable opt
ceval (env, Exp.IFEXP(b,e1,e2),impl,st,dim)
=> (v,st'')

rule (* asub *)
ceval (env,e,impl,st,dim) => (Values.ARRAY(vals),st') &
int_sub(indx,1) => indx' &
list_nth(vals,indx') => v
-----------------------
ceval (env, Exp.ASUB(e,indx),impl,st,dim) => (v,st')

rule Print.print_buf "#-- ceval reduction\n"
---------------------------------------
ceval (env, Exp.REDUCTION(p,exp,iter,iterexp),impl,st,dim)
=> fail (* (v,st) *)

(* ceval can apparently fail and that is ok, catched by other rules...
rule Debug.fprint("failtrace", "- ceval ") &
(* ceval can apparently fail and that is ok, catched by other rules...*)
rule Debug.fprint("failtrace", "- ceval ") &
Debug.fcall("failtrace",Exp.print_exp, e) &
Debug.fprint("failtrace", " failed\n")
Debug.fprint("failtrace", " failed\n") &
Debug.fprint("failtrace", " Env:" ) &
Debug.fcall("failtrace",Env.print_env, env)
-----------------------------------------------------
ceval (_,e,_,_,_) => fail
*)
ceval (env,e,_,_,_) => fail

end


Expand Down Expand Up @@ -1746,9 +1754,9 @@ relation ceval_cref : (Env.Env, Exp.ComponentRef) => Values.Value =
(* default *)

rule print "# No constant binding for " &
Exp.print_component_ref_str c => str & print str & print "\n"
Exp.print_component_ref_str c => str & print str & print "\n"
-------------------------------------
ceval_cref (_,c) => fail
ceval_cref (env,c) => fail

rule Print.print_buf "# No constant binding for " &
Exp.print_component_ref c & Print.print_buf "\n"
Expand Down
5 changes: 3 additions & 2 deletions modeq/codegen.rml
Expand Up @@ -1209,7 +1209,7 @@ relation generate_alloc_outvar : (DAE.Element,string,int) => (CFunction,int) =
c_add_inits(cfn1',[alloc_str]) => cfn' &
Util.if (is_a,cfn',cfn1') => cfn
--------------------------------
generate_alloc_outvar(var as DAE.VAR(id, vk, vd, typ, e,
generate_alloc_outvar(var as DAE.VAR(id, vk, vd, typ, e,
inst_dims,start,flow),
prefix,
tnr)
Expand Down Expand Up @@ -1276,7 +1276,7 @@ relation generate_alloc_outvar_f77 : (DAE.Element,string,int) => (CFunction,int)
c_add_inits(cfn1',[alloc_str]) => cfn' &
Util.if (is_a,cfn',cfn1') => cfn
--------------------------------
generate_alloc_outvar_f77(var as DAE.VAR(id, vk, vd, typ, e,
generate_alloc_outvar_f77(var as DAE.VAR(id, vk, vd, typ, e,
inst_dims,start,flow),
prefix,
tnr)
Expand Down Expand Up @@ -1713,6 +1713,7 @@ relation generate_var_init : (DAE.Element, int) => (CFunction, int) =
DAE.OUTPUT,
typ,
SOME(e),
_,
_,start,flow),tnr)
=> (cfn, tnr)

Expand Down
18 changes: 15 additions & 3 deletions modeq/dae.rml
Expand Up @@ -63,7 +63,7 @@ module DAE:
VarKind *
VarDirection *
Type *
Exp.Exp option * (* Binding e.g. for parameters*)
Exp.Exp option * (* Binding expression e.g. for parameters*)
InstDims *
StartValue * (* value of start attribute *)
Flow (* Flow of connector variable. Needed for
Expand Down Expand Up @@ -119,6 +119,7 @@ module DAE:
relation get_output_vars: Element list => Element list
relation get_bidir_vars: Element list => Element list
relation get_input_vars: Element list => Element list
relation generate_dae_type: Type => Types.Type
relation is_algorithm : Element => ()
relation is_function : Element => ()
relation is_var: Element => ()
Expand Down Expand Up @@ -1164,7 +1165,7 @@ end
relation is_parameter: Element => () =

(* LS: false means not protected, hence we ignore protected variables *)
axiom is_parameter VAR(_, PARAM, _, _, _, _,_,_)
axiom is_parameter VAR(_, PARAM, _, _, _, _,_,_)

end

Expand Down Expand Up @@ -1201,6 +1202,17 @@ relation get_input_vars: Element list => Element list =
get_input_vars vl => vl'
end

(* Generate a Types.Type from a DAE.Type
** Is needed when investigating the DAE and want to e.g. evaluate expressions.
**)
relation generate_dae_type: Type => Types.Type =

axiom generate_dae_type(REAL) => ((Types.T_REAL([]),NONE))
axiom generate_dae_type(INT) => ((Types.T_INTEGER([]),NONE))
axiom generate_dae_type(BOOL) => ((Types.T_BOOL([]),NONE))
axiom generate_dae_type(STRING) => ((Types.T_STRING([]),NONE))
end

(* LS *)
relation is_output_var: Element => () =

Expand All @@ -1218,7 +1230,7 @@ end
(* HJ *)
relation is_input_var: Element => () =

axiom is_input_var VAR(n, VARIABLE, INPUT, ty, _, _, _, _)
axiom is_input_var VAR(n, VARIABLE, INPUT, ty, _, _, _, _)

end

Expand Down

0 comments on commit 49a3b15

Please sign in to comment.