Mercurial > projects > dil
comparison trunk/src/dil/TypeSystem.d @ 536:0781ac288537
Added some semantic() methods.
Renamed member typ of dil.TypeSystem.Type to tid.
Added 'Undefined' to struct Types.
Removed charLiteral and added 'dchar character' to class CharExpression.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Tue, 18 Dec 2007 15:14:41 +0100 |
parents | c8c3aec130f7 |
children | faf16f4e7fc8 |
comparison
equal
deleted
inserted
replaced
535:bdd49ad84f5f | 536:0781ac288537 |
---|---|
10 import dil.Identifier; | 10 import dil.Identifier; |
11 | 11 |
12 abstract class Type : Symbol | 12 abstract class Type : Symbol |
13 { | 13 { |
14 Type next; | 14 Type next; |
15 TYP typ; | 15 TYP tid; /// The ID of the type. |
16 | 16 |
17 this(){} | 17 this(){} |
18 | 18 |
19 this(Type next, TYP typ) | 19 this(Type next, TYP tid) |
20 { | 20 { |
21 this.next = next; | 21 this.next = next; |
22 this.typ = typ; | 22 this.tid = tid; |
23 } | 23 } |
24 | 24 |
25 TypePointer ptrTo() | 25 TypePointer ptrTo() |
26 { | 26 { |
27 return new TypePointer(this); | 27 return new TypePointer(this); |
247 {'y', SNA}, // Invariant, D2 | 247 {'y', SNA}, // Invariant, D2 |
248 ]; | 248 ]; |
249 | 249 |
250 size_t getSize(Type type) | 250 size_t getSize(Type type) |
251 { | 251 { |
252 auto size = metaInfoTable[type.typ].size; | 252 auto size = metaInfoTable[type.tid].size; |
253 if (size == SIZE_NOT_AVAILABLE) | 253 if (size == SIZE_NOT_AVAILABLE) |
254 return type.sizeOf_(); | 254 return type.sizeOf_(); |
255 return size; | 255 return size; |
256 } | 256 } |
257 } | 257 } |
268 Ifloat, Idouble, Ireal, | 268 Ifloat, Idouble, Ireal, |
269 Cfloat, Cdouble, Creal, Void; | 269 Cfloat, Cdouble, Creal, Void; |
270 | 270 |
271 TypeBasic Size_t, Ptrdiff_t; | 271 TypeBasic Size_t, Ptrdiff_t; |
272 TypePointer Void_ptr; | 272 TypePointer Void_ptr; |
273 TypeBasic Undefined; | |
273 | 274 |
274 /// Allocates an instance of TypeBasic and assigns it to typeName. | 275 /// Allocates an instance of TypeBasic and assigns it to typeName. |
275 template newTB(char[] typeName) | 276 template newTB(char[] typeName) |
276 { | 277 { |
277 const TypeBasic newTB = mixin(typeName~" = new TypeBasic(TYP."~typeName~")"); | 278 const TypeBasic newTB = mixin(typeName~" = new TypeBasic(TYP."~typeName~")"); |
312 { | 313 { |
313 Size_t = Uint; | 314 Size_t = Uint; |
314 Ptrdiff_t = Int; | 315 Ptrdiff_t = Int; |
315 } | 316 } |
316 Void_ptr = Void.ptrTo; | 317 Void_ptr = Void.ptrTo; |
317 } | 318 Undefined = new TypeBasic(TYP.Error); |
318 } | 319 } |
320 } |