Mercurial > projects > dil
comparison trunk/src/dil/Types.d @ 511:aa73f669c298
Renamed class Type to TypeNode.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Thu, 13 Dec 2007 21:23:41 +0100 |
parents | 3bb94ba21490 |
children | 112c17300069 |
comparison
equal
deleted
inserted
replaced
510:dd3ce87b3569 | 511:aa73f669c298 |
---|---|
11 | 11 |
12 class Parameter : Node | 12 class Parameter : Node |
13 { | 13 { |
14 StorageClass stc; | 14 StorageClass stc; |
15 Token* stcTok; | 15 Token* stcTok; |
16 Type type; | 16 TypeNode type; |
17 Identifier* ident; | 17 Identifier* ident; |
18 Expression assignExpr; | 18 Expression defValue; |
19 | 19 |
20 this(StorageClass stc, Type type, Identifier* ident, Expression assignExpr) | 20 this(StorageClass stc, TypeNode type, Identifier* ident, Expression defValue) |
21 { | 21 { |
22 super(NodeCategory.Other); | 22 super(NodeCategory.Other); |
23 mixin(set_kind); | 23 mixin(set_kind); |
24 // type can be null when param in foreach statement | 24 // type can be null when param in foreach statement |
25 addOptChild(type); | 25 addOptChild(type); |
26 addOptChild(assignExpr); | 26 addOptChild(defValue); |
27 | 27 |
28 this.stc = stc; | 28 this.stc = stc; |
29 this.type = type; | 29 this.type = type; |
30 this.ident = ident; | 30 this.ident = ident; |
31 this.assignExpr = assignExpr; | 31 this.defValue = defValue; |
32 } | 32 } |
33 | 33 |
34 /// func(...) or func(int[] values ...) | 34 /// func(...) or func(int[] values ...) |
35 bool isVariadic() | 35 bool isVariadic() |
36 { | 36 { |
71 } | 71 } |
72 | 72 |
73 class BaseClass : Node | 73 class BaseClass : Node |
74 { | 74 { |
75 Protection prot; | 75 Protection prot; |
76 Type type; | 76 TypeNode type; |
77 this(Protection prot, Type type) | 77 this(Protection prot, TypeNode type) |
78 { | 78 { |
79 super(NodeCategory.Other); | 79 super(NodeCategory.Other); |
80 mixin(set_kind); | 80 mixin(set_kind); |
81 addChild(type); | 81 addChild(type); |
82 this.prot = prot; | 82 this.prot = prot; |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 class TemplateAliasParameter : TemplateParameter | 97 class TemplateAliasParameter : TemplateParameter |
98 { | 98 { |
99 Type specType, defType; | 99 TypeNode specType, defType; |
100 this(Identifier* ident, Type specType, Type defType) | 100 this(Identifier* ident, TypeNode specType, TypeNode defType) |
101 { | 101 { |
102 super(ident); | 102 super(ident); |
103 mixin(set_kind); | 103 mixin(set_kind); |
104 addOptChild(specType); | 104 addOptChild(specType); |
105 addOptChild(defType); | 105 addOptChild(defType); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 class TemplateTypeParameter : TemplateParameter | 112 class TemplateTypeParameter : TemplateParameter |
113 { | 113 { |
114 Type specType, defType; | 114 TypeNode specType, defType; |
115 this(Identifier* ident, Type specType, Type defType) | 115 this(Identifier* ident, TypeNode specType, TypeNode defType) |
116 { | 116 { |
117 super(ident); | 117 super(ident); |
118 mixin(set_kind); | 118 mixin(set_kind); |
119 addOptChild(specType); | 119 addOptChild(specType); |
120 addOptChild(defType); | 120 addOptChild(defType); |
126 | 126 |
127 version(D2) | 127 version(D2) |
128 { | 128 { |
129 class TemplateThisParameter : TemplateParameter | 129 class TemplateThisParameter : TemplateParameter |
130 { | 130 { |
131 Type specType, defType; | 131 TypeNode specType, defType; |
132 this(Identifier* ident, Type specType, Type defType) | 132 this(Identifier* ident, TypeNode specType, TypeNode defType) |
133 { | 133 { |
134 super(ident); | 134 super(ident); |
135 mixin(set_kind); | 135 mixin(set_kind); |
136 addOptChild(specType); | 136 addOptChild(specType); |
137 addOptChild(defType); | 137 addOptChild(defType); |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 class TemplateValueParameter : TemplateParameter | 145 class TemplateValueParameter : TemplateParameter |
146 { | 146 { |
147 Type valueType; | 147 TypeNode valueType; |
148 Expression specValue, defValue; | 148 Expression specValue, defValue; |
149 this(Type valueType, Identifier* ident, Expression specValue, Expression defValue) | 149 this(TypeNode valueType, Identifier* ident, Expression specValue, Expression defValue) |
150 { | 150 { |
151 super(ident); | 151 super(ident); |
152 mixin(set_kind); | 152 mixin(set_kind); |
153 addChild(valueType); | 153 addChild(valueType); |
154 addOptChild(specValue); | 154 addOptChild(specValue); |
225 Idouble = TOK.Idouble, | 225 Idouble = TOK.Idouble, |
226 Ireal = TOK.Ireal, | 226 Ireal = TOK.Ireal, |
227 Cfloat = TOK.Cfloat, | 227 Cfloat = TOK.Cfloat, |
228 Cdouble = TOK.Cdouble, | 228 Cdouble = TOK.Cdouble, |
229 Creal = TOK.Creal, | 229 Creal = TOK.Creal, |
230 Ucent = TOK.Ucent, | |
230 | 231 |
231 Undefined, | 232 Undefined, |
232 Function, | 233 Function, |
233 Delegate, | 234 Delegate, |
234 Pointer, | 235 Pointer, |
241 TemplateInstance, | 242 TemplateInstance, |
242 Const, // D2 | 243 Const, // D2 |
243 Invariant, // D2 | 244 Invariant, // D2 |
244 } | 245 } |
245 | 246 |
246 abstract class Type : Node | 247 abstract class TypeNode : Node |
247 { | 248 { |
248 TID tid; | 249 TID tid; |
249 Type next; | 250 TypeNode next; |
250 | 251 |
251 this(TID tid) | 252 this(TID tid) |
252 { | 253 { |
253 this(tid, null); | 254 this(tid, null); |
254 } | 255 } |
255 | 256 |
256 this(TID tid, Type next) | 257 this(TID tid, TypeNode next) |
257 { | 258 { |
258 super(NodeCategory.Type); | 259 super(NodeCategory.Type); |
259 addOptChild(next); | 260 addOptChild(next); |
260 this.tid = tid; | 261 this.tid = tid; |
261 this.next = next; | 262 this.next = next; |
262 } | 263 } |
263 } | 264 } |
264 | 265 |
265 class IntegralType : Type | 266 class IntegralType : TypeNode |
266 { | 267 { |
267 this(TOK tok) | 268 this(TOK tok) |
268 { | 269 { |
269 super(cast(TID)tok); | 270 super(cast(TID)tok); |
270 mixin(set_kind); | 271 mixin(set_kind); |
271 } | 272 } |
272 } | 273 } |
273 | 274 |
274 class UndefinedType : Type | 275 class UndefinedType : TypeNode |
275 { | 276 { |
276 this() | 277 this() |
277 { | 278 { |
278 super(TID.Undefined); | 279 super(TID.Undefined); |
279 mixin(set_kind); | 280 mixin(set_kind); |
280 } | 281 } |
281 } | 282 } |
282 | 283 |
283 class DotListType : Type | 284 class DotListType : TypeNode |
284 { | 285 { |
285 Type[] dotList; | 286 TypeNode[] dotList; |
286 this(Type[] dotList) | 287 this(TypeNode[] dotList) |
287 { | 288 { |
288 super(TID.DotList); | 289 super(TID.DotList); |
289 mixin(set_kind); | 290 mixin(set_kind); |
290 addChildren(dotList); | 291 addChildren(dotList); |
291 this.dotList = dotList; | 292 this.dotList = dotList; |
292 } | 293 } |
293 } | 294 } |
294 | 295 |
295 class IdentifierType : Type | 296 class IdentifierType : TypeNode |
296 { | 297 { |
297 Identifier* ident; | 298 Identifier* ident; |
298 this(Identifier* ident) | 299 this(Identifier* ident) |
299 { | 300 { |
300 super(TID.Identifier); | 301 super(TID.Identifier); |
301 mixin(set_kind); | 302 mixin(set_kind); |
302 this.ident = ident; | 303 this.ident = ident; |
303 } | 304 } |
304 } | 305 } |
305 | 306 |
306 class DotType : Type | 307 class DotType : TypeNode |
307 { | 308 { |
308 this() | 309 this() |
309 { | 310 { |
310 super(TID.Dot); | 311 super(TID.Dot); |
311 mixin(set_kind); | 312 mixin(set_kind); |
312 } | 313 } |
313 } | 314 } |
314 | 315 |
315 class TypeofType : Type | 316 class TypeofType : TypeNode |
316 { | 317 { |
317 Expression e; | 318 Expression e; |
318 this(Expression e) | 319 this(Expression e) |
319 { | 320 { |
320 this(); | 321 this(); |
332 { | 333 { |
333 return e is null; | 334 return e is null; |
334 } | 335 } |
335 } | 336 } |
336 | 337 |
337 class TemplateInstanceType : Type | 338 class TemplateInstanceType : TypeNode |
338 { | 339 { |
339 Identifier* ident; | 340 Identifier* ident; |
340 TemplateArguments targs; | 341 TemplateArguments targs; |
341 this(Identifier* ident, TemplateArguments targs) | 342 this(Identifier* ident, TemplateArguments targs) |
342 { | 343 { |
346 this.ident = ident; | 347 this.ident = ident; |
347 this.targs = targs; | 348 this.targs = targs; |
348 } | 349 } |
349 } | 350 } |
350 | 351 |
351 class PointerType : Type | 352 class PointerType : TypeNode |
352 { | 353 { |
353 this(Type t) | 354 this(TypeNode t) |
354 { | 355 { |
355 super(TID.Pointer, t); | 356 super(TID.Pointer, t); |
356 mixin(set_kind); | 357 mixin(set_kind); |
357 } | 358 } |
358 } | 359 } |
359 | 360 |
360 class ArrayType : Type | 361 class ArrayType : TypeNode |
361 { | 362 { |
362 Expression e, e2; | 363 Expression e, e2; |
363 Type assocType; | 364 TypeNode assocType; |
364 | 365 |
365 this(Type t) | 366 this(TypeNode t) |
366 { | 367 { |
367 super(TID.Array, t); | 368 super(TID.Array, t); |
368 mixin(set_kind); | 369 mixin(set_kind); |
369 } | 370 } |
370 | 371 |
371 this(Type t, Expression e, Expression e2) | 372 this(TypeNode t, Expression e, Expression e2) |
372 { | 373 { |
373 addChild(e); | 374 addChild(e); |
374 addOptChild(e2); | 375 addOptChild(e2); |
375 this.e = e; | 376 this.e = e; |
376 this.e2 = e2; | 377 this.e2 = e2; |
377 this(t); | 378 this(t); |
378 } | 379 } |
379 | 380 |
380 this(Type t, Type assocType) | 381 this(TypeNode t, TypeNode assocType) |
381 { | 382 { |
382 addChild(assocType); | 383 addChild(assocType); |
383 this.assocType = assocType; | 384 this.assocType = assocType; |
384 this(t); | 385 this(t); |
385 } | 386 } |
386 } | 387 } |
387 | 388 |
388 class FunctionType : Type | 389 class FunctionType : TypeNode |
389 { | 390 { |
390 Type returnType; | 391 TypeNode returnType; |
391 Parameters parameters; | 392 Parameters parameters; |
392 this(Type returnType, Parameters parameters) | 393 this(TypeNode returnType, Parameters parameters) |
393 { | 394 { |
394 super(TID.Function); | 395 super(TID.Function); |
395 mixin(set_kind); | 396 mixin(set_kind); |
396 addChild(returnType); | 397 addChild(returnType); |
397 addChild(parameters); | 398 addChild(parameters); |
398 this.returnType = returnType; | 399 this.returnType = returnType; |
399 this.parameters = parameters; | 400 this.parameters = parameters; |
400 } | 401 } |
401 } | 402 } |
402 | 403 |
403 class DelegateType : Type | 404 class DelegateType : TypeNode |
404 { | 405 { |
405 Type returnType; | 406 TypeNode returnType; |
406 Parameters parameters; | 407 Parameters parameters; |
407 this(Type returnType, Parameters parameters) | 408 this(TypeNode returnType, Parameters parameters) |
408 { | 409 { |
409 super(TID.Delegate); | 410 super(TID.Delegate); |
410 mixin(set_kind); | 411 mixin(set_kind); |
411 addChild(returnType); | 412 addChild(returnType); |
412 addChild(parameters); | 413 addChild(parameters); |
413 this.returnType = returnType; | 414 this.returnType = returnType; |
414 this.parameters = parameters; | 415 this.parameters = parameters; |
415 } | 416 } |
416 } | 417 } |
417 | 418 |
418 class CFuncPointerType : Type | 419 class CFuncPointerType : TypeNode |
419 { | 420 { |
420 Parameters params; | 421 Parameters params; |
421 this(Type type, Parameters params) | 422 this(TypeNode type, Parameters params) |
422 { | 423 { |
423 super(TID.CFuncPointer, type); | 424 super(TID.CFuncPointer, type); |
424 mixin(set_kind); | 425 mixin(set_kind); |
425 addOptChild(params); | 426 addOptChild(params); |
426 } | 427 } |
427 } | 428 } |
428 | 429 |
429 version(D2) | 430 version(D2) |
430 { | 431 { |
431 class ConstType : Type | 432 class ConstType : TypeNode |
432 { | 433 { |
433 this(Type t) | 434 this(TypeNode t) |
434 { | 435 { |
435 // If t is null: cast(const) | 436 // If t is null: cast(const) |
436 super(TID.Const, t); | 437 super(TID.Const, t); |
437 mixin(set_kind); | 438 mixin(set_kind); |
438 } | 439 } |
439 } | 440 } |
440 | 441 |
441 class InvariantType : Type | 442 class InvariantType : TypeNode |
442 { | 443 { |
443 this(Type t) | 444 this(TypeNode t) |
444 { | 445 { |
445 // If t is null: cast(invariant) | 446 // If t is null: cast(invariant) |
446 super(TID.Invariant, t); | 447 super(TID.Invariant, t); |
447 mixin(set_kind); | 448 mixin(set_kind); |
448 } | 449 } |