Skip to content

Commit 71b7d33

Browse files
author
Peter Aronsson
committed
Fixed lookup of local classes, incl. packages.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@806 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 5a759a0 commit 71b7d33

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

modeq/inst.rml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,12 @@ relation dae_declare : (Exp.ComponentRef,
11991199
)
12001200
=> DAE.Element list =
12011201

1202-
rule dae_declare2 (vn, ty, par, dir, e, inst_dims) => dae
1202+
rule Debug.fprint( "insttr", "dae_declare(") &
1203+
Debug.fcall ( "insttr", Exp.print_component_ref,vn) &
1204+
Debug.fprint ( "insttr", ",") &
1205+
Debug.fcall ( "insttr", Types.print_type,ty) &
1206+
Debug.fprint ("insttr", "...)\n") &
1207+
dae_declare2 (vn, ty, par, dir, e, inst_dims) => dae
12031208
-----------------------------------
12041209
dae_declare (vn, ty, SCode.ATTR(_,_,_,par,dir), e, inst_dims) => dae
12051210

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

1290-
rule print "dae_declare4 complex arg.\n"
1291-
---------
1292-
dae_declare4(vn, Types.T_COMPLEX(_,_),kind,dir,e,inst_dims)
1293-
=> []
1294-
1295-
rule print "dae_declare4 failed!\n"
1296-
------------------------------
1297-
dae_declare4 (_,_,_,_,_,_) => []
12981295
axiom dae_declare4 (c,ty,_,_,_,_) => []
12991296

13001297
end

modeq/lookup.rml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,55 @@ relation lookup_class_in_env: (Env.Env,Absyn.Path) => (SCode.Class, Env.Env) =
310310
rule lookup_class_in_frame(items,id) => (c, _)
311311
---------------------
312312
lookup_class_in_env(env as (Env.FRAME(items)::fs),Absyn.IDENT(id))
313-
=> (c,env)
313+
=> (c,env)
314+
315+
rule lookup_class_in_frame(items, id) => (c, _) &
316+
lookup_class_in_class(env, c, path) => (c2, _)
317+
-------------------------------------------
318+
lookup_class_in_env(env as (Env.FRAME(items)::fs), Absyn.QUALIFIED(id,path))
319+
=> (c2,env)
314320

315321
rule lookup_class_in_env(fs,id) => (c, _)
316322
---------------------
317323
lookup_class_in_env(f::fs,id) => (c, f::fs)
318324

319325
end
326+
327+
(** relation: lookup_class_in_class
328+
** This relation looks up an inner class of a class (The outer class can be a package)
329+
** Environment is passed along in case it needs to be modified...
330+
**)
331+
relation lookup_class_in_class: (Env.Env, SCode.Class, Absyn.Path) => (SCode.Class, Env.Env) =
332+
333+
rule lookup_class_in_parts(env,classname,parts) => (c,env)
334+
----------------------------------------------------
335+
lookup_class_in_class (env, SCode.CLASS(_,_,_,SCode.PARTS(parts,_,_)),Absyn.IDENT(classname)) => (c,env)
336+
337+
rule lookup_class_in_parts (env, c1, parts) => (c,env) &
338+
lookup_class_in_class (env,c,p1) => (c',env)
339+
-------------------------------------------
340+
lookup_class_in_class (env, SCode.CLASS(_,_,_,SCode.PARTS(parts,_,_)), Absyn.QUALIFIED(c1,p1)) => (c',env)
341+
342+
end
343+
344+
(** relation: lookup_class_in_parts
345+
** This relation takes an `Env' and an `Ident' and an `Element' list, and returns the `Class'
346+
** having the name specified by the `Ident'. If not found, the relation fails.
347+
**)
348+
relation lookup_class_in_parts: (Env.Env, SCode.Ident, SCode.Element list) => (SCode.Class, Env.Env) =
349+
350+
rule name = name2
351+
------------
352+
lookup_class_in_parts(env, name, SCode.CLASSDEF(name2,_,_,c)::xs) => (c, env)
353+
354+
355+
rule lookup_class_in_parts(env, name, xs) => (c,env)
356+
-----------------------------------------------
357+
lookup_class_in_parts(env, name, _::xs) => (c,env)
358+
359+
axiom lookup_class_in_parts(env, name, []) => fail
360+
end
361+
320362
(**)
321363
relation lookup_class_in_frame: ((SCode.Ident * Env.Item) list,
322364
SCode.Ident)

0 commit comments

Comments
 (0)