Skip to content

Commit

Permalink
reinserted overload operator, fixed external bug.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1086 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Jan 29, 2004
1 parent 7216bd6 commit 14b6d1e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 11 deletions.
4 changes: 3 additions & 1 deletion modeq/absyn.rml
Expand Up @@ -82,6 +82,8 @@ module Absyn:

| ENUMERATION of EnumLiteral list
* Comment option (* comment*)
| OVERLOAD of Path list (* function names *)
* Comment option
(** The `ClassDef' type contains the definition part of a class *)
(** declaration. The definition is either explicit, with a list of *)
(** parts (`public', `protected', `equation' and `algorithm'), or it *)
Expand All @@ -100,7 +102,7 @@ module Absyn:
| INITIALEQUATIONS of EquationItem list
| ALGORITHMS of AlgorithmItem list
| INITIALALGORITHMS of AlgorithmItem list
| EXTERNAL of ExternalDecl
| EXTERNAL of ExternalDecl * Annotation option
(** A class definition contains several parts. There are public and *)
(** protected component declarations, type definitions and `extends' *)
(** clauses, collectively called elements. There are also equation *)
Expand Down
19 changes: 19 additions & 0 deletions modeq/ceval.rml
Expand Up @@ -144,6 +144,14 @@ relation ceval : (Env.Env, Exp.Exp, bool, Interactive.InteractiveSymbolTable opt
-------------------------------------
ceval (env, e as Exp.CALL(_,_,_,_),true, SOME(st)) => (value,SOME(st))

rule (* Call of record constructors, etc., i.e. functions that can be
constant propagated. *)
ceval_list(env,expl,true,st) => vallst &
ceval_function(env,func,vallst) => newval
-------------------------------------------------------
ceval (env, e as Exp.CALL(func,expl,_,_),true,st as SOME(_))
=> (newval,st)

rule (* Call externally implemented functions. *)
ceval_list(env,expl,true,st) => vallst &
ModUtil.path_string2(func,"_") => funcstr &
Expand Down Expand Up @@ -408,6 +416,17 @@ end



(* relation: ceval_function for constant evaluation of functions
returning a single value. For now only record constructors. *)
relation ceval_function: (Env.Env, Absyn.Path, Values.Value list)
=> Values.Value =

rule
----------------------
ceval_function(env,funcname,vallst) => fail

end

(** relaton: ceval_ast_exp
**
** This relation evaluates a piece of Expression AST, replacing Eval(variable) with
Expand Down
6 changes: 4 additions & 2 deletions modeq/explode.rml
Expand Up @@ -90,6 +90,7 @@ module SCode :
* Mod
| ENUMERATION of Ident list

| OVERLOAD of Absyn.Path list
(** The major difference between these types and their `Absyn' *)
(** counterparts is that the `PARTS' constructor contains separate *)
(** lists for elements, equations and algorithms. *)
Expand Down Expand Up @@ -224,7 +225,7 @@ end

relation contain_external_func_decl:(Absyn.Class) => bool =

axiom contain_external_func_decl(Absyn.CLASS(_,_,_,_,_,Absyn.PARTS(Absyn.EXTERNAL(_)::_,_))) => true
axiom contain_external_func_decl(Absyn.CLASS(_,_,_,_,_,Absyn.PARTS(Absyn.EXTERNAL(_,_)::_,_))) => true

rule contain_external_func_decl(Absyn.CLASS(a,b,c,d,e,Absyn.PARTS(rest,cmt))) => res
----------------------
Expand Down Expand Up @@ -267,6 +268,7 @@ relation elab_classdef: Absyn.ClassDef => ClassDef =
--------------------------
elab_classdef(Absyn.ENUMERATION(lst,_)) => ENUMERATION(lst')

axiom elab_classdef(Absyn.OVERLOAD(lst,_)) => OVERLOAD(lst)
end

relation elab_enumlist:(Absyn.EnumLiteral list) => Ident list =
Expand Down Expand Up @@ -395,7 +397,7 @@ end

relation elab_classdef_externaldecls: (Absyn.ClassPart list) => Absyn.ExternalDecl option =

axiom elab_classdef_externaldecls(Absyn.EXTERNAL(decl)::_) => SOME(decl)
axiom elab_classdef_externaldecls(Absyn.EXTERNAL(decl,_)::_) => SOME(decl)

rule elab_classdef_externaldecls(rest) => res
---------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions modeq/inst.rml
Expand Up @@ -2712,6 +2712,16 @@ rule (*Prefix.prefix_add(n,[],pre) => pre' &*)
inst_dims, false)
=> (env', [DAE.EXTFUNCTION(fpath,DAE.DAE(dae), ty, extdecl)])

rule (* Overloaded functions *)
inst_overloaded_functions(env,n,funcnames) => (env',daefuncs)
-----------------------------
implicit_function_instantiation(env,mod,pre,csets,
c as SCode.CLASS(n,_,_, restr as SCode.R_FUNCTION
,
SCode.OVERLOAD(funcnames)),
inst_dims, false)
=> (env', daefuncs)

rule (*Debug.fprint("failtrace", "#-- implicit_function_instantiation failed\n")*)
------------------------------------------------------------------------
implicit_function_instantiation(_,_,_,_,_,_,_) => fail
Expand Down
3 changes: 3 additions & 0 deletions modeq/interactive.rml
Expand Up @@ -149,8 +149,11 @@ relation evaluate_expr: (InteractiveStmt, InteractiveSymbolTable) =>
(string,InteractiveSymbolTable) =

rule build_env_from_symboltable(st) => env &
print "built env\n" &
Static.elab_exp(env,exp,true,SOME(st)) => (sexp,prop,SOME(st')) &
print "elabed expr\n" &
Ceval.ceval (env,sexp,true,SOME(st')) => (value,SOME(st'')) &
print "evaluated expr\n" &
Values.val_string value => str
-------------------------------
evaluate_expr(IEXP(exp),st as SYMBOLTABLE(p,_,_,_,_)) => (str,st'')
Expand Down
18 changes: 10 additions & 8 deletions modeq/staticexp.rml
Expand Up @@ -1257,12 +1257,12 @@ relation elab_call : (Env.Env, Absyn.ComponentRef, Absyn.Exp list,Absyn.NamedArg
------------------------------------
elab_call (env,fn,args,nargs,impl,st) => (e,prop,st')

rule (*Debug.fprint("failtrace", "- elab_call failed\n") &
rule Debug.fprint("failtrace", "- elab_call failed\n") &
Debug.fprint("failtrace", " function: ") &
Debug.fcall("failtrace", Dump.print_component_ref,fn) &
Debug.fprint("failtrace", " posargs: ") &
Debug.fprint_list("failtrace", args, Dump.print_exp,", ") &
Debug.fprint("failtrace", "\n") *)
Debug.fprint("failtrace", "\n")
----------------------------
elab_call (env,fn,args,nargs,impl,st) => fail

Expand Down Expand Up @@ -1858,16 +1858,18 @@ relation generate_compiled_function: (Env.Env, Absyn.ComponentRef, Exp.Exp, Type
-----------------------------------------------
generate_compiled_function(env,fn,e,Types.PROP(t,_),NONE) => NONE

rule (* If fails, skip it. *)
--------------------------------------------------
generate_compiled_function(_,_,_,_,st) => st



rule (*Debug.fprint("failtrace", "- generate_compiled_function failed4\n") &
rule Debug.fprint("failtrace", "- generate_compiled_function failed4\n") &
Dump.print_component_ref_str cr => str1 &
Exp.print_exp_str exp => str2 &
Print.print_buf str1 &
Print.print_buf " -- " &
Print.print_buf str2 &
Print.print_buf "\n"*)
Print.print_buf "\n"
------------------------------------------------------------------
generate_compiled_function(env,cr,exp,_,_) => fail

Expand Down Expand Up @@ -2014,7 +2016,7 @@ relation elab_call_args : (Env.Env, Absyn.Path, Absyn.Exp list, Absyn.NamedArg l
elab_call_args(env,fn,_,_,_) => fail

rule (*elab_exp(env, e) => (e',Types.PROP(t,_)) &*)
(*Debug.fprint("failtrace", "- elab_call_args failed\n")*)
Debug.fprint("failtrace", "- elab_call_args failed\n")
---------------------------------
elab_call_args(_,_,_,_,_) => fail

Expand Down Expand Up @@ -2072,10 +2074,10 @@ relation elab_types: (Env.Env, Absyn.Exp list, Types.Type list)
elab_types(env, args, (Types.T_FUNCTION(params,restype),_)::trest)
=> (args', c, restype,t)

(* rule Debug.fprint("failtrace","- elab_types failed.")
rule Debug.fprint("failtrace","- elab_types failed.")
--------------
elab_types(env,_,_) => fail
*)

end


Expand Down

0 comments on commit 14b6d1e

Please sign in to comment.