Mercurial > projects > ldc
comparison dmd2/init.h @ 758:f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 11 Nov 2008 01:38:48 +0100 |
parents | |
children | 638d16625da2 |
comparison
equal
deleted
inserted
replaced
757:2c730d530c98 | 758:f04dde6e882c |
---|---|
1 | |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2007 by Digital Mars | |
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 INIT_H | |
12 #define INIT_H | |
13 | |
14 #include "root.h" | |
15 | |
16 #include "mars.h" | |
17 #include "arraytypes.h" | |
18 | |
19 struct Identifier; | |
20 struct Expression; | |
21 struct Scope; | |
22 struct Type; | |
23 struct dt_t; | |
24 struct AggregateDeclaration; | |
25 struct VoidInitializer; | |
26 struct StructInitializer; | |
27 struct ArrayInitializer; | |
28 struct ExpInitializer; | |
29 struct StructInitializer; | |
30 #ifdef _DH | |
31 struct HdrGenState; | |
32 #endif | |
33 | |
34 struct Initializer : Object | |
35 { | |
36 Loc loc; | |
37 | |
38 Initializer(Loc loc); | |
39 virtual Initializer *syntaxCopy(); | |
40 virtual Initializer *semantic(Scope *sc, Type *t); | |
41 virtual Type *inferType(Scope *sc); | |
42 virtual Expression *toExpression() = 0; | |
43 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs) = 0; | |
44 char *toChars(); | |
45 | |
46 static Initializers *arraySyntaxCopy(Initializers *ai); | |
47 | |
48 virtual dt_t *toDt(); | |
49 | |
50 virtual VoidInitializer *isVoidInitializer() { return NULL; } | |
51 virtual StructInitializer *isStructInitializer() { return NULL; } | |
52 virtual ArrayInitializer *isArrayInitializer() { return NULL; } | |
53 virtual ExpInitializer *isExpInitializer() { return NULL; } | |
54 }; | |
55 | |
56 struct VoidInitializer : Initializer | |
57 { | |
58 Type *type; // type that this will initialize to | |
59 | |
60 VoidInitializer(Loc loc); | |
61 Initializer *syntaxCopy(); | |
62 Initializer *semantic(Scope *sc, Type *t); | |
63 Expression *toExpression(); | |
64 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
65 | |
66 dt_t *toDt(); | |
67 | |
68 virtual VoidInitializer *isVoidInitializer() { return this; } | |
69 }; | |
70 | |
71 struct StructInitializer : Initializer | |
72 { | |
73 Identifiers field; // of Identifier *'s | |
74 Initializers value; // parallel array of Initializer *'s | |
75 | |
76 Array vars; // parallel array of VarDeclaration *'s | |
77 AggregateDeclaration *ad; // which aggregate this is for | |
78 | |
79 StructInitializer(Loc loc); | |
80 Initializer *syntaxCopy(); | |
81 void addInit(Identifier *field, Initializer *value); | |
82 Initializer *semantic(Scope *sc, Type *t); | |
83 Expression *toExpression(); | |
84 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
85 | |
86 dt_t *toDt(); | |
87 | |
88 StructInitializer *isStructInitializer() { return this; } | |
89 }; | |
90 | |
91 struct ArrayInitializer : Initializer | |
92 { | |
93 Expressions index; // indices | |
94 Initializers value; // of Initializer *'s | |
95 unsigned dim; // length of array being initialized | |
96 Type *type; // type that array will be used to initialize | |
97 int sem; // !=0 if semantic() is run | |
98 | |
99 ArrayInitializer(Loc loc); | |
100 Initializer *syntaxCopy(); | |
101 void addInit(Expression *index, Initializer *value); | |
102 Initializer *semantic(Scope *sc, Type *t); | |
103 Type *inferType(Scope *sc); | |
104 Expression *toExpression(); | |
105 Initializer *toAssocArrayInitializer(); | |
106 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
107 | |
108 dt_t *toDt(); | |
109 dt_t *toDtBit(); // for bit arrays | |
110 | |
111 ArrayInitializer *isArrayInitializer() { return this; } | |
112 }; | |
113 | |
114 struct ExpInitializer : Initializer | |
115 { | |
116 Expression *exp; | |
117 | |
118 ExpInitializer(Loc loc, Expression *exp); | |
119 Initializer *syntaxCopy(); | |
120 Initializer *semantic(Scope *sc, Type *t); | |
121 Type *inferType(Scope *sc); | |
122 Expression *toExpression(); | |
123 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
124 | |
125 dt_t *toDt(); | |
126 | |
127 virtual ExpInitializer *isExpInitializer() { return this; } | |
128 }; | |
129 | |
130 #endif |