Skip to content

Commit

Permalink
Fixed bug with bindings not getting automatic type converts in make_b…
Browse files Browse the repository at this point in the history
…inding.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2041 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Jan 19, 2006
1 parent 73138e3 commit 63551f3
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 105 deletions.
53 changes: 27 additions & 26 deletions Compiler/Ceval.rml
Expand Up @@ -142,6 +142,7 @@ with "ClassLoader.rml"
with "Derive.rml"
with "Connect.rml"
with "Error.rml"
with "ErrorExt.rml"



Expand Down Expand Up @@ -509,7 +510,7 @@ ceval (env, Exp.BINARY(lh, Exp.MUL_ARRAY_SCALAR(_), rh),impl,st,dim,msg)

rule ceval (env,lh,impl,st,dim,msg) => (Values.REAL(lhv),st') &
ceval (env,rh,impl,st',dim,msg) => (Values.REAL(rhv),st'') &
real_div(lhv, rhv) => div
real_div(lhv, rhv) => div
-------------------------
ceval (env, Exp.BINARY(lh, Exp.DIV(Exp.REAL), rh),impl,st,dim,msg)
=> (Values.REAL(div),st'')
Expand All @@ -531,37 +532,25 @@ ceval (env, Exp.BINARY(lh, Exp.DIV(Exp.REAL), rh),impl,st,dim,msg)
ceval (env, Exp.BINARY(lh, Exp.MUL(Exp.INT), rh),impl,st,dim,msg)
=> (Values.INTEGER(sum),st'')
(**)
rule ceval (env,exp,impl,st,dim,msg) => (Values.REAL(x),st') &
real_neg (x) => x'
---------------------
ceval (env, Exp.UNARY(Exp.UMINUS(Exp.REAL), exp),impl,st,dim,msg)
=> (Values.REAL(x'),st')

(* unary minus of array*)
rule ceval (env,exp,impl,st,dim,msg) => (Values.ARRAY(arr),st') &
Util.list_map(arr,Values.value_neg) => arr'
---------------------
ceval (env, Exp.UNARY(Exp.UMINUS_ARR(_), exp),impl,st,dim,msg)
=> (Values.ARRAY(arr'),st')


rule ceval (env,exp,impl,st,dim,msg) => (Values.INTEGER(x),st') &
int_neg (x) => x'
rule ceval (env,exp,impl,st,dim,msg) => (v,st') &
Values.value_neg (v) => v'
---------------------
ceval (env, Exp.UNARY(Exp.UMINUS(Exp.INT), exp),impl,st,dim,msg)
=> (Values.INTEGER(x'),st')
(**)
rule ceval (env,exp,impl,st,dim,msg) => (Values.REAL(x),st') &
real_neg (x) => x'
---------------------
ceval (env, Exp.UNARY(Exp.UPLUS(Exp.REAL), exp),impl,st,dim,msg)
=> (Values.REAL(x'),st')
ceval (env, Exp.UNARY(Exp.UMINUS(_), exp),impl,st,dim,msg)
=> (v',st')


rule ceval (env,exp,impl,st,dim,msg) => (Values.INTEGER(x),st') &
int_neg (x) => x'
rule ceval (env,exp,impl,st,dim,msg) => (v,st')
---------------------
ceval (env, Exp.UNARY(Exp.UPLUS(Exp.INT), exp),impl,st,dim,msg)
=> (Values.INTEGER(x'),st')
ceval (env, Exp.UNARY(Exp.UPLUS(_), exp),impl,st,dim,msg)
=> (v,st')

(** Logical *)

Expand Down Expand Up @@ -694,6 +683,7 @@ ceval (env, Exp.BINARY(lh, Exp.DIV(Exp.REAL), rh),impl,st,dim,msg)
(* ceval can apparently fa-il and that is ok, catched by other rules...*)
rule Debug.fprint("failtrace", "- ceval failed: ")
& Exp.print_exp_str e => str

& Debug.fprint("failtrace",str)
& Debug.fprint("failtrace", "\n")
(*& Debug.fprint("failtrace", " Env:" )
Expand Down Expand Up @@ -1914,7 +1904,7 @@ end
**
**translates and builds the model through the compiler script
**)
relation build_model:(Env.Env,
relation build_model:(Env.Env,
Exp.Exp, (* component ref for model *)
Interactive.InteractiveSymbolTable,
Msg)
Expand Down Expand Up @@ -2943,12 +2933,12 @@ relation ceval_builtin_max : (Env.Env, Exp.Exp list, bool,
Msg)
=> (Values.Value, Interactive.InteractiveSymbolTable option) =

rule ceval (env,arr,impl,st,NONE,msg) => (v,_) &
rule ceval (env,arr,impl,st,NONE,msg) => (v,_) &
ceval_builtin_max2(v) => (v')
--------------------------------------
ceval_builtin_max(env,[arr],impl,st,msg) => (v',st)

rule ceval (env,s1,impl,st,NONE,msg) => (Values.INTEGER(i1),_) &
rule ceval (env,s1,impl,st,NONE,msg) => (Values.INTEGER(i1),_) &
ceval (env,s2,impl,st,NONE,msg) => (Values.INTEGER(i2),_) &
int_max(i1,i2) => i
--------------------------------------
Expand All @@ -2959,6 +2949,7 @@ relation ceval_builtin_max : (Env.Env, Exp.Exp list, bool,
real_max(r1,r2) => r
--------------------------------------
ceval_builtin_max(env,[s1,s2],impl,st,msg) => (Values.REAL(r),st)

end


Expand Down Expand Up @@ -2995,6 +2986,10 @@ relation ceval_builtin_max2 : (Values.Value) => (Values.Value) =

axiom ceval_builtin_max2(Values.REAL(i))
=> (Values.REAL(i))

rule print "ceval_builtin_max2 failed\n"
------------------------
ceval_builtin_max2(_)=>fail
end

(** relation: ceval_builtin_min
Expand Down Expand Up @@ -3814,6 +3809,10 @@ relation ceval_cref : (Env.Env, Exp.ComponentRef, bool, (*impl*) Msg)
Error.add_message(Error.NO_CONSTANT_BINDING,[str,scope_str])
-------------------------------------
ceval_cref (env,c,impl as false, MSG) => fail

(* rule print "ceval_cref failed\n"
---------------
ceval_cref(_,_,_,_) => fail*)

end

Expand Down Expand Up @@ -3909,26 +3908,28 @@ relation ceval_cref_binding : (Env.Env, Exp.ComponentRef,
Exp.cref_last_subs(cr) => subsc &
Lookup.lookup_var(env,cr'(*Exp.CREF_IDENT(id,[])*)) => (_,tp,_) &
Types.get_dimension_sizes(tp) => sizelst &

ceval (env,exp,impl,NONE,NONE,msg) => (v,_) &
ceval_subscript_value(env,subsc,v,sizelst,impl,msg) => res
------------------------
ceval_cref_binding (env,cr(*Exp.CREF_IDENT(id,subsc)*),Types.EQBOUND(exp,_,Types.C_PARAM),impl,msg)
=> res

rule Debug.fprint("ceval", "#- ceval_cref__binding failed (nonconstant EQBOUND(") &
rule
Debug.fprint("ceval", "#- ceval_cref__binding failed (nonconstant EQBOUND(") &
Exp.print_exp_str exp => expstr &
Debug.fprint("ceval", expstr) &
Debug.fprintln("ceval", "))")
--------------------------------
ceval_cref_binding (env,_,Types.EQBOUND(exp,_,Types.C_VAR),impl,MSG) => fail


rule Exp.print_component_ref_str e1 => s1 &
Exp.print_exp_str exp => s2 &
Util.string_append_list(["-ceval_cref_binding : ",s1," = ",s2," failed\n"]) => str &
Debug.fprint("failtrace", str)
----------------------
ceval_cref_binding(_,e1,Types.EQBOUND(exp,_,_),_,_) => fail

end

(** relation: ceval_subscript_value
Expand Down
5 changes: 3 additions & 2 deletions Compiler/DAE.rml
Expand Up @@ -537,7 +537,8 @@ relation dump_elements_str : Element list => string =
Dump.select_string(noeq,"","equation\n") => eqstr &
Dump.select_string(noalg,"","algorithm\n") => algstr &

Util.string_append_list([s1,initeqstr,s2,initalgstr,s4,eqstr,s3,algstr,s5]) => str
Util.string_append_list([s1,initeqstr,s2,
initalgstr,s4,eqstr,s3,algstr,s5]) => str
---------------------------
dump_elements_str l => str

Expand Down Expand Up @@ -685,7 +686,7 @@ relation dump_initialequations_str: Element list => string =
Exp.print_exp_str e2 => s4 &
string_append(s3,s4) => s4' &
string_append(s4',";\n") => s5 &
dump_equations_str(xs) => s6 &
dump_initialequations_str(xs) => s6 &
string_append(s5,s6) => str
-------------------------------
dump_initialequations_str( INITIALEQUATION(e1,e2)::xs) => str
Expand Down
4 changes: 2 additions & 2 deletions Compiler/DAELow.rml
Expand Up @@ -3951,11 +3951,11 @@ relation matching_algorithm: (DAELow,IncidenceMatrix, IncidenceMatrixT,
--------------------------
matching_algorithm(dae,m,mt,match_opts) => (vec1,vec2,dae,m,mt)

rule (*Print.print_error_buf "#Error, matching failed\n" &*)
(* rule (*Print.print_error_buf "#Error, matching failed\n" &*)
list_vector([]) => v1 &
list_vector([]) => v2
------------------------
matching_algorithm(dae,m,mt,indx_red) => (v1,v2,dae,m,mt)
matching_algorithm(dae,m,mt,indx_red) => (v1,v2,dae,m,mt)*)

end

Expand Down

0 comments on commit 63551f3

Please sign in to comment.