Mercurial > projects > dil
annotate trunk/src/dil/Declarations.d @ 461:c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Tue, 30 Oct 2007 18:17:14 +0100 |
parents | e242f0ee2d27 |
children | bd176bc73e43 |
rev | line source |
---|---|
102 | 1 /++ |
2 Author: Aziz Köksal | |
249 | 3 License: GPL3 |
102 | 4 +/ |
326 | 5 module dil.Declarations; |
327 | 6 import dil.SyntaxTree; |
7 import dil.Expressions; | |
8 import dil.Types; | |
9 import dil.Statements; | |
10 import dil.Token; | |
102 | 11 |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
12 abstract class Declaration : Node |
102 | 13 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
14 bool hasBody; |
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
15 this(bool hasBody) |
116 | 16 { |
275 | 17 super(NodeCategory.Declaration); |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
18 this.hasBody = hasBody; |
116 | 19 } |
102 | 20 } |
21 | |
305 | 22 class Declarations : Declaration |
23 { | |
24 this() | |
25 { | |
26 super(true); | |
27 mixin(set_kind); | |
28 } | |
29 | |
30 void opCatAssign(Declaration d) | |
31 { | |
32 this.children ~= d; | |
33 } | |
34 | |
35 void opCatAssign(Declarations ds) | |
36 { | |
37 this.children ~= ds.children; | |
38 } | |
39 } | |
40 | |
129 | 41 class EmptyDeclaration : Declaration |
42 { | |
43 this() | |
44 { | |
45 super(false); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
46 mixin(set_kind); |
129 | 47 } |
48 } | |
49 | |
211 | 50 class IllegalDeclaration : Declaration |
51 { | |
292 | 52 Token* token; |
53 this(Token* token) | |
211 | 54 { |
55 super(false); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
56 mixin(set_kind); |
292 | 57 this.token = token; |
211 | 58 } |
59 } | |
60 | |
364 | 61 /// FQN = fully qualified name |
62 alias Token*[] ModuleFQN; // Identifier(.Identifier)* | |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
63 |
102 | 64 class ModuleDeclaration : Declaration |
65 { | |
364 | 66 Token* moduleName; |
67 Token*[] packages; | |
68 this(ModuleFQN moduleFQN) | |
102 | 69 { |
116 | 70 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
71 mixin(set_kind); |
365 | 72 assert(moduleFQN.length != 0); |
73 this.moduleName = moduleFQN[$-1]; | |
74 this.packages = moduleFQN[0..$-1]; | |
75 } | |
76 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
77 char[] getFQN() |
370 | 78 { |
79 auto pname = getPackageName('.'); | |
80 if (pname.length) | |
81 return pname ~ "." ~ getName(); | |
82 else | |
83 return getName(); | |
84 } | |
85 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
86 char[] getName() |
365 | 87 { |
88 if (moduleName) | |
89 return moduleName.identifier; | |
90 return null; | |
91 } | |
92 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
93 char[] getPackageName(char separator) |
365 | 94 { |
95 char[] pname; | |
96 foreach (pckg; packages) | |
97 if (pckg) | |
98 pname ~= pckg.identifier ~ separator; | |
367
dda55fae37de
- ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents:
366
diff
changeset
|
99 if (pname.length) |
dda55fae37de
- ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents:
366
diff
changeset
|
100 pname = pname[0..$-1]; // Remove last separator |
365 | 101 return pname; |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
102 } |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
103 } |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
104 |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
105 class ImportDeclaration : Declaration |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
106 { |
364 | 107 ModuleFQN[] moduleFQNs; |
263 | 108 Token*[] moduleAliases; |
109 Token*[] bindNames; | |
110 Token*[] bindAliases; | |
461
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
111 bool isStatic_; |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
112 |
366 | 113 this(ModuleFQN[] moduleFQNs, Token*[] moduleAliases, Token*[] bindNames, Token*[] bindAliases, bool isStatic) |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
114 { |
116 | 115 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
116 mixin(set_kind); |
364 | 117 this.moduleFQNs = moduleFQNs; |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
118 this.moduleAliases = moduleAliases; |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
119 this.bindNames = bindNames; |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
120 this.bindAliases = bindAliases; |
461
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
121 this.isStatic_ = isStatic; |
366 | 122 } |
123 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
124 char[][] getModuleFQNs(char separator) |
366 | 125 { |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
126 char[][] FQNs; |
366 | 127 foreach (moduleFQN; moduleFQNs) |
128 { | |
129 char[] FQN; | |
130 foreach (ident; moduleFQN) | |
131 if (ident) | |
132 FQN ~= ident.identifier ~ separator; | |
133 FQNs ~= FQN[0..$-1]; // Remove last separator | |
134 } | |
135 return FQNs; | |
102 | 136 } |
461
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
137 |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
138 bool isStatic() |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
139 { |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
140 return isStatic_; |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
141 } |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
142 |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
143 bool isPublic() |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
144 { |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
145 // TODO: |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
146 return false; |
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
147 } |
102 | 148 } |
149 | |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
150 class AliasDeclaration : Declaration |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
151 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
152 Declaration decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
153 this(Declaration decl) |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
154 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
155 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
156 mixin(set_kind); |
292 | 157 this.children = [decl]; |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
158 this.decl = decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
159 } |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
160 } |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
161 |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
162 class TypedefDeclaration : Declaration |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
163 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
164 Declaration decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
165 this(Declaration decl) |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
166 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
167 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
168 mixin(set_kind); |
292 | 169 this.children = [decl]; |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
170 this.decl = decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
171 } |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
172 } |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
173 |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
174 class EnumDeclaration : Declaration |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
175 { |
264 | 176 Token* name; |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
177 Type baseType; |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
178 EnumMember[] members; |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
179 this(Token* name, Type baseType, EnumMember[] members, bool hasBody) |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
180 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
181 super(hasBody); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
182 mixin(set_kind); |
300
6cf3a5069109
- Fix: adding only non-null members to this.children in EnumDeclaration ctor.
aziz
parents:
299
diff
changeset
|
183 if (baseType) |
6cf3a5069109
- Fix: adding only non-null members to this.children in EnumDeclaration ctor.
aziz
parents:
299
diff
changeset
|
184 this.children = [baseType]; |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
185 if (members.length) |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
186 this.children ~= members; |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
187 |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
188 this.name = name; |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
189 this.baseType = baseType; |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
190 this.members = members; |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
191 } |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
192 } |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
193 |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
194 class EnumMember : Node |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
195 { |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
196 Token* name; |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
197 Expression value; |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
198 this(Token* name, Expression value) |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
199 { |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
200 super(NodeCategory.Other); |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
201 mixin(set_kind); |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
202 if (value) |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
203 this.children = [value]; |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
204 |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
205 this.name = name; |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
206 this.value = value; |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
207 } |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
208 } |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
209 |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
210 class ClassDeclaration : Declaration |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
211 { |
264 | 212 Token* name; |
258 | 213 TemplateParameters tparams; |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
214 BaseClass[] bases; |
305 | 215 Declarations decls; |
216 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls, bool hasBody) | |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
217 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
218 super(hasBody); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
219 mixin(set_kind); |
299
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
220 if (tparams) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
221 this.children = [tparams]; |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
222 if (bases.length) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
223 this.children ~= bases; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
224 if (decls) |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
225 this.children ~= decls; |
305 | 226 |
112 | 227 this.name = name; |
195
37c2ffd649c4
- Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents:
194
diff
changeset
|
228 this.tparams = tparams; |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
229 this.bases = bases; |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
230 this.decls = decls; |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
231 } |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
232 } |
112 | 233 |
234 class InterfaceDeclaration : Declaration | |
235 { | |
264 | 236 Token* name; |
258 | 237 TemplateParameters tparams; |
112 | 238 BaseClass[] bases; |
305 | 239 Declarations decls; |
240 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls, bool hasBody) | |
112 | 241 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
242 super(hasBody); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
243 mixin(set_kind); |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
244 if (tparams) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
245 this.children = [tparams]; |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
246 if (bases.length) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
247 this.children ~= bases; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
248 if (decls) |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
249 this.children ~= decls; |
305 | 250 |
112 | 251 this.name = name; |
195
37c2ffd649c4
- Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents:
194
diff
changeset
|
252 this.tparams = tparams; |
112 | 253 this.bases = bases; |
254 this.decls = decls; | |
255 } | |
256 } | |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
257 |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
258 class StructDeclaration : Declaration |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
259 { |
264 | 260 Token* name; |
258 | 261 TemplateParameters tparams; |
305 | 262 Declarations decls; |
263 this(Token* name, TemplateParameters tparams, Declarations decls, bool hasBody) | |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
264 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
265 super(hasBody); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
266 mixin(set_kind); |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
267 if (tparams) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
268 this.children = [tparams]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
269 if (decls) |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
270 this.children ~= decls; |
305 | 271 |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
272 this.name = name; |
195
37c2ffd649c4
- Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents:
194
diff
changeset
|
273 this.tparams = tparams; |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
274 this.decls = decls; |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
275 } |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
276 } |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
277 |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
278 class UnionDeclaration : Declaration |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
279 { |
264 | 280 Token* name; |
258 | 281 TemplateParameters tparams; |
305 | 282 Declarations decls; |
283 this(Token* name, TemplateParameters tparams, Declarations decls, bool hasBody) | |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
284 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
285 super(hasBody); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
286 mixin(set_kind); |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
287 if (tparams) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
288 this.children = [tparams]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
289 if (decls) |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
290 this.children ~= decls; |
305 | 291 |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
292 this.name = name; |
195
37c2ffd649c4
- Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents:
194
diff
changeset
|
293 this.tparams = tparams; |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
294 this.decls = decls; |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
295 } |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
296 } |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
297 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
298 class ConstructorDeclaration : Declaration |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
299 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
300 Parameters parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
301 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
302 this(Parameters parameters, FunctionBody funcBody) |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
303 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
304 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
305 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
306 assert(parameters !is null && funcBody !is null); |
292 | 307 this.children = [cast(Node)parameters, funcBody]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
308 |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
309 this.parameters = parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
310 this.funcBody = funcBody; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
311 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
312 } |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
313 |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
314 class StaticConstructorDeclaration : Declaration |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
315 { |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
316 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
317 this(FunctionBody funcBody) |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
318 { |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
319 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
320 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
321 assert(funcBody !is null); |
292 | 322 this.children = [funcBody]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
323 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
324 this.funcBody = funcBody; |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
325 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
326 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
327 |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
328 class DestructorDeclaration : Declaration |
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
329 { |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
330 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
331 this(FunctionBody funcBody) |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
332 { |
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
333 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
334 mixin(set_kind); |
292 | 335 this.children = [funcBody]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
336 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
337 this.funcBody = funcBody; |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
338 } |
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
339 } |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
340 |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
341 class StaticDestructorDeclaration : Declaration |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
342 { |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
343 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
344 this(FunctionBody funcBody) |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
345 { |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
346 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
347 mixin(set_kind); |
292 | 348 this.children = [funcBody]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
349 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
350 this.funcBody = funcBody; |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
351 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
352 } |
120 | 353 |
192 | 354 class FunctionDeclaration : Declaration |
355 { | |
290
7933a0c17c9f
- Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents:
283
diff
changeset
|
356 Type returnType; |
262 | 357 Token* funcName; |
258 | 358 TemplateParameters tparams; |
290
7933a0c17c9f
- Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents:
283
diff
changeset
|
359 Parameters params; |
192 | 360 FunctionBody funcBody; |
290
7933a0c17c9f
- Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents:
283
diff
changeset
|
361 this(Type returnType, Token* funcName, TemplateParameters tparams, Parameters params, FunctionBody funcBody) |
192 | 362 { |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
363 assert(returnType !is null); |
194 | 364 super(funcBody.funcBody !is null); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
365 mixin(set_kind); |
299
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
366 this.children = [returnType]; |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
367 if (tparams) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
368 this.children ~= tparams; |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
369 this.children ~= [cast(Node)params, funcBody]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
370 |
290
7933a0c17c9f
- Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents:
283
diff
changeset
|
371 this.returnType = returnType; |
192 | 372 this.funcName = funcName; |
290
7933a0c17c9f
- Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents:
283
diff
changeset
|
373 this.tparams = tparams; |
7933a0c17c9f
- Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents:
283
diff
changeset
|
374 this.params = params; |
192 | 375 this.funcBody = funcBody; |
376 } | |
377 } | |
378 | |
194 | 379 class VariableDeclaration : Declaration |
380 { | |
283 | 381 Type type; |
262 | 382 Token*[] idents; |
194 | 383 Expression[] values; |
283 | 384 this(Type type, Token*[] idents, Expression[] values) |
194 | 385 { |
386 super(false); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
387 mixin(set_kind); |
299
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
388 if (type) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
389 this.children = [type]; |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
390 foreach(value; values) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
391 if (value) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
392 this.children ~= value; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
393 |
283 | 394 this.type = type; |
194 | 395 this.idents = idents; |
396 this.values = values; | |
397 } | |
398 } | |
399 | |
120 | 400 class InvariantDeclaration : Declaration |
401 { | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
402 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
403 this(FunctionBody funcBody) |
120 | 404 { |
405 super(true); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
406 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
407 assert(funcBody !is null); |
292 | 408 this.children = [funcBody]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
409 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
410 this.funcBody = funcBody; |
120 | 411 } |
412 } | |
121 | 413 |
414 class UnittestDeclaration : Declaration | |
415 { | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
416 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
417 this(FunctionBody funcBody) |
121 | 418 { |
419 super(true); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
420 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
421 assert(funcBody !is null); |
292 | 422 this.children = [funcBody]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
423 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
424 this.funcBody = funcBody; |
121 | 425 } |
426 } | |
122 | 427 |
428 class DebugDeclaration : Declaration | |
429 { | |
264 | 430 Token* spec; |
431 Token* cond; | |
305 | 432 Declaration decls, elseDecls; |
122 | 433 |
305 | 434 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
122 | 435 { |
305 | 436 super(true /+decls.length != 0+/); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
437 mixin(set_kind); |
313
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
438 if (decls) |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
439 this.children = [decls]; |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
440 if (elseDecls) |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
441 this.children ~= elseDecls; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
442 |
264 | 443 this.spec = spec; |
444 this.cond = cond; | |
122 | 445 this.decls = decls; |
446 this.elseDecls = elseDecls; | |
447 } | |
448 } | |
123 | 449 |
450 class VersionDeclaration : Declaration | |
451 { | |
264 | 452 Token* spec; |
453 Token* cond; | |
305 | 454 Declaration decls, elseDecls; |
123 | 455 |
305 | 456 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
123 | 457 { |
305 | 458 super(true /+decls.length != 0+/); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
459 mixin(set_kind); |
313
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
460 if (decls) |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
461 this.children = [decls]; |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
462 if (elseDecls) |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
463 this.children ~= elseDecls; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
464 |
264 | 465 this.spec = spec; |
466 this.cond = cond; | |
123 | 467 this.decls = decls; |
468 this.elseDecls = elseDecls; | |
469 } | |
470 } | |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
471 |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
472 class StaticIfDeclaration : Declaration |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
473 { |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
474 Expression condition; |
305 | 475 Declaration ifDecls, elseDecls; |
476 this(Expression condition, Declaration ifDecls, Declaration elseDecls) | |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
477 { |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
478 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
479 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
480 assert(condition !is null); |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
481 this.children = [condition]; |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
482 if (ifDecls) |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
483 this.children ~= ifDecls; |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
484 if (elseDecls) |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
485 this.children ~= elseDecls; |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
486 |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
487 this.condition = condition; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
488 this.ifDecls = ifDecls; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
489 this.elseDecls = elseDecls; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
490 } |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
491 } |
127
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
492 |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
493 class StaticAssertDeclaration : Declaration |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
494 { |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
495 Expression condition, message; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
496 this(Expression condition, Expression message) |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
497 { |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
498 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
499 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
500 assert(condition !is null); |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
501 this.children = [condition]; |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
502 if (message) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
503 this.children ~= message; |
127
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
504 this.condition = condition; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
505 this.message = message; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
506 } |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
507 } |
140 | 508 |
509 class TemplateDeclaration : Declaration | |
510 { | |
292 | 511 Token* name; |
512 TemplateParameters tparams; | |
305 | 513 Declarations decls; |
514 this(Token* name, TemplateParameters tparams, Declarations decls) | |
140 | 515 { |
516 super(true); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
517 mixin(set_kind); |
377 | 518 if (tparams) |
519 this.children = [tparams]; | |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
520 assert(decls !is null); |
377 | 521 this.children ~= decls; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
522 |
292 | 523 this.name = name; |
524 this.tparams = tparams; | |
140 | 525 this.decls = decls; |
526 } | |
527 } | |
141 | 528 |
529 class NewDeclaration : Declaration | |
530 { | |
531 Parameters parameters; | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
532 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
533 this(Parameters parameters, FunctionBody funcBody) |
141 | 534 { |
535 super(true); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
536 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
537 assert(parameters !is null && funcBody !is null); |
292 | 538 this.children = [cast(Node)parameters, funcBody]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
539 |
141 | 540 this.parameters = parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
541 this.funcBody = funcBody; |
141 | 542 } |
543 } | |
544 | |
545 class DeleteDeclaration : Declaration | |
546 { | |
547 Parameters parameters; | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
548 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
549 this(Parameters parameters, FunctionBody funcBody) |
141 | 550 { |
551 super(true); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
552 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
553 assert(parameters !is null && funcBody !is null); |
292 | 554 this.children = [cast(Node)parameters, funcBody]; |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
555 |
141 | 556 this.parameters = parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
557 this.funcBody = funcBody; |
141 | 558 } |
559 } | |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
560 |
149 | 561 class AttributeDeclaration : Declaration |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
562 { |
149 | 563 TOK attribute; |
305 | 564 Declaration decls; |
565 this(TOK attribute, Declaration decls) | |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
566 { |
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
567 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
568 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
569 assert(decls !is null); |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
570 this.children ~= decls; |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
571 |
149 | 572 this.attribute = attribute; |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
573 this.decls = decls; |
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
574 } |
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
575 } |
147 | 576 |
149 | 577 class ExternDeclaration : AttributeDeclaration |
578 { | |
159 | 579 Linkage linkage; |
305 | 580 this(Linkage linkage, Declaration decls) |
149 | 581 { |
582 super(TOK.Extern, decls); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
583 mixin(set_kind); |
359
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
327
diff
changeset
|
584 if (linkage) |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
327
diff
changeset
|
585 this.children ~= linkage; |
149 | 586 this.linkage = linkage; |
587 } | |
588 } | |
589 | |
590 class AlignDeclaration : AttributeDeclaration | |
591 { | |
592 int size; | |
305 | 593 this(int size, Declaration decls) |
149 | 594 { |
595 super(TOK.Align, decls); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
596 mixin(set_kind); |
149 | 597 this.size = size; |
598 } | |
599 } | |
600 | |
601 class PragmaDeclaration : AttributeDeclaration | |
147 | 602 { |
245 | 603 Token* ident; |
147 | 604 Expression[] args; |
305 | 605 this(Token* ident, Expression[] args, Declaration decls) |
147 | 606 { |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
607 if (args.length) |
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
608 this.children ~= args; // Add args before calling super(). |
149 | 609 super(TOK.Pragma, decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
610 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
611 |
147 | 612 this.ident = ident; |
613 this.args = args; | |
614 } | |
615 } | |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
616 |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
617 class MixinDeclaration : Declaration |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
618 { |
292 | 619 Expression[] templateIdents; |
252
788398655d24
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
249
diff
changeset
|
620 Token* mixinIdent; |
292 | 621 Expression argument; // mixin ( AssignExpression ) |
622 this(Expression[] templateIdents, Token* mixinIdent) | |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
623 { |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
624 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
625 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
626 assert(templateIdents.length != 0); |
292 | 627 this.children = templateIdents; |
628 this.templateIdents = templateIdents; | |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
629 this.mixinIdent = mixinIdent; |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
630 } |
292 | 631 this(Expression argument) |
151
2e959f67000b
- Added code for parsing mixin expression declarations.
aziz
parents:
150
diff
changeset
|
632 { |
2e959f67000b
- Added code for parsing mixin expression declarations.
aziz
parents:
150
diff
changeset
|
633 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
634 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
635 assert(argument !is null); |
292 | 636 this.children = [argument]; |
637 this.argument = argument; | |
151
2e959f67000b
- Added code for parsing mixin expression declarations.
aziz
parents:
150
diff
changeset
|
638 } |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
639 } |