Mercurial > projects > dil
comparison trunk/src/dil/Declarations.d @ 505:3bb94ba21490
Refactored a great amount of code.
Changed many declaration types from Token* to Identifier*.
Fix in parseStructInitializer(): append null to idents in else body.
Fixed class Parameter and parseParameterList().
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Wed, 12 Dec 2007 02:25:42 +0100 |
parents | 9076c4cea2a4 |
children | aa73f669c298 |
comparison
equal
deleted
inserted
replaced
504:9076c4cea2a4 | 505:3bb94ba21490 |
---|---|
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 class EnumDeclaration : Declaration | 210 class EnumDeclaration : Declaration |
211 { | 211 { |
212 Token* name; | 212 Identifier* name; |
213 Type baseType; | 213 Type baseType; |
214 EnumMember[] members; | 214 EnumMember[] members; |
215 this(Token* name, Type baseType, EnumMember[] members, bool hasBody) | 215 this(Identifier* name, Type baseType, EnumMember[] members, bool hasBody) |
216 { | 216 { |
217 super.hasBody = hasBody; | 217 super.hasBody = hasBody; |
218 mixin(set_kind); | 218 mixin(set_kind); |
219 addOptChild(baseType); | 219 addOptChild(baseType); |
220 addOptChildren(members); | 220 addOptChildren(members); |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 class EnumMember : Node | 228 class EnumMember : Node |
229 { | 229 { |
230 Token* name; | 230 Identifier* name; |
231 Expression value; | 231 Expression value; |
232 this(Token* name, Expression value) | 232 this(Identifier* name, Expression value) |
233 { | 233 { |
234 super(NodeCategory.Other); | 234 super(NodeCategory.Other); |
235 mixin(set_kind); | 235 mixin(set_kind); |
236 addOptChild(value); | 236 addOptChild(value); |
237 | 237 |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 class ClassDeclaration : Declaration | 243 class ClassDeclaration : Declaration |
244 { | 244 { |
245 Token* name; | 245 Identifier* name; |
246 TemplateParameters tparams; | 246 TemplateParameters tparams; |
247 BaseClass[] bases; | 247 BaseClass[] bases; |
248 Declarations decls; | 248 Declarations decls; |
249 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls) | 249 this(Identifier* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls) |
250 { | 250 { |
251 super.hasBody = decls !is null; | 251 super.hasBody = decls !is null; |
252 mixin(set_kind); | 252 mixin(set_kind); |
253 addOptChild(tparams); | 253 addOptChild(tparams); |
254 addOptChildren(bases); | 254 addOptChildren(bases); |
261 } | 261 } |
262 } | 262 } |
263 | 263 |
264 class InterfaceDeclaration : Declaration | 264 class InterfaceDeclaration : Declaration |
265 { | 265 { |
266 Token* name; | 266 Identifier* name; |
267 TemplateParameters tparams; | 267 TemplateParameters tparams; |
268 BaseClass[] bases; | 268 BaseClass[] bases; |
269 Declarations decls; | 269 Declarations decls; |
270 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls) | 270 this(Identifier* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls) |
271 { | 271 { |
272 super.hasBody = decls !is null; | 272 super.hasBody = decls !is null; |
273 mixin(set_kind); | 273 mixin(set_kind); |
274 addOptChild(tparams); | 274 addOptChild(tparams); |
275 addOptChildren(bases); | 275 addOptChildren(bases); |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 class StructDeclaration : Declaration | 285 class StructDeclaration : Declaration |
286 { | 286 { |
287 Token* name; | 287 Identifier* name; |
288 TemplateParameters tparams; | 288 TemplateParameters tparams; |
289 Declarations decls; | 289 Declarations decls; |
290 uint alignSize; | 290 uint alignSize; |
291 this(Token* name, TemplateParameters tparams, Declarations decls) | 291 this(Identifier* name, TemplateParameters tparams, Declarations decls) |
292 { | 292 { |
293 super.hasBody = decls !is null; | 293 super.hasBody = decls !is null; |
294 mixin(set_kind); | 294 mixin(set_kind); |
295 addOptChild(tparams); | 295 addOptChild(tparams); |
296 addOptChild(decls); | 296 addOptChild(decls); |
306 } | 306 } |
307 } | 307 } |
308 | 308 |
309 class UnionDeclaration : Declaration | 309 class UnionDeclaration : Declaration |
310 { | 310 { |
311 Token* name; | 311 Identifier* name; |
312 TemplateParameters tparams; | 312 TemplateParameters tparams; |
313 Declarations decls; | 313 Declarations decls; |
314 this(Token* name, TemplateParameters tparams, Declarations decls) | 314 this(Identifier* name, TemplateParameters tparams, Declarations decls) |
315 { | 315 { |
316 super.hasBody = decls !is null; | 316 super.hasBody = decls !is null; |
317 mixin(set_kind); | 317 mixin(set_kind); |
318 addOptChild(tparams); | 318 addOptChild(tparams); |
319 addOptChild(decls); | 319 addOptChild(decls); |
380 } | 380 } |
381 | 381 |
382 class FunctionDeclaration : Declaration | 382 class FunctionDeclaration : Declaration |
383 { | 383 { |
384 Type returnType; | 384 Type returnType; |
385 Token* funcName; | 385 Identifier* funcName; |
386 TemplateParameters tparams; | 386 TemplateParameters tparams; |
387 Parameters params; | 387 Parameters params; |
388 FunctionBody funcBody; | 388 FunctionBody funcBody; |
389 LinkageType linkageType; | 389 LinkageType linkageType; |
390 this(Type returnType, Token* funcName, TemplateParameters tparams, | 390 this(Type returnType, Identifier* funcName, TemplateParameters tparams, |
391 Parameters params, FunctionBody funcBody) | 391 Parameters params, FunctionBody funcBody) |
392 { | 392 { |
393 super.hasBody = funcBody.funcBody !is null; | 393 super.hasBody = funcBody.funcBody !is null; |
394 mixin(set_kind); | 394 mixin(set_kind); |
395 addChild(returnType); | 395 addChild(returnType); |
411 } | 411 } |
412 | 412 |
413 class VariableDeclaration : Declaration | 413 class VariableDeclaration : Declaration |
414 { | 414 { |
415 Type type; | 415 Type type; |
416 Token*[] idents; | 416 Identifier*[] idents; |
417 Expression[] values; | 417 Expression[] values; |
418 LinkageType linkageType; | 418 LinkageType linkageType; |
419 this(Type type, Token*[] idents, Expression[] values) | 419 this(Type type, Identifier*[] idents, Expression[] values) |
420 { | 420 { |
421 mixin(set_kind); | 421 mixin(set_kind); |
422 addOptChild(type); | 422 addOptChild(type); |
423 foreach(value; values) | 423 foreach(value; values) |
424 addOptChild(value); | 424 addOptChild(value); |
458 | 458 |
459 this.funcBody = funcBody; | 459 this.funcBody = funcBody; |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 class DebugDeclaration : Declaration | 463 abstract class ConditionalCompilationDeclaration : Declaration |
464 { | 464 { |
465 Token* spec; | 465 Token* spec; |
466 Token* cond; | 466 Token* cond; |
467 Declaration decls, elseDecls; | 467 Declaration decls, elseDecls; |
468 | 468 |
469 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) | 469 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
470 { | 470 { |
471 super.hasBody = decls !is null; | 471 super.hasBody = decls !is null; |
472 mixin(set_kind); | |
473 addOptChild(decls); | 472 addOptChild(decls); |
474 addOptChild(elseDecls); | 473 addOptChild(elseDecls); |
475 | 474 |
476 this.spec = spec; | 475 this.spec = spec; |
477 this.cond = cond; | 476 this.cond = cond; |
478 this.decls = decls; | 477 this.decls = decls; |
479 this.elseDecls = elseDecls; | 478 this.elseDecls = elseDecls; |
480 } | 479 } |
481 } | 480 } |
482 | 481 |
483 class VersionDeclaration : Declaration | 482 class DebugDeclaration : ConditionalCompilationDeclaration |
484 { | 483 { |
485 Token* spec; | |
486 Token* cond; | |
487 Declaration decls, elseDecls; | |
488 | |
489 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) | 484 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
490 { | 485 { |
491 super.hasBody = decls !is null; | 486 super(spec, cond, decls, elseDecls); |
492 mixin(set_kind); | 487 mixin(set_kind); |
493 addOptChild(decls); | 488 } |
494 addOptChild(elseDecls); | 489 } |
495 | 490 |
496 this.spec = spec; | 491 class VersionDeclaration : ConditionalCompilationDeclaration |
497 this.cond = cond; | 492 { |
498 this.decls = decls; | 493 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
499 this.elseDecls = elseDecls; | 494 { |
495 super(spec, cond, decls, elseDecls); | |
496 mixin(set_kind); | |
500 } | 497 } |
501 } | 498 } |
502 | 499 |
503 class StaticIfDeclaration : Declaration | 500 class StaticIfDeclaration : Declaration |
504 { | 501 { |
533 } | 530 } |
534 } | 531 } |
535 | 532 |
536 class TemplateDeclaration : Declaration | 533 class TemplateDeclaration : Declaration |
537 { | 534 { |
538 Token* name; | 535 Identifier* name; |
539 TemplateParameters tparams; | 536 TemplateParameters tparams; |
540 Declarations decls; | 537 Declarations decls; |
541 this(Token* name, TemplateParameters tparams, Declarations decls) | 538 this(Identifier* name, TemplateParameters tparams, Declarations decls) |
542 { | 539 { |
543 super.hasBody = true; | 540 super.hasBody = true; |
544 mixin(set_kind); | 541 mixin(set_kind); |
545 addOptChild(tparams); | 542 addOptChild(tparams); |
546 addChild(decls); | 543 addChild(decls); |
605 { | 602 { |
606 super(cast(TOK)0, decls); | 603 super(cast(TOK)0, decls); |
607 mixin(set_kind); | 604 mixin(set_kind); |
608 this.prot = prot; | 605 this.prot = prot; |
609 } | 606 } |
610 | |
611 void semantic(Scope scop) | |
612 { | |
613 // auto saved_prot = scop.protection; | |
614 // scop.protection = this.prot; | |
615 // decls.semantic(scop); | |
616 // scop.protection = saved_prot; | |
617 } | |
618 } | 607 } |
619 | 608 |
620 class StorageClassDeclaration : AttributeDeclaration | 609 class StorageClassDeclaration : AttributeDeclaration |
621 { | 610 { |
622 StorageClass storageClass; | 611 StorageClass storageClass; |
652 } | 641 } |
653 } | 642 } |
654 | 643 |
655 class PragmaDeclaration : AttributeDeclaration | 644 class PragmaDeclaration : AttributeDeclaration |
656 { | 645 { |
657 Token* ident; | 646 Identifier* ident; |
658 Expression[] args; | 647 Expression[] args; |
659 this(Token* ident, Expression[] args, Declaration decls) | 648 this(Identifier* ident, Expression[] args, Declaration decls) |
660 { | 649 { |
661 addOptChildren(args); // Add args before calling super(). | 650 addOptChildren(args); // Add args before calling super(). |
662 super(TOK.Pragma, decls); | 651 super(TOK.Pragma, decls); |
663 mixin(set_kind); | 652 mixin(set_kind); |
664 | 653 |
668 } | 657 } |
669 | 658 |
670 class MixinDeclaration : Declaration | 659 class MixinDeclaration : Declaration |
671 { | 660 { |
672 Expression[] templateIdents; | 661 Expression[] templateIdents; |
673 Token* mixinIdent; | 662 Identifier* mixinIdent; |
674 Expression argument; // mixin ( AssignExpression ) | 663 Expression argument; // mixin ( AssignExpression ) |
675 | 664 |
676 this(Expression[] templateIdents, Token* mixinIdent) | 665 this(Expression[] templateIdents, Identifier* mixinIdent) |
677 { | 666 { |
678 mixin(set_kind); | 667 mixin(set_kind); |
679 addChildren(templateIdents); | 668 addChildren(templateIdents); |
680 | 669 |
681 this.templateIdents = templateIdents; | 670 this.templateIdents = templateIdents; |