Skip to content

Commit

Permalink
Fixed bug with value propagation into parameter values
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@831 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Aug 14, 2002
1 parent d1c6b4a commit 6d767ea
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 12 deletions.
34 changes: 25 additions & 9 deletions modeq/inst.rml
Expand Up @@ -965,16 +965,26 @@ end
relation update_variable_in_env: (Mod.Mod,Absyn.ComponentRef, Env.Env) => Env.Env =


rule Debug.fprint ("decl", "update_variable_in_env called\n") &
Lookup.lookup_ident_local(env,id) => (ty,SOME(SCode.COMPONENT(n,final,prot,
rule Debug.fprint ("peter3", "update_variable_in_env called, ident =") &
Debug.fcall ("peter3", Dump.print_component_ref, cref) &
Debug.fprint ("peter3", "\n") &
Debug.fprint("peter3","inst_var, env =") &
Debug.fcall("peter3",Env.print_env, env) &
Lookup.lookup_ident(env,id) => (ty,SOME(SCode.COMPONENT(n,final,prot,
attr as SCode.ATTR(ad,flow,acc,param,dir),
t,m))) &

Debug.fprint("peter3","got local ident\n") &
Lookup.lookup_class(env,t) => (cl,cenv) &
Debug.fprint("peter3","got class \n") &

get_cref_from_mod(m) => crefs &
update_variables_in_env(mods,crefs,cenv) => env2 &

Debug.fprint("peter3","inst_var, env =") &
Debug.fcall("peter3",Env.print_env, env) &
update_variables_in_env(mods,crefs,env) => env2 &
Debug.fprint("peter3","performed update of variables for ident=") &
Debug.fcall ("peter3", Dump.print_component_ref, cref) &
Debug.fprint ("peter3", "\n") &
(* Prefix does not matter, since we only update types in env, and does
not make any dae elements, etc.. *)
Mod.elab_mod(env2,Prefix.NOPRE,m) => m' &
Expand All @@ -989,13 +999,13 @@ relation update_variable_in_env: (Mod.Mod,Absyn.ComponentRef, Env.Env) => Env.En

Mod.mod_equation mod' => eq &

Debug.fprintln ("insttr", "mod equation done") &
Debug.fprintln ("peter3", "mod equation done") &
(** The variable declaration and the (optional) equation *)
(** modification are inspected for array dimensions. *)

elab_arraydim(env2,ad,eq) => dims &

Debug.fprintln ("insttr", "arraydim elabed") &
Debug.fprintln ("peter3", "arraydim elabed") &
Debug.fprint("peter2","inst_var, env =") &
Debug.fcall("peter2",Env.print_env, env) &
(** Instantiate the component *)
Expand All @@ -1009,11 +1019,17 @@ relation update_variable_in_env: (Mod.Mod,Absyn.ComponentRef, Env.Env) => Env.En
Env.update_frame_v(env2,Types.VAR(n,Types.ATTR(flow,acc,param,dir),
prot,ty,binding)) => env'
----------------------------------
update_variable_in_env (mods,Absyn.CREF_IDENT(id,subscr),env) => env'
update_variable_in_env (mods,cref as Absyn.CREF_IDENT(id,subscr),env) => env'

rule Lookup.lookup_ident(env,id) => (ty,NONE)
----------------------------------
update_variable_in_env (mods,cref as Absyn.CREF_IDENT(id,subscr),env) => env

rule print "update_variable_in_env failed\n"
rule print "update_variable_in_env failed\n ident =" &
Dump.print_component_ref cref &
print "\n"
---------------------------
update_variable_in_env(_,_,env) => env
update_variable_in_env(_,cref,env) => env
end

relation inst_dim_exp : DimExp => Exp.Subscript =
Expand Down
21 changes: 21 additions & 0 deletions modeq/lookup.rml
Expand Up @@ -45,6 +45,7 @@ module Lookup:
relation lookup_var_local : (Env.Env,Exp.ComponentRef)
=> (Types.Attributes, Types.Type, Types.Binding)
relation lookup_ident_local : (Env.Env, SCode.Ident) => (Types.Var,SCode.Element option)
relation lookup_ident : (Env.Env, SCode.Ident) => (Types.Var,SCode.Element option)
relation lookup_functions_in_env: (Env.Env,Absyn.Path) => (Types.Type list)
end

Expand Down Expand Up @@ -247,6 +248,26 @@ relation lookup_ident_local : (Env.Env, SCode.Ident) => (Types.Var,SCode.Element

end

(* Same as lookup_ident_local, except check all frames *)
relation lookup_ident : (Env.Env, SCode.Ident) => (Types.Var,SCode.Element option) =



rule lookup_var2(items, id) => (fv,b)
----------------------------
lookup_ident(Env.FRAME(items)::_, id) => (fv,b)

rule lookup_ident(rest,id) => (fv,b)
---------------------------------
lookup_ident(_::rest,id) => (fv,b)

rule print "# Error lookup_ident: " &
print id &
print " failed\n"
--------------
lookup_ident(_,id) => fail
end


(** Function lookup *)

Expand Down
11 changes: 8 additions & 3 deletions modeq/staticexp.rml
Expand Up @@ -153,7 +153,7 @@ relation elab_exp : (Env.Env, Absyn.Exp) => (Exp.Exp, Properties) =
rule Debug.fprintln("setr", "elab_exp_cref") &
elab_cref(env, cr) => (exp,prop,_)
---------------------------------------
elab_exp(env, Absyn.CREF(cr)) => (exp,prop)
elab_exp(env, Absyn.CREF(cr)) => (exp,prop)

(** Binary and unary operations *)

Expand Down Expand Up @@ -1415,7 +1415,12 @@ relation elab_cref2 : (Env.Env,

rule value_exp v => e
----------------
elab_cref2 (_,cr,_,_,t, Types.VALBOUND(v)) => (e,true,SCode.RO)
elab_cref2 (_,cr,_,Absyn.CONST,t, Types.VALBOUND(v)) => (e,true,SCode.RO)

rule elab_type tt => t &
fill_cref_subscripts (cr,tt) => cr'
----------------
elab_cref2 (_,cr,acc,Absyn.PARAM,tt, Types.VALBOUND(v)) => (Exp.CREF(cr',t),false,acc)

rule elab_type tt => t &
fill_cref_subscripts (cr,tt) => cr'
Expand Down Expand Up @@ -1687,7 +1692,7 @@ relation ceval : (Env.Env, Exp.Exp) => Values.Value =

rule ceval_cref (env,c) => v
---------------------------
ceval (env,Exp.CREF(c,_)) => v
ceval (env,Exp.CREF(c,_)) => v

rule print "# Can't call functions at compile time\n" &
print " expression: " & Exp.print_exp e & print "\n"
Expand Down

0 comments on commit 6d767ea

Please sign in to comment.