Mercurial > projects > dil
annotate trunk/src/dil/ast/Declarations.d @ 618:07946b379006
Refactored the way dot expressions are parsed.
DotExpression is a binary expression now.
Added ModuleScopeExpression.
Removed some obsolete expression classes.
Added QualifiedType and ModuleScopeType.
Removed some obsolete type node classes.
Added genAnonymousID() to IdTable.
Removed obsolete parser functions.
Improved Node.getDocComments().
Added semantic() methods to some declaration classes.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Fri, 11 Jan 2008 00:42:35 +0100 |
parents | 6d449e777f5d |
children | f15b054bb27e |
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 |
580
fa6d3c52757d
Moved SyntaxTree.d to new package 'ast'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
574
diff
changeset
|
7 import dil.ast.Node; |
586
e25345656d10
Moved dil.Expressions to dil.ast.Expressions.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
585
diff
changeset
|
8 import dil.ast.Expressions; |
588
dcfec202718d
Moved dil.Types to dil.ast.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
587
diff
changeset
|
9 import dil.ast.Types; |
587
7d0ba0c93e95
Moved dil.Statements to dil.ast.Statements.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
586
diff
changeset
|
10 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
|
11 import dil.ast.Parameters; |
606
e98d659f1c29
Moved class BaseClass to module dil.ast.BaseClass.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
604
diff
changeset
|
12 import dil.ast.BaseClass; |
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; |
592
b8dd677e0ace
Moved dil.Scope to dil.semantic.Scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
590
diff
changeset
|
14 import dil.semantic.Scope; |
583
af16adf500f4
Moved dil.Semantics to dil.semantic.Analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
580
diff
changeset
|
15 import dil.semantic.Analysis; |
590
641041912670
Moved dil.Symbols to dil.semantic.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
588
diff
changeset
|
16 import dil.semantic.Symbols; |
584
556bfb18dff8
Moved dil.TypeSystem to dil.semantic.Types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
583
diff
changeset
|
17 import dil.semantic.Types; |
601
9f96fd51cb41
Moved dil.IdTable to dil.lexer.IdTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
18 import dil.Enums; |
574
ae8f58a13917
Added messages to struct MSG.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
573
diff
changeset
|
19 import dil.Messages; |
564
3c867a683258
Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
563
diff
changeset
|
20 import common; |
102 | 21 |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
22 abstract class Declaration : Node |
102 | 23 { |
126
0f0e7352e91d
- Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents:
125
diff
changeset
|
24 bool hasBody; |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
25 this() |
116 | 26 { |
275 | 27 super(NodeCategory.Declaration); |
116 | 28 } |
486
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
461
diff
changeset
|
29 |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
30 // Members relevant to semantic phase. |
490
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
31 StorageClass stc; /// The storage class of this declaration. |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
32 Protection prot; /// The protection attribute of this declaration. |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
33 |
486
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
461
diff
changeset
|
34 void semantic(Scope sc) |
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
461
diff
changeset
|
35 { |
563
c838ed7f2ac9
Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
36 foreach (node; this.children) |
564
3c867a683258
Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
563
diff
changeset
|
37 { |
3c867a683258
Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
563
diff
changeset
|
38 assert(node !is null); |
563
c838ed7f2ac9
Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
39 if (node.category == NodeCategory.Declaration) |
c838ed7f2ac9
Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
40 (cast(Declaration)cast(void*)node).semantic(sc); |
564
3c867a683258
Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
563
diff
changeset
|
41 } |
486
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
461
diff
changeset
|
42 } |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
43 |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
44 final bool isStatic() |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
45 { |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
46 return !!(stc & StorageClass.Static); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
47 } |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
48 |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
49 final bool isPublic() |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
50 { |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
51 return !!(prot & Protection.Public); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
52 } |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
53 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
54 final void setStorageClass(StorageClass stc) |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
55 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
56 this.stc = stc; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
57 } |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
58 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
59 final void setProtection(Protection prot) |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
60 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
61 this.prot = prot; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
62 } |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
63 |
102 | 64 } |
65 | |
305 | 66 class Declarations : Declaration |
67 { | |
68 this() | |
69 { | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
70 hasBody = true; |
305 | 71 mixin(set_kind); |
72 } | |
73 | |
74 void opCatAssign(Declaration d) | |
75 { | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
76 addChild(d); |
486
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
461
diff
changeset
|
77 } |
bd176bc73e43
Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
461
diff
changeset
|
78 |
305 | 79 void opCatAssign(Declarations ds) |
80 { | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
81 addChildren(ds.children); |
305 | 82 } |
494
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
83 |
563
c838ed7f2ac9
Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
84 override void semantic(Scope scop) |
494
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
85 { |
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
86 foreach (node; this.children) |
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
87 { |
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
88 assert(node.category == NodeCategory.Declaration); |
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
89 (cast(Declaration)cast(void*)node).semantic(scop); |
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
90 } |
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
91 } |
305 | 92 } |
93 | |
563
c838ed7f2ac9
Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
94 /// Single semicolon. |
129 | 95 class EmptyDeclaration : Declaration |
96 { | |
97 this() | |
98 { | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
99 mixin(set_kind); |
129 | 100 } |
494
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
101 |
563
c838ed7f2ac9
Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
102 override void semantic(Scope) |
494
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
103 {} |
129 | 104 } |
105 | |
496
5a607597dc22
Improved error recovery in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
106 /++ |
5a607597dc22
Improved error recovery in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
107 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
|
108 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
|
109 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
|
110 +/ |
211 | 111 class IllegalDeclaration : Declaration |
112 { | |
496
5a607597dc22
Improved error recovery in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
113 this() |
211 | 114 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
115 mixin(set_kind); |
211 | 116 } |
494
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
117 |
563
c838ed7f2ac9
Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
118 override void semantic(Scope) |
494
9a7ca8c56e59
Refactored a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
119 {} |
211 | 120 } |
121 | |
364 | 122 /// 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
|
123 alias Identifier*[] ModuleFQN; // Identifier(.Identifier)* |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
124 |
102 | 125 class ModuleDeclaration : Declaration |
126 { | |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
127 Identifier* moduleName; |
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
128 Identifier*[] packages; |
364 | 129 this(ModuleFQN moduleFQN) |
102 | 130 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
131 mixin(set_kind); |
365 | 132 assert(moduleFQN.length != 0); |
133 this.moduleName = moduleFQN[$-1]; | |
134 this.packages = moduleFQN[0..$-1]; | |
135 } | |
136 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
137 char[] getFQN() |
370 | 138 { |
139 auto pname = getPackageName('.'); | |
140 if (pname.length) | |
141 return pname ~ "." ~ getName(); | |
142 else | |
143 return getName(); | |
144 } | |
145 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
146 char[] getName() |
365 | 147 { |
148 if (moduleName) | |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
149 return moduleName.str; |
365 | 150 return null; |
151 } | |
152 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
153 char[] getPackageName(char separator) |
365 | 154 { |
155 char[] pname; | |
156 foreach (pckg; packages) | |
157 if (pckg) | |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
158 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
|
159 if (pname.length) |
dda55fae37de
- ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents:
366
diff
changeset
|
160 pname = pname[0..$-1]; // Remove last separator |
365 | 161 return pname; |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
162 } |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
163 } |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
164 |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
165 class ImportDeclaration : Declaration |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
166 { |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
167 private alias Identifier*[] Ids; |
364 | 168 ModuleFQN[] moduleFQNs; |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
169 Ids moduleAliases; |
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
170 Ids bindNames; |
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
171 Ids bindAliases; |
461
c78a54b2617c
Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
172 |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
173 this(ModuleFQN[] moduleFQNs, Ids moduleAliases, Ids bindNames, Ids bindAliases, bool isStatic) |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
174 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
175 mixin(set_kind); |
364 | 176 this.moduleFQNs = moduleFQNs; |
114
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
177 this.moduleAliases = moduleAliases; |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
178 this.bindNames = bindNames; |
83bb5190c0fc
- Completed implementation of parseImportDeclaration().
aziz
parents:
113
diff
changeset
|
179 this.bindAliases = bindAliases; |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
180 if (isStatic) |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
181 this.stc |= StorageClass.Static; |
366 | 182 } |
183 | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
184 char[][] getModuleFQNs(char separator) |
366 | 185 { |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
377
diff
changeset
|
186 char[][] FQNs; |
366 | 187 foreach (moduleFQN; moduleFQNs) |
188 { | |
189 char[] FQN; | |
190 foreach (ident; moduleFQN) | |
191 if (ident) | |
504
9076c4cea2a4
Changed occur. of Token* to Identifier* and refactored Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
496
diff
changeset
|
192 FQN ~= ident.str ~ separator; |
366 | 193 FQNs ~= FQN[0..$-1]; // Remove last separator |
194 } | |
195 return FQNs; | |
102 | 196 } |
197 } | |
198 | |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
199 class AliasDeclaration : Declaration |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
200 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
201 Declaration decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
202 this(Declaration decl) |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
203 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
204 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
205 addChild(decl); |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
206 this.decl = decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
207 } |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
208 |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
209 override void semantic(Scope scop) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
210 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
211 /+ |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
212 decl.semantic(scop); // call semantic() or do SA in if statements? |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
213 if (auto fd = TryCast!(FunctionDeclaration)(decl)) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
214 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
215 // TODO: do SA here? |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
216 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
217 else if (auto vd = TryCast!(VariableDeclaration)(decl)) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
218 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
219 // TODO: do SA here? |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
220 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
221 +/ |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
222 } |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
223 } |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
224 |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
225 class TypedefDeclaration : Declaration |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
226 { |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
227 Declaration decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
228 this(Declaration decl) |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
229 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
230 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
231 addChild(decl); |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
232 this.decl = decl; |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
233 } |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
234 |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
235 override void semantic(Scope scop) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
236 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
237 /+ |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
238 decl.semantic(scop); // call semantic() or do SA in if statements? |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
239 if (auto fd = TryCast!(FunctionDeclaration)(decl)) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
240 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
241 // TODO: do SA here? |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
242 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
243 else if (auto vd = TryCast!(VariableDeclaration)(decl)) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
244 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
245 // TODO: do SA here? |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
246 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
247 +/ |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
248 } |
191
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
249 } |
3ce110cefbc5
- Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents:
161
diff
changeset
|
250 |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
251 class EnumDeclaration : Declaration |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
252 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
253 Identifier* name; |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
254 TypeNode baseType; |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
255 EnumMember[] members; |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
256 this(Identifier* name, TypeNode baseType, EnumMember[] members, bool hasBody) |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
257 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
258 super.hasBody = hasBody; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
259 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
260 addOptChild(baseType); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
261 addOptChildren(members); |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
262 |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
263 this.name = name; |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
264 this.baseType = baseType; |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
265 this.members = members; |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
266 } |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
267 |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
268 Enum symbol; |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
269 |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
270 override void semantic(Scope scop) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
271 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
272 /+ |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
273 // Create the symbol. |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
274 symbol = new Enum(name, this); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
275 // Type semantics. |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
276 Type type = Types.Int; // Default to integer. |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
277 if (baseType) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
278 type = baseType.semantic(scop); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
279 auto enumType = new EnumType(symbol, type); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
280 // Set the base type of the enum symbol. |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
281 symbol.setType(enumType); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
282 if (name) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
283 { // Insert named enum into scope. |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
284 scop.insert(symbol, symbol.ident); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
285 // Create new scope. |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
286 scop = scop.push(symbol); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
287 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
288 // Semantic on members. |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
289 foreach (member; members) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
290 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
291 auto value = member.value; |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
292 if (value) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
293 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
294 // value = value.semantic(scop); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
295 // value = value.evaluate(); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
296 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
297 auto variable = new Variable(StorageClass.Const, LinkageType.None, type, member.name, member); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
298 scop.insert(variable, variable.ident); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
299 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
300 if (name) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
301 scop.pop(); |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
302 +/ |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
303 } |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
304 } |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
305 |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
306 class EnumMember : Node |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
307 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
308 Identifier* name; |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
309 Expression value; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
310 this(Identifier* name, Expression value) |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
311 { |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
312 super(NodeCategory.Other); |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
313 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
314 addOptChild(value); |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
315 |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
316 this.name = name; |
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
396
diff
changeset
|
317 this.value = value; |
107
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
318 } |
722c05bbd5eb
- Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents:
102
diff
changeset
|
319 } |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
320 |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
321 abstract class AggregateDeclaration : Declaration |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
322 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
323 Identifier* name; |
258 | 324 TemplateParameters tparams; |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
325 Declarations decls; |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
326 this(Identifier* name, TemplateParameters tparams, Declarations decls) |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
327 { |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
328 super.hasBody = decls !is null; |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
329 this.name = name; |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
330 this.tparams = tparams; |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
331 this.decls = decls; |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
332 } |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
333 } |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
334 |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
335 class ClassDeclaration : AggregateDeclaration |
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
336 { |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
337 BaseClass[] bases; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
338 this(Identifier* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls) |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
339 { |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
340 super(name, tparams, decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
341 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
342 addOptChild(tparams); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
343 addOptChildren(bases); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
344 addOptChild(decls); |
305 | 345 |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
346 this.bases = bases; |
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
347 } |
573
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
348 |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
349 Class symbol; /// The class symbol for this declaration. |
573
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
350 |
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
351 override void semantic(Scope scop) |
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
352 { |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
353 if (symbol) |
573
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
354 return; |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
355 symbol = new Class(name, this); |
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
356 // Insert into current scope. |
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
357 scop.insert(symbol, name); |
573
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
358 // Create a new scope. |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
359 scop = scop.push(symbol); |
573
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
360 // Continue semantic analysis. |
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
361 decls && decls.semantic(scop); |
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
362 scop.pop(); |
87c4474a1295
Added semantic() to ClassDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
572
diff
changeset
|
363 } |
109
d0cc281cacbd
- Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents:
107
diff
changeset
|
364 } |
112 | 365 |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
366 class InterfaceDeclaration : AggregateDeclaration |
112 | 367 { |
368 BaseClass[] bases; | |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
369 this(Identifier* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls) |
112 | 370 { |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
371 super(name, tparams, decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
372 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
373 addOptChild(tparams); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
374 addOptChildren(bases); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
375 addOptChild(decls); |
305 | 376 |
112 | 377 this.bases = bases; |
378 } | |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
379 |
590
641041912670
Moved dil.Symbols to dil.semantic.Symbols.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
588
diff
changeset
|
380 alias dil.semantic.Symbols.Interface Interface; |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
381 |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
382 Interface symbol; /// The interface symbol for this declaration. |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
383 |
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
384 override void semantic(Scope scop) |
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
385 { |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
386 if (symbol) |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
387 return; |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
388 symbol = new Interface(name, this); |
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
389 // Insert into current scope. |
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
390 scop.insert(symbol, name); |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
391 // Create a new scope. |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
392 scop = scop.push(symbol); |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
393 // Continue semantic analysis. |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
394 decls && decls.semantic(scop); |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
395 scop.pop(); |
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
396 } |
112 | 397 } |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
398 |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
399 class StructDeclaration : AggregateDeclaration |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
400 { |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
401 uint alignSize; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
402 this(Identifier* name, TemplateParameters tparams, Declarations decls) |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
403 { |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
404 super(name, tparams, decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
405 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
406 addOptChild(tparams); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
407 addOptChild(decls); |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
408 } |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
409 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
410 void setAlignSize(uint alignSize) |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
411 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
412 this.alignSize = alignSize; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
413 } |
565
184a8d8bad2e
Added semantic() to StructDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
414 |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
415 Struct symbol; /// The struct symbol for this declaration. |
565
184a8d8bad2e
Added semantic() to StructDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
416 |
184a8d8bad2e
Added semantic() to StructDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
417 override void semantic(Scope scop) |
184a8d8bad2e
Added semantic() to StructDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
418 { |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
419 if (symbol) |
565
184a8d8bad2e
Added semantic() to StructDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
420 return; |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
421 symbol = new Struct(name, this); |
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
422 // Insert into current scope. |
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
423 scop.insert(symbol, name); |
565
184a8d8bad2e
Added semantic() to StructDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
424 // Create a new scope. |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
425 scop = scop.push(symbol); |
565
184a8d8bad2e
Added semantic() to StructDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
426 // Continue semantic analysis. |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
427 decls && decls.semantic(scop); |
565
184a8d8bad2e
Added semantic() to StructDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
428 scop.pop(); |
184a8d8bad2e
Added semantic() to StructDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
429 } |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
430 } |
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
431 |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
432 class UnionDeclaration : AggregateDeclaration |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
433 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
434 this(Identifier* name, TemplateParameters tparams, Declarations decls) |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
435 { |
571
35a8926253c8
Added AggregateDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
570
diff
changeset
|
436 super(name, tparams, decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
437 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
438 addOptChild(tparams); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
439 addOptChild(decls); |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
440 } |
572
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
441 |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
442 Union symbol; /// The union symbol for this declaration. |
572
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
443 |
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
444 override void semantic(Scope scop) |
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
445 { |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
446 if (symbol) |
572
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
447 return; |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
448 symbol = new Union(name, this); |
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
449 // Insert into current scope. |
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
450 scop.insert(symbol, name); |
572
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
451 // Create a new scope. |
611
6d449e777f5d
Added semantic code to insert symbols into the scope.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
608
diff
changeset
|
452 scop = scop.push(symbol); |
572
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
453 // Continue semantic analysis. |
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
454 decls && decls.semantic(scop); |
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
455 scop.pop(); |
751d84733e07
Added semantic() to UnionDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
571
diff
changeset
|
456 } |
113
20d8ae8a3fd9
- Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents:
112
diff
changeset
|
457 } |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
458 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
459 class ConstructorDeclaration : Declaration |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
460 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
461 Parameters parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
462 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
463 this(Parameters parameters, FunctionBody funcBody) |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
464 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
465 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
466 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
467 addChild(parameters); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
468 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
469 |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
470 this.parameters = parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
471 this.funcBody = funcBody; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
472 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
116
diff
changeset
|
473 } |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
474 |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
475 class StaticConstructorDeclaration : Declaration |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
476 { |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
477 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
478 this(FunctionBody funcBody) |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
479 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
480 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
481 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
482 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
483 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
484 this.funcBody = funcBody; |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
485 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
486 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
487 |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
488 class DestructorDeclaration : Declaration |
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
489 { |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
490 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
491 this(FunctionBody funcBody) |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
492 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
493 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
494 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
495 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
496 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
497 this.funcBody = funcBody; |
118
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
498 } |
379f33cbd521
- Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents:
117
diff
changeset
|
499 } |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
500 |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
501 class StaticDestructorDeclaration : Declaration |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
502 { |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
503 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
504 this(FunctionBody funcBody) |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
505 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
506 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
507 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
508 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
509 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
510 this.funcBody = funcBody; |
119
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
511 } |
363cd39022f9
- Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents:
118
diff
changeset
|
512 } |
120 | 513 |
192 | 514 class FunctionDeclaration : Declaration |
515 { | |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
516 TypeNode returnType; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
517 Identifier* funcName; |
258 | 518 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
|
519 Parameters params; |
192 | 520 FunctionBody funcBody; |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
521 LinkageType linkageType; |
511
aa73f669c298
Renamed class Type to TypeNode.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
505
diff
changeset
|
522 this(TypeNode returnType, Identifier* funcName, TemplateParameters tparams, |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
523 Parameters params, FunctionBody funcBody) |
192 | 524 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
525 super.hasBody = funcBody.funcBody !is null; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
526 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
527 addChild(returnType); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
528 addOptChild(tparams); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
529 addChild(params); |
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 |
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
|
532 this.returnType = returnType; |
192 | 533 this.funcName = funcName; |
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
|
534 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
|
535 this.params = params; |
192 | 536 this.funcBody = funcBody; |
537 } | |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
538 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
539 void setLinkageType(LinkageType linkageType) |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
540 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
541 this.linkageType = linkageType; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
542 } |
192 | 543 } |
544 | |
194 | 545 class VariableDeclaration : Declaration |
546 { | |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
547 TypeNode typeNode; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
548 Identifier*[] idents; |
194 | 549 Expression[] values; |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
550 LinkageType linkageType; |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
551 this(TypeNode typeNode, Identifier*[] idents, Expression[] values) |
194 | 552 { |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
553 // No empty arrays allowed. Both arrays must be of same size. |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
554 assert(idents.length != 0 && idents.length == values.length); |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
555 // If no type (in case of AutoDeclaration), first value mustn't be null. |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
556 assert(typeNode ? 1 : values[0] !is null); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
557 mixin(set_kind); |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
558 addOptChild(typeNode); |
299
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
292
diff
changeset
|
559 foreach(value; values) |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
560 addOptChild(value); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
561 |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
562 this.typeNode = typeNode; |
194 | 563 this.idents = idents; |
564 this.values = values; | |
565 } | |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
566 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
567 void setLinkageType(LinkageType linkageType) |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
568 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
569 this.linkageType = linkageType; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
570 } |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
571 |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
572 Variable[] variables; |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
573 |
563
c838ed7f2ac9
Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
574 override void semantic(Scope scop) |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
575 { |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
576 Type type; |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
577 |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
578 if (typeNode) |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
579 // Get type from typeNode. |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
580 type = typeNode.semantic(scop); |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
581 else |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
582 { // Infer type from first initializer. |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
583 auto firstValue = values[0]; |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
584 firstValue = firstValue.semantic(scop); |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
585 type = firstValue.type; |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
586 } |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
587 assert(type !is null); |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
588 |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
589 // Check for interface. |
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
590 if (scop.isInterface) |
574
ae8f58a13917
Added messages to struct MSG.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
573
diff
changeset
|
591 return scop.error(begin, MSG.InterfaceCantHaveVariables); |
570
3ebdc510a7fc
Added semantic() to InterfaceDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
565
diff
changeset
|
592 |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
593 // Iterate over variable identifiers in this declaration. |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
594 foreach (i, ident; idents) |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
595 { |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
596 // Perform semantic analysis on value. |
564
3c867a683258
Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
563
diff
changeset
|
597 if (values[i]) |
3c867a683258
Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
563
diff
changeset
|
598 values[i] = values[i].semantic(scop); |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
599 // Create a new variable symbol. |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
600 // TODO: pass 'prot' to constructor. |
562
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
601 auto variable = new Variable(stc, linkageType, type, ident, this); |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
602 variables ~= variable; |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
603 // Add to scope. |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
604 scop.insert(variable); |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
605 } |
b0533550d64c
Added semantic() to VariableDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
559
diff
changeset
|
606 } |
194 | 607 } |
608 | |
120 | 609 class InvariantDeclaration : Declaration |
610 { | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
611 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
612 this(FunctionBody funcBody) |
120 | 613 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
614 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
615 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
616 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
617 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
618 this.funcBody = funcBody; |
120 | 619 } |
620 } | |
121 | 621 |
622 class UnittestDeclaration : Declaration | |
623 { | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
624 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
625 this(FunctionBody funcBody) |
121 | 626 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
627 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
628 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
629 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
630 |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
631 this.funcBody = funcBody; |
121 | 632 } |
633 } | |
122 | 634 |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
635 abstract class ConditionalCompilationDeclaration : Declaration |
122 | 636 { |
264 | 637 Token* spec; |
638 Token* cond; | |
305 | 639 Declaration decls, elseDecls; |
122 | 640 |
305 | 641 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
122 | 642 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
643 super.hasBody = decls !is null; |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
644 addOptChild(decls); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
645 addOptChild(elseDecls); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
646 |
264 | 647 this.spec = spec; |
648 this.cond = cond; | |
122 | 649 this.decls = decls; |
650 this.elseDecls = elseDecls; | |
651 } | |
652 } | |
123 | 653 |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
654 class DebugDeclaration : ConditionalCompilationDeclaration |
123 | 655 { |
305 | 656 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls) |
123 | 657 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
658 super(spec, cond, decls, elseDecls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
659 mixin(set_kind); |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
660 } |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
661 } |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
662 |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
663 class VersionDeclaration : ConditionalCompilationDeclaration |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
664 { |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
665 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
|
666 { |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
667 super(spec, cond, decls, elseDecls); |
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
668 mixin(set_kind); |
123 | 669 } |
670 } | |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
671 |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
672 class StaticIfDeclaration : Declaration |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
673 { |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
674 Expression condition; |
305 | 675 Declaration ifDecls, elseDecls; |
676 this(Expression condition, Declaration ifDecls, Declaration elseDecls) | |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
677 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
678 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
679 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
680 addChild(condition); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
681 addOptChild(ifDecls); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
682 addOptChild(elseDecls); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
683 |
125
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
684 this.condition = condition; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
685 this.ifDecls = ifDecls; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
686 this.elseDecls = elseDecls; |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
687 } |
240a8b053803
- Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents:
123
diff
changeset
|
688 } |
127
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
689 |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
690 class StaticAssertDeclaration : Declaration |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
691 { |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
692 Expression condition, message; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
693 this(Expression condition, Expression message) |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
694 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
695 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
696 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
697 addChild(condition); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
698 addOptChild(message); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
699 |
127
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
700 this.condition = condition; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
701 this.message = message; |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
702 } |
cb9a97ebb570
- Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents:
126
diff
changeset
|
703 } |
140 | 704 |
705 class TemplateDeclaration : Declaration | |
706 { | |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
707 Identifier* name; |
292 | 708 TemplateParameters tparams; |
305 | 709 Declarations decls; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
710 this(Identifier* name, TemplateParameters tparams, Declarations decls) |
140 | 711 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
712 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
713 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
714 addOptChild(tparams); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
715 addChild(decls); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
716 |
292 | 717 this.name = name; |
718 this.tparams = tparams; | |
140 | 719 this.decls = decls; |
720 } | |
721 } | |
141 | 722 |
723 class NewDeclaration : Declaration | |
724 { | |
725 Parameters parameters; | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
726 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
727 this(Parameters parameters, FunctionBody funcBody) |
141 | 728 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
729 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
730 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
731 addChild(parameters); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
732 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
733 |
141 | 734 this.parameters = parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
735 this.funcBody = funcBody; |
141 | 736 } |
737 } | |
738 | |
739 class DeleteDeclaration : Declaration | |
740 { | |
741 Parameters parameters; | |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
742 FunctionBody funcBody; |
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
743 this(Parameters parameters, FunctionBody funcBody) |
141 | 744 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
745 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
746 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
747 addChild(parameters); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
748 addChild(funcBody); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
749 |
141 | 750 this.parameters = parameters; |
197
ff32eb87300e
- Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents:
195
diff
changeset
|
751 this.funcBody = funcBody; |
141 | 752 } |
753 } | |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
754 |
149 | 755 class AttributeDeclaration : Declaration |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
756 { |
149 | 757 TOK attribute; |
305 | 758 Declaration decls; |
759 this(TOK attribute, Declaration decls) | |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
760 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
761 super.hasBody = true; |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
762 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
763 addChild(decls); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
764 |
149 | 765 this.attribute = attribute; |
146
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
766 this.decls = decls; |
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
767 } |
8180eb84e69c
- Started implementation of parseAttributeSpecifier().
aziz
parents:
141
diff
changeset
|
768 } |
147 | 769 |
490
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
770 class ProtectionDeclaration : AttributeDeclaration |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
771 { |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
772 Protection prot; |
490
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
773 this(Protection prot, Declaration decls) |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
774 { |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
775 super(cast(TOK)0, decls); |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
776 mixin(set_kind); |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
777 this.prot = prot; |
490
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
778 } |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
779 } |
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
780 |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
781 class StorageClassDeclaration : AttributeDeclaration |
149 | 782 { |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
783 StorageClass storageClass; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
784 this(StorageClass storageClass, TOK tok, Declaration decl) |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
785 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
786 super(tok, decl); |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
787 mixin(set_kind); |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
788 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
789 this.storageClass = storageClass; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
790 } |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
791 } |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
792 |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
793 class LinkageDeclaration : AttributeDeclaration |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
794 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
795 LinkageType linkageType; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
796 this(LinkageType linkageType, Declaration decls) |
149 | 797 { |
798 super(TOK.Extern, decls); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
799 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
800 |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
494
diff
changeset
|
801 this.linkageType = linkageType; |
149 | 802 } |
803 } | |
804 | |
805 class AlignDeclaration : AttributeDeclaration | |
806 { | |
807 int size; | |
305 | 808 this(int size, Declaration decls) |
149 | 809 { |
810 super(TOK.Align, decls); | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
811 mixin(set_kind); |
149 | 812 this.size = size; |
813 } | |
814 } | |
815 | |
816 class PragmaDeclaration : AttributeDeclaration | |
147 | 817 { |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
818 Identifier* ident; |
147 | 819 Expression[] args; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
820 this(Identifier* ident, Expression[] args, Declaration decls) |
147 | 821 { |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
822 addOptChildren(args); // Add args before calling super(). |
149 | 823 super(TOK.Pragma, decls); |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
824 mixin(set_kind); |
396
0a4619735ce9
Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
825 |
147 | 826 this.ident = ident; |
827 this.args = args; | |
828 } | |
559
c4bb948e5cc1
Added semantic code for pragmas.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
511
diff
changeset
|
829 |
563
c838ed7f2ac9
Added 'override' to some methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
562
diff
changeset
|
830 override void semantic(Scope scop) |
559
c4bb948e5cc1
Added semantic code for pragmas.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
511
diff
changeset
|
831 { |
c4bb948e5cc1
Added semantic code for pragmas.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
511
diff
changeset
|
832 pragmaSemantic(scop, begin, ident, args); |
c4bb948e5cc1
Added semantic code for pragmas.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
511
diff
changeset
|
833 decls.semantic(scop); |
c4bb948e5cc1
Added semantic code for pragmas.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
511
diff
changeset
|
834 } |
147 | 835 } |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
836 |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
837 class MixinDeclaration : Declaration |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
838 { |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
839 Expression templateExpr; |
505
3bb94ba21490
Refactored a great amount of code.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
504
diff
changeset
|
840 Identifier* mixinIdent; |
292 | 841 Expression argument; // mixin ( AssignExpression ) |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
842 |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
843 this(Expression templateExpr, Identifier* mixinIdent) |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
844 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
845 mixin(set_kind); |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
846 addChild(templateExpr); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
847 |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
611
diff
changeset
|
848 this.templateExpr = templateExpr; |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
849 this.mixinIdent = mixinIdent; |
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
850 } |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
851 |
292 | 852 this(Expression argument) |
151
2e959f67000b
- Added code for parsing mixin expression declarations.
aziz
parents:
150
diff
changeset
|
853 { |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
275
diff
changeset
|
854 mixin(set_kind); |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
855 addChild(argument); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
486
diff
changeset
|
856 |
292 | 857 this.argument = argument; |
151
2e959f67000b
- Added code for parsing mixin expression declarations.
aziz
parents:
150
diff
changeset
|
858 } |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
149
diff
changeset
|
859 } |