Mercurial > projects > ldc
annotate dmd/dsymbol.h @ 715:30b42a283c8e
Removed TypeOpaque from DMD.
Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:55:33 +0200 |
parents | 44f08170f4ef |
children | 29c0d1194033 |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
336 | 3 // Copyright (c) 1999-2008 by Digital Mars |
159 | 4 // All Rights Reserved |
5 // written by Walter Bright | |
6 // http://www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
11 #ifndef DMD_DSYMBOL_H | |
12 #define DMD_DSYMBOL_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include "root.h" | |
19 #include "stringtable.h" | |
20 | |
21 #include "mars.h" | |
22 #include "arraytypes.h" | |
23 | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
159
diff
changeset
|
24 // llvm |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
159
diff
changeset
|
25 #include "../ir/irsymbol.h" |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
159
diff
changeset
|
26 |
159 | 27 struct Identifier; |
28 struct Scope; | |
29 struct DsymbolTable; | |
30 struct Declaration; | |
31 struct TupleDeclaration; | |
32 struct TypedefDeclaration; | |
33 struct AliasDeclaration; | |
34 struct AggregateDeclaration; | |
35 struct EnumDeclaration; | |
36 struct ClassDeclaration; | |
37 struct InterfaceDeclaration; | |
38 struct StructDeclaration; | |
39 struct UnionDeclaration; | |
40 struct FuncDeclaration; | |
41 struct FuncAliasDeclaration; | |
42 struct FuncLiteralDeclaration; | |
43 struct CtorDeclaration; | |
44 struct DtorDeclaration; | |
45 struct StaticCtorDeclaration; | |
46 struct StaticDtorDeclaration; | |
47 struct InvariantDeclaration; | |
48 struct UnitTestDeclaration; | |
49 struct NewDeclaration; | |
50 struct VarDeclaration; | |
51 struct AttribDeclaration; | |
52 struct Symbol; | |
53 struct Package; | |
54 struct Module; | |
55 struct Import; | |
56 struct Type; | |
57 struct TypeTuple; | |
58 struct WithStatement; | |
59 struct LabelDsymbol; | |
60 struct ScopeDsymbol; | |
61 struct TemplateDeclaration; | |
62 struct TemplateInstance; | |
63 struct TemplateMixin; | |
64 struct EnumMember; | |
65 struct ScopeDsymbol; | |
66 struct WithScopeSymbol; | |
67 struct ArrayScopeSymbol; | |
68 struct SymbolDeclaration; | |
69 struct Expression; | |
70 struct DeleteDeclaration; | |
71 struct HdrGenState; | |
72 struct TypeInfoDeclaration; | |
73 struct ClassInfoDeclaration; | |
74 | |
75 #if IN_GCC | |
76 union tree_node; | |
77 typedef union tree_node TYPE; | |
78 #else | |
79 struct TYPE; | |
80 #endif | |
81 | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
159
diff
changeset
|
82 // llvm |
159 | 83 #if IN_LLVM |
84 namespace llvm | |
85 { | |
86 class Value; | |
87 } | |
88 #endif | |
89 | |
90 enum PROT | |
91 { | |
92 PROTundefined, | |
93 PROTnone, // no access | |
94 PROTprivate, | |
95 PROTpackage, | |
96 PROTprotected, | |
97 PROTpublic, | |
98 PROTexport, | |
99 }; | |
100 | |
101 | |
102 struct Dsymbol : Object | |
103 { | |
104 Identifier *ident; | |
105 Identifier *c_ident; | |
106 Dsymbol *parent; | |
107 Symbol *csym; // symbol for code generator | |
108 Symbol *isym; // import version of csym | |
109 unsigned char *comment; // documentation comment for this Dsymbol | |
110 Loc loc; // where defined | |
111 | |
112 Dsymbol(); | |
113 Dsymbol(Identifier *); | |
114 char *toChars(); | |
115 char *toPrettyChars(); | |
116 char *locToChars(); | |
117 int equals(Object *o); | |
118 int isAnonymous(); | |
119 void error(Loc loc, const char *format, ...); | |
120 void error(const char *format, ...); | |
121 void checkDeprecated(Loc loc, Scope *sc); | |
122 Module *getModule(); | |
123 Dsymbol *pastMixin(); | |
124 Dsymbol *toParent(); | |
125 Dsymbol *toParent2(); | |
336 | 126 TemplateInstance *inTemplateInstance(); |
159 | 127 |
128 int dyncast() { return DYNCAST_DSYMBOL; } // kludge for template.isSymbol() | |
129 | |
130 static Array *arraySyntaxCopy(Array *a); | |
131 | |
336 | 132 virtual const char *kind(); |
159 | 133 virtual Dsymbol *toAlias(); // resolve real symbol |
134 virtual int addMember(Scope *sc, ScopeDsymbol *s, int memnum); | |
135 virtual void semantic(Scope *sc); | |
136 virtual void semantic2(Scope *sc); | |
137 virtual void semantic3(Scope *sc); | |
138 virtual void inlineScan(); | |
139 virtual Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
140 Dsymbol *searchX(Loc loc, Scope *sc, Identifier *id); | |
141 virtual int overloadInsert(Dsymbol *s); | |
142 #ifdef _DH | |
143 char *toHChars(); | |
144 virtual void toHBuffer(OutBuffer *buf, HdrGenState *hgs); | |
145 #endif | |
146 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
147 virtual void toDocBuffer(OutBuffer *buf); | |
148 virtual unsigned size(Loc loc); | |
149 virtual int isforwardRef(); | |
150 virtual void defineRef(Dsymbol *s); | |
151 virtual AggregateDeclaration *isThis(); // is a 'this' required to access the member | |
152 virtual ClassDeclaration *isClassMember(); // are we a member of a class? | |
153 virtual int isExport(); // is Dsymbol exported? | |
336 | 154 virtual int isImportedSymbol(); // is Dsymbol imported? |
159 | 155 virtual int isDeprecated(); // is Dsymbol deprecated? |
156 virtual LabelDsymbol *isLabel(); // is this a LabelDsymbol? | |
157 virtual AggregateDeclaration *isMember(); // is this symbol a member of an AggregateDeclaration? | |
158 virtual Type *getType(); // is this a type? | |
159 virtual char *mangle(); | |
160 virtual int needThis(); // need a 'this' pointer? | |
161 virtual enum PROT prot(); | |
162 virtual Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees | |
163 virtual int oneMember(Dsymbol **ps); | |
164 static int oneMembers(Array *members, Dsymbol **ps); | |
165 virtual int hasPointers(); | |
166 virtual void addLocalClass(ClassDeclarations *) { } | |
167 virtual void checkCtorConstInit() { } | |
168 | |
169 virtual void addComment(unsigned char *comment); | |
170 virtual void emitComment(Scope *sc); | |
171 void emitDitto(Scope *sc); | |
172 | |
173 // Backend | |
174 | |
175 virtual Symbol *toSymbol(); // to backend symbol | |
336 | 176 virtual void toObjFile(int multiobj); // compile to .obj file |
159 | 177 virtual int cvMember(unsigned char *p); // emit cv debug info for member |
178 | |
179 Symbol *toImport(); // to backend import symbol | |
180 static Symbol *toImport(Symbol *s); // to backend import symbol | |
181 | |
182 Symbol *toSymbolX(const char *prefix, int sclass, TYPE *t, const char *suffix); // helper | |
183 | |
184 // Eliminate need for dynamic_cast | |
185 virtual Package *isPackage() { return NULL; } | |
186 virtual Module *isModule() { return NULL; } | |
187 virtual EnumMember *isEnumMember() { return NULL; } | |
188 virtual TemplateDeclaration *isTemplateDeclaration() { return NULL; } | |
189 virtual TemplateInstance *isTemplateInstance() { return NULL; } | |
190 virtual TemplateMixin *isTemplateMixin() { return NULL; } | |
191 virtual Declaration *isDeclaration() { return NULL; } | |
192 virtual TupleDeclaration *isTupleDeclaration() { return NULL; } | |
193 virtual TypedefDeclaration *isTypedefDeclaration() { return NULL; } | |
194 virtual AliasDeclaration *isAliasDeclaration() { return NULL; } | |
195 virtual AggregateDeclaration *isAggregateDeclaration() { return NULL; } | |
196 virtual FuncDeclaration *isFuncDeclaration() { return NULL; } | |
197 virtual FuncAliasDeclaration *isFuncAliasDeclaration() { return NULL; } | |
198 virtual FuncLiteralDeclaration *isFuncLiteralDeclaration() { return NULL; } | |
199 virtual CtorDeclaration *isCtorDeclaration() { return NULL; } | |
200 virtual DtorDeclaration *isDtorDeclaration() { return NULL; } | |
201 virtual StaticCtorDeclaration *isStaticCtorDeclaration() { return NULL; } | |
202 virtual StaticDtorDeclaration *isStaticDtorDeclaration() { return NULL; } | |
203 virtual InvariantDeclaration *isInvariantDeclaration() { return NULL; } | |
204 virtual UnitTestDeclaration *isUnitTestDeclaration() { return NULL; } | |
205 virtual NewDeclaration *isNewDeclaration() { return NULL; } | |
206 virtual VarDeclaration *isVarDeclaration() { return NULL; } | |
207 virtual ClassDeclaration *isClassDeclaration() { return NULL; } | |
208 virtual StructDeclaration *isStructDeclaration() { return NULL; } | |
209 virtual UnionDeclaration *isUnionDeclaration() { return NULL; } | |
210 virtual InterfaceDeclaration *isInterfaceDeclaration() { return NULL; } | |
211 virtual ScopeDsymbol *isScopeDsymbol() { return NULL; } | |
212 virtual WithScopeSymbol *isWithScopeSymbol() { return NULL; } | |
213 virtual ArrayScopeSymbol *isArrayScopeSymbol() { return NULL; } | |
214 virtual Import *isImport() { return NULL; } | |
215 virtual EnumDeclaration *isEnumDeclaration() { return NULL; } | |
216 #ifdef _DH | |
217 virtual DeleteDeclaration *isDeleteDeclaration() { return NULL; } | |
218 #endif | |
219 virtual SymbolDeclaration *isSymbolDeclaration() { return NULL; } | |
220 virtual AttribDeclaration *isAttribDeclaration() { return NULL; } | |
221 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return NULL; } | |
222 virtual ClassInfoDeclaration* isClassInfoDeclaration() { return NULL; } | |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
223 |
159 | 224 // llvm stuff |
225 int llvmInternal; | |
443
44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
336
diff
changeset
|
226 |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
159
diff
changeset
|
227 IrDsymbol ir; |
159 | 228 }; |
229 | |
230 // Dsymbol that generates a scope | |
231 | |
232 struct ScopeDsymbol : Dsymbol | |
233 { | |
234 Array *members; // all Dsymbol's in this scope | |
235 DsymbolTable *symtab; // members[] sorted into table | |
236 | |
237 Array *imports; // imported ScopeDsymbol's | |
238 unsigned char *prots; // PROT for each import | |
239 | |
240 ScopeDsymbol(); | |
241 ScopeDsymbol(Identifier *id); | |
242 Dsymbol *syntaxCopy(Dsymbol *s); | |
243 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
244 void importScope(ScopeDsymbol *s, enum PROT protection); | |
245 int isforwardRef(); | |
246 void defineRef(Dsymbol *s); | |
247 static void multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2); | |
248 Dsymbol *nameCollision(Dsymbol *s); | |
336 | 249 const char *kind(); |
159 | 250 |
251 void emitMemberComments(Scope *sc); | |
252 | |
253 ScopeDsymbol *isScopeDsymbol() { return this; } | |
254 }; | |
255 | |
256 // With statement scope | |
257 | |
258 struct WithScopeSymbol : ScopeDsymbol | |
259 { | |
260 WithStatement *withstate; | |
261 | |
262 WithScopeSymbol(WithStatement *withstate); | |
263 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
264 | |
265 WithScopeSymbol *isWithScopeSymbol() { return this; } | |
266 }; | |
267 | |
268 // Array Index/Slice scope | |
269 | |
270 struct ArrayScopeSymbol : ScopeDsymbol | |
271 { | |
272 Expression *exp; // IndexExp or SliceExp | |
273 TypeTuple *type; // for tuple[length] | |
274 TupleDeclaration *td; // for tuples of objects | |
275 | |
276 ArrayScopeSymbol(Expression *e); | |
277 ArrayScopeSymbol(TypeTuple *t); | |
278 ArrayScopeSymbol(TupleDeclaration *td); | |
279 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
280 | |
281 ArrayScopeSymbol *isArrayScopeSymbol() { return this; } | |
282 }; | |
283 | |
284 // Table of Dsymbol's | |
285 | |
286 struct DsymbolTable : Object | |
287 { | |
288 StringTable *tab; | |
289 | |
290 DsymbolTable(); | |
291 ~DsymbolTable(); | |
292 | |
293 // Look up Identifier. Return Dsymbol if found, NULL if not. | |
294 Dsymbol *lookup(Identifier *ident); | |
295 | |
296 // Insert Dsymbol in table. Return NULL if already there. | |
297 Dsymbol *insert(Dsymbol *s); | |
298 | |
299 // Look for Dsymbol in table. If there, return it. If not, insert s and return that. | |
300 Dsymbol *update(Dsymbol *s); | |
301 Dsymbol *insert(Identifier *ident, Dsymbol *s); // when ident and s are not the same | |
302 }; | |
303 | |
304 #endif /* DMD_DSYMBOL_H */ |