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