Skip to content

Commit

Permalink
Fixed lookup of local classes, incl. packages.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@806 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Jun 4, 2002
1 parent 5a759a0 commit 71b7d33
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 10 deletions.
15 changes: 6 additions & 9 deletions modeq/inst.rml
Expand Up @@ -1199,7 +1199,12 @@ relation dae_declare : (Exp.ComponentRef,
)
=> DAE.Element list =

rule dae_declare2 (vn, ty, par, dir, e, inst_dims) => dae
rule Debug.fprint( "insttr", "dae_declare(") &
Debug.fcall ( "insttr", Exp.print_component_ref,vn) &
Debug.fprint ( "insttr", ",") &
Debug.fcall ( "insttr", Types.print_type,ty) &
Debug.fprint ("insttr", "...)\n") &
dae_declare2 (vn, ty, par, dir, e, inst_dims) => dae
-----------------------------------
dae_declare (vn, ty, SCode.ATTR(_,_,_,par,dir), e, inst_dims) => dae

Expand Down Expand Up @@ -1287,14 +1292,6 @@ axiom dae_declare4 (vn, Types.T_ENUM, kind, dir, e, inst_dims)
axiom dae_declare4 (vn, Types.T_ENUMERATION(l), kind, dir, e, inst_dims)
=> [DAE.VAR(vn, kind, dir, DAE.ENUMERATION(l), e, inst_dims)]

rule print "dae_declare4 complex arg.\n"
---------
dae_declare4(vn, Types.T_COMPLEX(_,_),kind,dir,e,inst_dims)
=> []

rule print "dae_declare4 failed!\n"
------------------------------
dae_declare4 (_,_,_,_,_,_) => []
axiom dae_declare4 (c,ty,_,_,_,_) => []

end
Expand Down
44 changes: 43 additions & 1 deletion modeq/lookup.rml
Expand Up @@ -310,13 +310,55 @@ relation lookup_class_in_env: (Env.Env,Absyn.Path) => (SCode.Class, Env.Env) =
rule lookup_class_in_frame(items,id) => (c, _)
---------------------
lookup_class_in_env(env as (Env.FRAME(items)::fs),Absyn.IDENT(id))
=> (c,env)
=> (c,env)

rule lookup_class_in_frame(items, id) => (c, _) &
lookup_class_in_class(env, c, path) => (c2, _)
-------------------------------------------
lookup_class_in_env(env as (Env.FRAME(items)::fs), Absyn.QUALIFIED(id,path))
=> (c2,env)

rule lookup_class_in_env(fs,id) => (c, _)
---------------------
lookup_class_in_env(f::fs,id) => (c, f::fs)

end

(** relation: lookup_class_in_class
** This relation looks up an inner class of a class (The outer class can be a package)
** Environment is passed along in case it needs to be modified...
**)
relation lookup_class_in_class: (Env.Env, SCode.Class, Absyn.Path) => (SCode.Class, Env.Env) =

rule lookup_class_in_parts(env,classname,parts) => (c,env)
----------------------------------------------------
lookup_class_in_class (env, SCode.CLASS(_,_,_,SCode.PARTS(parts,_,_)),Absyn.IDENT(classname)) => (c,env)

rule lookup_class_in_parts (env, c1, parts) => (c,env) &
lookup_class_in_class (env,c,p1) => (c',env)
-------------------------------------------
lookup_class_in_class (env, SCode.CLASS(_,_,_,SCode.PARTS(parts,_,_)), Absyn.QUALIFIED(c1,p1)) => (c',env)

end

(** relation: lookup_class_in_parts
** This relation takes an `Env' and an `Ident' and an `Element' list, and returns the `Class'
** having the name specified by the `Ident'. If not found, the relation fails.
**)
relation lookup_class_in_parts: (Env.Env, SCode.Ident, SCode.Element list) => (SCode.Class, Env.Env) =

rule name = name2
------------
lookup_class_in_parts(env, name, SCode.CLASSDEF(name2,_,_,c)::xs) => (c, env)


rule lookup_class_in_parts(env, name, xs) => (c,env)
-----------------------------------------------
lookup_class_in_parts(env, name, _::xs) => (c,env)

axiom lookup_class_in_parts(env, name, []) => fail
end

(**)
relation lookup_class_in_frame: ((SCode.Ident * Env.Item) list,
SCode.Ident)
Expand Down

0 comments on commit 71b7d33

Please sign in to comment.