comparison trunk/src/dil/Declarations.d @ 489:a7291d3ee9d7

Refactored classes that inherit from Node. Added methods addChild(), addOptChild(), addChildren(), addOptChildren() to class Node. Refactored subclasses to use the new methods instead of appending directly to the array Node.children. Moved enums StorageClass and Protection to new module dil.Enums. Added members stc, prot, isStatic() and isPulic() to Declaration.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Mon, 03 Dec 2007 22:44:27 +0100
parents bd176bc73e43
children 47be6bfe39cd
comparison
equal deleted inserted replaced
488:cfb3805768b6 489:a7291d3ee9d7
6 import dil.SyntaxTree; 6 import dil.SyntaxTree;
7 import dil.Expressions; 7 import dil.Expressions;
8 import dil.Types; 8 import dil.Types;
9 import dil.Statements; 9 import dil.Statements;
10 import dil.Token; 10 import dil.Token;
11 import dil.Enums;
11 import dil.Scope; 12 import dil.Scope;
12 13
13 abstract class Declaration : Node 14 abstract class Declaration : Node
14 { 15 {
15 bool hasBody; 16 bool hasBody;
16 this(bool hasBody) 17 this()
17 { 18 {
18 super(NodeCategory.Declaration); 19 super(NodeCategory.Declaration);
19 this.hasBody = hasBody; 20 }
20 } 21
22 // Members relevant to semantic phase.
23 StorageClass stc;
24 Protection prot;
21 25
22 void semantic(Scope sc) 26 void semantic(Scope sc)
23 { 27 {
24 // foreach (node; this.children) 28 // foreach (node; this.children)
25 // if (node.category == NodeCategory.Declaration) 29 // if (node.category == NodeCategory.Declaration)
26 // (cast(Declaration)cast(void*)node).semantic(sc); 30 // (cast(Declaration)cast(void*)node).semantic(sc);
27 } 31 }
32
33 final bool isStatic()
34 {
35 return !!(stc & StorageClass.Static);
36 }
37
38 final bool isPublic()
39 {
40 return !!(prot & Protection.Public);
41 }
28 } 42 }
29 43
30 class Declarations : Declaration 44 class Declarations : Declaration
31 { 45 {
32 this() 46 this()
33 { 47 {
34 super(true); 48 hasBody = true;
35 mixin(set_kind); 49 mixin(set_kind);
36 } 50 }
37 51
38 void opCatAssign(Declaration d) 52 void opCatAssign(Declaration d)
39 { 53 {
40 this.children ~= d; 54 addChild(d);
41 }
42
43 void opCatAssign(Declaration[] decls)
44 {
45 this.children ~= decls;
46 } 55 }
47 56
48 void opCatAssign(Declarations ds) 57 void opCatAssign(Declarations ds)
49 { 58 {
50 this.children ~= ds.children; 59 addChildren(ds.children);
51 } 60 }
52 } 61 }
53 62
54 class EmptyDeclaration : Declaration 63 class EmptyDeclaration : Declaration
55 { 64 {
56 this() 65 this()
57 { 66 {
58 super(false);
59 mixin(set_kind); 67 mixin(set_kind);
60 } 68 }
61 } 69 }
62 70
63 class IllegalDeclaration : Declaration 71 class IllegalDeclaration : Declaration
64 { 72 {
65 Token* token; 73 Token* token;
66 this(Token* token) 74 this(Token* token)
67 { 75 {
68 super(false);
69 mixin(set_kind); 76 mixin(set_kind);
70 this.token = token; 77 this.token = token;
71 } 78 }
72 } 79 }
73 80
78 { 85 {
79 Token* moduleName; 86 Token* moduleName;
80 Token*[] packages; 87 Token*[] packages;
81 this(ModuleFQN moduleFQN) 88 this(ModuleFQN moduleFQN)
82 { 89 {
83 super(false);
84 mixin(set_kind); 90 mixin(set_kind);
85 assert(moduleFQN.length != 0); 91 assert(moduleFQN.length != 0);
86 this.moduleName = moduleFQN[$-1]; 92 this.moduleName = moduleFQN[$-1];
87 this.packages = moduleFQN[0..$-1]; 93 this.packages = moduleFQN[0..$-1];
88 } 94 }
119 { 125 {
120 ModuleFQN[] moduleFQNs; 126 ModuleFQN[] moduleFQNs;
121 Token*[] moduleAliases; 127 Token*[] moduleAliases;
122 Token*[] bindNames; 128 Token*[] bindNames;
123 Token*[] bindAliases; 129 Token*[] bindAliases;
124 bool isStatic_;
125 130
126 this(ModuleFQN[] moduleFQNs, Token*[] moduleAliases, Token*[] bindNames, Token*[] bindAliases, bool isStatic) 131 this(ModuleFQN[] moduleFQNs, Token*[] moduleAliases, Token*[] bindNames, Token*[] bindAliases, bool isStatic)
127 { 132 {
128 super(false);
129 mixin(set_kind); 133 mixin(set_kind);
130 this.moduleFQNs = moduleFQNs; 134 this.moduleFQNs = moduleFQNs;
131 this.moduleAliases = moduleAliases; 135 this.moduleAliases = moduleAliases;
132 this.bindNames = bindNames; 136 this.bindNames = bindNames;
133 this.bindAliases = bindAliases; 137 this.bindAliases = bindAliases;
134 this.isStatic_ = isStatic; 138 if (isStatic)
139 this.stc |= StorageClass.Static;
135 } 140 }
136 141
137 char[][] getModuleFQNs(char separator) 142 char[][] getModuleFQNs(char separator)
138 { 143 {
139 char[][] FQNs; 144 char[][] FQNs;
145 FQN ~= ident.identifier ~ separator; 150 FQN ~= ident.identifier ~ separator;
146 FQNs ~= FQN[0..$-1]; // Remove last separator 151 FQNs ~= FQN[0..$-1]; // Remove last separator
147 } 152 }
148 return FQNs; 153 return FQNs;
149 } 154 }
150
151 bool isStatic()
152 {
153 return isStatic_;
154 }
155
156 bool isPublic()
157 {
158 // TODO:
159 return false;
160 }
161 } 155 }
162 156
163 class AliasDeclaration : Declaration 157 class AliasDeclaration : Declaration
164 { 158 {
165 Declaration decl; 159 Declaration decl;
166 this(Declaration decl) 160 this(Declaration decl)
167 { 161 {
168 super(false); 162 mixin(set_kind);
169 mixin(set_kind); 163 addChild(decl);
170 this.children = [decl];
171 this.decl = decl; 164 this.decl = decl;
172 } 165 }
173 } 166 }
174 167
175 class TypedefDeclaration : Declaration 168 class TypedefDeclaration : Declaration
176 { 169 {
177 Declaration decl; 170 Declaration decl;
178 this(Declaration decl) 171 this(Declaration decl)
179 { 172 {
180 super(false); 173 mixin(set_kind);
181 mixin(set_kind); 174 addChild(decl);
182 this.children = [decl];
183 this.decl = decl; 175 this.decl = decl;
184 } 176 }
185 } 177 }
186 178
187 class EnumDeclaration : Declaration 179 class EnumDeclaration : Declaration
189 Token* name; 181 Token* name;
190 Type baseType; 182 Type baseType;
191 EnumMember[] members; 183 EnumMember[] members;
192 this(Token* name, Type baseType, EnumMember[] members, bool hasBody) 184 this(Token* name, Type baseType, EnumMember[] members, bool hasBody)
193 { 185 {
194 super(hasBody); 186 super.hasBody = hasBody;
195 mixin(set_kind); 187 mixin(set_kind);
196 if (baseType) 188 addOptChild(baseType);
197 this.children = [baseType]; 189 addOptChildren(members);
198 if (members.length)
199 this.children ~= members;
200 190
201 this.name = name; 191 this.name = name;
202 this.baseType = baseType; 192 this.baseType = baseType;
203 this.members = members; 193 this.members = members;
204 } 194 }
210 Expression value; 200 Expression value;
211 this(Token* name, Expression value) 201 this(Token* name, Expression value)
212 { 202 {
213 super(NodeCategory.Other); 203 super(NodeCategory.Other);
214 mixin(set_kind); 204 mixin(set_kind);
215 if (value) 205 addOptChild(value);
216 this.children = [value];
217 206
218 this.name = name; 207 this.name = name;
219 this.value = value; 208 this.value = value;
220 } 209 }
221 } 210 }
226 TemplateParameters tparams; 215 TemplateParameters tparams;
227 BaseClass[] bases; 216 BaseClass[] bases;
228 Declarations decls; 217 Declarations decls;
229 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls, bool hasBody) 218 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls, bool hasBody)
230 { 219 {
231 super(hasBody); 220 super.hasBody = hasBody;
232 mixin(set_kind); 221 mixin(set_kind);
233 if (tparams) 222 addOptChild(tparams);
234 this.children = [tparams]; 223 addOptChildren(bases);
235 if (bases.length) 224 addOptChild(decls);
236 this.children ~= bases;
237 if (decls)
238 this.children ~= decls;
239 225
240 this.name = name; 226 this.name = name;
241 this.tparams = tparams; 227 this.tparams = tparams;
242 this.bases = bases; 228 this.bases = bases;
243 this.decls = decls; 229 this.decls = decls;
250 TemplateParameters tparams; 236 TemplateParameters tparams;
251 BaseClass[] bases; 237 BaseClass[] bases;
252 Declarations decls; 238 Declarations decls;
253 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls, bool hasBody) 239 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls, bool hasBody)
254 { 240 {
255 super(hasBody); 241 super.hasBody = hasBody;
256 mixin(set_kind); 242 mixin(set_kind);
257 if (tparams) 243 addOptChild(tparams);
258 this.children = [tparams]; 244 addOptChildren(bases);
259 if (bases.length) 245 addOptChild(decls);
260 this.children ~= bases;
261 if (decls)
262 this.children ~= decls;
263 246
264 this.name = name; 247 this.name = name;
265 this.tparams = tparams; 248 this.tparams = tparams;
266 this.bases = bases; 249 this.bases = bases;
267 this.decls = decls; 250 this.decls = decls;
273 Token* name; 256 Token* name;
274 TemplateParameters tparams; 257 TemplateParameters tparams;
275 Declarations decls; 258 Declarations decls;
276 this(Token* name, TemplateParameters tparams, Declarations decls, bool hasBody) 259 this(Token* name, TemplateParameters tparams, Declarations decls, bool hasBody)
277 { 260 {
278 super(hasBody); 261 super.hasBody = hasBody;
279 mixin(set_kind); 262 mixin(set_kind);
280 if (tparams) 263 addOptChild(tparams);
281 this.children = [tparams]; 264 addOptChild(decls);
282 if (decls)
283 this.children ~= decls;
284 265
285 this.name = name; 266 this.name = name;
286 this.tparams = tparams; 267 this.tparams = tparams;
287 this.decls = decls; 268 this.decls = decls;
288 } 269 }
293 Token* name; 274 Token* name;
294 TemplateParameters tparams; 275 TemplateParameters tparams;
295 Declarations decls; 276 Declarations decls;
296 this(Token* name, TemplateParameters tparams, Declarations decls, bool hasBody) 277 this(Token* name, TemplateParameters tparams, Declarations decls, bool hasBody)
297 { 278 {
298 super(hasBody); 279 super.hasBody = hasBody;
299 mixin(set_kind); 280 mixin(set_kind);
300 if (tparams) 281 addOptChild(tparams);
301 this.children = [tparams]; 282 addOptChild(decls);
302 if (decls)
303 this.children ~= decls;
304 283
305 this.name = name; 284 this.name = name;
306 this.tparams = tparams; 285 this.tparams = tparams;
307 this.decls = decls; 286 this.decls = decls;
308 } 287 }
312 { 291 {
313 Parameters parameters; 292 Parameters parameters;
314 FunctionBody funcBody; 293 FunctionBody funcBody;
315 this(Parameters parameters, FunctionBody funcBody) 294 this(Parameters parameters, FunctionBody funcBody)
316 { 295 {
317 super(true); 296 super.hasBody = true;
318 mixin(set_kind); 297 mixin(set_kind);
319 assert(parameters !is null && funcBody !is null); 298 addChild(parameters);
320 this.children = [cast(Node)parameters, funcBody]; 299 addChild(funcBody);
321 300
322 this.parameters = parameters; 301 this.parameters = parameters;
323 this.funcBody = funcBody; 302 this.funcBody = funcBody;
324 } 303 }
325 } 304 }
327 class StaticConstructorDeclaration : Declaration 306 class StaticConstructorDeclaration : Declaration
328 { 307 {
329 FunctionBody funcBody; 308 FunctionBody funcBody;
330 this(FunctionBody funcBody) 309 this(FunctionBody funcBody)
331 { 310 {
332 super(true); 311 super.hasBody = true;
333 mixin(set_kind); 312 mixin(set_kind);
334 assert(funcBody !is null); 313 addChild(funcBody);
335 this.children = [funcBody];
336 314
337 this.funcBody = funcBody; 315 this.funcBody = funcBody;
338 } 316 }
339 } 317 }
340 318
341 class DestructorDeclaration : Declaration 319 class DestructorDeclaration : Declaration
342 { 320 {
343 FunctionBody funcBody; 321 FunctionBody funcBody;
344 this(FunctionBody funcBody) 322 this(FunctionBody funcBody)
345 { 323 {
346 super(true); 324 super.hasBody = true;
347 mixin(set_kind); 325 mixin(set_kind);
348 this.children = [funcBody]; 326 addChild(funcBody);
349 327
350 this.funcBody = funcBody; 328 this.funcBody = funcBody;
351 } 329 }
352 } 330 }
353 331
354 class StaticDestructorDeclaration : Declaration 332 class StaticDestructorDeclaration : Declaration
355 { 333 {
356 FunctionBody funcBody; 334 FunctionBody funcBody;
357 this(FunctionBody funcBody) 335 this(FunctionBody funcBody)
358 { 336 {
359 super(true); 337 super.hasBody = true;
360 mixin(set_kind); 338 mixin(set_kind);
361 this.children = [funcBody]; 339 addChild(funcBody);
362 340
363 this.funcBody = funcBody; 341 this.funcBody = funcBody;
364 } 342 }
365 } 343 }
366 344
371 TemplateParameters tparams; 349 TemplateParameters tparams;
372 Parameters params; 350 Parameters params;
373 FunctionBody funcBody; 351 FunctionBody funcBody;
374 this(Type returnType, Token* funcName, TemplateParameters tparams, Parameters params, FunctionBody funcBody) 352 this(Type returnType, Token* funcName, TemplateParameters tparams, Parameters params, FunctionBody funcBody)
375 { 353 {
376 assert(returnType !is null); 354 super.hasBody = funcBody.funcBody !is null;
377 super(funcBody.funcBody !is null); 355 mixin(set_kind);
378 mixin(set_kind); 356 addChild(returnType);
379 this.children = [returnType]; 357 addOptChild(tparams);
380 if (tparams) 358 addChild(params);
381 this.children ~= tparams; 359 addChild(funcBody);
382 this.children ~= [cast(Node)params, funcBody];
383 360
384 this.returnType = returnType; 361 this.returnType = returnType;
385 this.funcName = funcName; 362 this.funcName = funcName;
386 this.tparams = tparams; 363 this.tparams = tparams;
387 this.params = params; 364 this.params = params;
394 Type type; 371 Type type;
395 Token*[] idents; 372 Token*[] idents;
396 Expression[] values; 373 Expression[] values;
397 this(Type type, Token*[] idents, Expression[] values) 374 this(Type type, Token*[] idents, Expression[] values)
398 { 375 {
399 super(false); 376 mixin(set_kind);
400 mixin(set_kind); 377 addOptChild(type);
401 if (type)
402 this.children = [type];
403 foreach(value; values) 378 foreach(value; values)
404 if (value) 379 addOptChild(value);
405 this.children ~= value;
406 380
407 this.type = type; 381 this.type = type;
408 this.idents = idents; 382 this.idents = idents;
409 this.values = values; 383 this.values = values;
410 } 384 }
413 class InvariantDeclaration : Declaration 387 class InvariantDeclaration : Declaration
414 { 388 {
415 FunctionBody funcBody; 389 FunctionBody funcBody;
416 this(FunctionBody funcBody) 390 this(FunctionBody funcBody)
417 { 391 {
418 super(true); 392 super.hasBody = true;
419 mixin(set_kind); 393 mixin(set_kind);
420 assert(funcBody !is null); 394 addChild(funcBody);
421 this.children = [funcBody];
422 395
423 this.funcBody = funcBody; 396 this.funcBody = funcBody;
424 } 397 }
425 } 398 }
426 399
427 class UnittestDeclaration : Declaration 400 class UnittestDeclaration : Declaration
428 { 401 {
429 FunctionBody funcBody; 402 FunctionBody funcBody;
430 this(FunctionBody funcBody) 403 this(FunctionBody funcBody)
431 { 404 {
432 super(true); 405 super.hasBody = true;
433 mixin(set_kind); 406 mixin(set_kind);
434 assert(funcBody !is null); 407 addChild(funcBody);
435 this.children = [funcBody];
436 408
437 this.funcBody = funcBody; 409 this.funcBody = funcBody;
438 } 410 }
439 } 411 }
440 412
444 Token* cond; 416 Token* cond;
445 Declaration decls, elseDecls; 417 Declaration decls, elseDecls;
446 418
447 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) 419 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls)
448 { 420 {
449 super(true /+decls.length != 0+/); 421 super.hasBody = decls !is null;
450 mixin(set_kind); 422 mixin(set_kind);
451 if (decls) 423 addOptChild(decls);
452 this.children = [decls]; 424 addOptChild(elseDecls);
453 if (elseDecls)
454 this.children ~= elseDecls;
455 425
456 this.spec = spec; 426 this.spec = spec;
457 this.cond = cond; 427 this.cond = cond;
458 this.decls = decls; 428 this.decls = decls;
459 this.elseDecls = elseDecls; 429 this.elseDecls = elseDecls;
466 Token* cond; 436 Token* cond;
467 Declaration decls, elseDecls; 437 Declaration decls, elseDecls;
468 438
469 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) 439 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls)
470 { 440 {
471 super(true /+decls.length != 0+/); 441 super.hasBody = decls !is null;
472 mixin(set_kind); 442 mixin(set_kind);
473 if (decls) 443 addOptChild(decls);
474 this.children = [decls]; 444 addOptChild(elseDecls);
475 if (elseDecls)
476 this.children ~= elseDecls;
477 445
478 this.spec = spec; 446 this.spec = spec;
479 this.cond = cond; 447 this.cond = cond;
480 this.decls = decls; 448 this.decls = decls;
481 this.elseDecls = elseDecls; 449 this.elseDecls = elseDecls;
486 { 454 {
487 Expression condition; 455 Expression condition;
488 Declaration ifDecls, elseDecls; 456 Declaration ifDecls, elseDecls;
489 this(Expression condition, Declaration ifDecls, Declaration elseDecls) 457 this(Expression condition, Declaration ifDecls, Declaration elseDecls)
490 { 458 {
491 super(true); 459 super.hasBody = true;
492 mixin(set_kind); 460 mixin(set_kind);
493 assert(condition !is null); 461 addChild(condition);
494 this.children = [condition]; 462 addOptChild(ifDecls);
495 if (ifDecls) 463 addOptChild(elseDecls);
496 this.children ~= ifDecls;
497 if (elseDecls)
498 this.children ~= elseDecls;
499 464
500 this.condition = condition; 465 this.condition = condition;
501 this.ifDecls = ifDecls; 466 this.ifDecls = ifDecls;
502 this.elseDecls = elseDecls; 467 this.elseDecls = elseDecls;
503 } 468 }
506 class StaticAssertDeclaration : Declaration 471 class StaticAssertDeclaration : Declaration
507 { 472 {
508 Expression condition, message; 473 Expression condition, message;
509 this(Expression condition, Expression message) 474 this(Expression condition, Expression message)
510 { 475 {
511 super(true); 476 super.hasBody = true;
512 mixin(set_kind); 477 mixin(set_kind);
513 assert(condition !is null); 478 addChild(condition);
514 this.children = [condition]; 479 addOptChild(message);
515 if (message) 480
516 this.children ~= message;
517 this.condition = condition; 481 this.condition = condition;
518 this.message = message; 482 this.message = message;
519 } 483 }
520 } 484 }
521 485
524 Token* name; 488 Token* name;
525 TemplateParameters tparams; 489 TemplateParameters tparams;
526 Declarations decls; 490 Declarations decls;
527 this(Token* name, TemplateParameters tparams, Declarations decls) 491 this(Token* name, TemplateParameters tparams, Declarations decls)
528 { 492 {
529 super(true); 493 super.hasBody = true;
530 mixin(set_kind); 494 mixin(set_kind);
531 if (tparams) 495 addOptChild(tparams);
532 this.children = [tparams]; 496 addChild(decls);
533 assert(decls !is null);
534 this.children ~= decls;
535 497
536 this.name = name; 498 this.name = name;
537 this.tparams = tparams; 499 this.tparams = tparams;
538 this.decls = decls; 500 this.decls = decls;
539 } 501 }
543 { 505 {
544 Parameters parameters; 506 Parameters parameters;
545 FunctionBody funcBody; 507 FunctionBody funcBody;
546 this(Parameters parameters, FunctionBody funcBody) 508 this(Parameters parameters, FunctionBody funcBody)
547 { 509 {
548 super(true); 510 super.hasBody = true;
549 mixin(set_kind); 511 mixin(set_kind);
550 assert(parameters !is null && funcBody !is null); 512 addChild(parameters);
551 this.children = [cast(Node)parameters, funcBody]; 513 addChild(funcBody);
552 514
553 this.parameters = parameters; 515 this.parameters = parameters;
554 this.funcBody = funcBody; 516 this.funcBody = funcBody;
555 } 517 }
556 } 518 }
559 { 521 {
560 Parameters parameters; 522 Parameters parameters;
561 FunctionBody funcBody; 523 FunctionBody funcBody;
562 this(Parameters parameters, FunctionBody funcBody) 524 this(Parameters parameters, FunctionBody funcBody)
563 { 525 {
564 super(true); 526 super.hasBody = true;
565 mixin(set_kind); 527 mixin(set_kind);
566 assert(parameters !is null && funcBody !is null); 528 addChild(parameters);
567 this.children = [cast(Node)parameters, funcBody]; 529 addChild(funcBody);
568 530
569 this.parameters = parameters; 531 this.parameters = parameters;
570 this.funcBody = funcBody; 532 this.funcBody = funcBody;
571 } 533 }
572 } 534 }
575 { 537 {
576 TOK attribute; 538 TOK attribute;
577 Declaration decls; 539 Declaration decls;
578 this(TOK attribute, Declaration decls) 540 this(TOK attribute, Declaration decls)
579 { 541 {
580 super(true); 542 super.hasBody = true;
581 mixin(set_kind); 543 mixin(set_kind);
582 assert(decls !is null); 544 addChild(decls);
583 this.children ~= decls;
584 545
585 this.attribute = attribute; 546 this.attribute = attribute;
586 this.decls = decls; 547 this.decls = decls;
587 } 548 }
588 } 549 }
592 Linkage linkage; 553 Linkage linkage;
593 this(Linkage linkage, Declaration decls) 554 this(Linkage linkage, Declaration decls)
594 { 555 {
595 super(TOK.Extern, decls); 556 super(TOK.Extern, decls);
596 mixin(set_kind); 557 mixin(set_kind);
597 if (linkage) 558 addOptChild(linkage);
598 this.children ~= linkage; 559
599 this.linkage = linkage; 560 this.linkage = linkage;
600 } 561 }
601 } 562 }
602 563
603 class AlignDeclaration : AttributeDeclaration 564 class AlignDeclaration : AttributeDeclaration
615 { 576 {
616 Token* ident; 577 Token* ident;
617 Expression[] args; 578 Expression[] args;
618 this(Token* ident, Expression[] args, Declaration decls) 579 this(Token* ident, Expression[] args, Declaration decls)
619 { 580 {
620 if (args.length) 581 addOptChildren(args); // Add args before calling super().
621 this.children ~= args; // Add args before calling super().
622 super(TOK.Pragma, decls); 582 super(TOK.Pragma, decls);
623 mixin(set_kind); 583 mixin(set_kind);
624 584
625 this.ident = ident; 585 this.ident = ident;
626 this.args = args; 586 this.args = args;
630 class MixinDeclaration : Declaration 590 class MixinDeclaration : Declaration
631 { 591 {
632 Expression[] templateIdents; 592 Expression[] templateIdents;
633 Token* mixinIdent; 593 Token* mixinIdent;
634 Expression argument; // mixin ( AssignExpression ) 594 Expression argument; // mixin ( AssignExpression )
595
635 this(Expression[] templateIdents, Token* mixinIdent) 596 this(Expression[] templateIdents, Token* mixinIdent)
636 { 597 {
637 super(false); 598 mixin(set_kind);
638 mixin(set_kind); 599 addChildren(templateIdents);
639 assert(templateIdents.length != 0); 600
640 this.children = templateIdents;
641 this.templateIdents = templateIdents; 601 this.templateIdents = templateIdents;
642 this.mixinIdent = mixinIdent; 602 this.mixinIdent = mixinIdent;
643 } 603 }
604
644 this(Expression argument) 605 this(Expression argument)
645 { 606 {
646 super(false); 607 mixin(set_kind);
647 mixin(set_kind); 608 addChild(argument);
648 assert(argument !is null); 609
649 this.children = [argument];
650 this.argument = argument; 610 this.argument = argument;
651 } 611 }
652 } 612 }