Mercurial > projects > dil
annotate trunk/src/dil/ast/Declarations.d @ 751:8caf18892c1b
Improved DDocEmitter and fixed bugs.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Mon, 11 Feb 2008 22:39:58 +0100 |
parents | 7917811f8116 |
children | bc812843603c |
rev | line source |
---|---|
102 | 1 /++ |
2 Author: Aziz Köksal | |
249 | 3 License: GPL3 |
102 | 4 +/ |
585
05c375fb2d5c
Moved dil.Declarations to dil.ast.Declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
584
diff
changeset
|
5 module dil.ast.Declarations; |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
6 |
654
2a71e2f50e13
Moved class Declaration to its own module.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
650
diff
changeset
|
7 public import dil.ast.Declaration; |
580
fa6d3c52757d
Moved SyntaxTree.d to new package 'ast'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
574
diff
changeset
|
8 import dil.ast.Node; |
586
e25345656d10
Moved dil.Expressions to dil.ast.Expressions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
585
diff
changeset
|
9 import dil.ast.Expressions; |
588
dcfec202718d
Moved dil.Types to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
587
diff
changeset
|
10 import dil.ast.Types; |
587
7d0ba0c93e95
Moved dil.Statements to dil.ast.Statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
586
diff
changeset
|
11 import dil.ast.Statements; |
608
fac9e8b258fc
Moved dil.ast.Parameter to dil.ast.Parameters.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
606
diff
changeset
|
12 import dil.ast.Parameters; |
601
9f96fd51cb41
Moved dil.IdTable to dil.lexer.IdTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
13 import dil.lexer.IdTable; |
590
641041912670
Moved dil.Symbols to dil.semantic.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
588
diff
changeset
|
14 import dil.semantic.Symbols; |
601
9f96fd51cb41
Moved dil.IdTable to dil.lexer.IdTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
15 import dil.Enums; |
564
3c867a683258
Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
563
diff
changeset
|
16 import common; |
102 | 17 |
680
6b3e397229c5
Renamed Statements, Declarations and EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
673
diff
changeset
|
18 class CompoundDeclaration : Declaration |
305 | 19 { |
20 this() | |
21 { | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
22 hasBody = true; |
305 | 23 mixin(set_kind); |
24 } | |
25 | |
26 void opCatAssign(Declaration d) | |
27 { | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
28 addChild(d); |
486
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
461
diff
changeset
|
29 } |
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
461
diff
changeset
|
30 |
680
6b3e397229c5
Renamed Statements, Declarations and EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
673
diff
changeset
|
31 void opCatAssign(CompoundDeclaration ds) |
305 | 32 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
33 addChildren(ds.children); |
305 | 34 } |
696
c67d2c3c0b3d
Wrote code for SemanticPass2.visit(ImportExpression).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
35 |
c67d2c3c0b3d
Wrote code for SemanticPass2.visit(ImportExpression).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
36 Declaration[] decls() |
c67d2c3c0b3d
Wrote code for SemanticPass2.visit(ImportExpression).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
37 { |
c67d2c3c0b3d
Wrote code for SemanticPass2.visit(ImportExpression).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
38 return cast(Declaration[])this.children; |
c67d2c3c0b3d
Wrote code for SemanticPass2.visit(ImportExpression).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
683
diff
changeset
|
39 } |
305 | 40 } |
41 | |
563
c838ed7f2ac9
Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
42 /// Single semicolon. |
129 | 43 class EmptyDeclaration : Declaration |
44 { | |
45 this() | |
46 { | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
47 mixin(set_kind); |
129 | 48 } |
49 } | |
50 | |
496
5a607597dc22
Improved error recovery in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
51 /++ |
5a607597dc22
Improved error recovery in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
52 Illegal declarations encompass all tokens that don't |
5a607597dc22
Improved error recovery in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
53 start a DeclarationDefinition. |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
54 See_Also: dil.lexer.Token.isDeclDefStartToken() |
496
5a607597dc22
Improved error recovery in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
55 +/ |
211 | 56 class IllegalDeclaration : Declaration |
57 { | |
496
5a607597dc22
Improved error recovery in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
58 this() |
211 | 59 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
60 mixin(set_kind); |
211 | 61 } |
62 } | |
63 | |
364 | 64 /// FQN = fully qualified name |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
65 alias Identifier*[] ModuleFQN; // Identifier(.Identifier)* |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
66 |
102 | 67 class ModuleDeclaration : Declaration |
68 { | |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
69 Identifier* moduleName; |
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
70 Identifier*[] packages; |
364 | 71 this(ModuleFQN moduleFQN) |
102 | 72 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
73 mixin(set_kind); |
365 | 74 assert(moduleFQN.length != 0); |
75 this.moduleName = moduleFQN[$-1]; | |
76 this.packages = moduleFQN[0..$-1]; | |
77 } | |
78 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
79 char[] getFQN() |
370 | 80 { |
81 auto pname = getPackageName('.'); | |
82 if (pname.length) | |
83 return pname ~ "." ~ getName(); | |
84 else | |
85 return getName(); | |
86 } | |
87 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
88 char[] getName() |
365 | 89 { |
90 if (moduleName) | |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
91 return moduleName.str; |
365 | 92 return null; |
93 } | |
94 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
95 char[] getPackageName(char separator) |
365 | 96 { |
97 char[] pname; | |
98 foreach (pckg; packages) | |
99 if (pckg) | |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
100 pname ~= pckg.str ~ separator; |
367
dda55fae37de
- ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents:
366
diff
changeset
|
101 if (pname.length) |
dda55fae37de
- ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents:
366
diff
changeset
|
102 pname = pname[0..$-1]; // Remove last separator |
365 | 103 return pname; |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
104 } |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
105 } |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
106 |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
107 class ImportDeclaration : Declaration |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
108 { |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
109 private alias Identifier*[] Ids; |
364 | 110 ModuleFQN[] moduleFQNs; |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
111 Ids moduleAliases; |
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
112 Ids bindNames; |
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
113 Ids bindAliases; |
461
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
114 |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
115 this(ModuleFQN[] moduleFQNs, Ids moduleAliases, Ids bindNames, Ids bindAliases, bool isStatic) |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
116 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
117 mixin(set_kind); |
364 | 118 this.moduleFQNs = moduleFQNs; |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
119 this.moduleAliases = moduleAliases; |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
120 this.bindNames = bindNames; |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
121 this.bindAliases = bindAliases; |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
122 if (isStatic) |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
123 this.stc |= StorageClass.Static; |
366 | 124 } |
125 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
126 char[][] getModuleFQNs(char separator) |
366 | 127 { |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
128 char[][] FQNs; |
366 | 129 foreach (moduleFQN; moduleFQNs) |
130 { | |
131 char[] FQN; | |
132 foreach (ident; moduleFQN) | |
133 if (ident) | |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
134 FQN ~= ident.str ~ separator; |
366 | 135 FQNs ~= FQN[0..$-1]; // Remove last separator |
136 } | |
137 return FQNs; | |
102 | 138 } |
139 } | |
140 | |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
141 class AliasDeclaration : 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 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
146 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
147 addChild(decl); |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
148 this.decl = decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
149 } |
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 class TypedefDeclaration : Declaration |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
153 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
154 Declaration decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
155 this(Declaration decl) |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
156 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
157 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
158 addChild(decl); |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
159 this.decl = decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
160 } |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
161 } |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
162 |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
163 class EnumDeclaration : Declaration |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
164 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
165 Identifier* name; |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
166 TypeNode baseType; |
680
6b3e397229c5
Renamed Statements, Declarations and EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
673
diff
changeset
|
167 EnumMemberDeclaration[] members; |
6b3e397229c5
Renamed Statements, Declarations and EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
673
diff
changeset
|
168 this(Identifier* name, TypeNode baseType, EnumMemberDeclaration[] members, bool hasBody) |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
169 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
170 super.hasBody = hasBody; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
171 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
172 addOptChild(baseType); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
173 addOptChildren(members); |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
174 |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
175 this.name = name; |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
176 this.baseType = baseType; |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
177 this.members = members; |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
178 } |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
179 |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
180 Enum symbol; |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
181 } |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
182 |
680
6b3e397229c5
Renamed Statements, Declarations and EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
673
diff
changeset
|
183 class EnumMemberDeclaration : Declaration |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
184 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
185 Identifier* name; |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
186 Expression value; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
187 this(Identifier* name, Expression value) |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
188 { |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
189 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
190 addOptChild(value); |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
191 |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
192 this.name = name; |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
193 this.value = value; |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
194 } |
707
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
704
diff
changeset
|
195 |
efa5fcb9aa14
Added semantic code related to enums.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
704
diff
changeset
|
196 EnumMember symbol; |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
197 } |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
198 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
199 class TemplateDeclaration : Declaration |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
200 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
201 Identifier* name; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
202 TemplateParameters tparams; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
203 CompoundDeclaration decls; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
204 this(Identifier* name, TemplateParameters tparams, CompoundDeclaration decls) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
205 { |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
206 super.hasBody = true; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
207 mixin(set_kind); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
208 addOptChild(tparams); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
209 addChild(decls); |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
210 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
211 this.name = name; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
212 this.tparams = tparams; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
213 this.decls = decls; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
214 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
215 |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
216 Template symbol; /// The template symbol for this declaration. |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
217 } |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
218 |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
219 abstract class AggregateDeclaration : Declaration |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
220 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
221 Identifier* name; |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
222 // TemplateParameters tparams; |
680
6b3e397229c5
Renamed Statements, Declarations and EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
673
diff
changeset
|
223 CompoundDeclaration decls; |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
224 this(Identifier* name, /+TemplateParameters tparams, +/CompoundDeclaration decls) |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
225 { |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
226 super.hasBody = decls !is null; |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
227 this.name = name; |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
228 // this.tparams = tparams; |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
229 this.decls = decls; |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
230 } |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
231 } |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
232 |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
233 class ClassDeclaration : AggregateDeclaration |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
234 { |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
235 BaseClassType[] bases; |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
236 this(Identifier* name, /+TemplateParameters tparams, +/BaseClassType[] bases, CompoundDeclaration decls) |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
237 { |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
238 super(name, /+tparams, +/decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
239 mixin(set_kind); |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
240 // addOptChild(tparams); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
241 addOptChildren(bases); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
242 addOptChild(decls); |
305 | 243 |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
244 this.bases = bases; |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
245 } |
573
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
246 |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
247 Class symbol; /// The class symbol for this declaration. |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
248 } |
112 | 249 |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
250 class InterfaceDeclaration : AggregateDeclaration |
112 | 251 { |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
252 BaseClassType[] bases; |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
253 this(Identifier* name, /+TemplateParameters tparams, +/BaseClassType[] bases, CompoundDeclaration decls) |
112 | 254 { |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
255 super(name, /+tparams, +/decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
256 mixin(set_kind); |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
257 // addOptChild(tparams); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
258 addOptChildren(bases); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
259 addOptChild(decls); |
305 | 260 |
112 | 261 this.bases = bases; |
262 } | |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
263 |
590
641041912670
Moved dil.Symbols to dil.semantic.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
588
diff
changeset
|
264 alias dil.semantic.Symbols.Interface Interface; |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
265 |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
266 Interface symbol; /// The interface symbol for this declaration. |
112 | 267 } |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
268 |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
269 class StructDeclaration : AggregateDeclaration |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
270 { |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
271 uint alignSize; |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
272 this(Identifier* name, /+TemplateParameters tparams, +/CompoundDeclaration decls) |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
273 { |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
274 super(name, /+tparams, +/decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
275 mixin(set_kind); |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
276 // addOptChild(tparams); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
277 addOptChild(decls); |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
278 } |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
279 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
280 void setAlignSize(uint alignSize) |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
281 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
282 this.alignSize = alignSize; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
283 } |
565
184a8d8bad2e
Added semantic() to StructDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
284 |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
285 Struct symbol; /// The struct symbol for this declaration. |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
286 } |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
287 |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
288 class UnionDeclaration : AggregateDeclaration |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
289 { |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
290 this(Identifier* name, /+TemplateParameters tparams, +/CompoundDeclaration decls) |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
291 { |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
292 super(name, /+tparams, +/decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
293 mixin(set_kind); |
726
7917811f8116
AggregateDeclarations are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
707
diff
changeset
|
294 // addOptChild(tparams); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
295 addOptChild(decls); |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
296 } |
572
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
297 |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
298 Union symbol; /// The union symbol for this declaration. |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
299 } |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
300 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
301 class ConstructorDeclaration : Declaration |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
302 { |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
303 Parameters params; |
682
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
304 FuncBodyStatement funcBody; |
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
305 this(Parameters params, FuncBodyStatement funcBody) |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
306 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
307 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
308 mixin(set_kind); |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
309 addChild(params); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
310 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
311 |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
312 this.params = params; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
313 this.funcBody = funcBody; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
314 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
315 } |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
316 |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
317 class StaticConstructorDeclaration : Declaration |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
318 { |
682
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
319 FuncBodyStatement funcBody; |
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
320 this(FuncBodyStatement funcBody) |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
321 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
322 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
323 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
324 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
325 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
326 this.funcBody = funcBody; |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
327 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
328 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
329 |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
330 class DestructorDeclaration : Declaration |
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
331 { |
682
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
332 FuncBodyStatement funcBody; |
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
333 this(FuncBodyStatement funcBody) |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
334 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
335 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
336 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
337 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
338 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
339 this.funcBody = funcBody; |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
340 } |
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
341 } |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
342 |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
343 class StaticDestructorDeclaration : Declaration |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
344 { |
682
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
345 FuncBodyStatement funcBody; |
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
346 this(FuncBodyStatement funcBody) |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
347 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
348 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
349 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
350 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
351 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
352 this.funcBody = funcBody; |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
353 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
354 } |
120 | 355 |
192 | 356 class FunctionDeclaration : Declaration |
357 { | |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
358 TypeNode returnType; |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
359 Identifier* name; |
258 | 360 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
|
361 Parameters params; |
682
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
362 FuncBodyStatement funcBody; |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
363 LinkageType linkageType; |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
364 this(TypeNode returnType, Identifier* name, TemplateParameters tparams, |
682
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
365 Parameters params, FuncBodyStatement funcBody) |
192 | 366 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
367 super.hasBody = funcBody.funcBody !is null; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
368 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
369 addChild(returnType); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
370 addOptChild(tparams); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
371 addChild(params); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
372 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
373 |
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
|
374 this.returnType = returnType; |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
375 this.name = name; |
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
|
376 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
|
377 this.params = params; |
192 | 378 this.funcBody = funcBody; |
379 } | |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
380 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
381 void setLinkageType(LinkageType linkageType) |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
382 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
383 this.linkageType = linkageType; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
384 } |
751
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
726
diff
changeset
|
385 |
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
726
diff
changeset
|
386 bool isTemplatized() |
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
726
diff
changeset
|
387 { // E.g.: void func(T)(T t) |
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
726
diff
changeset
|
388 // ^ params.begin.prevNWS |
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
726
diff
changeset
|
389 return params.begin.prevNWS.kind == TOK.RParen; |
8caf18892c1b
Improved DDocEmitter and fixed bugs.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
726
diff
changeset
|
390 } |
192 | 391 } |
392 | |
673
64fec49651cf
Renamed VariableDeclaration to VariablesDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
393 /// VariablesDeclaration := Type? Identifier ("=" Init)? ("," Identifier ("=" Init)?)* ";" |
64fec49651cf
Renamed VariableDeclaration to VariablesDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
668
diff
changeset
|
394 class VariablesDeclaration : Declaration |
194 | 395 { |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
396 TypeNode typeNode; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
397 Identifier*[] names; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
398 Expression[] inits; |
697
b0732f766ba0
Fixed parameter name in constructor of VariablesDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
696
diff
changeset
|
399 this(TypeNode typeNode, Identifier*[] names, Expression[] inits) |
194 | 400 { |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
401 // No empty arrays allowed. Both arrays must be of same size. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
402 assert(names.length != 0 && names.length == inits.length); |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
403 // If no type (in case of AutoDeclaration), first value mustn't be null. |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
404 assert(typeNode ? 1 : inits[0] !is null); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
405 mixin(set_kind); |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
406 addOptChild(typeNode); |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
407 foreach(init; inits) |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
408 addOptChild(init); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
409 |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
410 this.typeNode = typeNode; |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
411 this.names = names; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
412 this.inits = inits; |
194 | 413 } |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
414 |
683
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
415 LinkageType linkageType; |
1ae72234db26
Implemented some methods in SemanticPass1.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
682
diff
changeset
|
416 |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
417 void setLinkageType(LinkageType linkageType) |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
418 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
419 this.linkageType = linkageType; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
420 } |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
421 |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
422 Variable[] variables; |
194 | 423 } |
424 | |
120 | 425 class InvariantDeclaration : Declaration |
426 { | |
682
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
427 FuncBodyStatement funcBody; |
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
428 this(FuncBodyStatement funcBody) |
120 | 429 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
430 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
431 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
432 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
433 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
434 this.funcBody = funcBody; |
120 | 435 } |
436 } | |
121 | 437 |
438 class UnittestDeclaration : Declaration | |
439 { | |
682
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
440 FuncBodyStatement funcBody; |
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
441 this(FuncBodyStatement funcBody) |
121 | 442 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
443 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
444 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
445 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
446 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
447 this.funcBody = funcBody; |
121 | 448 } |
449 } | |
122 | 450 |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
451 abstract class ConditionalCompilationDeclaration : Declaration |
122 | 452 { |
264 | 453 Token* spec; |
454 Token* cond; | |
305 | 455 Declaration decls, elseDecls; |
122 | 456 |
305 | 457 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
122 | 458 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
459 super.hasBody = decls !is null; |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
460 addOptChild(decls); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
461 addOptChild(elseDecls); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
462 |
264 | 463 this.spec = spec; |
464 this.cond = cond; | |
122 | 465 this.decls = decls; |
466 this.elseDecls = elseDecls; | |
467 } | |
468 } | |
123 | 469 |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
470 class DebugDeclaration : ConditionalCompilationDeclaration |
123 | 471 { |
305 | 472 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
123 | 473 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
474 super(spec, cond, decls, elseDecls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
475 mixin(set_kind); |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
476 } |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
477 } |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
478 |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
479 class VersionDeclaration : ConditionalCompilationDeclaration |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
480 { |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
481 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
482 { |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
483 super(spec, cond, decls, elseDecls); |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
484 mixin(set_kind); |
123 | 485 } |
486 } | |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
487 |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
488 class StaticIfDeclaration : Declaration |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
489 { |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
490 Expression condition; |
305 | 491 Declaration ifDecls, elseDecls; |
492 this(Expression condition, Declaration ifDecls, Declaration elseDecls) | |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
493 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
494 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
495 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
496 addChild(condition); |
660
085bac570c7e
Implemented class DefaultVisitor.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
656
diff
changeset
|
497 addChild(ifDecls); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
498 addOptChild(elseDecls); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
499 |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
500 this.condition = condition; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
501 this.ifDecls = ifDecls; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
502 this.elseDecls = elseDecls; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
503 } |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
504 } |
127
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
505 |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
506 class StaticAssertDeclaration : Declaration |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
507 { |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
508 Expression condition, message; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
509 this(Expression condition, Expression message) |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
510 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
511 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
512 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
513 addChild(condition); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
514 addOptChild(message); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
515 |
127
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
516 this.condition = condition; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
517 this.message = message; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
518 } |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
519 } |
140 | 520 |
141 | 521 class NewDeclaration : Declaration |
522 { | |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
523 Parameters params; |
682
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
524 FuncBodyStatement funcBody; |
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
525 this(Parameters params, FuncBodyStatement funcBody) |
141 | 526 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
527 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
528 mixin(set_kind); |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
529 addChild(params); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
530 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
531 |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
532 this.params = params; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
533 this.funcBody = funcBody; |
141 | 534 } |
535 } | |
536 | |
537 class DeleteDeclaration : Declaration | |
538 { | |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
539 Parameters params; |
682
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
540 FuncBodyStatement funcBody; |
7541c64fc423
Renamed FunctionBody, CatchBody and FinallyBody.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
680
diff
changeset
|
541 this(Parameters params, FuncBodyStatement funcBody) |
141 | 542 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
543 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
544 mixin(set_kind); |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
545 addChild(params); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
546 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
547 |
668
a1f8d8f2db38
Renamed some identifiers.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
660
diff
changeset
|
548 this.params = params; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
549 this.funcBody = funcBody; |
141 | 550 } |
551 } | |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
552 |
650
eb490ba8dba0
Made AttributeDeclaration abstract.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
553 abstract class AttributeDeclaration : Declaration |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
554 { |
305 | 555 Declaration decls; |
650
eb490ba8dba0
Made AttributeDeclaration abstract.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
556 this(Declaration decls) |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
557 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
558 super.hasBody = true; |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
559 addChild(decls); |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
560 this.decls = decls; |
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
561 } |
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
562 } |
147 | 563 |
490
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
564 class ProtectionDeclaration : AttributeDeclaration |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
565 { |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
566 Protection prot; |
490
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
567 this(Protection prot, Declaration decls) |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
568 { |
650
eb490ba8dba0
Made AttributeDeclaration abstract.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
569 super(decls); |
490
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
570 mixin(set_kind); |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
571 this.prot = prot; |
490
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
572 } |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
573 } |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
574 |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
575 class StorageClassDeclaration : AttributeDeclaration |
149 | 576 { |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
577 StorageClass storageClass; |
650
eb490ba8dba0
Made AttributeDeclaration abstract.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
578 this(StorageClass storageClass, Declaration decl) |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
579 { |
650
eb490ba8dba0
Made AttributeDeclaration abstract.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
580 super(decl); |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
581 mixin(set_kind); |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
582 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
583 this.storageClass = storageClass; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
584 } |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
585 } |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
586 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
587 class LinkageDeclaration : AttributeDeclaration |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
588 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
589 LinkageType linkageType; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
590 this(LinkageType linkageType, Declaration decls) |
149 | 591 { |
650
eb490ba8dba0
Made AttributeDeclaration abstract.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
592 super(decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
593 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
594 |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
595 this.linkageType = linkageType; |
149 | 596 } |
597 } | |
598 | |
599 class AlignDeclaration : AttributeDeclaration | |
600 { | |
601 int size; | |
305 | 602 this(int size, Declaration decls) |
149 | 603 { |
650
eb490ba8dba0
Made AttributeDeclaration abstract.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
604 super(decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
605 mixin(set_kind); |
149 | 606 this.size = size; |
607 } | |
608 } | |
609 | |
610 class PragmaDeclaration : AttributeDeclaration | |
147 | 611 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
612 Identifier* ident; |
147 | 613 Expression[] args; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
614 this(Identifier* ident, Expression[] args, Declaration decls) |
147 | 615 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
616 addOptChildren(args); // Add args before calling super(). |
650
eb490ba8dba0
Made AttributeDeclaration abstract.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
648
diff
changeset
|
617 super(decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
618 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
619 |
147 | 620 this.ident = ident; |
621 this.args = args; | |
622 } | |
623 } | |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
624 |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
625 class MixinDeclaration : Declaration |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
626 { |
704
ff4643a4a97c
Wrote code for SemanticPass2.visit(MixinDeclaration).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
697
diff
changeset
|
627 /// IdExpression := IdentifierExpression | TemplateInstanceExpression |
ff4643a4a97c
Wrote code for SemanticPass2.visit(MixinDeclaration).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
697
diff
changeset
|
628 /// MixinTemplate := IdExpression ("." IdExpression)* |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
629 Expression templateExpr; |
704
ff4643a4a97c
Wrote code for SemanticPass2.visit(MixinDeclaration).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
697
diff
changeset
|
630 Identifier* mixinIdent; /// Optional mixin identifier. |
ff4643a4a97c
Wrote code for SemanticPass2.visit(MixinDeclaration).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
697
diff
changeset
|
631 Expression argument; /// "mixin" "(" AssignExpression ")" |
ff4643a4a97c
Wrote code for SemanticPass2.visit(MixinDeclaration).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
697
diff
changeset
|
632 Declaration decls; /// Initialized in the semantic phase. |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
633 |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
634 this(Expression templateExpr, Identifier* mixinIdent) |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
635 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
636 mixin(set_kind); |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
637 addChild(templateExpr); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
638 |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
639 this.templateExpr = templateExpr; |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
640 this.mixinIdent = mixinIdent; |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
641 } |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
642 |
292 | 643 this(Expression argument) |
151
2e959f67000b
- Added code for parsing mixin expression declarations.
aziz
parents:
150
diff
changeset
|
644 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
645 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
646 addChild(argument); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
647 |
292 | 648 this.argument = argument; |
151
2e959f67000b
- Added code for parsing mixin expression declarations.
aziz
parents:
150
diff
changeset
|
649 } |
704
ff4643a4a97c
Wrote code for SemanticPass2.visit(MixinDeclaration).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
697
diff
changeset
|
650 |
ff4643a4a97c
Wrote code for SemanticPass2.visit(MixinDeclaration).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
697
diff
changeset
|
651 bool isMixinExpression() |
ff4643a4a97c
Wrote code for SemanticPass2.visit(MixinDeclaration).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
697
diff
changeset
|
652 { |
ff4643a4a97c
Wrote code for SemanticPass2.visit(MixinDeclaration).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
697
diff
changeset
|
653 return argument !is null; |
ff4643a4a97c
Wrote code for SemanticPass2.visit(MixinDeclaration).
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
697
diff
changeset
|
654 } |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
655 } |