Modules |
Files |
Inheritance Tree |
Inheritance Graph |
Name Index |
Config
File: Synopsis/Parser/C++/occ/env.h
1| /*
2| Copyright (C) 1997-2000 Shigeru Chiba, University of Tsukuba.
3|
4| Permission to use, copy, distribute and modify this software and
5| its documentation for any purpose is hereby granted without fee,
6| provided that the above copyright notice appear in all copies and that
7| both that copyright notice and this permission notice appear in
8| supporting documentation.
9|
10| Shigeru Chiba makes no representations about the suitability of this
11| software for any purpose. It is provided "as is" without express or
12| implied warranty.
13| */
14|
15| #ifndef _env_h
16| #define _env_h
17|
18| #include "types.h"
19| #include "ptree-core.h"
20|
21| class Class;
22| class HashTable;
23| class Bind;
24| class Encoding;
25| class TypeInfo;
26| class Walker;
27|
28|
29|
30| class OCXXMOP Environment : public LightObject {
31| public:
32| Environment(Walker* w);
33| Environment(Environment* e);
34| Environment(Environment* e, Walker* w);
35| static void do_init_static();
36| bool IsEmpty();
37| Environment* GetOuterEnvironment() { return next; }
38| Environment* GetBottom();
39| void AddBaseclassEnv(Environment* e) { baseclasses.Append(e); }
40| Walker* GetWalker() { return walker; }
41| void SetWalker(Walker* w) { walker = w; }
42|
43| Class* LookupClassMetaobject(Ptree* name);
44| bool LookupType(const char* name, int len, Bind*& t);
45|
46| bool Lookup(Ptree* name, bool& is_type_name, TypeInfo& t);
47| bool Lookup(Ptree* name, TypeInfo& t);
48| bool Lookup(Ptree*, Bind*&);
49| bool LookupTop(Ptree*, Bind*&);
50|
51| bool LookupTop(const char* name, int len, Bind*& t);
52| bool LookupAll(const char* name, int len, Bind*& t);
53|
54| bool RecordVariable(char* name, Class* c);
55| bool RecordPointerVariable(char* name, Class* c);
56|
57| int AddEntry(char*, int, Bind*);
58| int AddDupEntry(char*, int, Bind*);
59|
60| void RecordNamespace(Ptree*);
61| bool LookupNamespace(char*, int);
62| void RecordTypedefName(Ptree*);
63| void RecordEnumName(Ptree*);
64| void RecordClassName(char*, Class*);
65| void RecordTemplateClass(Ptree*, Class*);
66| Environment* RecordTemplateFunction(Ptree*, Ptree*);
67| Environment* RecordDeclarator(Ptree*);
68| Environment* DontRecordDeclarator(Ptree*);
69| void RecordMetaclassName(Ptree*);
70| Ptree* LookupMetaclass(Ptree*);
71| static bool RecordClasskeyword(char*, char*);
72| static Ptree* LookupClasskeyword(Ptree*);
73|
74| void SetMetaobject(Class* m) { metaobject = m; }
75| Class* IsClassEnvironment() { return metaobject; }
76| Class* LookupThis();
77| Environment* IsMember(Ptree*);
78|
79| void Dump();
80| void Dump(int);
81|
82| Ptree* GetLineNumber(Ptree*, int&);
83|
84| public:
85| class OCXXMOP Array : public LightObject {
86| public:
87| Array(int = 2);
88| uint Number() { return num; }
89| Environment* Ref(uint index);
90| void Append(Environment*);
91| private:
92| uint num, size;
93| Environment** array;
94| };
95|
96| private:
97| Environment* next;
98| HashTable* htable;
99| Class* metaobject;
100| Walker* walker;
101| PtreeArray metaclasses;
102| static PtreeArray* classkeywords;
103| Array baseclasses;
104| static HashTable* namespace_table;
105| };
106|
107|
108|
109| class Bind : public LightObject {
110| public:
111| enum Kind {
112| isVarName, isTypedefName, isClassName, isEnumName, isTemplateClass,
113| isTemplateFunction
114| };
115| virtual Kind What() = nil;
116| virtual void GetType(TypeInfo&, Environment*) = nil;
117| virtual char* GetEncodedType();
118| virtual bool IsType();
119| virtual Class* ClassMetaobject();
120| virtual void SetClassMetaobject(Class*);
121| };
122|
123| class BindVarName : public Bind {
124| public:
125| BindVarName(char* t) { type = t; }
126| Kind What();
127| void GetType(TypeInfo&, Environment*);
128| char* GetEncodedType();
129| bool IsType();
130|
131| private:
132| char* type;
133| };
134|
135| class BindTypedefName : public Bind {
136| public:
137| BindTypedefName(char* t) { type = t; }
138| Kind What();
139| void GetType(TypeInfo&, Environment*);
140| char* GetEncodedType();
141|
142| private:
143| char* type;
144| };
145|
146| class BindClassName : public Bind {
147| public:
148| BindClassName(Class* c) { metaobject = c; }
149| Kind What();
150| void GetType(TypeInfo&, Environment*);
151| Class* ClassMetaobject();
152| void SetClassMetaobject(Class*);
153|
154| private:
155| Class* metaobject;
156| };
157|
158| class BindEnumName : public Bind {
159| public:
160| BindEnumName(char*, Ptree*);
161| Kind What();
162| void GetType(TypeInfo&, Environment*);
163| Ptree* GetSpecification() { return specification; }
164|
165| private:
166| char* type;
167| Ptree* specification;
168| };
169|
170| class BindTemplateClass : public Bind {
171| public:
172| BindTemplateClass(Class* c) { metaobject = c; }
173| Kind What();
174| void GetType(TypeInfo&, Environment*);
175| Class* ClassMetaobject();
176| void SetClassMetaobject(Class*);
177|
178| private:
179| Class* metaobject;
180| };
181|
182| class BindTemplateFunction : public Bind {
183| public:
184| BindTemplateFunction(Ptree* d) { decl = d; }
185| Kind What();
186| void GetType(TypeInfo&, Environment*);
187| bool IsType();
188|
189| private:
190| Ptree* decl;
191| };
192|
193| #endif /* _env_h */