Mercurial > projects > dil
annotate trunk/src/dil/TypeSystem.d @ 525:a3f66502ea64
Added struct Types with pre-defined types.
Added PTR_SIZE to dil.CompilerInfo.
Fixed size of some types in metaInfoTable.
Moved Cent and Ucent in a few places in enum TOK.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sun, 16 Dec 2007 21:24:54 +0100 |
parents | 812f497b20dc |
children | ee22dc0ba82c |
rev | line source |
---|---|
512
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
1 /++ |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
2 Author: Aziz Köksal |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
3 License: GPL3 |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
4 +/ |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
5 module dil.TypeSystem; |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
6 |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
7 import dil.Symbol; |
522
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
8 import dil.TypesEnum; |
525
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
9 import dil.CompilerInfo; |
512
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
10 |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
11 abstract class Type : Symbol |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
12 { |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
13 Type next; |
522
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
14 TYP typ; |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
15 |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
16 this(){} |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
17 |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
18 this(Type next, TYP typ) |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
19 { |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
20 this.next = next; |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
21 this.typ = typ; |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
22 } |
525
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
23 |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
24 TypePointer ptrTo() |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
25 { |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
26 return new TypePointer(this); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
27 } |
512
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
28 } |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
29 |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
30 class TypeBasic : Type |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
31 { |
525
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
32 this(TYP typ) |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
33 { |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
34 super(null, typ); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
35 } |
512
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
36 } |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
37 |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
38 class TypeDArray : Type |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
39 { |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
40 |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
41 } |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
42 |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
43 class TypeAArray : Type |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
44 { |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
45 |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
46 } |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
47 |
522
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
48 class TypeSArray : Type |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
49 { |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
50 |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
51 } |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
52 |
512
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
53 class TypePointer : Type |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
54 { |
525
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
55 this(Type next) |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
56 { |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
57 super(next, TYP.Pointer); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
58 } |
512
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
59 } |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
60 |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
61 class TypeReference : Type |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
62 { |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
63 |
112c17300069
Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff
changeset
|
64 } |
522
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
65 |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
66 struct TypeMetaInfo |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
67 { |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
68 char mangle; /// Mangle character of the type. |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
69 size_t size; /// Byte size of the type. |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
70 } |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
71 |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
72 static const TypeMetaInfo metaInfoTable[] = [ |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
73 {'?', -1}, // Error |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
74 |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
75 {'a', 1}, // Char |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
76 {'u', 2}, // Wchar |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
77 {'w', 4}, // Dchar |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
78 {'b', 1}, // Bool |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
79 {'g', 1}, // Byte |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
80 {'h', 1}, // Ubyte |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
81 {'s', 2}, // Short |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
82 {'t', 2}, // Ushort |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
83 {'i', 4}, // Int |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
84 {'k', 4}, // Uint |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
85 {'l', 8}, // Long |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
86 {'m', 8}, // Ulong |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
87 {'?', 16}, // Cent |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
88 {'?', 16}, // Ucent |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
89 {'f', 4}, // Float |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
90 {'d', 8}, // Double |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
91 {'e', 12}, // Real |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
92 {'o', 4}, // Ifloat |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
93 {'p', 8}, // Idouble |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
94 {'j', 12}, // Ireal |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
95 {'q', 8}, // Cfloat |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
96 {'r', 16}, // Cdouble |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
97 {'c', 24}, // Creal |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
98 {'v', 1}, // void |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
99 |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
100 {'n', -1}, // None |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
101 |
525
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
102 {'A', PTR_SIZE*2}, // Dynamic array |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
103 {'G', PTR_SIZE*2}, // Static array |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
104 {'H', PTR_SIZE*2}, // Associative array |
522
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
105 |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
106 {'E', -1}, // Enum |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
107 {'S', -1}, // Struct |
525
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
108 {'C', PTR_SIZE}, // Class |
522
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
109 {'T', -1}, // Typedef |
525
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
110 {'F', PTR_SIZE}, // Function |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
111 {'D', PTR_SIZE*2}, // Delegate |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
112 {'P', PTR_SIZE}, // Pointer |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
113 {'R', PTR_SIZE}, // Reference |
522
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
114 {'I', -1}, // Identifier |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
115 {'?', -1}, // Template instance |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
116 {'B', -1}, // Tuple |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
117 {'x', -1}, // Const, D2 |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
118 {'y', -1}, // Invariant, D2 |
812f497b20dc
Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
512
diff
changeset
|
119 ]; |
525
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
120 |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
121 /// A set of pre-defined types. |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
122 struct Types |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
123 { |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
124 static: |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
125 TypeBasic Char, Wchar, Dchar, Bool, |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
126 Byte, Ubyte, Short, Ushort, |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
127 Int, Uint, Long, Ulong, |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
128 Cent, Ucent, |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
129 Float, Double, Real, |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
130 Ifloat, Idouble, Ireal, |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
131 Cfloat, Cdouble, Creal, Void; |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
132 |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
133 TypeBasic Size_t, Ptrdiff_t; |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
134 TypePointer Void_ptr; |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
135 |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
136 /// Allocates an instance of TypeBasic and assigns it to typeName. |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
137 template newTB(char[] typeName) |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
138 { |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
139 const TypeBasic newTB = mixin(typeName~" = new TypeBasic(TYP."~typeName~")"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
140 } |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
141 |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
142 static this() |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
143 { |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
144 newTB!("Char"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
145 newTB!("Wchar"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
146 newTB!("Dchar"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
147 newTB!("Bool"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
148 newTB!("Byte"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
149 newTB!("Ubyte"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
150 newTB!("Short"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
151 newTB!("Ushort"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
152 newTB!("Int"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
153 newTB!("Uint"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
154 newTB!("Long"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
155 newTB!("Ulong"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
156 newTB!("Cent"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
157 newTB!("Ucent"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
158 newTB!("Float"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
159 newTB!("Double"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
160 newTB!("Real"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
161 newTB!("Ifloat"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
162 newTB!("Idouble"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
163 newTB!("Ireal"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
164 newTB!("Cfloat"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
165 newTB!("Cdouble"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
166 newTB!("Creal"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
167 newTB!("Void"); |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
168 version(X86_64) |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
169 { |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
170 Size_t = Ulong; |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
171 Ptrdiff_t = Long; |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
172 } |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
173 else |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
174 { |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
175 Size_t = Uint; |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
176 Ptrdiff_t = Int; |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
177 } |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
178 Void_ptr = Void.ptrTo; |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
179 } |
a3f66502ea64
Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
522
diff
changeset
|
180 } |