Mercurial > projects > dil
annotate trunk/src/dil/Declarations.d @ 367:dda55fae37de
- ImportGraph.execute() can parse all modules depending on the imports of the root module.
- Added function findModule().
- Renamed option includes to import_paths.
- Fix in ctor of ModuleDeclaration: check for pname.length before removing last separator.
- Fixed scanning binary numbers.
- Added member modules and method getFQN() to class Module.
- Fix in parseIfStatement(): AttributeStatement mustn't have a null parameter.
- Parsing import_paths in GlobalSettings.load().
author | aziz |
---|---|
date | Fri, 31 Aug 2007 23:07:05 +0000 |
parents | dcbd3bf9bf74 |
children | ae4afb66768f |
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 | |
77 string getName() | |
78 { | |
79 if (moduleName) | |
80 return moduleName.identifier; | |
81 return null; | |
82 } | |
83 | |
84 string getPackageName(char separator) | |
85 { | |
86 char[] pname; | |
87 foreach (pckg; packages) | |
88 if (pckg) | |
89 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
|
90 if (pname.length) |
dda55fae37de
- ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents:
366
diff
changeset
|
91 pname = pname[0..$-1]; // Remove last separator |
365 | 92 return pname; |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
93 } |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
94 } |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
95 |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
96 class ImportDeclaration : Declaration |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
97 { |
364 | 98 ModuleFQN[] moduleFQNs; |
263 | 99 Token*[] moduleAliases; |
100 Token*[] bindNames; | |
101 Token*[] bindAliases; | |
366 | 102 bool isStatic; |
103 this(ModuleFQN[] moduleFQNs, Token*[] moduleAliases, Token*[] bindNames, Token*[] bindAliases, bool isStatic) | |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
104 { |
116 | 105 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
106 mixin(set_kind); |
364 | 107 this.moduleFQNs = moduleFQNs; |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
108 this.moduleAliases = moduleAliases; |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
109 this.bindNames = bindNames; |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
110 this.bindAliases = bindAliases; |
366 | 111 this.isStatic = isStatic; |
112 } | |
113 | |
114 string[] getModuleFQNs(char separator) | |
115 { | |
116 string[] FQNs; | |
117 foreach (moduleFQN; moduleFQNs) | |
118 { | |
119 char[] FQN; | |
120 foreach (ident; moduleFQN) | |
121 if (ident) | |
122 FQN ~= ident.identifier ~ separator; | |
123 FQNs ~= FQN[0..$-1]; // Remove last separator | |
124 } | |
125 return FQNs; | |
102 | 126 } |
127 } | |
128 | |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
129 class AliasDeclaration : Declaration |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
130 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
131 Declaration decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
132 this(Declaration decl) |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
133 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
134 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
135 mixin(set_kind); |
292 | 136 this.children = [decl]; |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
137 this.decl = decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
138 } |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
139 } |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
140 |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
141 class TypedefDeclaration : Declaration |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
142 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
143 Declaration decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
144 this(Declaration decl) |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
145 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
146 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
147 mixin(set_kind); |
292 | 148 this.children = [decl]; |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
149 this.decl = decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
150 } |
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 |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
153 class EnumDeclaration : Declaration |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
154 { |
264 | 155 Token* name; |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
156 Type baseType; |
264 | 157 Token*[] members; |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
158 Expression[] values; |
264 | 159 this(Token* name, Type baseType, Token*[] members, Expression[] values, bool hasBody) |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
160 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
161 super(hasBody); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
162 mixin(set_kind); |
300
6cf3a5069109
- Fix: adding only non-null members to this.children in EnumDeclaration ctor.
aziz
parents:
299
diff
changeset
|
163 if (baseType) |
6cf3a5069109
- Fix: adding only non-null members to this.children in EnumDeclaration ctor.
aziz
parents:
299
diff
changeset
|
164 this.children = [baseType]; |
6cf3a5069109
- Fix: adding only non-null members to this.children in EnumDeclaration ctor.
aziz
parents:
299
diff
changeset
|
165 foreach(value; values) |
6cf3a5069109
- Fix: adding only non-null members to this.children in EnumDeclaration ctor.
aziz
parents:
299
diff
changeset
|
166 if (value) |
6cf3a5069109
- Fix: adding only non-null members to this.children in EnumDeclaration ctor.
aziz
parents:
299
diff
changeset
|
167 this.children ~= value; |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
168 this.name = name; |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
169 this.baseType = baseType; |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
170 this.members = members; |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
171 this.values = values; |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
172 } |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
173 } |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
174 |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
175 class ClassDeclaration : Declaration |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
176 { |
264 | 177 Token* name; |
258 | 178 TemplateParameters tparams; |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
179 BaseClass[] bases; |
305 | 180 Declarations decls; |
181 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls, bool hasBody) | |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
182 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
183 super(hasBody); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
184 mixin(set_kind); |
299
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
185 if (tparams) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
186 this.children = [tparams]; |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
187 if (bases.length) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
188 this.children ~= bases; |
305 | 189 this.children ~= decls; |
190 | |
112 | 191 this.name = name; |
195
37c2ffd649c4
- Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents:
194
diff
changeset
|
192 this.tparams = tparams; |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
193 this.bases = bases; |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
194 this.decls = decls; |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
195 } |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
196 } |
112 | 197 |
198 class InterfaceDeclaration : Declaration | |
199 { | |
264 | 200 Token* name; |
258 | 201 TemplateParameters tparams; |
112 | 202 BaseClass[] bases; |
305 | 203 Declarations decls; |
204 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls, bool hasBody) | |
112 | 205 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
206 super(hasBody); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
207 mixin(set_kind); |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
208 if (tparams) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
209 this.children = [tparams]; |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
210 if (bases.length) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
211 this.children ~= bases; |
305 | 212 this.children ~= decls; |
213 | |
112 | 214 this.name = name; |
195
37c2ffd649c4
- Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents:
194
diff
changeset
|
215 this.tparams = tparams; |
112 | 216 this.bases = bases; |
217 this.decls = decls; | |
218 } | |
219 } | |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
220 |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
221 class StructDeclaration : Declaration |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
222 { |
264 | 223 Token* name; |
258 | 224 TemplateParameters tparams; |
305 | 225 Declarations decls; |
226 this(Token* name, TemplateParameters tparams, Declarations decls, bool hasBody) | |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
227 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
228 super(hasBody); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
229 mixin(set_kind); |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
230 if (tparams) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
231 this.children = [tparams]; |
305 | 232 this.children ~= decls; |
233 | |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
234 this.name = name; |
195
37c2ffd649c4
- Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents:
194
diff
changeset
|
235 this.tparams = tparams; |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
236 this.decls = decls; |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
237 } |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
238 } |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
239 |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
240 class UnionDeclaration : Declaration |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
241 { |
264 | 242 Token* name; |
258 | 243 TemplateParameters tparams; |
305 | 244 Declarations decls; |
245 this(Token* name, TemplateParameters tparams, Declarations decls, bool hasBody) | |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
246 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
247 super(hasBody); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
248 mixin(set_kind); |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
249 if (tparams) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
250 this.children = [tparams]; |
305 | 251 this.children ~= decls; |
252 | |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
253 this.name = name; |
195
37c2ffd649c4
- Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents:
194
diff
changeset
|
254 this.tparams = tparams; |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
255 this.decls = decls; |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
256 } |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
257 } |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
258 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
259 class ConstructorDeclaration : Declaration |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
260 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
261 Parameters parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
262 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
263 this(Parameters parameters, FunctionBody funcBody) |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
264 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
265 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
266 mixin(set_kind); |
292 | 267 this.children = [cast(Node)parameters, funcBody]; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
268 this.parameters = parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
269 this.funcBody = funcBody; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
270 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
271 } |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
272 |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
273 class StaticConstructorDeclaration : Declaration |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
274 { |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
275 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
276 this(FunctionBody funcBody) |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
277 { |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
278 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
279 mixin(set_kind); |
292 | 280 this.children = [funcBody]; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
281 this.funcBody = funcBody; |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
282 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
283 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
284 |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
285 class DestructorDeclaration : Declaration |
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
286 { |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
287 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
288 this(FunctionBody funcBody) |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
289 { |
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
290 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
291 mixin(set_kind); |
292 | 292 this.children = [funcBody]; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
293 this.funcBody = funcBody; |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
294 } |
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
295 } |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
296 |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
297 class StaticDestructorDeclaration : Declaration |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
298 { |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
299 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
300 this(FunctionBody funcBody) |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
301 { |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
302 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
303 mixin(set_kind); |
292 | 304 this.children = [funcBody]; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
305 this.funcBody = funcBody; |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
306 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
307 } |
120 | 308 |
192 | 309 class FunctionDeclaration : Declaration |
310 { | |
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
|
311 Type returnType; |
262 | 312 Token* funcName; |
258 | 313 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
|
314 Parameters params; |
192 | 315 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
|
316 this(Type returnType, Token* funcName, TemplateParameters tparams, Parameters params, FunctionBody funcBody) |
192 | 317 { |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
318 assert(returnType !is null); |
194 | 319 super(funcBody.funcBody !is null); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
320 mixin(set_kind); |
299
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
321 this.children = [returnType]; |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
322 if (tparams) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
323 this.children ~= tparams; |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
324 this.children ~= [cast(Node)params, 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
|
325 this.returnType = returnType; |
192 | 326 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
|
327 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
|
328 this.params = params; |
192 | 329 this.funcBody = funcBody; |
330 } | |
331 } | |
332 | |
194 | 333 class VariableDeclaration : Declaration |
334 { | |
283 | 335 Type type; |
262 | 336 Token*[] idents; |
194 | 337 Expression[] values; |
283 | 338 this(Type type, Token*[] idents, Expression[] values) |
194 | 339 { |
340 super(false); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
341 mixin(set_kind); |
299
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
342 if (type) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
343 this.children = [type]; |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
344 foreach(value; values) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
345 if (value) |
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
346 this.children ~= value; |
283 | 347 this.type = type; |
194 | 348 this.idents = idents; |
349 this.values = values; | |
350 } | |
351 } | |
352 | |
120 | 353 class InvariantDeclaration : Declaration |
354 { | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
355 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
356 this(FunctionBody funcBody) |
120 | 357 { |
358 super(true); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
359 mixin(set_kind); |
292 | 360 this.children = [funcBody]; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
361 this.funcBody = funcBody; |
120 | 362 } |
363 } | |
121 | 364 |
365 class UnittestDeclaration : Declaration | |
366 { | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
367 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
368 this(FunctionBody funcBody) |
121 | 369 { |
370 super(true); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
371 mixin(set_kind); |
292 | 372 this.children = [funcBody]; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
373 this.funcBody = funcBody; |
121 | 374 } |
375 } | |
122 | 376 |
377 class DebugDeclaration : Declaration | |
378 { | |
264 | 379 Token* spec; |
380 Token* cond; | |
305 | 381 Declaration decls, elseDecls; |
122 | 382 |
305 | 383 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
122 | 384 { |
305 | 385 super(true /+decls.length != 0+/); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
386 mixin(set_kind); |
313
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
387 if (decls) |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
388 this.children = [decls]; |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
389 if (elseDecls) |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
390 this.children ~= elseDecls; |
264 | 391 this.spec = spec; |
392 this.cond = cond; | |
122 | 393 this.decls = decls; |
394 this.elseDecls = elseDecls; | |
395 } | |
396 } | |
123 | 397 |
398 class VersionDeclaration : Declaration | |
399 { | |
264 | 400 Token* spec; |
401 Token* cond; | |
305 | 402 Declaration decls, elseDecls; |
123 | 403 |
305 | 404 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
123 | 405 { |
305 | 406 super(true /+decls.length != 0+/); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
407 mixin(set_kind); |
313
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
408 if (decls) |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
409 this.children = [decls]; |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
410 if (elseDecls) |
1c1adededd8f
- Fix: assign new EmptyDeclaration to decls when parsing PragmaStatement.
aziz
parents:
305
diff
changeset
|
411 this.children ~= elseDecls; |
264 | 412 this.spec = spec; |
413 this.cond = cond; | |
123 | 414 this.decls = decls; |
415 this.elseDecls = elseDecls; | |
416 } | |
417 } | |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
418 |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
419 class StaticIfDeclaration : Declaration |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
420 { |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
421 Expression condition; |
305 | 422 Declaration ifDecls, elseDecls; |
423 this(Expression condition, Declaration ifDecls, Declaration elseDecls) | |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
424 { |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
425 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
426 mixin(set_kind); |
305 | 427 this.children = [cast(Node)condition, ifDecls, elseDecls]; |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
428 this.condition = condition; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
429 this.ifDecls = ifDecls; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
430 this.elseDecls = elseDecls; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
431 } |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
432 } |
127
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
433 |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
434 class StaticAssertDeclaration : Declaration |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
435 { |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
436 Expression condition, message; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
437 this(Expression condition, Expression message) |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
438 { |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
439 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
440 mixin(set_kind); |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
441 this.children = [condition]; |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
442 if (message) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
443 this.children ~= message; |
127
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
444 this.condition = condition; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
445 this.message = message; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
446 } |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
447 } |
140 | 448 |
449 class TemplateDeclaration : Declaration | |
450 { | |
292 | 451 Token* name; |
452 TemplateParameters tparams; | |
305 | 453 Declarations decls; |
454 this(Token* name, TemplateParameters tparams, Declarations decls) | |
140 | 455 { |
456 super(true); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
457 mixin(set_kind); |
305 | 458 this.children = [cast(Node)tparams, decls]; |
292 | 459 this.name = name; |
460 this.tparams = tparams; | |
140 | 461 this.decls = decls; |
462 } | |
463 } | |
141 | 464 |
465 class NewDeclaration : Declaration | |
466 { | |
467 Parameters parameters; | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
468 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
469 this(Parameters parameters, FunctionBody funcBody) |
141 | 470 { |
471 super(true); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
472 mixin(set_kind); |
292 | 473 this.children = [cast(Node)parameters, funcBody]; |
141 | 474 this.parameters = parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
475 this.funcBody = funcBody; |
141 | 476 } |
477 } | |
478 | |
479 class DeleteDeclaration : Declaration | |
480 { | |
481 Parameters parameters; | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
482 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
483 this(Parameters parameters, FunctionBody funcBody) |
141 | 484 { |
485 super(true); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
486 mixin(set_kind); |
292 | 487 this.children = [cast(Node)parameters, funcBody]; |
141 | 488 this.parameters = parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
489 this.funcBody = funcBody; |
141 | 490 } |
491 } | |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
492 |
149 | 493 class AttributeDeclaration : Declaration |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
494 { |
149 | 495 TOK attribute; |
305 | 496 Declaration decls; |
497 this(TOK attribute, Declaration decls) | |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
498 { |
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
499 super(true); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
500 mixin(set_kind); |
305 | 501 this.children = [decls]; |
149 | 502 this.attribute = attribute; |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
503 this.decls = decls; |
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
504 } |
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
505 } |
147 | 506 |
149 | 507 class ExternDeclaration : AttributeDeclaration |
508 { | |
159 | 509 Linkage linkage; |
305 | 510 this(Linkage linkage, Declaration decls) |
149 | 511 { |
512 super(TOK.Extern, decls); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
513 mixin(set_kind); |
359
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
327
diff
changeset
|
514 if (linkage) |
511c14950cac
- Added messages MissingLinkageType and UnrecognizedLinkageType.
aziz
parents:
327
diff
changeset
|
515 this.children ~= linkage; |
149 | 516 this.linkage = linkage; |
517 } | |
518 } | |
519 | |
520 class AlignDeclaration : AttributeDeclaration | |
521 { | |
522 int size; | |
305 | 523 this(int size, Declaration decls) |
149 | 524 { |
525 super(TOK.Align, decls); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
526 mixin(set_kind); |
149 | 527 this.size = size; |
528 } | |
529 } | |
530 | |
531 class PragmaDeclaration : AttributeDeclaration | |
147 | 532 { |
245 | 533 Token* ident; |
147 | 534 Expression[] args; |
305 | 535 this(Token* ident, Expression[] args, Declaration decls) |
147 | 536 { |
149 | 537 super(TOK.Pragma, decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
538 mixin(set_kind); |
301
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
539 if (args.length) |
caef255a2801
- Fix in some ctors: adding only non-null members to this.children.
aziz
parents:
300
diff
changeset
|
540 this.children ~= args; |
147 | 541 this.ident = ident; |
542 this.args = args; | |
543 } | |
544 } | |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
545 |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
546 class MixinDeclaration : Declaration |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
547 { |
292 | 548 Expression[] templateIdents; |
252
788398655d24
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
249
diff
changeset
|
549 Token* mixinIdent; |
292 | 550 Expression argument; // mixin ( AssignExpression ) |
551 this(Expression[] templateIdents, Token* mixinIdent) | |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
552 { |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
553 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
554 mixin(set_kind); |
292 | 555 this.children = templateIdents; |
556 this.templateIdents = templateIdents; | |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
557 this.mixinIdent = mixinIdent; |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
558 } |
292 | 559 this(Expression argument) |
151
2e959f67000b
- Added code for parsing mixin expression declarations.
aziz
parents:
150
diff
changeset
|
560 { |
2e959f67000b
- Added code for parsing mixin expression declarations.
aziz
parents:
150
diff
changeset
|
561 super(false); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
562 mixin(set_kind); |
292 | 563 this.children = [argument]; |
564 this.argument = argument; | |
151
2e959f67000b
- Added code for parsing mixin expression declarations.
aziz
parents:
150
diff
changeset
|
565 } |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
566 } |