annotate trunk/src/dil/TypeSystem.d @ 548:faf16f4e7fc8

Added union Value and updated metaInfoTable.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 19 Dec 2007 22:16:26 +0100
parents 0781ac288537
children 709e223a8eb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
526
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
10 import dil.Identifier;
512
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
11
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
12 abstract class Type : Symbol
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
13 {
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
14 Type next;
536
0781ac288537 Added some semantic() methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 527
diff changeset
15 TYP tid; /// The ID of the type.
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
16
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
17 this(){}
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
18
536
0781ac288537 Added some semantic() methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 527
diff changeset
19 this(Type next, TYP tid)
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
20 {
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
21 this.next = next;
536
0781ac288537 Added some semantic() methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 527
diff changeset
22 this.tid = tid;
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
23 }
525
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
24
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
25 TypePointer ptrTo()
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
26 {
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
27 return new TypePointer(this);
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
28 }
527
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
29
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
30 /// Get byte size of this type.
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
31 final size_t sizeOf()
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
32 {
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
33 return MITable.getSize(this);
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
34 }
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
35
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
36 /// Size is not in MITable. Find out via virtual method.
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
37 size_t sizeOf_()
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
38 {
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
39 return sizeOf();
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
40 }
512
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 TypeBasic : Type
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
44 {
525
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
45 this(TYP typ)
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
46 {
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
47 super(null, typ);
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
48 }
512
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
49 }
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
50
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
51 class TypeDArray : Type
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
52 {
526
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
53 this(Type next)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
54 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
55 super(next, TYP.DArray);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
56 }
512
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
57 }
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
58
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
59 class TypeAArray : Type
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
60 {
526
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
61 Type keyType;
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
62 this(Type next, Type keyType)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
63 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
64 super(next, TYP.AArray);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
65 this.keyType = keyType;
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
66 }
512
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
67 }
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
68
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
69 class TypeSArray : Type
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
70 {
526
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
71 size_t dimension;
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
72 this(Type next, size_t dimension)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
73 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
74 super(next, TYP.SArray);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
75 this.dimension = dimension;
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
76 }
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
77 }
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
78
512
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
79 class TypePointer : Type
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
80 {
525
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
81 this(Type next)
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
82 {
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
83 super(next, TYP.Pointer);
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
84 }
512
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
85 }
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
86
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
87 class TypeReference : Type
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
88 {
526
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
89 this(Type next)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
90 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
91 super(next, TYP.Reference);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
92 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
93 }
512
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
94
526
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
95 class EnumType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
96 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
97 this(Type baseType)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
98 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
99 super(baseType, TYP.Enum);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
100 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
101
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
102 Type baseType()
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
103 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
104 return next;
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
105 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
106 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
107
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
108 class StructType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
109 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
110 this()
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
111 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
112 super(null, TYP.Struct);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
113 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
114 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
115
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
116 class ClassType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
117 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
118 this()
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
119 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
120 super(null, TYP.Class);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
121 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
122 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
123
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
124 class TypedefType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
125 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
126 this(Type next)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
127 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
128 super(next, TYP.Typedef);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
129 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
130 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
131
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
132 class FunctionType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
133 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
134 this(Type next)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
135 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
136 super(next, TYP.Function);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
137 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
138 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
139
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
140 class DelegateType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
141 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
142 this(Type next)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
143 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
144 super(next, TYP.Delegate);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
145 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
146 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
147
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
148 class IdentifierType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
149 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
150 Identifier* ident;
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
151 this(Identifier* ident)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
152 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
153 super(null, TYP.Identifier);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
154 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
155 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
156
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
157 class TInstanceType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
158 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
159 this()
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
160 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
161 super(null, TYP.TInstance);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
162 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
163 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
164
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
165 class TupleType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
166 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
167 this(Type next)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
168 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
169 super(next, TYP.Tuple);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
170 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
171 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
172
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
173 class ConstType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
174 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
175 this(Type next)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
176 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
177 super(next, TYP.Const);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
178 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
179 }
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
180
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
181 class InvariantType : Type
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
182 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
183 this(Type next)
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
184 {
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
185 super(next, TYP.Const);
ee22dc0ba82c Added more Type classes to dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 525
diff changeset
186 }
512
112c17300069 Added module dil.TypeSystem.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
diff changeset
187 }
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
188
548
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
189 /// Represents a value related to a type.
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
190 union Value
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
191 {
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
192 void* pvoid;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
193 bool bool_;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
194 dchar dchar_;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
195 long long_;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
196 ulong ulong_;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
197 int int_;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
198 uint uint_;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
199 float float_;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
200 double double_;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
201 real real_;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
202 creal creal_;
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
203 }
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
204
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
205 struct TypeMetaInfo
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
206 {
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
207 char mangle; /// Mangle character of the type.
548
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
208 ushort size; /// Byte size of the type.
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
209 Value* defaultInit; /// Default initialization value.
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
210 }
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
211
527
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
212 struct MITable
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
213 {
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
214 static:
548
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
215 const ushort SIZE_NOT_AVAILABLE = 0; /// Size not available.
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
216 const Value VZERO = {int_:0}; /// Value 0.
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
217 const Value VNULL = {pvoid:null}; /// Value null.
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
218 const Value V0xFF = {dchar_:0xFF}; /// Value 0xFF.
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
219 const Value V0xFFFF = {dchar_:0xFFFF}; /// Value 0xFFFF.
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
220 const Value VFALSE = {bool_:false}; /// Value false.
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
221 const Value VNAN = {float_:float.nan}; /// Value NAN.
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
222 const Value VCNAN = {creal_:creal.nan}; /// Value complex NAN.
527
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
223 private alias SIZE_NOT_AVAILABLE SNA;
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
224 private alias PTR_SIZE PS;
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
225 private const TypeMetaInfo metaInfoTable[] = [
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
226 {'?', SNA}, // Error
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
227
548
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
228 {'a', 1, &V0xFF}, // Char
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
229 {'u', 2, &V0xFFFF}, // Wchar
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
230 {'w', 4, &V0xFFFF}, // Dchar
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
231 {'b', 1, &VFALSE}, // Bool
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
232 {'g', 1, &VZERO}, // Byte
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
233 {'h', 1, &VZERO}, // Ubyte
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
234 {'s', 2, &VZERO}, // Short
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
235 {'t', 2, &VZERO}, // Ushort
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
236 {'i', 4, &VZERO}, // Int
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
237 {'k', 4, &VZERO}, // Uint
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
238 {'l', 8, &VZERO}, // Long
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
239 {'m', 8, &VZERO}, // Ulong
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
240 {'?', 16, &VZERO}, // Cent
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
241 {'?', 16, &VZERO}, // Ucent
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
242 {'f', 4, &VNAN}, // Float
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
243 {'d', 8, &VNAN}, // Double
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
244 {'e', 12, &VNAN}, // Real
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
245 {'o', 4, &VNAN}, // Ifloat
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
246 {'p', 8, &VNAN}, // Idouble
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
247 {'j', 12, &VNAN}, // Ireal
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
248 {'q', 8, &VCNAN}, // Cfloat
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
249 {'r', 16, &VCNAN}, // Cdouble
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
250 {'c', 24, &VCNAN}, // Creal
527
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
251 {'v', 1}, // void
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
252
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
253 {'n', SNA}, // None
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
254
548
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
255 {'A', PS*2, &VNULL}, // Dynamic array
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
256 {'G', PS*2, &VNULL}, // Static array
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
257 {'H', PS*2, &VNULL}, // Associative array
522
812f497b20dc Added module dil.TypesEnum.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 512
diff changeset
258
527
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
259 {'E', SNA}, // Enum
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
260 {'S', SNA}, // Struct
548
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
261 {'C', PS, &VNULL}, // Class
527
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
262 {'T', SNA}, // Typedef
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
263 {'F', PS}, // Function
548
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
264 {'D', PS*2, &VNULL}, // Delegate
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
265 {'P', PS, &VNULL}, // Pointer
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
266 {'R', PS, &VNULL}, // Reference
527
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
267 {'I', SNA}, // Identifier
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
268 {'?', SNA}, // Template instance
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
269 {'B', SNA}, // Tuple
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
270 {'x', SNA}, // Const, D2
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
271 {'y', SNA}, // Invariant, D2
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
272 ];
548
faf16f4e7fc8 Added union Value and updated metaInfoTable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 536
diff changeset
273 static assert(metaInfoTable.length == TYP.max+1);
527
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
274
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
275 size_t getSize(Type type)
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
276 {
536
0781ac288537 Added some semantic() methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 527
diff changeset
277 auto size = metaInfoTable[type.tid].size;
527
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
278 if (size == SIZE_NOT_AVAILABLE)
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
279 return type.sizeOf_();
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
280 return size;
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
281 }
c8c3aec130f7 Added struct MITable.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 526
diff changeset
282 }
525
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
283
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
284 /// 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
285 struct Types
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
286 {
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
287 static:
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
288 TypeBasic Char, Wchar, Dchar, Bool,
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
289 Byte, Ubyte, Short, Ushort,
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
290 Int, Uint, Long, Ulong,
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
291 Cent, Ucent,
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
292 Float, Double, Real,
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
293 Ifloat, Idouble, Ireal,
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
294 Cfloat, Cdouble, Creal, Void;
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
295
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
296 TypeBasic Size_t, Ptrdiff_t;
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
297 TypePointer Void_ptr;
536
0781ac288537 Added some semantic() methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 527
diff changeset
298 TypeBasic Undefined;
525
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
299
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
300 /// 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
301 template newTB(char[] typeName)
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
302 {
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
303 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
304 }
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
305
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
306 static this()
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
307 {
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
308 newTB!("Char");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
309 newTB!("Wchar");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
310 newTB!("Dchar");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
311 newTB!("Bool");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
312 newTB!("Byte");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
313 newTB!("Ubyte");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
314 newTB!("Short");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
315 newTB!("Ushort");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
316 newTB!("Int");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
317 newTB!("Uint");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
318 newTB!("Long");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
319 newTB!("Ulong");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
320 newTB!("Cent");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
321 newTB!("Ucent");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
322 newTB!("Float");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
323 newTB!("Double");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
324 newTB!("Real");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
325 newTB!("Ifloat");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
326 newTB!("Idouble");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
327 newTB!("Ireal");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
328 newTB!("Cfloat");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
329 newTB!("Cdouble");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
330 newTB!("Creal");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
331 newTB!("Void");
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
332 version(X86_64)
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
333 {
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
334 Size_t = Ulong;
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
335 Ptrdiff_t = Long;
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
336 }
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
337 else
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
338 {
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
339 Size_t = Uint;
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
340 Ptrdiff_t = Int;
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
341 }
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
342 Void_ptr = Void.ptrTo;
536
0781ac288537 Added some semantic() methods.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 527
diff changeset
343 Undefined = new TypeBasic(TYP.Error);
525
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
344 }
a3f66502ea64 Added struct Types with pre-defined types.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 522
diff changeset
345 }