Mercurial > projects > ddmd
annotate dmd/Type.d @ 110:12c0c84d13fd
merged in 2.036 changes
author | Trass3r |
---|---|
date | Tue, 31 Aug 2010 22:29:00 +0200 |
parents | 5c859d5fbe27 3a0b150c9841 |
children | 3482c73a991b |
rev | line source |
---|---|
0 | 1 module dmd.Type; |
2 | |
3 import dmd.TY; | |
4 import dmd.Argument; | |
5 import dmd.TOK; | |
6 import dmd.STC; | |
7 import dmd.TypeArray; | |
8 import dmd.DotVarExp; | |
9 import dmd.ErrorExp; | |
10 import dmd.StringExp; | |
11 import dmd.IntegerExp; | |
12 import dmd.VarExp; | |
13 import dmd.TemplateParameter; | |
14 import dmd.TypeInfoSharedDeclaration; | |
15 import dmd.TypeInfoConstDeclaration; | |
16 import dmd.TypeInfoInvariantDeclaration; | |
17 import dmd.Module; | |
18 import dmd.Id; | |
19 import dmd.Util; | |
20 import dmd.VarDeclaration; | |
21 import dmd.Loc; | |
22 import dmd.Scope; | |
23 import dmd.OutBuffer; | |
24 import dmd.Identifier; | |
25 import dmd.HdrGenState; | |
26 import dmd.Expression; | |
27 import dmd.Dsymbol; | |
28 import dmd.MATCH; | |
29 import dmd.TypeInfoDeclaration; | |
30 import dmd.ClassDeclaration; | |
31 import dmd.StringTable; | |
32 import dmd.ArrayTypes; | |
33 import dmd.TypeBasic; | |
34 import dmd.DYNCAST; | |
35 import dmd.MOD; | |
36 import dmd.Lexer; | |
37 import dmd.TypeSArray; | |
38 import dmd.TypeDArray; | |
39 import dmd.TypeAArray; | |
40 import dmd.TypePointer; | |
41 import dmd.TypeReference; | |
42 import dmd.TypeFunction; | |
43 import dmd.TypeDelegate; | |
44 import dmd.TypeIdentifier; | |
45 import dmd.TypeInstance; | |
46 import dmd.TypeTypeof; | |
47 import dmd.TypeReturn; | |
48 import dmd.TypeStruct; | |
49 import dmd.TypeEnum; | |
50 import dmd.TypeTypedef; | |
51 import dmd.TypeClass; | |
52 import dmd.TypeTuple; | |
53 import dmd.TypeSlice; | |
54 import dmd.Global; | |
55 import dmd.StringValue; | |
56 | |
57 import dmd.backend.Symbol; | |
58 import dmd.backend.TYPE; | |
59 import dmd.backend.dt_t; | |
60 import dmd.backend.Util; | |
61 import dmd.backend.TYM; | |
62 import dmd.backend.mTY; | |
63 | |
64 import core.stdc.stdio; | |
65 | |
4 | 66 import core.memory; |
2 | 67 |
0 | 68 /* These have default values for 32 bit code, they get |
69 * adjusted for 64 bit code. | |
70 */ | |
71 | |
72 int PTRSIZE = 4; | |
73 | |
74 int Tsize_t; | |
75 int Tptrdiff_t; | |
76 | |
77 /* REALSIZE = size a real consumes in memory | |
78 * REALPAD = 'padding' added to the CPU real size to bring it up to REALSIZE | |
79 * REALALIGNSIZE = alignment for reals | |
80 */ | |
81 version (TARGET_OSX) { | |
82 int REALSIZE = 16; | |
83 int REALPAD = 6; | |
84 int REALALIGNSIZE = 16; | |
22
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
20
diff
changeset
|
85 } else version (POSIX) { /// TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS |
0 | 86 int REALSIZE = 12; |
87 int REALPAD = 2; | |
88 int REALALIGNSIZE = 4; | |
89 } else { | |
90 int REALSIZE = 10; | |
91 int REALPAD = 0; | |
92 int REALALIGNSIZE = 2; | |
93 } | |
94 | |
95 /**** | |
96 * Given an identifier, figure out which TemplateParameter it is. | |
97 * Return -1 if not found. | |
98 */ | |
99 | |
100 int templateIdentifierLookup(Identifier id, TemplateParameters parameters) | |
101 { | |
102 for (size_t i = 0; i < parameters.dim; i++) | |
103 { | |
104 TemplateParameter tp = cast(TemplateParameter)parameters.data[i]; | |
105 | |
106 if (tp.ident.equals(id)) | |
107 return i; | |
108 } | |
109 return -1; | |
110 } | |
111 | |
112 int templateParameterLookup(Type tparam, TemplateParameters parameters) | |
113 { | |
114 assert(tparam.ty == Tident); | |
115 TypeIdentifier tident = cast(TypeIdentifier)tparam; | |
116 //printf("\ttident = '%s'\n", tident.toChars()); | |
117 if (tident.idents.dim == 0) | |
118 { | |
119 return templateIdentifierLookup(tident.ident, parameters); | |
120 } | |
121 return -1; | |
122 } | |
123 | |
124 class Type | |
125 { | |
126 TY ty; | |
127 MOD mod; // modifiers MODxxxx | |
128 /* pick this order of numbers so switch statements work better | |
129 */ | |
130 /// #define MODconst 1 // type is const | |
95 | 131 /// #define MODinvariant 4 // type is immutable |
132 /// #define MODimmutable 4 // type is immutable | |
0 | 133 /// #define MODshared 2 // type is shared |
134 string deco; | |
135 | |
136 /* These are cached values that are lazily evaluated by constOf(), invariantOf(), etc. | |
137 * They should not be referenced by anybody but mtype.c. | |
138 * They can be null if not lazily evaluated yet. | |
139 * Note that there is no "shared immutable", because that is just immutable | |
140 */ | |
141 | |
142 Type cto; // MODconst ? mutable version of this type : const version | |
143 Type ito; // MODinvariant ? mutable version of this type : invariant version | |
144 Type sto; // MODshared ? mutable version of this type : shared mutable version | |
145 Type scto; // MODshared|MODconst ? mutable version of this type : shared const version | |
146 | |
147 Type pto; // merged pointer to this type | |
148 Type rto; // reference to this type | |
149 Type arrayof; // array of this type | |
150 TypeInfoDeclaration vtinfo; // TypeInfo object for this Type | |
151 | |
152 type* ctype; // for back end | |
153 | |
154 static ClassDeclaration typeinfo; | |
155 static ClassDeclaration typeinfoclass; | |
156 static ClassDeclaration typeinfointerface; | |
157 static ClassDeclaration typeinfostruct; | |
158 static ClassDeclaration typeinfotypedef; | |
159 static ClassDeclaration typeinfopointer; | |
160 static ClassDeclaration typeinfoarray; | |
161 static ClassDeclaration typeinfostaticarray; | |
162 static ClassDeclaration typeinfoassociativearray; | |
163 static ClassDeclaration typeinfoenum; | |
164 static ClassDeclaration typeinfofunction; | |
165 static ClassDeclaration typeinfodelegate; | |
166 static ClassDeclaration typeinfotypelist; | |
167 static ClassDeclaration typeinfoconst; | |
168 static ClassDeclaration typeinfoinvariant; | |
169 static ClassDeclaration typeinfoshared; | |
170 | |
171 static Type basic[TY.TMAX]; | |
172 static ubyte mangleChar[TY.TMAX]; | |
173 static ubyte sizeTy[TY.TMAX]; | |
174 static StringTable stringtable; | |
175 | |
176 // These tables are for implicit conversion of binary ops; | |
177 // the indices are the type of operand one, followed by operand two. | |
178 static ubyte impcnvResult[TY.TMAX][TY.TMAX] = [ | |
179 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
180 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
181 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
182 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
183 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
184 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
185 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
186 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
187 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
188 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
189 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
190 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
191 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
192 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
193 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
194 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,19,37,37,37,37,37,37,37,37,37], | |
195 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,19,37,37,37,37,37,37,37,37,37], | |
196 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,19,37,37,37,37,37,37,37,37,37], | |
197 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,19,37,37,37,37,37,37,37,37,37], | |
198 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,19,37,37,37,37,37,37,37,37,37], | |
199 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,20,20,20,20,20,20,21,22,23,24,25,23,24,25,29,30,31,37,20,37,37,37,37,37,37,37,37,37], | |
200 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,21,21,21,21,21,21,21,22,23,24,25,23,24,25,29,30,31,37,21,37,37,37,37,37,37,37,37,37], | |
201 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,22,22,22,22,22,22,22,22,23,24,25,23,24,25,29,30,31,37,22,37,37,37,37,37,37,37,37,37], | |
202 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,23,24,25,29,30,31,37,23,37,37,37,37,37,37,37,37,37], | |
203 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,24,24,25,30,30,31,37,24,37,37,37,37,37,37,37,37,37], | |
204 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,25,25,25,31,31,31,37,25,37,37,37,37,37,37,37,37,37], | |
205 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,26,27,28,29,30,31,37,23,37,37,37,37,37,37,37,37,37], | |
206 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,27,27,28,30,30,31,37,24,37,37,37,37,37,37,37,37,37], | |
207 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,28,28,28,31,31,31,37,25,37,37,37,37,37,37,37,37,37], | |
208 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,29,29,29,29,29,29,29,29,29,30,31,29,30,31,29,30,31,37,29,37,37,37,37,37,37,37,37,37], | |
209 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,30,30,30,30,30,30,30,30,30,30,31,30,30,31,30,30,31,37,30,37,37,37,37,37,37,37,37,37], | |
210 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,37,31,37,37,37,37,37,37,37,37,37], | |
211 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
212 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,29,30,31,37,33,37,37,37,37,37,37,37,37,37], | |
213 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
214 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
215 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
216 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
217 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
218 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
219 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
220 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
221 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
222 ]; | |
223 | |
224 static ubyte impcnvType1[TY.TMAX][TY.TMAX] = [ | |
225 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
226 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
227 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
228 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
229 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
230 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
231 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
232 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
233 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
234 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
235 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
236 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
237 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
238 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
239 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
240 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,19,37,37,37,37,37,37,37,37,37], | |
241 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,19,37,37,37,37,37,37,37,37,37], | |
242 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,19,37,37,37,37,37,37,37,37,37], | |
243 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,19,37,37,37,37,37,37,37,37,37], | |
244 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,19,37,37,37,37,37,37,37,37,37], | |
245 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,20,20,20,20,20,20,21,22,23,24,25,23,24,25,23,24,25,37,20,37,37,37,37,37,37,37,37,37], | |
246 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,21,21,21,21,21,21,21,22,23,24,25,23,24,25,23,24,25,37,21,37,37,37,37,37,37,37,37,37], | |
247 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,22,22,22,22,22,22,22,22,23,24,25,23,24,25,23,24,25,37,22,37,37,37,37,37,37,37,37,37], | |
248 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,23,24,25,23,24,25,37,23,37,37,37,37,37,37,37,37,37], | |
249 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,24,24,25,24,24,25,37,24,37,37,37,37,37,37,37,37,37], | |
250 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,37,25,37,37,37,37,37,37,37,37,37], | |
251 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,26,26,26,26,26,26,26,26,26,27,28,26,27,28,26,27,28,37,26,37,37,37,37,37,37,37,37,37], | |
252 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,27,27,27,27,27,27,27,27,27,27,28,27,27,28,27,27,28,37,27,37,37,37,37,37,37,37,37,37], | |
253 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,37,28,37,37,37,37,37,37,37,37,37], | |
254 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,29,29,29,29,29,29,29,29,29,30,31,29,30,31,29,30,31,37,29,37,37,37,37,37,37,37,37,37], | |
255 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,30,30,30,30,30,30,30,30,30,30,31,30,30,31,30,30,31,37,30,37,37,37,37,37,37,37,37,37], | |
256 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,37,31,37,37,37,37,37,37,37,37,37], | |
257 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
258 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,23,24,25,23,24,25,37,33,37,37,37,37,37,37,37,37,37], | |
259 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
260 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
261 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
262 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
263 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
264 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
265 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
266 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
267 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
268 ]; | |
269 | |
270 static ubyte impcnvType2[TY.TMAX][TY.TMAX] = [ | |
271 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
272 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
273 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
274 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
275 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
276 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
277 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
278 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
279 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
280 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
281 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
282 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
283 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
284 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
285 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
286 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,19,37,37,37,37,37,37,37,37,37], | |
287 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,19,37,37,37,37,37,37,37,37,37], | |
288 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,19,37,37,37,37,37,37,37,37,37], | |
289 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,19,37,37,37,37,37,37,37,37,37], | |
290 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,19,37,37,37,37,37,37,37,37,37], | |
291 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,20,20,20,20,20,20,21,22,23,24,25,26,27,28,29,30,31,37,20,37,37,37,37,37,37,37,37,37], | |
292 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,21,21,21,21,21,21,21,22,23,24,25,26,27,28,29,30,31,37,21,37,37,37,37,37,37,37,37,37], | |
293 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,22,22,22,22,22,22,22,22,23,24,25,26,27,28,29,30,31,37,22,37,37,37,37,37,37,37,37,37], | |
294 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,26,27,28,29,30,31,37,23,37,37,37,37,37,37,37,37,37], | |
295 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,27,27,28,30,30,31,37,24,37,37,37,37,37,37,37,37,37], | |
296 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,28,28,28,31,31,31,37,25,37,37,37,37,37,37,37,37,37], | |
297 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,26,27,28,29,30,31,37,23,37,37,37,37,37,37,37,37,37], | |
298 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,27,27,28,30,30,31,37,24,37,37,37,37,37,37,37,37,37], | |
299 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,28,28,28,31,31,31,37,25,37,37,37,37,37,37,37,37,37], | |
300 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,23,23,23,23,23,23,23,23,23,24,25,26,27,28,29,30,31,37,23,37,37,37,37,37,37,37,37,37], | |
301 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,24,24,24,24,24,24,24,24,24,24,25,27,27,28,30,30,31,37,24,37,37,37,37,37,37,37,37,37], | |
302 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,25,25,25,25,25,25,25,25,25,25,25,28,28,28,31,31,31,37,25,37,37,37,37,37,37,37,37,37], | |
303 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
304 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,19,19,19,19,19,20,21,22,23,24,25,26,27,28,29,30,31,37,33,37,37,37,37,37,37,37,37,37], | |
305 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
306 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
307 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
308 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
309 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
310 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
311 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
312 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
313 [37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37], | |
314 ]; | |
315 | |
316 // If !=0, give warning on implicit conversion | |
317 static const(bool) impcnvWarn[TY.TMAX][TY.TMAX] = [ | |
318 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
319 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
320 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
321 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
322 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
323 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
324 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
325 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
326 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
327 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
328 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
329 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
330 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
331 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
332 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
333 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0], | |
334 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
335 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0], | |
336 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0], | |
337 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0], | |
338 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0], | |
339 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0], | |
340 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0], | |
341 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
342 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
343 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
344 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
345 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
346 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
347 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
348 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
349 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
350 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
351 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
352 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
353 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
354 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
355 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
356 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
357 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
358 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
359 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
360 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | |
361 ]; | |
362 | |
363 static this() | |
364 { | |
365 stringtable = new StringTable(); | |
366 } | |
367 | |
368 static ~this() | |
369 { | |
370 delete stringtable; | |
371 } | |
372 | |
373 this(TY ty) | |
374 { | |
375 this.ty = ty; | |
376 } | |
377 | |
378 Type syntaxCopy() | |
379 { | |
380 assert(false); | |
381 } | |
382 | |
45 | 383 bool equals(Object o) |
0 | 384 { |
385 Type t = cast(Type)o; | |
386 //printf("Type.equals(%s, %s)\n", toChars(), t.toChars()); | |
387 if (this is o || (t && deco == t.deco) && // deco strings are unique | |
388 deco !is null) // and semantic() has been run | |
389 { | |
390 //printf("deco = '%s', t.deco = '%s'\n", deco, t.deco); | |
391 return 1; | |
392 } | |
393 //if (deco && t && t.deco) printf("deco = '%s', t.deco = '%s'\n", deco, t.deco); | |
394 return 0; | |
395 } | |
396 | |
397 DYNCAST dyncast() { return DYNCAST.DYNCAST_TYPE; } // kludge for template.isType() | |
398 | |
399 /******************************* | |
98 | 400 * Covariant means that 'this' can substitute for 't'. |
0 | 401 * Returns: |
402 * 0 types are distinct | |
403 * 1 this is covariant with t | |
404 * 2 arguments match as far as overloading goes, | |
405 * but types are not covariant | |
406 * 3 cannot determine covariance because of forward references | |
407 */ | |
408 int covariant(Type t) | |
409 { | |
79 | 410 static if (false) |
411 { | |
0 | 412 printf("Type.covariant(t = %s) %s\n", t.toChars(), toChars()); |
413 printf("deco = %p, %p\n", deco, t.deco); | |
414 // printf("ty = %d\n", next.ty); | |
415 printf("mod = %x, %x\n", mod, t.mod); | |
416 } | |
417 | |
418 int inoutmismatch = 0; | |
419 | |
420 TypeFunction t1; | |
421 TypeFunction t2; | |
422 | |
423 if (equals(t)) | |
424 return 1; // covariant | |
425 | |
426 if (ty != TY.Tfunction || t.ty != TY.Tfunction) | |
427 goto Ldistinct; | |
428 | |
429 t1 = cast(TypeFunction)this; | |
430 t2 = cast(TypeFunction)t; | |
431 | |
432 if (t1.varargs != t2.varargs) | |
433 goto Ldistinct; | |
434 | |
435 if (t1.parameters && t2.parameters) | |
436 { | |
437 size_t dim = Argument.dim(t1.parameters); | |
438 if (dim != Argument.dim(t2.parameters)) | |
439 goto Ldistinct; | |
440 | |
441 for (size_t i = 0; i < dim; i++) | |
442 { | |
443 Argument arg1 = Argument.getNth(t1.parameters, i); | |
444 Argument arg2 = Argument.getNth(t2.parameters, i); | |
445 | |
446 if (!arg1.type.equals(arg2.type)) | |
447 { | |
448 ///static if (false) { | |
449 /// // turn on this for contravariant argument types, see bugzilla 3075 | |
98 | 450 /// // BUG: cannot convert ref to const to ref to immutable |
0 | 451 /// // We can add const, but not subtract it |
452 /// if (arg2.type.implicitConvTo(arg1.type) < MATCH.MATCHconst) | |
453 ///} | |
454 goto Ldistinct; | |
455 } | |
456 if ((arg1.storageClass & ~STC.STCscope) != (arg2.storageClass & ~STC.STCscope)) | |
457 inoutmismatch = 1; | |
458 // We can add scope, but not subtract it | |
459 if (!(arg1.storageClass & STC.STCscope) && (arg2.storageClass & STC.STCscope)) | |
460 inoutmismatch = 1; | |
461 } | |
462 } | |
463 else if (t1.parameters != t2.parameters) | |
464 goto Ldistinct; | |
465 | |
466 // The argument lists match | |
467 if (inoutmismatch) | |
468 goto Lnotcovariant; | |
469 if (t1.linkage != t2.linkage) | |
470 goto Lnotcovariant; | |
471 | |
472 { | |
473 // Return types | |
474 Type t1n = t1.next; | |
475 Type t2n = t2.next; | |
476 | |
79 | 477 if (t1n is null || t2n is null) // happens with return type inference |
478 goto Lnotcovariant; | |
479 | |
0 | 480 if (t1n.equals(t2n)) |
481 goto Lcovariant; | |
482 if (t1n.ty == TY.Tclass && t2n.ty == TY.Tclass) | |
483 { | |
484 /* If same class type, but t2n is const, then it's | |
485 * covariant. Do this test first because it can work on | |
486 * forward references. | |
487 */ | |
488 if ((cast(TypeClass)t1n).sym == (cast(TypeClass)t2n).sym && | |
489 t2n.mod == MOD.MODconst) | |
490 goto Lcovariant; | |
491 | |
492 // If t1n is forward referenced: | |
493 ClassDeclaration cd = (cast(TypeClass)t1n).sym; | |
494 if (!cd.baseClass && cd.baseclasses.dim && !cd.isInterfaceDeclaration()) | |
495 { | |
496 return 3; | |
497 } | |
498 } | |
499 if (t1n.implicitConvTo(t2n)) | |
500 goto Lcovariant; | |
501 } | |
502 | |
503 goto Lnotcovariant; | |
504 | |
505 Lcovariant: | |
506 /* Can convert mutable to const | |
507 */ | |
508 if (t1.mod != t2.mod) | |
509 { | |
510 if (!(t1.mod & MOD.MODconst) && (t2.mod & MOD.MODconst)) | |
511 goto Lnotcovariant; | |
512 if (!(t1.mod & MOD.MODshared) && (t2.mod & MOD.MODshared)) | |
513 goto Lnotcovariant; | |
514 } | |
515 | |
516 /* Can convert pure to impure, and nothrow to throw | |
517 */ | |
518 if (!t1.ispure && t2.ispure) | |
519 goto Lnotcovariant; | |
520 | |
521 if (!t1.isnothrow && t2.isnothrow) | |
522 goto Lnotcovariant; | |
523 | |
524 if (t1.isref != t2.isref) | |
525 goto Lnotcovariant; | |
526 | |
527 //printf("\tcovaraint: 1\n"); | |
528 return 1; | |
529 | |
530 Ldistinct: | |
531 //printf("\tcovaraint: 0\n"); | |
532 return 0; | |
533 | |
534 Lnotcovariant: | |
535 //printf("\tcovaraint: 2\n"); | |
536 return 2; | |
537 } | |
538 | |
539 string toChars() | |
540 { | |
541 scope OutBuffer buf = new OutBuffer(); | |
542 | |
543 HdrGenState hgs; | |
544 toCBuffer(buf, null, &hgs); | |
545 return buf.toChars(); | |
546 } | |
547 | |
548 static char needThisPrefix() | |
549 { | |
550 return 'M'; // name mangling prefix for functions needing 'this' | |
551 } | |
552 | |
553 static void init() | |
554 { | |
555 Lexer.initKeywords(); | |
556 | |
557 for (int i = 0; i < TY.TMAX; i++) | |
558 sizeTy[i] = TypeBasic.sizeof; | |
559 | |
560 sizeTy[TY.Tsarray] = TypeSArray.sizeof; | |
561 sizeTy[TY.Tarray] = TypeDArray.sizeof; | |
562 //sizeTy[TY.Tnarray] = TypeNArray.sizeof; | |
563 sizeTy[TY.Taarray] = TypeAArray.sizeof; | |
564 sizeTy[TY.Tpointer] = TypePointer.sizeof; | |
565 sizeTy[TY.Treference] = TypeReference.sizeof; | |
566 sizeTy[TY.Tfunction] = TypeFunction.sizeof; | |
567 sizeTy[TY.Tdelegate] = TypeDelegate.sizeof; | |
568 sizeTy[TY.Tident] = TypeIdentifier.sizeof; | |
569 sizeTy[TY.Tinstance] = TypeInstance.sizeof; | |
570 sizeTy[TY.Ttypeof] = TypeTypeof.sizeof; | |
571 sizeTy[TY.Tenum] = TypeEnum.sizeof; | |
572 sizeTy[TY.Ttypedef] = TypeTypedef.sizeof; | |
573 sizeTy[TY.Tstruct] = TypeStruct.sizeof; | |
574 sizeTy[TY.Tclass] = TypeClass.sizeof; | |
575 sizeTy[TY.Ttuple] = TypeTuple.sizeof; | |
576 sizeTy[TY.Tslice] = TypeSlice.sizeof; | |
577 sizeTy[TY.Treturn] = TypeReturn.sizeof; | |
578 | |
579 mangleChar[TY.Tarray] = 'A'; | |
580 mangleChar[TY.Tsarray] = 'G'; | |
581 mangleChar[TY.Tnarray] = '@'; | |
582 mangleChar[TY.Taarray] = 'H'; | |
583 mangleChar[TY.Tpointer] = 'P'; | |
584 mangleChar[TY.Treference] = 'R'; | |
585 mangleChar[TY.Tfunction] = 'F'; | |
586 mangleChar[TY.Tident] = 'I'; | |
587 mangleChar[TY.Tclass] = 'C'; | |
588 mangleChar[TY.Tstruct] = 'S'; | |
589 mangleChar[TY.Tenum] = 'E'; | |
590 mangleChar[TY.Ttypedef] = 'T'; | |
591 mangleChar[TY.Tdelegate] = 'D'; | |
592 | |
593 mangleChar[TY.Tnone] = 'n'; | |
594 mangleChar[TY.Tvoid] = 'v'; | |
595 mangleChar[TY.Tint8] = 'g'; | |
596 mangleChar[TY.Tuns8] = 'h'; | |
597 mangleChar[TY.Tint16] = 's'; | |
598 mangleChar[TY.Tuns16] = 't'; | |
599 mangleChar[TY.Tint32] = 'i'; | |
600 mangleChar[TY.Tuns32] = 'k'; | |
601 mangleChar[TY.Tint64] = 'l'; | |
602 mangleChar[TY.Tuns64] = 'm'; | |
603 mangleChar[TY.Tfloat32] = 'f'; | |
604 mangleChar[TY.Tfloat64] = 'd'; | |
605 mangleChar[TY.Tfloat80] = 'e'; | |
606 | |
607 mangleChar[TY.Timaginary32] = 'o'; | |
608 mangleChar[TY.Timaginary64] = 'p'; | |
609 mangleChar[TY.Timaginary80] = 'j'; | |
610 mangleChar[TY.Tcomplex32] = 'q'; | |
611 mangleChar[TY.Tcomplex64] = 'r'; | |
612 mangleChar[TY.Tcomplex80] = 'c'; | |
613 | |
614 mangleChar[TY.Tbool] = 'b'; | |
615 mangleChar[TY.Tascii] = 'a'; | |
616 mangleChar[TY.Twchar] = 'u'; | |
617 mangleChar[TY.Tdchar] = 'w'; | |
618 | |
619 mangleChar[TY.Tbit] = '@'; | |
620 mangleChar[TY.Tinstance] = '@'; | |
621 mangleChar[TY.Terror] = '@'; | |
622 mangleChar[TY.Ttypeof] = '@'; | |
623 mangleChar[TY.Ttuple] = 'B'; | |
624 mangleChar[TY.Tslice] = '@'; | |
625 mangleChar[TY.Treturn] = '@'; | |
626 | |
627 debug { | |
628 for (int i = 0; i < TY.TMAX; i++) { | |
629 if (!mangleChar[i]) { | |
630 writef("ty = %d\n", i); | |
631 } | |
632 assert(mangleChar[i]); | |
633 } | |
634 } | |
635 // Set basic types | |
636 static TY[] basetab = [ | |
637 TY.Tvoid, TY.Tint8, TY.Tuns8, TY.Tint16, TY.Tuns16, TY.Tint32, TY.Tuns32, TY.Tint64, TY.Tuns64, | |
638 TY.Tfloat32, TY.Tfloat64, TY.Tfloat80, | |
639 TY.Timaginary32, TY.Timaginary64, TY.Timaginary80, | |
640 TY.Tcomplex32, TY.Tcomplex64, TY.Tcomplex80, | |
641 TY.Tbool, | |
642 TY.Tascii, TY.Twchar, TY.Tdchar | |
643 ]; | |
644 | |
645 foreach (bt; basetab) { | |
646 Type t = new TypeBasic(bt); | |
647 t = t.merge(); | |
648 basic[bt] = t; | |
649 } | |
650 | |
651 basic[TY.Terror] = basic[TY.Tint32]; | |
652 | |
653 tvoidptr = tvoid.pointerTo(); | |
98 | 654 tstring = tchar.invariantOf().arrayOf(); |
0 | 655 |
656 if (global.params.isX86_64) { | |
657 PTRSIZE = 8; | |
658 if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris) | |
659 REALSIZE = 10; | |
660 else | |
661 REALSIZE = 8; | |
662 Tsize_t = TY.Tuns64; | |
663 Tptrdiff_t = TY.Tint64; | |
664 } | |
665 else | |
666 { | |
667 PTRSIZE = 4; | |
668 version (TARGET_OSX) { | |
669 REALSIZE = 16; | |
670 REALPAD = 6; | |
671 } else version (XXX) { //#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS | |
672 REALSIZE = 12; | |
673 REALPAD = 2; | |
674 } else { | |
675 REALSIZE = 10; | |
676 REALPAD = 0; | |
677 } | |
678 Tsize_t = TY.Tuns32; | |
679 Tptrdiff_t = TY.Tint32; | |
680 } | |
681 } | |
682 | |
683 ulong size() | |
684 { | |
685 return size(Loc(0)); | |
686 } | |
687 | |
688 ulong size(Loc loc) | |
689 { | |
690 error(loc, "no size for type %s", toChars()); | |
691 return 1; | |
692 } | |
693 | |
694 uint alignsize() | |
695 { | |
696 return cast(uint)size(Loc(0)); /// | |
697 } | |
698 | |
699 Type semantic(Loc loc, Scope sc) | |
700 { | |
701 return merge(); | |
702 } | |
703 | |
704 Type trySemantic(Loc loc, Scope sc) | |
705 { | |
706 uint errors = global.errors; | |
707 global.gag++; // suppress printing of error messages | |
708 Type t = semantic(loc, sc); | |
709 global.gag--; | |
710 if (errors != global.errors) // if any errors happened | |
711 { | |
712 global.errors = errors; | |
713 t = null; | |
714 } | |
715 return t; | |
716 } | |
717 | |
718 /******************************** | |
719 * Name mangling. | |
720 * Input: | |
721 * flag 0x100 do not do const/invariant | |
722 */ | |
723 void toDecoBuffer(OutBuffer buf, int flag = 0) | |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
16
diff
changeset
|
724 { |
0 | 725 if (flag != mod && flag != 0x100) |
726 { | |
727 if (mod & MOD.MODshared) | |
728 buf.writeByte('O'); | |
729 | |
730 if (mod & MOD.MODconst) | |
731 buf.writeByte('x'); | |
732 else if (mod & MOD.MODinvariant) | |
733 buf.writeByte('y'); | |
734 | |
735 // Cannot be both const and invariant | |
736 assert((mod & (MOD.MODconst | MOD.MODinvariant)) != (MOD.MODconst | MOD.MODinvariant)); | |
737 } | |
738 buf.writeByte(mangleChar[ty]); | |
739 } | |
740 | |
741 Type merge() | |
742 { | |
743 Type t = this; | |
744 assert(t); | |
745 | |
746 //printf("merge(%s)\n", toChars()); | |
747 if (deco is null) | |
748 { | |
749 OutBuffer buf = new OutBuffer(); | |
750 | |
751 //if (next) | |
752 //next = next.merge(); | |
753 toDecoBuffer(buf); | |
754 StringValue* sv = stringtable.update(buf.extractString()); | |
755 if (sv.ptrvalue) | |
756 { | |
757 t = cast(Type) sv.ptrvalue; | |
758 debug { | |
759 if (!t.deco) | |
760 writef("t = %s\n", t.toChars()); | |
761 } | |
762 assert(t.deco); | |
763 //printf("old value, deco = '%s' %p\n", t.deco, t.deco); | |
764 } | |
765 else | |
766 { | |
767 sv.ptrvalue = cast(void*)this; | |
768 deco = sv.lstring.string_; | |
769 //printf("new value, deco = '%s' %p\n", t.deco, t.deco); | |
770 } | |
771 } | |
772 return t; | |
773 } | |
774 | |
775 /************************************* | |
776 * This version does a merge even if the deco is already computed. | |
777 * Necessary for types that have a deco, but are not merged. | |
778 */ | |
779 Type merge2() | |
780 { | |
781 //printf("merge2(%s)\n", toChars()); | |
782 Type t = this; | |
783 assert(t); | |
784 if (!t.deco) | |
785 return t.merge(); | |
786 | |
787 StringValue* sv = stringtable.lookup(t.deco); | |
788 if (sv && sv.ptrvalue) | |
789 { | |
790 t = cast(Type)sv.ptrvalue; | |
791 assert(t.deco); | |
792 } | |
793 else | |
794 assert(0); | |
795 | |
796 return t; | |
797 } | |
798 | |
799 void toCBuffer(OutBuffer buf, Identifier ident, HdrGenState* hgs) | |
800 { | |
801 toCBuffer2(buf, hgs, MOD.MODundefined); | |
802 if (ident) | |
803 { | |
804 buf.writeByte(' '); | |
805 buf.writestring(ident.toChars()); | |
806 } | |
807 } | |
808 | |
809 void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod) | |
810 { | |
811 if (mod != this.mod) | |
812 { | |
813 toCBuffer3(buf, hgs, mod); | |
814 return; | |
815 } | |
816 buf.writestring(toChars()); | |
817 } | |
818 | |
819 void toCBuffer3(OutBuffer buf, HdrGenState* hgs, MOD mod) | |
820 { | |
821 if (mod != this.mod) | |
822 { | |
823 string p; | |
824 | |
825 if (this.mod & MOD.MODshared) | |
826 buf.writestring("shared("); | |
827 | |
828 switch (this.mod & (MOD.MODconst | MOD.MODinvariant)) | |
829 { | |
830 case MOD.MODundefined: | |
831 toCBuffer2(buf, hgs, this.mod); | |
832 break; | |
833 case MOD.MODconst: | |
834 p = "const("; | |
835 goto L1; | |
836 case MOD.MODinvariant: | |
837 p = "immutable("; | |
838 L1: buf.writestring(p); | |
839 toCBuffer2(buf, hgs, this.mod); | |
840 buf.writeByte(')'); | |
841 break; | |
842 } | |
843 | |
844 if (this.mod & MOD.MODshared) | |
845 buf.writeByte(')'); | |
846 } | |
847 } | |
848 | |
849 void modToBuffer(OutBuffer buf) | |
850 { | |
851 if (mod & MOD.MODshared) | |
852 buf.writestring(" shared"); | |
853 if (mod & MOD.MODconst) | |
854 buf.writestring(" const"); | |
855 if (mod & MOD.MODinvariant) | |
856 buf.writestring(" immutable"); | |
857 } | |
858 | |
859 version (CPP_MANGLE) { | |
860 void toCppMangle(OutBuffer buf, CppMangleState* cms) | |
861 { | |
862 assert(false); | |
863 } | |
864 } | |
865 bool isintegral() | |
866 { | |
867 return false; | |
868 } | |
869 | |
870 bool isfloating() // real, imaginary, or complex | |
871 { | |
872 return false; | |
873 } | |
874 | |
875 bool isreal() | |
876 { | |
877 return false; | |
878 } | |
879 | |
880 bool isimaginary() | |
881 { | |
882 return false; | |
883 } | |
884 | |
885 bool iscomplex() | |
886 { | |
887 return false; | |
888 } | |
889 | |
890 bool isscalar() | |
891 { | |
892 return false; | |
893 } | |
894 | |
895 bool isunsigned() | |
896 { | |
897 return false; | |
898 } | |
899 | |
900 bool isauto() | |
901 { | |
902 return false; | |
903 } | |
904 | |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
4
diff
changeset
|
905 bool isString() |
0 | 906 { |
907 return false; | |
908 } | |
909 | |
910 /************************** | |
911 * Given: | |
912 * T a, b; | |
913 * Can we assign: | |
914 * a = b; | |
915 * ? | |
916 */ | |
73 | 917 bool isAssignable() |
0 | 918 { |
919 return true; | |
920 } | |
921 | |
922 bool checkBoolean() // if can be converted to boolean value | |
923 { | |
924 return isscalar(); | |
925 } | |
926 | |
927 /********************************* | |
928 * Check type to see if it is based on a deprecated symbol. | |
929 */ | |
930 void checkDeprecated(Loc loc, Scope sc) | |
931 { | |
932 Dsymbol s = toDsymbol(sc); | |
933 if (s) | |
934 s.checkDeprecated(loc, sc); | |
935 } | |
936 | |
937 bool isConst() { return (mod & MOD.MODconst) != 0; } | |
938 | |
939 int isInvariant() { return mod & MOD.MODinvariant; } | |
940 | |
941 int isMutable() { return !(mod & (MOD.MODconst | MOD.MODinvariant)); } | |
942 | |
943 int isShared() { return mod & MOD.MODshared; } | |
944 | |
945 int isSharedConst() { return mod == (MOD.MODshared | MOD.MODconst); } | |
946 | |
947 /******************************** | |
948 * Convert to 'const'. | |
949 */ | |
950 Type constOf() | |
951 { | |
952 //printf("Type.constOf() %p %s\n", this, toChars()); | |
953 if (mod == MOD.MODconst) | |
954 return this; | |
955 if (cto) | |
956 { | |
957 assert(cto.mod == MOD.MODconst); | |
958 return cto; | |
959 } | |
960 Type t = makeConst(); | |
961 t = t.merge(); | |
962 t.fixTo(this); | |
963 //printf("-Type.constOf() %p %s\n", t, toChars()); | |
964 return t; | |
965 } | |
966 | |
967 /******************************** | |
968 * Convert to 'immutable'. | |
969 */ | |
970 Type invariantOf() | |
971 { | |
972 //printf("Type.invariantOf() %p %s\n", this, toChars()); | |
973 if (isInvariant()) | |
974 { | |
975 return this; | |
976 } | |
977 if (ito) | |
978 { | |
979 assert(ito.isInvariant()); | |
980 return ito; | |
981 } | |
982 Type t = makeInvariant(); | |
983 t = t.merge(); | |
984 t.fixTo(this); | |
985 //printf("\t%p\n", t); | |
986 return t; | |
987 } | |
988 | |
989 Type mutableOf() | |
990 { | |
991 //printf("Type.mutableOf() %p, %s\n", this, toChars()); | |
992 Type t = this; | |
993 if (isConst()) | |
994 { | |
995 if (isShared()) | |
996 t = sto; // shared const => shared | |
997 else | |
998 t = cto; | |
999 assert(!t || t.isMutable()); | |
1000 } | |
1001 else if (isInvariant()) | |
1002 { | |
1003 t = ito; | |
1004 assert(!t || (t.isMutable() && !t.isShared())); | |
1005 } | |
1006 if (!t) | |
1007 { | |
1008 uint sz = this.classinfo.init.length; | |
2 | 1009 t = cast(Type)GC.malloc(sz); |
0 | 1010 memcpy(cast(void*)t, cast(void*)this, sz); |
98 | 1011 t.mod = mod & MODshared; |
0 | 1012 t.deco = null; |
1013 t.arrayof = null; | |
1014 t.pto = null; | |
1015 t.rto = null; | |
1016 t.cto = null; | |
1017 t.ito = null; | |
1018 t.sto = null; | |
1019 t.scto = null; | |
1020 t.vtinfo = null; | |
1021 t = t.merge(); | |
1022 | |
1023 t.fixTo(this); | |
1024 | |
1025 switch (mod) | |
1026 { | |
1027 case MODconst: | |
1028 t.cto = this; | |
1029 break; | |
1030 | |
1031 case MODinvariant: | |
1032 t.ito = this; | |
1033 break; | |
1034 | |
1035 case MODshared | MODconst: | |
1036 t.scto = this; | |
1037 break; | |
1038 | |
1039 default: | |
1040 assert(0); | |
1041 } | |
1042 } | |
1043 return t; | |
1044 } | |
1045 | |
1046 Type sharedOf() | |
1047 { | |
1048 //printf("Type.sharedOf() %p, %s\n", this, toChars()); | |
1049 if (mod == MOD.MODshared) | |
1050 { | |
1051 return this; | |
1052 } | |
1053 if (sto) | |
1054 { | |
1055 assert(sto.isShared()); | |
1056 return sto; | |
1057 } | |
1058 | |
1059 Type t = makeShared(); | |
1060 t = t.merge(); | |
1061 t.fixTo(this); | |
1062 | |
1063 //printf("\t%p\n", t); | |
1064 return t; | |
1065 } | |
1066 | |
1067 Type sharedConstOf() | |
1068 { | |
1069 //printf("Type.sharedConstOf() %p, %s\n", this, toChars()); | |
1070 if (mod == (MODshared | MODconst)) | |
1071 { | |
1072 return this; | |
1073 } | |
1074 if (scto) | |
1075 { | |
1076 assert(scto.mod == (MODshared | MODconst)); | |
1077 return scto; | |
1078 } | |
1079 | |
1080 Type t = makeSharedConst(); | |
1081 t = t.merge(); | |
1082 t.fixTo(this); | |
1083 //printf("\t%p\n", t); | |
1084 | |
1085 return t; | |
1086 } | |
98 | 1087 |
1088 /******************************** | |
1089 * Make type unshared. | |
1090 */ | |
1091 Type unSharedOf() | |
1092 { | |
1093 //writef("Type::unSharedOf() %p, %s\n", this, toChars()); | |
1094 Type t = this; | |
1095 | |
1096 if (isShared()) | |
1097 { | |
1098 if (isConst()) | |
1099 t = cto; // shared const => const | |
1100 else | |
1101 t = sto; | |
1102 assert(!t || !t.isShared()); | |
1103 } | |
1104 | |
1105 if (!t) | |
1106 { | |
1107 uint sz = this.classinfo.init.length; | |
1108 t = cast(Type)GC.malloc(sz); | |
1109 memcpy(cast(void*)t, cast(void*)this, sz); | |
1110 t.mod = mod & ~MODshared; | |
1111 t.deco = null; | |
1112 t.arrayof = null; | |
1113 t.pto = null; | |
1114 t.rto = null; | |
1115 t.cto = null; | |
1116 t.ito = null; | |
1117 t.sto = null; | |
1118 t.scto = null; | |
1119 t.vtinfo = null; | |
1120 t = t.merge(); | |
0 | 1121 |
98 | 1122 t.fixTo(this); |
1123 | |
1124 switch (mod) | |
1125 { | |
1126 case MODshared: | |
1127 t.sto = this; | |
1128 break; | |
1129 | |
1130 case MODshared | MODconst: | |
1131 t.scto = this; | |
1132 break; | |
1133 | |
1134 default: | |
1135 assert(0); | |
1136 } | |
1137 } | |
1138 assert(!t.isShared()); | |
1139 return t; | |
1140 } | |
1141 | |
0 | 1142 static uint X(MOD m, MOD n) |
1143 { | |
1144 return (((m) << 3) | (n)); | |
1145 } | |
1146 | |
1147 /********************************** | |
1148 * For our new type 'this', which is type-constructed from t, | |
1149 * fill in the cto, ito, sto, scto shortcuts. | |
1150 */ | |
1151 void fixTo(Type t) | |
1152 { | |
1153 ito = t.ito; | |
1154 static if (false) { | |
1155 /* Cannot do these because these are not fully transitive: | |
1156 * there can be a shared ptr to immutable, for example. | |
1157 * Immutable subtypes are always immutable, though. | |
1158 */ | |
1159 cto = t.cto; | |
1160 sto = t.sto; | |
1161 scto = t.scto; | |
1162 } | |
1163 | |
1164 assert(mod != t.mod); | |
1165 | |
1166 switch (X(mod, t.mod)) | |
1167 { | |
1168 case X(MOD.MODundefined, MOD.MODconst): | |
1169 cto = t; | |
1170 break; | |
1171 | |
1172 case X(MOD.MODundefined, MOD.MODinvariant): | |
1173 ito = t; | |
1174 break; | |
1175 | |
1176 case X(MOD.MODundefined, MOD.MODshared): | |
1177 sto = t; | |
1178 break; | |
1179 | |
1180 case X(MOD.MODundefined, MOD.MODshared | MOD.MODconst): | |
1181 scto = t; | |
1182 break; | |
1183 | |
1184 | |
1185 case X(MOD.MODconst, MOD.MODundefined): | |
1186 cto = null; | |
1187 goto L2; | |
1188 | |
1189 case X(MOD.MODconst, MOD.MODinvariant): | |
1190 ito = t; | |
1191 goto L2; | |
1192 | |
1193 case X(MOD.MODconst, MOD.MODshared): | |
1194 sto = t; | |
1195 goto L2; | |
1196 | |
1197 case X(MOD.MODconst, MOD.MODshared | MOD.MODconst): | |
1198 scto = t; | |
1199 L2: | |
1200 t.cto = this; | |
1201 break; | |
1202 | |
1203 | |
1204 case X(MOD.MODinvariant, MOD.MODundefined): | |
1205 ito = null; | |
1206 goto L3; | |
1207 | |
1208 case X(MOD.MODinvariant, MOD.MODconst): | |
1209 cto = t; | |
1210 goto L3; | |
1211 | |
1212 case X(MOD.MODinvariant, MOD.MODshared): | |
1213 sto = t; | |
1214 goto L3; | |
1215 | |
1216 case X(MOD.MODinvariant, MOD.MODshared | MOD.MODconst): | |
1217 scto = t; | |
1218 L3: | |
1219 t.ito = this; | |
1220 if (t.cto) t.cto.ito = this; | |
1221 if (t.sto) t.sto.ito = this; | |
1222 if (t.scto) t.scto.ito = this; | |
1223 break; | |
1224 | |
1225 | |
1226 case X(MOD.MODshared, MOD.MODundefined): | |
1227 sto = null; | |
1228 goto L4; | |
1229 | |
1230 case X(MOD.MODshared, MOD.MODconst): | |
1231 cto = t; | |
1232 goto L4; | |
1233 | |
1234 case X(MOD.MODshared, MOD.MODinvariant): | |
1235 ito = t; | |
1236 goto L4; | |
1237 | |
1238 case X(MOD.MODshared, MOD.MODshared | MOD.MODconst): | |
1239 scto = t; | |
1240 L4: | |
1241 t.sto = this; | |
1242 break; | |
1243 | |
1244 | |
1245 case X(MOD.MODshared | MOD.MODconst, MOD.MODundefined): | |
1246 scto = null; | |
1247 break; | |
1248 | |
1249 case X(MOD.MODshared | MOD.MODconst, MOD.MODconst): | |
1250 cto = t; | |
1251 break; | |
1252 | |
1253 case X(MOD.MODshared | MOD.MODconst, MOD.MODinvariant): | |
1254 ito = t; | |
1255 break; | |
1256 | |
1257 case X(MOD.MODshared | MOD.MODconst, MOD.MODshared): | |
1258 sto = t; | |
1259 L5: | |
1260 t.scto = this; | |
1261 break; | |
1262 } | |
1263 | |
1264 check(); | |
1265 t.check(); | |
1266 //printf("fixTo: %s, %s\n", toChars(), t.toChars()); | |
1267 } | |
1268 | |
1269 /*************************** | |
1270 * Look for bugs in constructing types. | |
1271 */ | |
1272 void check() | |
1273 { | |
1274 switch (mod) | |
1275 { | |
1276 case MOD.MODundefined: | |
1277 if (cto) assert(cto.mod == MOD.MODconst); | |
1278 if (ito) assert(ito.mod == MOD.MODinvariant); | |
1279 if (sto) assert(sto.mod == MOD.MODshared); | |
1280 if (scto) assert(scto.mod == (MOD.MODshared | MOD.MODconst)); | |
1281 break; | |
1282 | |
1283 case MOD.MODconst: | |
1284 if (cto) assert(cto.mod == MOD.MODundefined); | |
1285 if (ito) assert(ito.mod == MOD.MODinvariant); | |
1286 if (sto) assert(sto.mod == MOD.MODshared); | |
1287 if (scto) assert(scto.mod == (MOD.MODshared | MOD.MODconst)); | |
1288 break; | |
1289 | |
1290 case MOD.MODinvariant: | |
1291 if (cto) assert(cto.mod == MOD.MODconst); | |
1292 if (ito) assert(ito.mod == MOD.MODundefined); | |
1293 if (sto) assert(sto.mod == MOD.MODshared); | |
1294 if (scto) assert(scto.mod == (MOD.MODshared | MOD.MODconst)); | |
1295 break; | |
1296 | |
1297 case MOD.MODshared: | |
1298 if (cto) assert(cto.mod == MOD.MODconst); | |
1299 if (ito) assert(ito.mod == MOD.MODinvariant); | |
1300 if (sto) assert(sto.mod == MOD.MODundefined); | |
1301 if (scto) assert(scto.mod == (MOD.MODshared | MOD.MODconst)); | |
1302 break; | |
1303 | |
1304 case MOD.MODshared | MOD.MODconst: | |
1305 if (cto) assert(cto.mod == MOD.MODconst); | |
1306 if (ito) assert(ito.mod == MOD.MODinvariant); | |
1307 if (sto) assert(sto.mod == MOD.MODshared); | |
1308 if (scto) assert(scto.mod == MOD.MODundefined); | |
1309 break; | |
1310 } | |
1311 | |
1312 Type tn = nextOf(); | |
1313 if (tn && ty != TY.Tfunction && ty != TY.Tdelegate) | |
1314 { | |
1315 // Verify transitivity | |
1316 switch (mod) | |
1317 { | |
1318 case MOD.MODundefined: | |
1319 break; | |
1320 | |
1321 case MOD.MODconst: | |
1322 assert(tn.mod & MOD.MODinvariant || tn.mod & MOD.MODconst); | |
1323 break; | |
1324 | |
1325 case MOD.MODinvariant: | |
1326 assert(tn.mod == MOD.MODinvariant); | |
1327 break; | |
1328 | |
1329 case MOD.MODshared: | |
1330 assert(tn.mod & MOD.MODinvariant || tn.mod & MOD.MODshared); | |
1331 break; | |
1332 | |
1333 case MOD.MODshared | MOD.MODconst: | |
1334 assert(tn.mod & MOD.MODinvariant || tn.mod & (MOD.MODshared | MOD.MODconst)); | |
1335 break; | |
1336 } | |
1337 tn.check(); | |
1338 } | |
1339 } | |
1340 | |
51 | 1341 /************************************ |
1342 * Apply MODxxxx bits to existing type. | |
1343 */ | |
0 | 1344 Type castMod(uint mod) |
1345 { | |
51 | 1346 Type t; |
1347 | |
1348 switch (mod) | |
1349 { | |
1350 case 0: | |
1351 t = mutableOf(); | |
1352 break; | |
1353 | |
1354 case MODconst: | |
1355 t = constOf(); | |
1356 break; | |
1357 | |
1358 case MODinvariant: | |
1359 t = invariantOf(); | |
1360 break; | |
1361 | |
1362 case MODshared: | |
1363 t = sharedOf(); | |
1364 break; | |
1365 | |
1366 case MODshared | MODconst: | |
1367 t = sharedConstOf(); | |
1368 break; | |
1369 | |
1370 default: | |
1371 assert(0); | |
1372 } | |
1373 return t; | |
0 | 1374 } |
1375 | |
1376 /************************************ | |
1377 * Add MODxxxx bits to existing type. | |
1378 * We're adding, not replacing, so adding const to | |
1379 * a shared type => "shared const" | |
1380 */ | |
1381 Type addMod(MOD mod) | |
1382 { | |
1383 Type t = this; | |
1384 | |
1385 /* Add anything to immutable, and it remains immutable | |
1386 */ | |
1387 if (!t.isInvariant()) | |
1388 { | |
1389 switch (mod) | |
1390 { | |
1391 case MOD.MODundefined: | |
1392 break; | |
1393 | |
1394 case MOD.MODconst: | |
1395 if (isShared()) | |
1396 t = sharedConstOf(); | |
1397 else | |
1398 t = constOf(); | |
1399 break; | |
1400 | |
1401 case MOD.MODinvariant: | |
1402 t = invariantOf(); | |
1403 break; | |
1404 | |
1405 case MOD.MODshared: | |
1406 if (isConst()) | |
1407 t = sharedConstOf(); | |
1408 else | |
1409 t = sharedOf(); | |
1410 break; | |
1411 | |
1412 case MOD.MODshared | MOD.MODconst: | |
1413 t = sharedConstOf(); | |
1414 break; | |
1415 } | |
1416 } | |
1417 return t; | |
1418 } | |
1419 | |
1420 Type addStorageClass(STC stc) | |
1421 { | |
1422 /* Just translate to MOD bits and let addMod() do the work | |
1423 */ | |
1424 MOD mod = MOD.MODundefined; | |
1425 | |
1426 if (stc & STC.STCimmutable) | |
1427 mod = MOD.MODinvariant; | |
1428 else | |
1429 { | |
1430 if (stc & (STC.STCconst | STC.STCin)) | |
1431 mod = MOD.MODconst; | |
1432 if (stc & STC.STCshared) | |
1433 mod |= MOD.MODshared; | |
1434 } | |
1435 | |
1436 return addMod(mod); | |
1437 } | |
1438 | |
1439 Type pointerTo() | |
1440 { | |
1441 if (pto is null) | |
1442 { | |
1443 Type t = new TypePointer(this); | |
1444 pto = t.merge(); | |
1445 } | |
1446 | |
1447 return pto; | |
1448 } | |
1449 | |
1450 Type referenceTo() | |
1451 { | |
1452 assert(false); | |
1453 } | |
1454 | |
1455 version (DumbClone) { | |
1456 final Type clone() | |
1457 { | |
1458 auto size = this.classinfo.init.length; | |
2 | 1459 auto ptr = GC.malloc(size); |
0 | 1460 memcpy(ptr, cast(void*)this, size); |
1461 | |
1462 return cast(Type)ptr; | |
1463 } | |
1464 } else { | |
1465 final Type cloneTo(Type t) | |
1466 { | |
1467 t.ctype = ctype; | |
1468 return t; | |
1469 } | |
1470 | |
1471 Type clone() | |
1472 { | |
1473 assert(this.classinfo is Type.classinfo); | |
1474 return cloneTo(new Type(ty)); | |
1475 } | |
1476 } | |
1477 | |
1478 Type arrayOf() | |
1479 { | |
1480 if (!arrayof) | |
1481 { | |
1482 Type t = new TypeDArray(this); | |
1483 arrayof = t.merge(); | |
1484 } | |
1485 return arrayof; | |
1486 } | |
1487 | |
1488 Type makeConst() | |
1489 { | |
1490 //printf("Type.makeConst() %p, %s\n", this, toChars()); | |
1491 if (cto) | |
1492 return cto; | |
1493 | |
1494 Type t = clone(); | |
1495 t.mod = MOD.MODconst; | |
1496 | |
1497 t.deco = null; | |
1498 t.arrayof = null; | |
1499 t.pto = null; | |
1500 t.rto = null; | |
1501 t.cto = null; | |
1502 t.ito = null; | |
1503 t.sto = null; | |
1504 t.scto = null; | |
1505 t.vtinfo = null; | |
1506 | |
1507 //printf("-Type.makeConst() %p, %s\n", t, toChars()); | |
1508 return t; | |
1509 } | |
1510 | |
1511 Type makeInvariant() | |
1512 { | |
1513 if (ito) { | |
1514 return ito; | |
1515 } | |
1516 | |
1517 Type t = clone(); | |
1518 t.mod = MOD.MODinvariant; | |
1519 | |
1520 t.deco = null; | |
1521 t.arrayof = null; | |
1522 t.pto = null; | |
1523 t.rto = null; | |
1524 t.cto = null; | |
1525 t.ito = null; | |
1526 t.sto = null; | |
1527 t.scto = null; | |
1528 t.vtinfo = null; | |
1529 | |
1530 return t; | |
1531 } | |
1532 | |
1533 Type makeShared() | |
1534 { | |
1535 if (sto) | |
1536 return sto; | |
1537 | |
1538 Type t = clone(); | |
1539 t.mod = MOD.MODshared; | |
1540 | |
1541 t.deco = null; | |
1542 t.arrayof = null; | |
1543 t.pto = null; | |
1544 t.rto = null; | |
1545 t.cto = null; | |
1546 t.ito = null; | |
1547 t.sto = null; | |
1548 t.scto = null; | |
1549 t.vtinfo = null; | |
1550 | |
1551 return t; | |
1552 } | |
1553 | |
1554 Type makeSharedConst() | |
1555 { | |
1556 if (scto) | |
1557 return scto; | |
1558 | |
1559 Type t = clone(); | |
1560 t.mod = MODshared | MODconst; | |
1561 | |
1562 t.deco = null; | |
1563 t.arrayof = null; | |
1564 t.pto = null; | |
1565 t.rto = null; | |
1566 t.cto = null; | |
1567 t.ito = null; | |
1568 t.sto = null; | |
1569 t.scto = null; | |
1570 t.vtinfo = null; | |
1571 | |
1572 return t; | |
1573 } | |
1574 | |
1575 Dsymbol toDsymbol(Scope sc) | |
1576 { | |
1577 return null; | |
1578 } | |
1579 | |
1580 /******************************* | |
1581 * If this is a shell around another type, | |
1582 * get that other type. | |
1583 */ | |
1584 | |
1585 Type toBasetype() | |
1586 { | |
1587 return this; | |
1588 } | |
1589 | |
1590 /************************** | |
1591 * Return type with the top level of it being mutable. | |
1592 */ | |
1593 Type toHeadMutable() | |
1594 { | |
1595 if (!mod) | |
1596 return this; | |
1597 | |
1598 return mutableOf(); | |
1599 } | |
1600 | |
1601 bool isBaseOf(Type t, int* poffset) | |
1602 { | |
1603 return false; // assume not | |
1604 } | |
1605 | |
1606 /******************************* | |
1607 * Determine if converting 'this' to 'to' is an identity operation, | |
1608 * a conversion to const operation, or the types aren't the same. | |
1609 * Returns: | |
1610 * MATCHequal 'this' == 'to' | |
1611 * MATCHconst 'to' is const | |
1612 * MATCHnomatch conversion to mutable or invariant | |
1613 */ | |
1614 MATCH constConv(Type to) | |
1615 { | |
1616 if (equals(to)) | |
1617 return MATCH.MATCHexact; | |
1618 if (ty == to.ty && to.mod == MOD.MODconst) | |
1619 return MATCH.MATCHconst; | |
1620 return MATCH.MATCHnomatch; | |
1621 } | |
1622 | |
1623 /******************************** | |
1624 * Determine if 'this' can be implicitly converted | |
1625 * to type 'to'. | |
1626 * Returns: | |
1627 * MATCHnomatch, MATCHconvert, MATCHconst, MATCHexact | |
1628 */ | |
1629 MATCH implicitConvTo(Type to) | |
1630 { | |
1631 //printf("Type.implicitConvTo(this=%p, to=%p)\n", this, to); | |
1632 //printf("from: %s\n", toChars()); | |
1633 //printf("to : %s\n", to.toChars()); | |
1634 if (this is to) | |
1635 return MATCHexact; | |
1636 | |
1637 return MATCHnomatch; | |
1638 } | |
1639 | |
1640 ClassDeclaration isClassHandle() | |
1641 { | |
1642 return null; | |
1643 } | |
1644 | |
1645 Expression getProperty(Loc loc, Identifier ident) | |
1646 { | |
1647 Expression e; | |
1648 | |
1649 version (LOGDOTEXP) { | |
1650 printf("Type.getProperty(type = '%s', ident = '%s')\n", toChars(), ident.toChars()); | |
1651 } | |
1652 if (ident == Id.__sizeof) | |
1653 { | |
1654 e = new IntegerExp(loc, size(loc), Type.tsize_t); | |
1655 } | |
1656 else if (ident == Id.size) | |
1657 { | |
1658 error(loc, ".size property should be replaced with .sizeof"); | |
1659 e = new ErrorExp(); | |
1660 } | |
1661 else if (ident is Id.alignof_) | |
1662 { | |
1663 e = new IntegerExp(loc, alignsize(), Type.tsize_t); | |
1664 } | |
1665 else if (ident == Id.typeinfo_) | |
1666 { | |
1667 if (!global.params.useDeprecated) | |
1668 error(loc, ".typeinfo deprecated, use typeid(type)"); | |
1669 e = getTypeInfo(null); | |
1670 } | |
1671 else if (ident == Id.init_) | |
1672 { | |
1673 if (ty == TY.Tvoid) | |
1674 error(loc, "void does not have an initializer"); | |
1675 e = defaultInit(loc); | |
1676 } | |
1677 else if (ident is Id.mangleof_) | |
1678 { | |
1679 string s; | |
1680 if (!deco) { | |
1681 s = toChars(); | |
1682 error(loc, "forward reference of type %s.mangleof", s); | |
1683 } else { | |
1684 s = deco; | |
1685 } | |
1686 | |
1687 e = new StringExp(loc, s, 'c'); | |
87
b17640f0e4e8
Fixed a bug with a Scope.this(Scope enclosing) being called instead of Scope.clone() method (as a copy ctor replacement)
korDen
parents:
79
diff
changeset
|
1688 scope Scope sc = new Scope(); |
0 | 1689 e = e.semantic(sc); |
1690 } | |
1691 else if (ident is Id.stringof_) | |
1692 { | |
1693 string s = toChars(); | |
1694 e = new StringExp(loc, s, 'c'); | |
87
b17640f0e4e8
Fixed a bug with a Scope.this(Scope enclosing) being called instead of Scope.clone() method (as a copy ctor replacement)
korDen
parents:
79
diff
changeset
|
1695 scope Scope sc = new Scope(); |
0 | 1696 e = e.semantic(sc); |
1697 } | |
1698 else | |
1699 { | |
1700 error(loc, "no property '%s' for type '%s'", ident.toChars(), toChars()); | |
1701 e = new ErrorExp(); | |
1702 } | |
1703 return e; | |
1704 } | |
1705 | |
1706 Expression dotExp(Scope sc, Expression e, Identifier ident) | |
1707 { | |
1708 VarDeclaration v = null; | |
1709 | |
1710 version (LOGDOTEXP) { | |
1711 printf("Type.dotExp(e = '%s', ident = '%s')\n", e.toChars(), ident.toChars()); | |
1712 } | |
1713 if (e.op == TOK.TOKdotvar) | |
1714 { | |
1715 DotVarExp dv = cast(DotVarExp)e; | |
1716 v = dv.var.isVarDeclaration(); | |
1717 } | |
1718 else if (e.op == TOK.TOKvar) | |
1719 { | |
1720 VarExp ve = cast(VarExp)e; | |
1721 v = ve.var.isVarDeclaration(); | |
1722 } | |
1723 if (v) | |
1724 { | |
1725 if (ident is Id.offset) | |
1726 { | |
1727 if (!global.params.useDeprecated) | |
1728 error(e.loc, ".offset deprecated, use .offsetof"); | |
1729 goto Loffset; | |
1730 } | |
1731 else if (ident is Id.offsetof) | |
1732 { | |
1733 Loffset: | |
1734 if (v.storage_class & STC.STCfield) | |
1735 { | |
1736 e = new IntegerExp(e.loc, v.offset, Type.tsize_t); | |
1737 return e; | |
1738 } | |
1739 } | |
1740 else if (ident is Id.init_) | |
1741 { | |
1742 static if (false) { | |
1743 if (v.init) | |
1744 { | |
1745 if (v.init.isVoidInitializer()) | |
1746 error(e.loc, "%s.init is void", v.toChars()); | |
1747 else | |
1748 { Loc loc = e.loc; | |
1749 e = v.init.toExpression(); | |
1750 if (e.op == TOK.TOKassign || e.op == TOK.TOKconstruct || e.op == TOK.TOKblit) | |
1751 { | |
1752 e = (cast(AssignExp)e).e2; | |
1753 | |
1754 /* Take care of case where we used a 0 | |
1755 * to initialize the struct. | |
1756 */ | |
1757 if (e.type == Type.tint32 && | |
1758 e.isBool(0) && | |
1759 v.type.toBasetype().ty == TY.Tstruct) | |
1760 { | |
1761 e = v.type.defaultInit(e.loc); | |
1762 } | |
1763 } | |
1764 e = e.optimize(WANTvalue | WANTinterpret); | |
1765 // if (!e.isConst()) | |
1766 // error(loc, ".init cannot be evaluated at compile time"); | |
1767 } | |
1768 return e; | |
1769 } | |
1770 } | |
1771 Expression ex = defaultInit(e.loc); | |
1772 return ex; | |
1773 } | |
1774 } | |
1775 if (ident is Id.typeinfo_) | |
1776 { | |
1777 if (!global.params.useDeprecated) | |
1778 error(e.loc, ".typeinfo deprecated, use typeid(type)"); | |
1779 e = getTypeInfo(sc); | |
1780 return e; | |
1781 } | |
1782 if (ident is Id.stringof_) | |
1783 { | |
1784 string s = e.toChars(); | |
1785 e = new StringExp(e.loc, s, 'c'); | |
87
b17640f0e4e8
Fixed a bug with a Scope.this(Scope enclosing) being called instead of Scope.clone() method (as a copy ctor replacement)
korDen
parents:
79
diff
changeset
|
1786 scope Scope sc2 = new Scope(); /// |
0 | 1787 e = e.semantic(sc2); |
1788 return e; | |
1789 } | |
1790 return getProperty(e.loc, ident); | |
1791 } | |
1792 | |
1793 uint memalign(uint salign) | |
1794 { | |
1795 return salign; | |
1796 } | |
1797 | |
1798 ///Expression defaultInit(Loc loc = Loc(0)) | |
1799 Expression defaultInit(Loc loc) | |
1800 { | |
1801 assert(false); | |
1802 } | |
1803 | |
1804 ///bool isZeroInit(Loc loc = Loc(0)) // if initializer is 0 | |
1805 bool isZeroInit(Loc loc) // if initializer is 0 | |
1806 { | |
1807 assert(false); | |
1808 } | |
1809 | |
1810 dt_t** toDt(dt_t** pdt) | |
1811 { | |
1812 //printf("Type.toDt()\n"); | |
1813 Expression e = defaultInit(Loc(0)); | |
1814 return e.toDt(pdt); | |
1815 } | |
1816 | |
1817 Identifier getTypeInfoIdent(int internal) | |
1818 { | |
1819 // _init_10TypeInfo_%s | |
1820 scope OutBuffer buf = new OutBuffer(); | |
1821 Identifier id; | |
1822 char* name; | |
1823 int len; | |
1824 | |
1825 if (internal) | |
1826 { | |
1827 buf.writeByte(mangleChar[ty]); | |
1828 if (ty == TY.Tarray) | |
1829 buf.writeByte(mangleChar[(cast(TypeArray)this).next.ty]); | |
1830 } | |
1831 else | |
1832 toDecoBuffer(buf); | |
1833 | |
1834 len = buf.offset; | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
4
diff
changeset
|
1835 version (Bug4054) |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
4
diff
changeset
|
1836 name = cast(char*)GC.malloc(19 + len.sizeof * 3 + len + 1); |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
4
diff
changeset
|
1837 else |
0 | 1838 name = cast(char*)alloca(19 + len.sizeof * 3 + len + 1); |
1839 buf.writeByte(0); | |
1840 version (TARGET_OSX) { | |
1841 // The LINKc will prepend the _ | |
1842 len = sprintf(name, "D%dTypeInfo_%s6__initZ".ptr, 9 + len, buf.data); | |
1843 } else { | |
1844 len = sprintf(name, "_D%dTypeInfo_%s6__initZ".ptr, 9 + len, buf.data); | |
1845 } | |
1846 if (global.params.isWindows) | |
1847 name++; // C mangling will add it back in | |
1848 //printf("name = %s\n", name); | |
1849 id = Lexer.idPool(name[0..len-1].idup); | |
1850 return id; | |
1851 } | |
1852 | |
1853 /* These form the heart of template argument deduction. | |
1854 * Given 'this' being the type argument to the template instance, | |
1855 * it is matched against the template declaration parameter specialization | |
1856 * 'tparam' to determine the type to be used for the parameter. | |
1857 * Example: | |
1858 * template Foo(T:T*) // template declaration | |
1859 * Foo!(int*) // template instantiation | |
1860 * Input: | |
1861 * this = int* | |
1862 * tparam = T | |
1863 * parameters = [ T:T* ] // Array of TemplateParameter's | |
1864 * Output: | |
1865 * dedtypes = [ int ] // Array of Expression/Type's | |
1866 */ | |
1867 MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes) | |
1868 { | |
98 | 1869 static if (false) |
1870 { | |
0 | 1871 printf("Type.deduceType()\n"); |
1872 printf("\tthis = %d, ", ty); print(); | |
1873 printf("\ttparam = %d, ", tparam.ty); tparam.print(); | |
1874 } | |
1875 if (!tparam) | |
1876 goto Lnomatch; | |
1877 | |
1878 if (this == tparam) | |
1879 goto Lexact; | |
1880 | |
1881 if (tparam.ty == Tident) | |
1882 { | |
1883 // Determine which parameter tparam is | |
1884 int i = templateParameterLookup(tparam, parameters); | |
1885 if (i == -1) | |
1886 { | |
1887 if (!sc) | |
1888 goto Lnomatch; | |
1889 | |
1890 /* Need a loc to go with the semantic routine. | |
1891 */ | |
1892 Loc loc; | |
1893 if (parameters.dim) | |
1894 { | |
1895 TemplateParameter tp = cast(TemplateParameter)parameters.data[0]; | |
1896 loc = tp.loc; | |
1897 } | |
1898 | |
1899 /* BUG: what if tparam is a template instance, that | |
1900 * has as an argument another Tident? | |
1901 */ | |
1902 tparam = tparam.semantic(loc, sc); | |
1903 assert(tparam.ty != Tident); | |
1904 return deduceType(sc, tparam, parameters, dedtypes); | |
1905 } | |
1906 | |
1907 TemplateParameter tp = cast(TemplateParameter)parameters.data[i]; | |
1908 | |
1909 // Found the corresponding parameter tp | |
1910 if (!tp.isTemplateTypeParameter()) | |
1911 goto Lnomatch; | |
1912 Type tt = this; | |
1913 Type at = cast(Type)dedtypes.data[i]; | |
1914 | |
98 | 1915 // 5*5 == 25 cases |
1916 static pure int X(int U, int T) { return ((U << 3) | T); } | |
1917 | |
1918 switch (X(tparam.mod, mod)) | |
1919 { | |
1920 case X(0, 0): | |
1921 case X(0, MODconst): | |
1922 case X(0, MODinvariant): | |
1923 case X(0, MODshared): | |
1924 case X(0, MODconst | MODshared): | |
1925 // foo(U:U) T => T | |
1926 // foo(U:U) const(T) => const(T) | |
1927 // foo(U:U) immutable(T) => immutable(T) | |
1928 // foo(U:U) shared(T) => shared(T) | |
1929 // foo(U:U) const(shared(T)) => const(shared(T)) | |
0 | 1930 if (!at) |
110 | 1931 { dedtypes[i] = tt; |
0 | 1932 goto Lexact; |
1933 } | |
98 | 1934 break; |
1935 | |
1936 case X(MODconst, MODconst): | |
1937 case X(MODinvariant, MODinvariant): | |
1938 case X(MODshared, MODshared): | |
1939 case X(MODconst | MODshared, MODconst | MODshared): | |
1940 // foo(U:const(U)) const(T) => T | |
1941 // foo(U:immutable(U)) immutable(T) => T | |
1942 // foo(U:shared(U)) shared(T) => T | |
1943 // foo(U:const(shared(U)) const(shared(T))=> T | |
1944 tt = mutableOf().unSharedOf(); | |
0 | 1945 if (!at) |
110 | 1946 { |
94
3a0b150c9841
Objects -> Vector!Object iteration 1
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
87
diff
changeset
|
1947 dedtypes[i] = tt; |
0 | 1948 goto Lexact; |
1949 } | |
98 | 1950 break; |
1951 | |
1952 case X(MODconst, 0): | |
1953 case X(MODconst, MODimmutable): | |
1954 case X(MODconst, MODconst | MODshared): | |
1955 case X(MODconst | MODshared, MODimmutable): | |
1956 // foo(U:const(U)) T => T | |
1957 // foo(U:const(U)) immutable(T) => T | |
1958 // foo(U:const(U)) const(shared(T)) => shared(T) | |
1959 // foo(U:const(shared(U)) immutable(T) => T | |
0 | 1960 tt = mutableOf(); |
1961 if (!at) | |
110 | 1962 { dedtypes[i] = tt; |
98 | 1963 goto Lconst; |
0 | 1964 } |
98 | 1965 break; |
1966 | |
1967 case X(MODshared, MODconst | MODshared): | |
1968 case X(MODconst | MODshared, MODshared): | |
1969 // foo(U:shared(U)) const(shared(T)) => const(T) | |
1970 // foo(U:const(shared(U)) shared(T) => T | |
1971 tt = unSharedOf(); | |
0 | 1972 if (!at) |
110 | 1973 { dedtypes[i] = tt; |
0 | 1974 goto Lconst; |
1975 } | |
98 | 1976 break; |
1977 | |
1978 case X(MODimmutable, 0): | |
1979 case X(MODimmutable, MODconst): | |
1980 case X(MODimmutable, MODshared): | |
1981 case X(MODimmutable, MODconst | MODshared): | |
1982 case X(MODconst, MODshared): | |
1983 case X(MODshared, 0): | |
1984 case X(MODshared, MODconst): | |
1985 case X(MODshared, MODimmutable): | |
1986 case X(MODconst | MODshared, 0): | |
1987 case X(MODconst | MODshared, MODconst): | |
1988 // foo(U:immutable(U)) T => nomatch | |
1989 // foo(U:immutable(U)) const(T) => nomatch | |
1990 // foo(U:immutable(U)) shared(T) => nomatch | |
1991 // foo(U:immutable(U)) const(shared(T)) => nomatch | |
1992 // foo(U:const(U)) shared(T) => nomatch | |
1993 // foo(U:shared(U)) T => nomatch | |
1994 // foo(U:shared(U)) const(T) => nomatch | |
1995 // foo(U:shared(U)) immutable(T) => nomatch | |
1996 // foo(U:const(shared(U)) T => nomatch | |
1997 // foo(U:const(shared(U)) const(T) => nomatch | |
1998 //if (!at) | |
0 | 1999 goto Lnomatch; |
98 | 2000 break; |
2001 | |
2002 default: | |
2003 assert(0); | |
0 | 2004 } |
2005 | |
2006 if (tt.equals(at)) | |
2007 goto Lexact; | |
2008 else if (tt.ty == Tclass && at.ty == Tclass) | |
2009 { | |
2010 return tt.implicitConvTo(at); | |
2011 } | |
2012 else if (tt.ty == Tsarray && at.ty == Tarray && | |
2013 tt.nextOf().implicitConvTo(at.nextOf()) >= MATCHconst) | |
2014 { | |
2015 goto Lexact; | |
2016 } | |
2017 else | |
2018 goto Lnomatch; | |
2019 } | |
2020 | |
2021 if (ty != tparam.ty) | |
2022 return implicitConvTo(tparam); | |
2023 // goto Lnomatch; | |
2024 | |
2025 if (nextOf()) | |
2026 return nextOf().deduceType(sc, tparam.nextOf(), parameters, dedtypes); | |
2027 | |
2028 Lexact: | |
2029 return MATCHexact; | |
2030 | |
2031 Lnomatch: | |
2032 return MATCHnomatch; | |
2033 | |
2034 version (DMDV2) { | |
2035 Lconst: | |
2036 return MATCHconst; | |
2037 } | |
2038 } | |
2039 | |
2040 void resolve(Loc loc, Scope sc, Expression* pe, Type* pt, Dsymbol* ps) | |
2041 { | |
2042 //printf("Type.resolve() %s, %d\n", toChars(), ty); | |
2043 Type t = semantic(loc, sc); | |
2044 *pt = t; | |
2045 *pe = null; | |
2046 *ps = null; | |
2047 } | |
2048 | |
2049 /******************************************* | |
2050 * Get a canonicalized form of the TypeInfo for use with the internal | |
2051 * runtime library routines. Canonicalized in that static arrays are | |
2052 * represented as dynamic arrays, enums are represented by their | |
2053 * underlying type, etc. This reduces the number of TypeInfo's needed, | |
2054 * so we can use the custom internal ones more. | |
2055 */ | |
2056 Expression getInternalTypeInfo(Scope sc) | |
2057 { | |
2058 TypeInfoDeclaration tid; | |
2059 Expression e; | |
2060 Type t; | |
2061 static TypeInfoDeclaration internalTI[TMAX]; | |
2062 | |
2063 //printf("Type.getInternalTypeInfo() %s\n", toChars()); | |
2064 t = toBasetype(); | |
2065 switch (t.ty) | |
2066 { | |
2067 case Tsarray: | |
2068 static if (false) { | |
2069 // convert to corresponding dynamic array type | |
2070 t = t.nextOf().mutableOf().arrayOf(); | |
2071 } | |
2072 break; | |
2073 | |
2074 case Tclass: | |
2075 if ((cast(TypeClass)t).sym.isInterfaceDeclaration()) | |
2076 break; | |
2077 goto Linternal; | |
2078 | |
2079 case Tarray: | |
2080 // convert to corresponding dynamic array type | |
2081 t = t.nextOf().mutableOf().arrayOf(); | |
2082 if (t.nextOf().ty != Tclass) | |
2083 break; | |
2084 goto Linternal; | |
2085 | |
2086 case Tfunction: | |
2087 case Tdelegate: | |
2088 case Tpointer: | |
2089 Linternal: | |
2090 tid = internalTI[t.ty]; | |
2091 if (!tid) | |
2092 { | |
2093 tid = new TypeInfoDeclaration(t, 1); | |
2094 internalTI[t.ty] = tid; | |
2095 } | |
2096 e = new VarExp(Loc(0), tid); | |
2097 e = e.addressOf(sc); | |
2098 e.type = tid.type; // do this so we don't get redundant dereference | |
2099 return e; | |
2100 | |
2101 default: | |
2102 break; | |
2103 } | |
2104 //printf("\tcalling getTypeInfo() %s\n", t.toChars()); | |
2105 return t.getTypeInfo(sc); | |
2106 } | |
2107 | |
2108 /**************************************************** | |
2109 * Get the exact TypeInfo. | |
2110 */ | |
2111 Expression getTypeInfo(Scope sc) | |
2112 { | |
2113 Expression e; | |
2114 Type t; | |
2115 | |
2116 //printf("Type.getTypeInfo() %p, %s\n", this, toChars()); | |
2117 t = merge2(); // do this since not all Type's are merge'd | |
2118 if (!t.vtinfo) | |
2119 { | |
2120 version (DMDV2) { | |
2121 if (t.isShared()) // does both 'shared' and 'shared const' | |
2122 t.vtinfo = new TypeInfoSharedDeclaration(t); | |
2123 else if (t.isConst()) | |
2124 t.vtinfo = new TypeInfoConstDeclaration(t); | |
2125 else if (t.isInvariant()) | |
2126 t.vtinfo = new TypeInfoInvariantDeclaration(t); | |
2127 else | |
2128 t.vtinfo = t.getTypeInfoDeclaration(); | |
2129 } else { | |
2130 t.vtinfo = t.getTypeInfoDeclaration(); | |
2131 } | |
2132 assert(t.vtinfo); | |
2133 vtinfo = t.vtinfo; | |
2134 | |
2135 /* If this has a custom implementation in std/typeinfo, then | |
2136 * do not generate a COMDAT for it. | |
2137 */ | |
2138 if (!t.builtinTypeInfo()) | |
2139 { | |
2140 // Generate COMDAT | |
2141 if (sc) // if in semantic() pass | |
2142 { | |
2143 // Find module that will go all the way to an object file | |
2144 Module m = sc.module_.importedFrom; | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
2145 m.members.push(t.vtinfo); |
0 | 2146 } |
2147 else // if in obj generation pass | |
2148 { | |
2149 t.vtinfo.toObjFile(global.params.multiobj); | |
2150 } | |
2151 } | |
2152 } | |
2153 e = new VarExp(Loc(0), t.vtinfo); | |
2154 e = e.addressOf(sc); | |
2155 e.type = t.vtinfo.type; // do this so we don't get redundant dereference | |
2156 return e; | |
2157 } | |
2158 | |
2159 TypeInfoDeclaration getTypeInfoDeclaration() | |
2160 { | |
2161 //printf("Type.getTypeInfoDeclaration() %s\n", toChars()); | |
2162 return new TypeInfoDeclaration(this, 0); | |
2163 } | |
2164 | |
2165 /* These decide if there's an instance for them already in std.typeinfo, | |
2166 * because then the compiler doesn't need to build one. | |
2167 */ | |
2168 bool builtinTypeInfo() | |
2169 { | |
2170 return false; | |
2171 } | |
2172 | |
2173 /******************************* | |
2174 * If one of the subtypes of this type is a TypeIdentifier, | |
2175 * i.e. it's an unresolved type, return that type. | |
2176 */ | |
2177 Type reliesOnTident() | |
2178 { | |
2179 return null; | |
2180 } | |
2181 | |
2182 Expression toExpression() | |
2183 { | |
2184 assert(false); | |
2185 } | |
2186 | |
2187 /*************************************** | |
2188 * Return true if type has pointers that need to | |
2189 * be scanned by the GC during a collection cycle. | |
2190 */ | |
2191 bool hasPointers() | |
2192 { | |
2193 return false; | |
2194 } | |
2195 | |
2196 /************************************* | |
2197 * If this is a type of something, return that something. | |
2198 */ | |
2199 Type nextOf() | |
2200 { | |
2201 return null; | |
2202 } | |
2203 | |
53 | 2204 /**************************************** |
2205 * Return the mask that an integral type will | |
2206 * fit into. | |
2207 */ | |
0 | 2208 ulong sizemask() |
2209 { | |
53 | 2210 ulong m; |
2211 | |
2212 switch (toBasetype().ty) | |
2213 { | |
2214 case Tbool: m = 1; break; | |
2215 case Tchar: | |
2216 case Tint8: | |
2217 case Tuns8: m = 0xFF; break; | |
2218 case Twchar: | |
2219 case Tint16: | |
2220 case Tuns16: m = 0xFFFFUL; break; | |
2221 case Tdchar: | |
2222 case Tint32: | |
2223 case Tuns32: m = 0xFFFFFFFFUL; break; | |
2224 case Tint64: | |
2225 case Tuns64: m = 0xFFFFFFFFFFFFFFFFUL; break; | |
2226 default: | |
2227 assert(0); | |
2228 } | |
2229 return m; | |
0 | 2230 } |
2231 | |
2232 static void error(T...)(Loc loc, string format, T t) | |
2233 { | |
2234 .error(loc, format, t); | |
2235 } | |
2236 | |
2237 static void warning(T...)(Loc loc, string format, T t) | |
2238 { | |
2239 assert(false); | |
2240 } | |
2241 | |
2242 // For backend | |
2243 /***************************** | |
2244 * Return back end type corresponding to D front end type. | |
2245 */ | |
2246 TYM totym() | |
2247 { | |
2248 TYM t; | |
2249 | |
2250 switch (ty) | |
2251 { | |
2252 case TY.Tvoid: t = TYM.TYvoid; break; | |
2253 case TY.Tint8: t = TYM.TYschar; break; | |
2254 case TY.Tuns8: t = TYM.TYuchar; break; | |
2255 case TY.Tint16: t = TYM.TYshort; break; | |
2256 case TY.Tuns16: t = TYM.TYushort; break; | |
2257 case TY.Tint32: t = TYM.TYint; break; | |
2258 case TY.Tuns32: t = TYM.TYuint; break; | |
2259 case TY.Tint64: t = TYM.TYllong; break; | |
2260 case TY.Tuns64: t = TYM.TYullong; break; | |
2261 case TY.Tfloat32: t = TYM.TYfloat; break; | |
2262 case TY.Tfloat64: t = TYM.TYdouble; break; | |
2263 case TY.Tfloat80: t = TYM.TYldouble; break; | |
2264 case TY.Timaginary32: t = TYM.TYifloat; break; | |
2265 case TY.Timaginary64: t = TYM.TYidouble; break; | |
2266 case TY.Timaginary80: t = TYM.TYildouble; break; | |
2267 case TY.Tcomplex32: t = TYM.TYcfloat; break; | |
2268 case TY.Tcomplex64: t = TYM.TYcdouble; break; | |
2269 case TY.Tcomplex80: t = TYM.TYcldouble; break; | |
2270 //case Tbit: t = TYM.TYuchar; break; | |
2271 case TY.Tbool: t = TYM.TYbool; break; | |
2272 case TY.Tchar: t = TYM.TYchar; break; | |
2273 version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS | |
2274 case TY.Twchar: t = TYM.TYwchar_t; break; | |
2275 case TY.Tdchar: t = TYM.TYdchar; break; | |
2276 } else { | |
2277 case TY.Twchar: t = TYM.TYwchar_t; break; | |
2278 case TY.Tdchar: | |
2279 t = (global.params.symdebug == 1) ? TYM.TYdchar : TYM.TYulong; | |
2280 break; | |
2281 } | |
2282 | |
2283 case TY.Taarray: t = TYM.TYaarray; break; | |
2284 case TY.Tclass: | |
2285 case TY.Treference: | |
2286 case TY.Tpointer: t = TYM.TYnptr; break; | |
2287 case TY.Tdelegate: t = TYM.TYdelegate; break; | |
2288 case TY.Tarray: t = TYM.TYdarray; break; | |
98 | 2289 version(SARRAYVALUE) |
2290 { case TY.Tsarray: t = TYstruct; break;} | |
2291 else | |
2292 { case TY.Tsarray: t = TYM.TYarray; break;} | |
0 | 2293 case TY.Tstruct: t = TYM.TYstruct; break; |
2294 | |
2295 case TY.Tenum: | |
2296 case TY.Ttypedef: | |
2297 t = toBasetype().totym(); | |
2298 break; | |
2299 | |
2300 case TY.Tident: | |
2301 case TY.Ttypeof: | |
2302 debug { | |
2303 writef("ty = %d, '%s'\n", ty, toChars()); | |
2304 } | |
2305 error (Loc(0), "forward reference of %s", toChars()); | |
2306 t = TYM.TYint; | |
2307 break; | |
2308 | |
2309 default: | |
2310 debug { | |
2311 writef("ty = %d, '%s'\n", ty, toChars()); | |
2312 } | |
2313 assert(0); | |
2314 } | |
2315 | |
2316 version (DMDV2) { | |
2317 // Add modifiers | |
2318 switch (mod) | |
2319 { | |
2320 case MOD.MODundefined: | |
2321 break; | |
2322 case MOD.MODconst: | |
2323 t |= mTY.mTYconst; | |
2324 break; | |
2325 case MOD.MODinvariant: | |
2326 t |= mTY.mTYimmutable; | |
2327 break; | |
2328 case MOD.MODshared: | |
2329 t |= mTY.mTYshared; | |
2330 break; | |
2331 case MOD.MODshared | MOD.MODconst: | |
2332 t |= mTY.mTYshared | mTY.mTYconst; | |
2333 break; | |
2334 default: | |
2335 assert(0); | |
2336 } | |
2337 } | |
2338 | |
2339 return t; | |
2340 } | |
2341 | |
2342 /*************************************** | |
2343 * Convert from D type to C type. | |
2344 * This is done so C debug info can be generated. | |
2345 */ | |
2346 type* toCtype() | |
2347 { | |
2348 if (!ctype) | |
2349 { | |
2350 ctype = type_fake(totym()); | |
2351 ctype.Tcount++; | |
2352 } | |
2353 return ctype; | |
2354 } | |
2355 | |
2356 type* toCParamtype() | |
2357 { | |
2358 return toCtype(); | |
2359 } | |
2360 | |
2361 Symbol* toSymbol() | |
2362 { | |
2363 assert(false); | |
2364 } | |
2365 | |
2366 // For eliminating dynamic_cast | |
2367 TypeBasic isTypeBasic() | |
2368 { | |
2369 return null; | |
2370 } | |
2371 | |
2372 static Type tvoid() | |
2373 { | |
2374 return basic[TY.Tvoid]; | |
2375 } | |
2376 | |
2377 static Type tint8() | |
2378 { | |
2379 return basic[TY.Tint8]; | |
2380 } | |
2381 | |
2382 static Type tuns8() | |
2383 { | |
2384 return basic[TY.Tuns8]; | |
2385 } | |
2386 | |
2387 static Type tint16() | |
2388 { | |
2389 return basic[TY.Tint16]; | |
2390 } | |
2391 | |
2392 static Type tuns16() | |
2393 { | |
2394 return basic[TY.Tuns16]; | |
2395 } | |
2396 | |
2397 static Type tint32() | |
2398 { | |
2399 return basic[TY.Tint32]; | |
2400 } | |
2401 | |
2402 static Type tuns32() | |
2403 { | |
2404 return basic[TY.Tuns32]; | |
2405 } | |
2406 | |
2407 static Type tint64() | |
2408 { | |
2409 return basic[TY.Tint64]; | |
2410 } | |
2411 | |
2412 static Type tuns64() | |
2413 { | |
2414 return basic[TY.Tuns64]; | |
2415 } | |
2416 | |
2417 static Type tfloat32() | |
2418 { | |
2419 return basic[TY.Tfloat32]; | |
2420 } | |
2421 | |
2422 static Type tfloat64() | |
2423 { | |
2424 return basic[TY.Tfloat64]; | |
2425 } | |
2426 | |
2427 static Type tfloat80() | |
2428 { | |
2429 return basic[TY.Tfloat80]; | |
2430 } | |
2431 | |
2432 static Type timaginary32() | |
2433 { | |
2434 return basic[TY.Timaginary32]; | |
2435 } | |
2436 | |
2437 static Type timaginary64() | |
2438 { | |
2439 return basic[TY.Timaginary64]; | |
2440 } | |
2441 | |
2442 static Type timaginary80() | |
2443 { | |
2444 return basic[TY.Timaginary80]; | |
2445 } | |
2446 | |
2447 static Type tcomplex32() | |
2448 { | |
2449 return basic[TY.Tcomplex32]; | |
2450 } | |
2451 | |
2452 static Type tcomplex64() | |
2453 { | |
2454 return basic[TY.Tcomplex64]; | |
2455 } | |
2456 | |
2457 static Type tcomplex80() | |
2458 { | |
2459 return basic[TY.Tcomplex80]; | |
2460 } | |
2461 | |
2462 static Type tbit() | |
2463 { | |
2464 return basic[TY.Tbit]; | |
2465 } | |
2466 | |
2467 static Type tbool() | |
2468 { | |
2469 return basic[TY.Tbool]; | |
2470 } | |
2471 | |
2472 static Type tchar() | |
2473 { | |
2474 return basic[TY.Tchar]; | |
2475 } | |
2476 | |
2477 static Type twchar() | |
2478 { | |
2479 return basic[TY.Twchar]; | |
2480 } | |
2481 | |
2482 static Type tdchar() | |
2483 { | |
2484 return basic[TY.Tdchar]; | |
2485 } | |
2486 | |
2487 // Some special types | |
2488 static Type tshiftcnt() | |
2489 { | |
2490 return tint32; // right side of shift expression | |
2491 } | |
2492 | |
2493 // #define tboolean tint32 // result of boolean expression | |
2494 static Type tboolean() | |
2495 { | |
2496 return tbool; // result of boolean expression | |
2497 } | |
2498 | |
2499 static Type tindex() | |
2500 { | |
2501 return tint32; // array/ptr index | |
2502 } | |
2503 | |
2504 static Type tvoidptr; // void* | |
98 | 2505 static Type tstring; // immutable(char)[] |
2506 | |
0 | 2507 static Type terror() |
2508 { | |
2509 return basic[TY.Terror]; // for error recovery | |
2510 } | |
2511 | |
2512 static Type tsize_t() | |
2513 { | |
2514 return basic[Tsize_t]; // matches size_t alias | |
2515 } | |
2516 | |
2517 static Type tptrdiff_t() | |
2518 { | |
2519 return basic[Tptrdiff_t]; // matches ptrdiff_t alias | |
2520 } | |
2521 | |
2522 static Type thash_t() | |
2523 { | |
2524 return tsize_t; // matches hash_t alias | |
2525 } | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
4
diff
changeset
|
2526 } |