Skip to content

Commit

Permalink
Fixed bug #32
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1929 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Oct 24, 2005
1 parent bb297a2 commit 422a4c1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
31 changes: 12 additions & 19 deletions Compiler/Interactive.rml
Expand Up @@ -142,6 +142,7 @@ module Interactive:
end


with "Connect.rml"
with "Dump.rml"
with "Debug.rml"
with "RTOpts.rml"
Expand Down Expand Up @@ -239,16 +240,7 @@ with "Ceval.rml"
-------------------------------
evaluate_expr(IEXP(exp),st as SYMBOLTABLE(p,_,_,_,_)) => (str,st'')

rule build_env_from_symboltable(st) => env &
not Static.elab_exp(env,exp,true,SOME(st)) => (sexp,prop,SOME(st'))
-------------------------------
evaluate_expr(IEXP(exp),st as SYMBOLTABLE(p,_,_,_,_)) => fail

rule build_env_from_symboltable(st) => env &
Static.elab_exp(env,exp,true,SOME(st)) => (sexp,prop,SOME(st')) &
not Ceval.ceval (env,sexp,true,SOME(st'),NONE,Ceval.NO_MSG) => (_,_)
-------------------------------
evaluate_expr(IEXP(exp),st as SYMBOLTABLE(p,_,_,_,_)) => fail

rule build_env_from_symboltable(st) => env &
Static.elab_exp(env,cond,true,SOME(st))
Expand Down Expand Up @@ -290,7 +282,8 @@ with "Ceval.rml"
evaluate_expr(IALG(Absyn.ALGORITHMITEM(Absyn.ALG_TUPLE_ASSIGN(Absyn.TUPLE(crefexps),rexp),_)),st as SYMBOLTABLE(p,_,_,_,_))
=> ("", newst)

rule Print.get_error_string() => s1 & Print.clear_error_buf() & string_append("Error evaluating expr.\n",s1) => str &
rule Print.get_error_string() => s1 & Print.clear_error_buf()
& string_append("Error evaluating expr.\n",s1) => str &
Debug.fprint ("failtrace", "#-- evaluate_expr failed:") &
Debug.fcall ("failtrace", Dump.dump_istmt, ISTMTS([stmt], true)) &
Debug.fprintln ("failtrace", "\n")
Expand Down Expand Up @@ -1212,7 +1205,7 @@ with "Ceval.rml"
=> (cl as SCode.CLASS(id,_,encflag,restr,_),env') &
Env.open_scope(env',encflag,SOME(id)) => env2 &
ClassInf.start(restr,id) => ci_state &
Inst.partial_inst_class_in(env2,Types.NOMOD,Prefix.NOPRE,[],ci_state,cl,false,[])
Inst.partial_inst_class_in(env2,Types.NOMOD,Prefix.NOPRE,Connect.empty_set,ci_state,cl,false,[])
=> (env'',_)
---------------------
get_class_env(p,p_class) => env''
Expand Down Expand Up @@ -3588,7 +3581,7 @@ relation get_nth_inherited_class: (Absyn.ComponentRef,int,Absyn.Program)
rule (* If that fails, instantiate, which takes more time*)
Env.open_scope(env,encflag,SOME(id)) => env2 &
ClassInf.start(restr,id) => ci_state &
Inst.partial_inst_class_in(env2,Types.NOMOD,Prefix.NOPRE,[],ci_state,c,false,[])
Inst.partial_inst_class_in(env2,Types.NOMOD,Prefix.NOPRE,Connect.empty_set,ci_state,c,false,[])
=> (env'',_) &
get_base_classes(cdef,env'') => lst &
int_sub(n,1) => n' &
Expand Down Expand Up @@ -3697,7 +3690,7 @@ relation get_component_count: (Absyn.ComponentRef,Absyn.Program) => int =

rule Env.open_scope(env,encflag,SOME(id)) => env2 &
ClassInf.start(restr,id) => ci_state &
Inst.partial_inst_class_in(env2,Types.NOMOD,Prefix.NOPRE,[],ci_state,c,false,[])
Inst.partial_inst_class_in(env2,Types.NOMOD,Prefix.NOPRE,Connect.empty_set,ci_state,c,false,[])
=> (env'',_) &
get_nth_component_in_class(cdef,n) => comp &
get_component_info_old (comp,env'') => [s1] &
Expand Down Expand Up @@ -3728,7 +3721,7 @@ relation get_component_count: (Absyn.ComponentRef,Absyn.Program) => int =
=> (c as SCode.CLASS(id,_,encflag,restr,_),env') &
Env.open_scope(env',encflag,SOME(id)) => env2 &
ClassInf.start(restr,id) => ci_state &
Inst.partial_inst_class_in(env2,Types.NOMOD,Prefix.NOPRE,[],ci_state,c,false,[])
Inst.partial_inst_class_in(env2,Types.NOMOD,Prefix.NOPRE,Connect.empty_set,ci_state,c,false,[])
=> (env'',_) &
get_public_components_in_class(cdef) => comps1 &
get_components_info (comps1,"\"public\"",env'') => s1 &
Expand Down Expand Up @@ -5033,7 +5026,7 @@ relation create_funcargs_from_elementargs: Absyn.ElementArg list
rule Lookup.lookup_class(env,Absyn.IDENT("Placement"),false) => (c,env') &
SCode.build_mod(SOME(Absyn.CLASSMOD(mod,NONE)),false) => mod' &
Mod.elab_mod(env',Prefix.NOPRE,mod',false) => mod'' &
Inst.inst_class(env', mod'', Prefix.NOPRE, [], c,
Inst.inst_class(env', mod'', Prefix.NOPRE, Connect.empty_set, c,
[], false,Inst.TOP_CALL)
=> (dae, _, cs, t, state) &
(* Put bindings of variables as expressions inside variable elements of the dae instead of equations *)
Expand Down Expand Up @@ -5179,7 +5172,7 @@ relation get_component_annotation: Absyn.Element => string =
get_class_in_program("Icon",p) => placementc &
SCode.elab_class(placementc) => placementclass &
Mod.elab_mod (env,Prefix.NOPRE,mod',false) => mod'' &
Inst.inst_class(env, mod'', Prefix.NOPRE, [], placementclass,
Inst.inst_class(env, mod'', Prefix.NOPRE, Connect.empty_set, placementclass,
[], false,Inst.TOP_CALL)
=> (dae, _, cs, t, state) &

Expand All @@ -5204,7 +5197,7 @@ relation get_component_annotation: Absyn.Element => string =
get_class_in_program("Icon",p) => placementc &
SCode.elab_class(placementc) => placementclass &
Mod.elab_mod (env,Prefix.NOPRE,mod',true) => mod'' &
Inst.inst_class(env, mod'', Prefix.NOPRE, [], placementclass,
Inst.inst_class(env, mod'', Prefix.NOPRE, Connect.empty_set, placementclass,
[], false,Inst.TOP_CALL)
=> (dae, _, cs, t, state) &
(* Put bindings of variables as expressions inside variable elements of the dae instead of equations *)
Expand All @@ -5221,7 +5214,7 @@ relation get_component_annotation: Absyn.Element => string =
get_class_in_program("Diagram",p) => placementc &
SCode.elab_class(placementc) => placementclass &
Mod.elab_mod (env,Prefix.NOPRE,mod',false) => mod'' &
Inst.inst_class(env, mod'', Prefix.NOPRE, [], placementclass,
Inst.inst_class(env, mod'', Prefix.NOPRE, Connect.empty_set, placementclass,
[], false,Inst.TOP_CALL)
=> (dae, _,cs, t, state) &

Expand All @@ -5244,7 +5237,7 @@ relation get_component_annotation: Absyn.Element => string =
get_class_in_program(anncname,p) => placementc &
SCode.elab_class(placementc) => placementclass &
Mod.elab_mod (env,Prefix.NOPRE,mod',false) => mod'' &
Inst.inst_class(env, mod'', Prefix.NOPRE, [], placementclass,
Inst.inst_class(env, mod'', Prefix.NOPRE, Connect.empty_set, placementclass,
[], false,Inst.TOP_CALL)
=> (dae, _, cs, t, state) &
(* Put bindings of variables as expressions inside variable elements of the dae instead of equations *)
Expand Down
17 changes: 16 additions & 1 deletion Compiler/Static.rml
Expand Up @@ -2374,7 +2374,6 @@ relation elab_call : (Env.Env, Absyn.ComponentRef, Absyn.Exp list,Absyn.NamedArg
------------------------------------
elab_call (env,fn,args,nargs,impl as true,st) => (e,prop,st')


(* Non-interactive mode *)
rule Debug.fprint ("sei", "elab_call 4: ") &
Dump.print_component_ref_str fn => fnstr &
Expand Down Expand Up @@ -3185,13 +3184,29 @@ relation elab_call_args : (Env.Env,
-----------------------------------------------
elab_call_args (env,fn,args,nargs,impl,st) => (Exp.CALL(fn',args',tuple,builtin), prop)


(* no matching type found. *)
rule Lookup.lookup_functions_in_env(env,fn) => typelist &
Util.list_map(typelist,Types.unparse_type) => t_lst &
Absyn.path_string fn => fn_str &
Util.string_delimit_list(t_lst,"\n -") => types_str &
Util.string_append_list(
["Error, no matching function found for ", fn_str,
", candidates are: \n -",types_str, ".\n"]) => str &
Print.print_error_buf str
-------------------------
elab_call_args(env,fn,args,nargs,impl,st) => fail

rule not Lookup.lookup_type(env,fn,false (*msg*)) => (_,_) &
Print.print_error_buf "# Couldn't find function " &
Absyn.path_string fn => s & Print.print_error_buf s &
Print.print_error_buf "\n"
-------------------------------------------------------------------
elab_call_args(env,fn,args,nargs,impl,st) => fail




rule (*elab_exp(env, e) => (e',Types.PROP(t,_)) &*)
Debug.fprint("failtrace", "- elab_call_args failed\n")
---------------------------------
Expand Down
13 changes: 7 additions & 6 deletions Compiler/Types.rml
Expand Up @@ -999,7 +999,8 @@ relation unparse_type: Type => string =

rule Util.list_map(vs,unparse_var) => vars &
Util.string_append_list(vars) => vstr &
Util.string_append_list(["record ",name,"\n",vstr,"end record;"]) => res
Util.string_append_list(["record ",name,"\n",vstr,"end record;"])
=> res
---------------------------
unparse_type((t as T_COMPLEX(ClassInf.RECORD(name),vs),_))=> res

Expand All @@ -1010,21 +1011,21 @@ relation unparse_type: Type => string =
rule Util.list_map(params, unparse_param) => paramstrs &
Util.string_delimit_list(paramstrs, ", ") => paramstr &
unparse_type restype => restypestr &
Util.string_append_list(["/* function(", paramstr, ") => ", restypestr, "*/"]) => res
Util.string_append_list(["function(", paramstr, ") => ", restypestr]) => res
--------------------------------------
unparse_type((T_FUNCTION(params,restype),_)) => res

rule Util.list_map(tys, unparse_type) => tystrs &
Util.string_delimit_list(tystrs, ", ") => tystr &
Util.string_append_list(["/* (", tystr, ") */"]) => res
Util.string_append_list(["(", tystr, ")"]) => res
--------------------------------------------------
unparse_type ((T_TUPLE(tys),_)) => res

axiom unparse_type ((T_NOTYPE,_)) => "/* #NOTYPE# */"
axiom unparse_type ((T_NOTYPE,_)) => "#NOTYPE#"

axiom unparse_type ((T_ANYTYPE(_),_)) => "/* #ANYTYPE# */"
axiom unparse_type ((T_ANYTYPE(_),_)) => "#ANYTYPE#"

axiom unparse_type(ty) => "/* unparse_type: not implemented yet */\n"
axiom unparse_type(ty) => "Internal error unparse_type: not implemented yet\n"

end

Expand Down

0 comments on commit 422a4c1

Please sign in to comment.