comparison trunk/src/dil/TypeSystem.d @ 522:812f497b20dc

Added module dil.TypesEnum. Added struct TypeMetaInfo and metaInfoTable array. Added type member to class Expression.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 16 Dec 2007 19:14:21 +0100
parents 112c17300069
children a3f66502ea64
comparison
equal deleted inserted replaced
521:772ffdb18fd4 522:812f497b20dc
3 License: GPL3 3 License: GPL3
4 +/ 4 +/
5 module dil.TypeSystem; 5 module dil.TypeSystem;
6 6
7 import dil.Symbol; 7 import dil.Symbol;
8 import dil.TypesEnum;
8 9
9 abstract class Type : Symbol 10 abstract class Type : Symbol
10 { 11 {
11 Type next; 12 Type next;
13 TYP typ;
14
15 this(){}
16
17 this(Type next, TYP typ)
18 {
19 this.next = next;
20 this.typ = typ;
21 }
12 } 22 }
13 23
14 class TypeBasic : Type 24 class TypeBasic : Type
15 { 25 {
16 26
24 class TypeAArray : Type 34 class TypeAArray : Type
25 { 35 {
26 36
27 } 37 }
28 38
39 class TypeSArray : Type
40 {
41
42 }
43
29 class TypePointer : Type 44 class TypePointer : Type
30 { 45 {
31 46
32 } 47 }
33 48
34 class TypeReference : Type 49 class TypeReference : Type
35 { 50 {
36 51
37 } 52 }
53
54 struct TypeMetaInfo
55 {
56 char mangle; /// Mangle character of the type.
57 size_t size; /// Byte size of the type.
58 }
59
60 static const TypeMetaInfo metaInfoTable[] = [
61 {'?', -1}, // Error
62
63 {'a', 1}, // Char
64 {'u', 2}, // Wchar
65 {'w', 4}, // Dchar
66 {'b', 1}, // Bool
67 {'g', 1}, // Byte
68 {'h', 1}, // Ubyte
69 {'s', 2}, // Short
70 {'t', 2}, // Ushort
71 {'i', 4}, // Int
72 {'k', 4}, // Uint
73 {'l', 8}, // Long
74 {'m', 8}, // Ulong
75 {'?', 16}, // Cent
76 {'?', 16}, // Ucent
77 {'f', 4}, // Float
78 {'d', 8}, // Double
79 {'e', 12}, // Real
80 {'o', 4}, // Ifloat
81 {'p', 8}, // Idouble
82 {'j', 12}, // Ireal
83 {'q', 8}, // Cfloat
84 {'r', 16}, // Cdouble
85 {'c', 24}, // Creal
86 {'v', 1}, // void
87
88 {'n', -1}, // None
89
90 {'A', 8}, // Dynamic array
91 {'G', 8}, // Static array
92 {'H', 8}, // Associative array
93
94 {'E', -1}, // Enum
95 {'S', -1}, // Struct
96 {'C', -1}, // Class
97 {'T', -1}, // Typedef
98 {'F', -1}, // Function
99 {'D', -1}, // Delegate
100 {'P', -1}, // Pointer
101 {'R', -1}, // Reference
102 {'I', -1}, // Identifier
103 {'?', -1}, // Template instance
104 {'B', -1}, // Tuple
105 {'x', -1}, // Const, D2
106 {'y', -1}, // Invariant, D2
107 ];