Mercurial > projects > ldc
comparison dmd2/template.h @ 1452:638d16625da2
LDC 2 compiles again.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Sat, 30 May 2009 17:23:32 +0100 |
parents | 5fa3e0ea06e9 |
children | 54b3c1394d62 |
comparison
equal
deleted
inserted
replaced
1423:42bd767ec5a4 | 1452:638d16625da2 |
---|---|
1 | 1 |
2 // Compiler implementation of the D programming language | 2 // Compiler implementation of the D programming language |
3 // Copyright (c) 1999-2008 by Digital Mars | 3 // Copyright (c) 1999-2009 by Digital Mars |
4 // All Rights Reserved | 4 // All Rights Reserved |
5 // written by Walter Bright | 5 // written by Walter Bright |
6 // http://www.digitalmars.com | 6 // http://www.digitalmars.com |
7 // License for redistribution is by either the Artistic License | 7 // License for redistribution is by either the Artistic License |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | 8 // in artistic.txt, or the GNU General Public License in gnu.txt. |
12 #define DMD_TEMPLATE_H | 12 #define DMD_TEMPLATE_H |
13 | 13 |
14 #ifdef __DMC__ | 14 #ifdef __DMC__ |
15 #pragma once | 15 #pragma once |
16 #endif /* __DMC__ */ | 16 #endif /* __DMC__ */ |
17 | 17 #if IN_LLVM |
18 #include <string> | 18 #include <string> |
19 | 19 #endif |
20 #include "root.h" | 20 #include "root.h" |
21 #include "arraytypes.h" | 21 #include "arraytypes.h" |
22 #include "dsymbol.h" | 22 #include "dsymbol.h" |
23 #if IN_LLVM | |
23 #include "mtype.h" | 24 #include "mtype.h" |
24 | 25 #endif |
25 | 26 |
26 struct OutBuffer; | 27 struct OutBuffer; |
27 struct Identifier; | 28 struct Identifier; |
28 struct TemplateInstance; | 29 struct TemplateInstance; |
29 struct TemplateParameter; | 30 struct TemplateParameter; |
52 struct TemplateDeclaration : ScopeDsymbol | 53 struct TemplateDeclaration : ScopeDsymbol |
53 { | 54 { |
54 TemplateParameters *parameters; // array of TemplateParameter's | 55 TemplateParameters *parameters; // array of TemplateParameter's |
55 | 56 |
56 TemplateParameters *origParameters; // originals for Ddoc | 57 TemplateParameters *origParameters; // originals for Ddoc |
57 | |
58 Expression *constraint; | 58 Expression *constraint; |
59 | |
60 Array instances; // array of TemplateInstance's | 59 Array instances; // array of TemplateInstance's |
61 | 60 |
62 TemplateDeclaration *overnext; // next overloaded TemplateDeclaration | 61 TemplateDeclaration *overnext; // next overloaded TemplateDeclaration |
63 TemplateDeclaration *overroot; // first in overnext list | 62 TemplateDeclaration *overroot; // first in overnext list |
64 | 63 |
65 Scope *scope; | 64 Scope *scope; |
66 Dsymbol *onemember; // if !=NULL then one member of this template | 65 Dsymbol *onemember; // if !=NULL then one member of this template |
66 | |
67 int literal; // this template declaration is a literal | |
67 | 68 |
68 TemplateDeclaration(Loc loc, Identifier *id, TemplateParameters *parameters, | 69 TemplateDeclaration(Loc loc, Identifier *id, TemplateParameters *parameters, |
69 Expression *constraint, Array *decldefs); | 70 Expression *constraint, Array *decldefs); |
70 Dsymbol *syntaxCopy(Dsymbol *); | 71 Dsymbol *syntaxCopy(Dsymbol *); |
71 void semantic(Scope *sc); | 72 void semantic(Scope *sc); |
86 | 87 |
87 TemplateDeclaration *isTemplateDeclaration() { return this; } | 88 TemplateDeclaration *isTemplateDeclaration() { return this; } |
88 | 89 |
89 TemplateTupleParameter *isVariadic(); | 90 TemplateTupleParameter *isVariadic(); |
90 int isOverloadable(); | 91 int isOverloadable(); |
91 | 92 |
93 #if IN_LLVM | |
92 // LDC | 94 // LDC |
93 std::string intrinsicName; | 95 std::string intrinsicName; |
96 #endif | |
94 }; | 97 }; |
95 | 98 |
96 struct TemplateParameter | 99 struct TemplateParameter |
97 { | 100 { |
98 /* For type-parameter: | 101 /* For type-parameter: |
115 TemplateParameter(Loc loc, Identifier *ident); | 118 TemplateParameter(Loc loc, Identifier *ident); |
116 | 119 |
117 virtual TemplateTypeParameter *isTemplateTypeParameter(); | 120 virtual TemplateTypeParameter *isTemplateTypeParameter(); |
118 virtual TemplateValueParameter *isTemplateValueParameter(); | 121 virtual TemplateValueParameter *isTemplateValueParameter(); |
119 virtual TemplateAliasParameter *isTemplateAliasParameter(); | 122 virtual TemplateAliasParameter *isTemplateAliasParameter(); |
123 #if DMDV2 | |
120 virtual TemplateThisParameter *isTemplateThisParameter(); | 124 virtual TemplateThisParameter *isTemplateThisParameter(); |
125 #endif | |
121 virtual TemplateTupleParameter *isTemplateTupleParameter(); | 126 virtual TemplateTupleParameter *isTemplateTupleParameter(); |
122 | 127 |
123 virtual TemplateParameter *syntaxCopy() = 0; | 128 virtual TemplateParameter *syntaxCopy() = 0; |
124 virtual void declareParameter(Scope *sc) = 0; | 129 virtual void declareParameter(Scope *sc) = 0; |
125 virtual void semantic(Scope *) = 0; | 130 virtual void semantic(Scope *) = 0; |
272 // to TemplateDeclaration.parameters | 277 // to TemplateDeclaration.parameters |
273 // [int, char, 100] | 278 // [int, char, 100] |
274 | 279 |
275 TemplateDeclaration *tempdecl; // referenced by foo.bar.abc | 280 TemplateDeclaration *tempdecl; // referenced by foo.bar.abc |
276 TemplateInstance *inst; // refer to existing instance | 281 TemplateInstance *inst; // refer to existing instance |
282 TemplateInstance *tinst; // enclosing template instance | |
277 ScopeDsymbol *argsym; // argument symbol table | 283 ScopeDsymbol *argsym; // argument symbol table |
278 AliasDeclaration *aliasdecl; // !=NULL if instance is an alias for its | 284 AliasDeclaration *aliasdecl; // !=NULL if instance is an alias for its |
279 // sole member | 285 // sole member |
280 WithScopeSymbol *withsym; // if a member of a with statement | 286 WithScopeSymbol *withsym; // if a member of a with statement |
281 int semanticdone; // has semantic() been done? | 287 int semanticdone; // has semantic() been done? |
303 Dsymbol *toAlias(); // resolve real symbol | 309 Dsymbol *toAlias(); // resolve real symbol |
304 const char *kind(); | 310 const char *kind(); |
305 int oneMember(Dsymbol **ps); | 311 int oneMember(Dsymbol **ps); |
306 char *toChars(); | 312 char *toChars(); |
307 char *mangle(); | 313 char *mangle(); |
308 | 314 void printInstantiationTrace(); |
315 | |
316 #if IN_DMD | |
309 void toObjFile(int multiobj); // compile to .obj file | 317 void toObjFile(int multiobj); // compile to .obj file |
318 #endif | |
310 | 319 |
311 // Internal | 320 // Internal |
312 static void semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int flags); | 321 static void semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int flags); |
313 void semanticTiargs(Scope *sc); | 322 void semanticTiargs(Scope *sc); |
314 TemplateDeclaration *findTemplateDeclaration(Scope *sc); | 323 TemplateDeclaration *findTemplateDeclaration(Scope *sc); |
315 TemplateDeclaration *findBestMatch(Scope *sc); | 324 TemplateDeclaration *findBestMatch(Scope *sc); |
316 void declareParameters(Scope *sc); | 325 void declareParameters(Scope *sc); |
317 int isNested(Objects *tiargs); | 326 int hasNestedArgs(Objects *tiargs); |
318 Identifier *genIdent(); | 327 Identifier *genIdent(); |
319 | 328 |
320 TemplateInstance *isTemplateInstance() { return this; } | 329 TemplateInstance *isTemplateInstance() { return this; } |
321 AliasDeclaration *isAliasDeclaration(); | 330 AliasDeclaration *isAliasDeclaration(); |
322 | 331 |
332 #if IN_LLVM | |
323 // LDC | 333 // LDC |
324 TemplateInstance *tinst; // enclosing template instance | |
325 Module* tmodule; // module from outermost enclosing template instantiation | 334 Module* tmodule; // module from outermost enclosing template instantiation |
326 void printInstantiationTrace(); | 335 Module* emittedInModule; // which module this template instance has been emitted in |
336 | |
337 void codegen(Ir*); | |
338 #endif | |
327 }; | 339 }; |
328 | 340 |
329 struct TemplateMixin : TemplateInstance | 341 struct TemplateMixin : TemplateInstance |
330 { | 342 { |
331 Array *idents; | 343 Array *idents; |
344 int hasPointers(); | 356 int hasPointers(); |
345 char *toChars(); | 357 char *toChars(); |
346 char *mangle(); | 358 char *mangle(); |
347 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | 359 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); |
348 | 360 |
361 #if IN_DMD | |
349 void toObjFile(int multiobj); // compile to .obj file | 362 void toObjFile(int multiobj); // compile to .obj file |
363 #endif | |
350 | 364 |
351 TemplateMixin *isTemplateMixin() { return this; } | 365 TemplateMixin *isTemplateMixin() { return this; } |
366 | |
367 #if IN_LLVM | |
368 void codegen(Ir*); | |
369 #endif | |
352 }; | 370 }; |
353 | 371 |
354 Expression *isExpression(Object *o); | 372 Expression *isExpression(Object *o); |
355 Dsymbol *isDsymbol(Object *o); | 373 Dsymbol *isDsymbol(Object *o); |
356 Type *isType(Object *o); | 374 Type *isType(Object *o); |