Mercurial > projects > dil
comparison trunk/src/dil/ast/Declarations.d @ 683:1ae72234db26
Implemented some methods in SemanticPass1.
Renamed Symbol.ident to name.
Added a constructor to Symbol.
Adapted constructors of classes that inherit from Symbol.
Added Alias and OverloadSet Symbol classes.
Renamed idents and values to names and inits in VariablesDeclaration.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Mon, 21 Jan 2008 17:10:12 +0100 |
parents | 7541c64fc423 |
children | c67d2c3c0b3d |
comparison
equal
deleted
inserted
replaced
682:7541c64fc423 | 683:1ae72234db26 |
---|---|
187 this.name = name; | 187 this.name = name; |
188 this.value = value; | 188 this.value = value; |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 abstract class AggregateDeclaration : Declaration | 192 class TemplateDeclaration : Declaration |
193 { | 193 { |
194 Identifier* name; | 194 Identifier* name; |
195 TemplateParameters tparams; | 195 TemplateParameters tparams; |
196 CompoundDeclaration decls; | 196 CompoundDeclaration decls; |
197 this(Identifier* name, TemplateParameters tparams, CompoundDeclaration decls) | 197 this(Identifier* name, TemplateParameters tparams, CompoundDeclaration decls) |
198 { | 198 { |
199 super.hasBody = true; | |
200 mixin(set_kind); | |
201 addOptChild(tparams); | |
202 addChild(decls); | |
203 | |
204 this.name = name; | |
205 this.tparams = tparams; | |
206 this.decls = decls; | |
207 } | |
208 | |
209 Template symbol; /// The template symbol for this declaration. | |
210 } | |
211 | |
212 abstract class AggregateDeclaration : Declaration | |
213 { | |
214 Identifier* name; | |
215 TemplateParameters tparams; | |
216 CompoundDeclaration decls; | |
217 this(Identifier* name, TemplateParameters tparams, CompoundDeclaration decls) | |
218 { | |
199 super.hasBody = decls !is null; | 219 super.hasBody = decls !is null; |
200 this.name = name; | 220 this.name = name; |
201 this.tparams = tparams; | 221 this.tparams = tparams; |
202 this.decls = decls; | 222 this.decls = decls; |
203 } | 223 } |
359 | 379 |
360 /// VariablesDeclaration := Type? Identifier ("=" Init)? ("," Identifier ("=" Init)?)* ";" | 380 /// VariablesDeclaration := Type? Identifier ("=" Init)? ("," Identifier ("=" Init)?)* ";" |
361 class VariablesDeclaration : Declaration | 381 class VariablesDeclaration : Declaration |
362 { | 382 { |
363 TypeNode typeNode; | 383 TypeNode typeNode; |
364 Identifier*[] idents; | 384 Identifier*[] names; |
365 Expression[] values; | 385 Expression[] inits; |
386 this(TypeNode typeNode, Identifier*[] names, Expression[] values) | |
387 { | |
388 // No empty arrays allowed. Both arrays must be of same size. | |
389 assert(names.length != 0 && names.length == inits.length); | |
390 // If no type (in case of AutoDeclaration), first value mustn't be null. | |
391 assert(typeNode ? 1 : inits[0] !is null); | |
392 mixin(set_kind); | |
393 addOptChild(typeNode); | |
394 foreach(init; inits) | |
395 addOptChild(init); | |
396 | |
397 this.typeNode = typeNode; | |
398 this.names = names; | |
399 this.inits = inits; | |
400 } | |
401 | |
366 LinkageType linkageType; | 402 LinkageType linkageType; |
367 this(TypeNode typeNode, Identifier*[] idents, Expression[] values) | |
368 { | |
369 // No empty arrays allowed. Both arrays must be of same size. | |
370 assert(idents.length != 0 && idents.length == values.length); | |
371 // If no type (in case of AutoDeclaration), first value mustn't be null. | |
372 assert(typeNode ? 1 : values[0] !is null); | |
373 mixin(set_kind); | |
374 addOptChild(typeNode); | |
375 foreach(value; values) | |
376 addOptChild(value); | |
377 | |
378 this.typeNode = typeNode; | |
379 this.idents = idents; | |
380 this.values = values; | |
381 } | |
382 | 403 |
383 void setLinkageType(LinkageType linkageType) | 404 void setLinkageType(LinkageType linkageType) |
384 { | 405 { |
385 this.linkageType = linkageType; | 406 this.linkageType = linkageType; |
386 } | 407 } |
482 this.condition = condition; | 503 this.condition = condition; |
483 this.message = message; | 504 this.message = message; |
484 } | 505 } |
485 } | 506 } |
486 | 507 |
487 class TemplateDeclaration : Declaration | |
488 { | |
489 Identifier* name; | |
490 TemplateParameters tparams; | |
491 CompoundDeclaration decls; | |
492 this(Identifier* name, TemplateParameters tparams, CompoundDeclaration decls) | |
493 { | |
494 super.hasBody = true; | |
495 mixin(set_kind); | |
496 addOptChild(tparams); | |
497 addChild(decls); | |
498 | |
499 this.name = name; | |
500 this.tparams = tparams; | |
501 this.decls = decls; | |
502 } | |
503 } | |
504 | |
505 class NewDeclaration : Declaration | 508 class NewDeclaration : Declaration |
506 { | 509 { |
507 Parameters params; | 510 Parameters params; |
508 FuncBodyStatement funcBody; | 511 FuncBodyStatement funcBody; |
509 this(Parameters params, FuncBodyStatement funcBody) | 512 this(Parameters params, FuncBodyStatement funcBody) |