Mercurial > projects > dil
comparison trunk/src/dil/Declarations.d @ 490:47be6bfe39cd
Refactored code and added new modules.
Added ProtectionDeclaration and changed Parser to make use of it.
Moved class Location to its own module.
Moved some Lexer functions to new module LexerFuncs.
Moved Lexer.getLocation() to struct Token.
Added methods semantic() and error() to class Expression.
Added method error() to class Scope.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Tue, 04 Dec 2007 23:31:20 +0100 |
parents | a7291d3ee9d7 |
children | 9c208925a3d4 |
comparison
equal
deleted
inserted
replaced
489:a7291d3ee9d7 | 490:47be6bfe39cd |
---|---|
18 { | 18 { |
19 super(NodeCategory.Declaration); | 19 super(NodeCategory.Declaration); |
20 } | 20 } |
21 | 21 |
22 // Members relevant to semantic phase. | 22 // Members relevant to semantic phase. |
23 StorageClass stc; | 23 StorageClass stc; /// The storage class of this declaration. |
24 Protection prot; | 24 Protection prot; /// The protection attribute of this declaration. |
25 | 25 |
26 void semantic(Scope sc) | 26 void semantic(Scope sc) |
27 { | 27 { |
28 // foreach (node; this.children) | 28 // foreach (node; this.children) |
29 // if (node.category == NodeCategory.Declaration) | 29 // if (node.category == NodeCategory.Declaration) |
546 this.attribute = attribute; | 546 this.attribute = attribute; |
547 this.decls = decls; | 547 this.decls = decls; |
548 } | 548 } |
549 } | 549 } |
550 | 550 |
551 class ProtectionDeclaration : AttributeDeclaration | |
552 { | |
553 this(Protection prot, Declaration decls) | |
554 { | |
555 super(cast(TOK)0, decls); | |
556 mixin(set_kind); | |
557 super.prot = prot; | |
558 } | |
559 | |
560 void semantic(Scope scop) | |
561 { | |
562 /+ | |
563 void traverse(Node[] nodes) | |
564 { | |
565 foreach (node; nodes) | |
566 { | |
567 if (node.kind == NodeKind.ProtectionDeclaration) | |
568 break; | |
569 if (node.category == NodeCategory.Declaration) | |
570 { | |
571 auto decl = cast(Declaration)cast(void*)node; | |
572 decl.prot = this.prot; | |
573 if (node.children) | |
574 traverse(node.children); | |
575 } | |
576 } | |
577 } | |
578 traverse([this.decls]); | |
579 +/ | |
580 } | |
581 } | |
582 | |
551 class ExternDeclaration : AttributeDeclaration | 583 class ExternDeclaration : AttributeDeclaration |
552 { | 584 { |
553 Linkage linkage; | 585 Linkage linkage; |
554 this(Linkage linkage, Declaration decls) | 586 this(Linkage linkage, Declaration decls) |
555 { | 587 { |