Skip to content

Commit

Permalink
Fixed bug in instantiation. Modifiers were not elabed in update_varia…
Browse files Browse the repository at this point in the history
…ble_in_env.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1216 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Aug 27, 2004
1 parent 2a92c1c commit d71bbcc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 26 deletions.
23 changes: 20 additions & 3 deletions modeq/explode.rml
Expand Up @@ -828,17 +828,34 @@ relation print_element : Element => () =
----------------------------------------------------
print_element EXTENDS(path,mod)

rule Print.print_buf "CLASSDEF(" & Print.print_buf n & Print.print_buf ")"
rule Print.print_buf "CLASSDEF(" & Print.print_buf n & Print.print_buf ", from baseclass: " &
Absyn.path_string path => str & Print.print_buf str &
Print.print_buf ")"
---------------------------------------
print_element CLASSDEF(n,final,repl,cl,_)
print_element CLASSDEF(n,final,repl,cl,SOME(path))

rule Print.print_buf "COMPONENT(" & Print.print_buf n &
Print.print_buf ",mod:" & print_mod mod &
Print.print_buf ",tp:" & Absyn.path_string typath => s &
Print.print_buf s &
Print.print_buf ", from baseclass: " &
Absyn.path_string path => str & Print.print_buf str &
Print.print_buf ")"
----------------------------------------
print_element COMPONENT(n,final,repl,prot,attr,typath,mod,_)
print_element COMPONENT(n,final,repl,prot,attr,typath,mod,SOME(path))

rule Print.print_buf "CLASSDEF(" & Print.print_buf n &
Print.print_buf ")"
---------------------------------------
print_element CLASSDEF(n,final,repl,cl,NONE)

rule Print.print_buf "COMPONENT(" & Print.print_buf n &
Print.print_buf ",mod:" & print_mod mod &
Print.print_buf ",tp:" & Absyn.path_string typath => s &
Print.print_buf s &
Print.print_buf ")"
----------------------------------------
print_element COMPONENT(n,final,repl,prot,attr,typath,mod,NONE)

rule Print.print_buf "IMPORT(_)\n"
-------------------------
Expand Down
60 changes: 37 additions & 23 deletions modeq/inst.rml
Expand Up @@ -547,7 +547,6 @@ relation inst_classdef: (Env, Mod, Prefix, Connect.Sets, ClassInf.State,

inst_extends_list(env1, mods, extendselts, ci_state,impl)
=> (env2, emods, extcomps, eqs2, initeqs2, alg2, initalg2) &

(* Problem. Modifiers on inherited components are unelabed, loosing their
type information. This will not work, since the modifier type can not always be found.
for instance.
Expand Down Expand Up @@ -810,20 +809,20 @@ relation inst_extends_list:(Env.Env, Types.Mod, SCode.Element list, ClassInf.Sta
Mod.lookup_modification_p(mod, Absyn.IDENT(cn)) => outermod &
inst_derived_classes(cenv, outermod, c, impl) =>
(cenv1, els, eq1, ieq1, alg1, ialg1) &
fully_qualified(tp,cenv) => tp' &
fully_qualified(tp,cenv1) => tp' &
add_inherit_scope(els,tp') => els' &
Env.open_scope(cenv1,encf,SOME(cn)) => cenv3 &
ClassInf.start(r, cn) => new_ci_state &
Mod.elab_untyped_mod(emod,cenv3,Prefix.NOPRE) => mod' &
Mod.merge(outermod,mod',cenv3,Prefix.NOPRE) => mod'' &

inst_extends_list(env, outermod, els', ci_state, impl)
inst_extends_list(cenv1(*env*), outermod, els', ci_state, impl)
=> (_,mods, compelts1, eq2, ieq2, alg2, ialg2) &

inst_extends_list(env, mod, rest, ci_state,impl)
=> (env2, mods', compelts2, eq3, ieq3, alg3, ialg3) &
(* Must merge(mod,emod) here and then apply the bindings to the *)
(* corresponding elements. But emod is Absyn.Mod and can not *)
(* Must merge(mod,emod) here and then apply the bindings to the *)
(* be elaborated, because for instance extends A(x=y) can reference *)
(* a variable y defined in A and will thus not be found. *)
(* On the other hand: A(n=4), n might be a structural parameter that must be set to *)
Expand Down Expand Up @@ -2044,15 +2043,17 @@ relation update_variable_in_env: (Types.Mod,Absyn.ComponentRef, Env.Env, ClassIn
Mod.merge(classmod,mm,env2,Prefix.NOPRE) => mod &
Mod.merge(mod,m',env2,Prefix.NOPRE) => mod' &
Mod.merge(cmod,mod',env2,Prefix.NOPRE) => mod'' &

Mod.mod_equation mod'' => eq &

Mod.update_mod(env2,Prefix.NOPRE,mod'') => mod''' &

Mod.mod_equation mod''' => eq &

(** The variable declaration and the (optional) equation *)
(** modification are inspected for array dimensions. *)
elab_arraydim(env2,cref,ad,eq,impl,NONE) => dims &

(** Instantiate the component *)
inst_var(cenv,ci_state, mod'', Prefix.NOPRE, [], n, cl, attr,
inst_var(cenv,ci_state, mod''', Prefix.NOPRE, [], n, cl, attr,
dims, [], [], false)
=> (dae1, csets', ty) &
(** The environment is extended with the new variable *)
Expand Down Expand Up @@ -2103,15 +2104,17 @@ relation update_variable_in_env: (Types.Mod,Absyn.ComponentRef, Env.Env, ClassIn
Mod.merge(classmod,mm,env2,Prefix.NOPRE) => mod &
Mod.merge(mod,m',env2,Prefix.NOPRE) => mod' &
Mod.merge(cmod,mod',env2,Prefix.NOPRE) => mod'' &
Mod.mod_equation mod'' => eq &

Mod.update_mod(env2,Prefix.NOPRE,mod'') => mod''' &
Mod.mod_equation mod''' => eq &

(** The variable declaration and the (optional) equation *)
(** modification are inspected for array dimensions. *)
let owncref = Absyn.CREF_IDENT(n,[]) &
elab_arraydim(env2,owncref,ad,eq,impl,NONE) => dims &

(** Instantiate the component *)
inst_var(cenv, ci_state, mod'', Prefix.NOPRE, [], n, cl, attr,
inst_var(cenv, ci_state, mod''', Prefix.NOPRE, [], n, cl, attr,
dims, [], [], false)
=> (dae1, csets', ty) &

Expand Down Expand Up @@ -2314,10 +2317,18 @@ relation elab_arraydim : (Env.Env, Absyn.ComponentRef, Absyn.ArrayDim, Types.EqM

rule elab_arraydim_decl(env,cref,ad,impl,cf) => dim1 &
elab_arraydim_type(t,ad) => dim2 &
compatible_arraydim(dim1,dim2) => dim3
compatible_arraydim(dim1,dim2) => dim3
---------------------------------
elab_arraydim(env,cref,ad,SOME(Types.TYPED(e,Types.PROP(t,c))),impl,cf) => dim3

rule Static.elab_exp(env,e,impl,cf) => (e',Types.PROP(t,c),_) &
elab_arraydim_decl(env,cref,ad,impl,cf) => dim1 &
elab_arraydim_type(t,ad) => dim2 &
compatible_arraydim(dim1,dim2) => dim3
---------------------------------
elab_arraydim(env,cref,ad,SOME(Types.UNTYPED(e)),impl,cf) => dim3


rule elab_arraydim_decl(env,cref,ad,impl,cf) => dim1 &
elab_arraydim_type(t,ad) => dim2 &
not compatible_arraydim(dim1,dim2) => dim3 &
Expand All @@ -2330,9 +2341,13 @@ relation elab_arraydim : (Env.Env, Absyn.ComponentRef, Absyn.ArrayDim, Types.EqM
elab_arraydim(env,cref,ad,SOME(Types.TYPED(e,Types.PROP(t,c))),impl,cf) => fail


rule Debug.fprint("failtrace", "- elab_arraydim failed\n")
rule Debug.fprint("failtrace", "- elab_arraydim failed\n cref:") &
Debug.fcall("failtrace", Dump.print_component_ref, cref) &
Debug.fprint("failtrace", " dim: " ) &
Debug.fcall("failtrace", Dump.print_arraydim, ad) &
Debug.fprint("failtrace", "\n" )
-------------------------------------
elab_arraydim(_,_,_,_,_,_) => fail
elab_arraydim(_,cref,ad,_,_,_) => fail

end

Expand Down Expand Up @@ -2550,7 +2565,8 @@ relation compatible_arraydim : ((DimExp option) list,(DimExp option) list)
compatible_arraydim (NONE::xs,NONE::ys)
=> DIMEXP(Exp.WHOLEDIM,NONE)::l

rule Debug.fprint("failtrace", "- compatible_arraydim failed\n")
rule Print.print_buf "-compatible_arraydim failed\n" &
Debug.fprint("failtrace", "- compatible_arraydim failed\n")
--------------------------------------
compatible_arraydim (_,_) => fail

Expand Down Expand Up @@ -4656,14 +4672,6 @@ end
relation inst_mod_equation : (Exp.ComponentRef, Types.Type, Mod)
=> DAE.Element list =

(* rule Print.print_buf "inst_mod_equation\n" &
Exp.cref_str cr => str &
Print.print_buf "cref = " & Print.print_buf str &
Print.print_buf "\nmod=" &
Mod.print_mod mod &
int_eq(1,0) => true
----------
inst_mod_equation(cr,ty1,mod) => [] *)

rule Types.elab_type ty1 => t &
(*
Expand All @@ -4683,9 +4691,15 @@ relation inst_mod_equation : (Exp.ComponentRef, Types.Type, Mod)
axiom inst_mod_equation(_,_,Types.NOMOD) => []
axiom inst_mod_equation(_,_,Types.REDECL(_,_)) => []

rule Debug.fprint("failtrace", "- inst_mod_equation failed\n")
rule Debug.fprint("failtrace", "- inst_mod_equation failed\n type: ") &
Debug.fcall("failtrace", Types.print_type, t) &
Debug.fprint("failtrace", "\n cref: ") &
Debug.fcall("failtrace", Exp.print_component_ref, c) &
Debug.fprint("failtrace", "\n mod:") &
Debug.fcall("failtrace", Mod.print_mod, m) &
Debug.fprint("failtrace", "\n")
------------------------------------
inst_mod_equation (_,_,_) => fail
inst_mod_equation (c,t,m) => fail

end

Expand Down

0 comments on commit d71bbcc

Please sign in to comment.