1 | % (c) 2009-2022 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, | |
2 | % Heinrich Heine Universitaet Duesseldorf | |
3 | % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html) | |
4 | ||
5 | :- module(zenvironment, | |
6 | [lookup_type/3 | |
7 | ,create_subenv/3 | |
8 | ,env_z_defs/2 | |
9 | ,zlookup/2 | |
10 | ,zlookup_schema/4 | |
11 | %,create_scope_typeinfos/2 | |
12 | %,lookup_typeinfo/5 | |
13 | %,all_schemas/2 | |
14 | ,create_initial_zenvironment/2 | |
15 | ]). | |
16 | ||
17 | ||
18 | :- use_module(probsrc(module_information)). | |
19 | :- module_info(group,proz). | |
20 | :- module_info(description,'This module provides predicates to access a type environment for Z specifications.'). | |
21 | ||
22 | lookup_type(env(_,Vars),Var,Type) :- member(variable(Var,T),Vars),!,T=Type. | |
23 | lookup_type(env(Up,_),Var,Type) :- lookup_type(Up,Var,Type). | |
24 | ||
25 | %all_schemas(Env,Names) :- env_z_defs(Env,Defs),findall(Name,zlookup_schema2(Defs,Name,[],_),Names). | |
26 | ||
27 | zlookup_schema(Env,Name,Params,Expr) :- env_z_defs(Env,Defs),zlookup_schema2(Defs,Name,Params,Expr),!. | |
28 | zlookup_schema2(Defs,Name,Params,Expr) :- member(sdef(shead(Name,Params),Expr),Defs). | |
29 | zlookup_schema2(Defs,Name,Params,Expr) :- member(defeq(shead(Name,Params),Expr),Defs). | |
30 | zlookup_schema2(Defs,Name,Params,Expr) :- member(eqeq(lhs(Name,Params),Expr),Defs). | |
31 | ||
32 | zlookup(Env,Entry) :- env_z_defs(Env,D),member(Entry,D). | |
33 | ||
34 | create_initial_zenvironment(Defs,zdef(Defs)). | |
35 | ||
36 | env_z_defs(zdef(D),D). | |
37 | env_z_defs(env(Up,_),D) :- env_z_defs(Up,D). | |
38 | ||
39 | create_subenv(Env,Vars,env(Env,Vars)). | |
40 | ||
41 | %create_scope_typeinfos(Env,tenv(TI)) :- | |
42 | % Env = env(_,Vars), | |
43 | % findall(tinfo(Name,_Expr,Env,Type), member(variable(Name,Type),Vars), TI). | |
44 | ||
45 | %lookup_typeinfo(tenv(Tenv),Name,Expr,Env,Type) :- | |
46 | % member(tinfo(Name,Expr,Env,Type),Tenv). |