Skip to content

Commit

Permalink
Fixed bug in connecting arrays of components. Added testcase Flexible…
Browse files Browse the repository at this point in the history
…Shaft.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2010 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Dec 11, 2005
1 parent cfc6b31 commit 6b6a8ef
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
1 change: 0 additions & 1 deletion Compiler/DAELow.rml
Expand Up @@ -5876,7 +5876,6 @@ relation calculate_param_sizes:( Var list) => (int) =

rule calculate_param_sizes(vs) => s1 &
is_param(var) => true &
dump_vars([var]) &
int_add(s1,1) => s2
------------------
calculate_param_sizes(var::vs)
Expand Down
15 changes: 13 additions & 2 deletions Compiler/Exp.rml
Expand Up @@ -2547,10 +2547,21 @@ relation to_exp_cref_subs: Absyn.Subscript list => Subscript list =
to_exp_cref_subs(Absyn.SUBSCRIPT(Absyn.INTEGER(i))::xs)
=> INDEX(ICONST(i))::xs'

rule Print.print_error_buf "#Error elaborating TypeName." &
(* Assumes index is INTEGER. TODO: what about if index
* is an array? *)
rule to_exp_cref(cr) => cr' &
to_exp_cref_subs(xs) => xs'
---------------------------
to_exp_cref_subs(Absyn.SUBSCRIPT(Absyn.CREF(cr))::xs)
=> INDEX(CREF(cr',INT))::xs'

rule Dump.print_subscripts_str [e] => s &
Util.string_append_list(["#Error converting subscript: ",s," to Exp.\n"])
=> str &
Print.print_error_buf str &
to_exp_cref_subs(xs) => xs'
---------------------------
to_exp_cref_subs(_::xs) => xs'
to_exp_cref_subs(e::xs) => xs'
end


Expand Down
8 changes: 6 additions & 2 deletions Compiler/Inst.rml
Expand Up @@ -2371,12 +2371,12 @@ relation inst_var2 : (Env.Env,
inst_dim_exp (dim,impl) => dime &
list_append(inst_dims,[dime]) => inst_dims' &
inst_array(env,ci_state,mod,pre,csets,n,(cl,attr),1,dim,dims,idxs,inst_dims',impl,comment)
=> (compenv,dae, csets', ty) &
=> (compenv,dae, Connect.SETS(_,crs), ty) &
inst_dim_type dim => dimt &
Types.lift_array(ty,dimt) => ty'
-------------------------------
inst_var2(env,ci_state,mod,pre,csets,n,cl,attr,dim::dims,idxs,inst_dims,impl,comment)
=> (compenv,dae,csets',ty')
=> (compenv,dae,Connect.SETS([],crs),ty')

(* Rules for instantation of function variables (e.g. input and output
parameters and protected variables) *)
Expand Down Expand Up @@ -5151,6 +5151,10 @@ relation inst_connect: (Connect.Sets, Env, Prefix,
---------------------------------
inst_connect(sets, env,pre,c1,c2,impl) => (sets',dae)

rule Debug.fprint("failtrace","-inst_connect failed\n")
---------------------------------
inst_connect(_,_,_,_,_,_) => fail

end

(** relation: valid_connector
Expand Down
9 changes: 6 additions & 3 deletions Compiler/Static.rml
Expand Up @@ -5322,7 +5322,7 @@ relation value_type : Values.Value => Types.Type =
end


(** relation: canon_cref
(** relation: canon_cref2
**
** This relation relates a `Exp.ComponentRef' to its canonical form,
** which is when all subscripts are evaluated to constant values. If
Expand All @@ -5336,6 +5336,7 @@ relation canon_cref2 : (Env.Env, Exp.ComponentRef, int list, bool (*impl*) )
rule Ceval.ceval_subscripts (env,ss,sl,impl,Ceval.MSG) => ss'
--------------------------------
canon_cref2 (env, Exp.CREF_IDENT(n,ss),sl,impl) => Exp.CREF_IDENT(n,ss')

end

(** relation: canon_cref
Expand All @@ -5353,13 +5354,15 @@ relation canon_cref : (Env.Env, Exp.ComponentRef, bool (*impl*) )
--------------------------------
canon_cref (env, Exp.CREF_IDENT(n,ss),impl) => Exp.CREF_IDENT(n,ss')

rule
Lookup.lookup_var (env,Exp.CREF_QUAL(n,[],c)) => (_,t,_) &
rule Lookup.lookup_var (env,Exp.CREF_IDENT(n,[])) => (_,t,_) &
Types.get_dimension_sizes t => sl &
Ceval.ceval_subscripts (env,ss,sl,impl,Ceval.MSG) => ss' &
canon_cref2 (env,c,sl,impl) => c'
------------------------
canon_cref (env, Exp.CREF_QUAL(n,ss,c),impl) => Exp.CREF_QUAL(n,ss',c')
rule Debug.fprint("failtrace","-canon_cref failed\n")
-----------------------
canon_cref(env,cr,_) => fail

end

Expand Down

0 comments on commit 6b6a8ef

Please sign in to comment.