Mercurial > projects > dil
annotate trunk/src/Types.d @ 269:a416e09c08ea
- Implemented D 2.0 additions.
- Added keyword __traits, TOK.Traits and TraitsExpression.
- Added ForeachRangeStatement, ConstType and InvariantType.
- Fix: avoid infinite loop by calling nT() to skip storage class.
- Fix: don't call nT() in parseVersionDeclaration.parseIdentOrInt().
author | aziz |
---|---|
date | Sat, 04 Aug 2007 18:59:04 +0000 |
parents | 50cc74026ea8 |
children | e8de572e4d01 |
rev | line source |
---|---|
94 | 1 /++ |
2 Author: Aziz Köksal | |
249 | 3 License: GPL3 |
94 | 4 +/ |
5 module Types; | |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
6 import SyntaxTree; |
94 | 7 import Token; |
8 import Expressions; | |
9 | |
159 | 10 enum Linkage |
11 { | |
12 Invalid, | |
13 C, | |
14 Cpp, | |
15 D, | |
16 Windows, | |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
17 Pascal, |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
18 System |
159 | 19 } |
20 | |
95 | 21 enum StorageClass |
22 { | |
23 None = 0, | |
24 Abstract = 1, | |
25 Auto = 1<<2, | |
26 Const = 1<<3, | |
27 Deprecated = 1<<4, | |
28 Extern = 1<<5, | |
29 Final = 1<<6, | |
30 Invariant = 1<<7, | |
31 Override = 1<<8, | |
32 Scope = 1<<9, | |
33 Static = 1<<10, | |
34 Synchronized = 1<<11, | |
35 In = 1<<12, | |
36 Out = 1<<13, | |
37 Ref = 1<<14, | |
38 Lazy = 1<<15, | |
39 Variadic = 1<<16, | |
40 } | |
41 | |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
42 class Parameter : Node |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
43 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
44 StorageClass stc; |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
45 Token* stcTok; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
46 Type type; |
253
4279b638c63e
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
249
diff
changeset
|
47 Token* ident; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
48 Expression assignExpr; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
49 |
253
4279b638c63e
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
249
diff
changeset
|
50 this(Token* stcTok, Type type, Token* ident, Expression assignExpr) |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
51 { |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
52 super(NodeType.Other); |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
53 |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
54 StorageClass stc; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
55 if (stcTok !is null) |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
56 { |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
57 // NB: In D 2.0 StorageClass.In means final/scope/const |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
58 switch (stcTok.type) |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
59 { |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
60 // TODO: D 2.0 invariant/const/final/scope |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
61 case TOK.In: stc = StorageClass.In; break; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
62 case TOK.Out: stc = StorageClass.Out; break; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
63 case TOK.Inout: |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
64 case TOK.Ref: stc = StorageClass.Ref; break; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
65 case TOK.Lazy: stc = StorageClass.Lazy; break; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
66 case TOK.Ellipses: |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
67 stc = StorageClass.Variadic; |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
68 default: |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
69 } |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
70 } |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
71 |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
72 this.stc = stc; |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
73 this.stcTok = stcTok; |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
74 this.type = type; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
75 this.ident = ident; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
76 this.assignExpr = assignExpr; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
77 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
78 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
79 bool isVariadic() |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
80 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
81 return !!(stc & StorageClass.Variadic); |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
82 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
83 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
84 bool isOnlyVariadic() |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
85 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
86 return stc == StorageClass.Variadic; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
87 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
88 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
89 |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
90 class Parameters : Node |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
91 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
92 Parameter[] items; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
93 |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
94 this() |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
95 { |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
96 super(NodeType.Other); |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
97 } |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
240
diff
changeset
|
98 |
117
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
99 bool hasVariadic() |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
100 { |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
101 if (items.length != 0) |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
102 return items[$-1].isVariadic(); |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
103 return false; |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
104 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
105 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
106 void opCatAssign(Parameter param) |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
107 { items ~= param; } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
108 |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
109 size_t length() |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
110 { return items.length; } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
111 } |
79857de26e86
- Moved class Parameter to module Types. Added struct Parameters.
aziz
parents:
106
diff
changeset
|
112 |
158
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
113 |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
114 enum Protection |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
115 { |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
116 None, |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
117 Private = 1, |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
118 Protected = 1<<1, |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
119 Package = 1<<2, |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
120 Public = 1<<3, |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
121 Export = 1<<4 |
158
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
122 } |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
123 |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
124 class BaseClass |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
125 { |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
126 Protection prot; |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
127 Type type; |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
128 this(Protection prot, Type type) |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
129 { |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
130 this.prot = prot; |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
131 this.type = type; |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
132 } |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
133 } |
759f437313f9
- Moved enum Protection and class BaseClass to module Types.
aziz
parents:
154
diff
changeset
|
134 |
137 | 135 enum TP |
136 { | |
137 Type, | |
138 Value, | |
139 Alias, | |
140 Tuple | |
141 } | |
142 | |
255
7ba0229af908
- Fixed parseTemplateArguments. Removed a return path and put the while loop into an if-statement.
aziz
parents:
254
diff
changeset
|
143 class TemplateParameter : Node |
137 | 144 { |
145 TP tp; | |
146 Type valueType; | |
253
4279b638c63e
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
249
diff
changeset
|
147 Token* ident; |
137 | 148 Type specType, defType; |
149 Expression specValue, defValue; | |
253
4279b638c63e
- Changed some string types to Token*. Adapted parser accordingly.
aziz
parents:
249
diff
changeset
|
150 this(TP tp, Type valueType, Token* ident, Type specType, Type defType, Expression specValue, Expression defValue) |
137 | 151 { |
255
7ba0229af908
- Fixed parseTemplateArguments. Removed a return path and put the while loop into an if-statement.
aziz
parents:
254
diff
changeset
|
152 super(NodeType.Other); |
137 | 153 this.tp = tp; |
154 this.valueType = valueType; | |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
137
diff
changeset
|
155 this.ident = ident; |
137 | 156 this.specType = specType; |
157 this.defType = defType; | |
158 this.specValue = specValue; | |
159 this.defValue = defValue; | |
160 } | |
161 } | |
162 | |
258 | 163 class TemplateParameters : Node |
164 { | |
165 TemplateParameter[] params; | |
166 | |
167 this() | |
168 { | |
169 super(NodeType.Other); | |
170 } | |
171 | |
172 void opCatAssign(TemplateParameter parameter) | |
173 { | |
174 params ~= parameter; | |
175 } | |
176 } | |
177 | |
254
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
178 class TemplateArguments : Node |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
179 { |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
180 Node[] args; |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
181 |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
182 this() |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
183 { |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
184 super(NodeType.Other); |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
185 } |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
186 |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
187 void opCatAssign(Node argument) |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
188 { |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
189 args ~= argument; |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
190 } |
eb6e3f1fbfee
- Removed typedef and created a proper TemplateArguments class.
aziz
parents:
253
diff
changeset
|
191 } |
150
753bc07bf3a0
- Forgot to pass ident to constructor of TemplateArgument.
aziz
parents:
137
diff
changeset
|
192 |
135 | 193 enum TID |
194 { | |
195 Void = TOK.Void, | |
196 Char = TOK.Char, | |
197 Wchar = TOK.Wchar, | |
198 Dchar = TOK.Dchar, | |
199 Bool = TOK.Bool, | |
200 Byte = TOK.Byte, | |
201 Ubyte = TOK.Ubyte, | |
202 Short = TOK.Short, | |
203 Ushort = TOK.Ushort, | |
204 Int = TOK.Int, | |
205 Uint = TOK.Uint, | |
206 Long = TOK.Long, | |
207 Ulong = TOK.Ulong, | |
208 Float = TOK.Float, | |
209 Double = TOK.Double, | |
210 Real = TOK.Real, | |
211 Ifloat = TOK.Ifloat, | |
212 Idouble = TOK.Idouble, | |
213 Ireal = TOK.Ireal, | |
214 Cfloat = TOK.Cfloat, | |
215 Cdouble = TOK.Cdouble, | |
216 Creal = TOK.Creal, | |
217 | |
218 Undefined, | |
219 Function, | |
220 Delegate, | |
221 Pointer, | |
222 Array, | |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
223 DotList, |
135 | 224 Identifier, |
225 Typeof, | |
153 | 226 TemplateInstance, |
269 | 227 Const, // D2 |
228 Invariant, // D2 | |
135 | 229 } |
230 | |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
231 class Type : Node |
94 | 232 { |
135 | 233 TID tid; |
95 | 234 Type next; |
235 | |
135 | 236 this(TOK tok) |
237 { | |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
238 this(cast(TID)tok); |
135 | 239 } |
95 | 240 |
135 | 241 this(TID tid) |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
242 { |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
243 this(tid, null); |
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
244 } |
135 | 245 |
246 this(TID tid, Type next) | |
94 | 247 { |
240
deab661906ae
- Classes Declaration, Expression, Statement and Type inherit from Node now.
aziz
parents:
196
diff
changeset
|
248 super(NodeType.Type); |
135 | 249 this.tid = tid; |
95 | 250 this.next = next; |
94 | 251 } |
252 } | |
253 | |
134
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
254 class UndefinedType : Type |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
255 { |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
256 this() |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
257 { |
135 | 258 super(TID.Undefined, null); |
134
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
259 } |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
260 } |
a31aa0d6dd5e
- Added class UndefinedType. Returning it in parseBasicType() when no token matched the basic type list.
aziz
parents:
130
diff
changeset
|
261 |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
262 class DotListType : Type |
153 | 263 { |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
264 Type[] dotList; |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
265 this(Type[] dotList) |
153 | 266 { |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
267 super(TID.DotList, null); |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
268 this.dotList = dotList; |
153 | 269 } |
270 } | |
271 | |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
272 class IdentifierType : Type |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
273 { |
264 | 274 Token* ident; |
275 this(Token* ident) | |
154
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
276 { |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
277 super(TID.Identifier, null); |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
278 this.ident = ident; |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
279 } |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
280 } |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
281 |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
282 class TypeofType : Type |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
283 { |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
284 Expression e; |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
285 this(Expression e) |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
286 { |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
287 super(TID.Typeof, null); |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
288 this.e = e; |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
289 } |
0e7cefb15e43
- Renamed IdentifierListExpression to DotListExpression, and parseIdentifierListExpression() to parseDotListExpression().
aziz
parents:
153
diff
changeset
|
290 } |
95 | 291 |
153 | 292 class TemplateInstanceType : Type |
293 { | |
264 | 294 Token* ident; |
153 | 295 TemplateArguments targs; |
264 | 296 this(Token* ident, TemplateArguments targs) |
153 | 297 { |
298 super(TID.TemplateInstance, null); | |
299 this.ident = ident; | |
300 this.targs = targs; | |
301 } | |
302 } | |
303 | |
95 | 304 class PointerType : Type |
305 { | |
306 this(Type t) | |
307 { | |
135 | 308 super(TID.Pointer, t); |
95 | 309 } |
310 } | |
311 | |
312 class ArrayType : Type | |
313 { | |
106 | 314 Expression e, e2; |
315 Type assocType; | |
316 this(Type t) | |
95 | 317 { |
135 | 318 super(TID.Array, t); |
106 | 319 } |
320 this(Type t, Expression e, Expression e2) | |
321 { | |
322 this(t); | |
95 | 323 this.e = e; |
106 | 324 this.e2 = e2; |
325 } | |
326 this(Type t, Type assocType) | |
327 { | |
328 this(t); | |
329 this.assocType = assocType; | |
95 | 330 } |
331 } | |
100 | 332 |
130 | 333 class FunctionType : Type |
334 { | |
335 Type returnType; | |
336 Parameters parameters; | |
258 | 337 TemplateParameters tparams; |
338 this(Type returnType, Parameters parameters, TemplateParameters tparams = null) | |
130 | 339 { |
135 | 340 super(TID.Function, null); |
130 | 341 this.returnType = returnType; |
342 this.parameters = parameters; | |
196
ea3f66901fa4
- Added code for parsing template parameter lists for functions.
aziz
parents:
159
diff
changeset
|
343 this.tparams = tparams; |
130 | 344 } |
345 } | |
135 | 346 |
347 class DelegateType : Type | |
348 { | |
349 this(Type func) | |
350 { | |
351 super(TID.Delegate, func); | |
352 } | |
353 } | |
269 | 354 |
355 version(D2) | |
356 { | |
357 class ConstType : Type | |
358 { | |
359 this(Type t) | |
360 { | |
361 // If t is null: cast(const) | |
362 super(TID.Const, t); | |
363 } | |
364 } | |
365 | |
366 class InvariantType : Type | |
367 { | |
368 this(Type t) | |
369 { | |
370 // If t is null: cast(invariant) | |
371 super(TID.Invariant, t); | |
372 } | |
373 } | |
374 } // version(D2) |