Mercurial > projects > ddmd
annotate dmd/TypeAArray.d @ 187:b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author | Abscissa |
---|---|
date | Tue, 07 Jun 2011 23:37:34 -0400 |
parents | cd48cb899aee |
children |
rev | line source |
---|---|
0 | 1 module dmd.TypeAArray; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.TypeArray; |
5 import dmd.MOD; | |
6 import dmd.ArrayTypes; | |
7 import dmd.TypeInfoDeclaration; | |
68
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
8 import dmd.TypeInfoAssociativeArrayDeclaration; |
0 | 9 import dmd.Expression; |
10 import dmd.Scope; | |
96 | 11 import dmd.StructDeclaration; |
0 | 12 import dmd.Loc; |
179 | 13 import dmd.DotTemplateInstanceExp; |
14 import dmd.IdentifierExp; | |
67 | 15 import dmd.Global; |
0 | 16 import dmd.Dsymbol; |
17 import dmd.Type; | |
18 import dmd.TypeSArray; | |
19 import dmd.OutBuffer; | |
20 import dmd.HdrGenState; | |
21 import dmd.Identifier; | |
22 import dmd.MATCH; | |
23 import dmd.TY; | |
96 | 24 import dmd.TemplateInstance; |
0 | 25 import dmd.Id; |
26 import dmd.CallExp; | |
27 import dmd.IntegerExp; | |
28 import dmd.FuncDeclaration; | |
29 import dmd.VarExp; | |
30 import dmd.TypeFunction; | |
31 import dmd.NullExp; | |
32 import dmd.Array; | |
33 | |
34 import dmd.backend.Symbol; | |
35 import dmd.backend.TYPE; | |
36 import dmd.backend.Util; | |
37 import dmd.backend.SC; | |
38 import dmd.backend.LIST; | |
39 import dmd.backend.TYM; | |
40 import dmd.backend.TF; | |
67 | 41 import dmd.backend.Classsym; |
0 | 42 import dmd.backend.mTYman; |
43 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
44 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
45 |
0 | 46 import core.stdc.stdio; |
47 import core.stdc.stdlib; | |
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:
0
diff
changeset
|
48 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:
0
diff
changeset
|
49 import core.memory; |
0 | 50 class TypeAArray : TypeArray |
51 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
52 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
53 |
96 | 54 Type index; // key type |
55 Loc loc; | |
56 Scope sc; | |
57 StructDeclaration impl; // implementation | |
0 | 58 |
59 this(Type t, Type index) | |
60 { | |
178 | 61 register(); |
0 | 62 super(Taarray, t); |
63 this.index = index; | |
64 } | |
65 | |
72 | 66 override Type syntaxCopy() |
0 | 67 { |
51 | 68 Type t = next.syntaxCopy(); |
69 Type ti = index.syntaxCopy(); | |
70 if (t == next && ti == index) | |
71 t = this; | |
72 else | |
73 { | |
74 t = new TypeAArray(t, ti); | |
75 t.mod = mod; | |
76 } | |
77 return t; | |
0 | 78 } |
79 | |
72 | 80 override ulong size(Loc loc) |
0 | 81 { |
82 return PTRSIZE /* * 2*/; | |
83 } | |
84 | |
72 | 85 override Type semantic(Loc loc, Scope sc) |
0 | 86 { |
87 //printf("TypeAArray::semantic() %s index.ty = %d\n", toChars(), index.ty); | |
96 | 88 this.loc = loc; |
89 this.sc = sc; | |
90 if (sc) | |
91 sc.setNoFree(); | |
92 | |
0 | 93 // Deal with the case where we thought the index was a type, but |
94 // in reality it was an expression. | |
95 if (index.ty == Tident || index.ty == Tinstance || index.ty == Tsarray) | |
96 { | |
97 Expression e; | |
98 Type t; | |
99 Dsymbol s; | |
100 | |
101 index.resolve(loc, sc, &e, &t, &s); | |
102 if (e) | |
103 { // It was an expression - | |
104 // Rewrite as a static array | |
105 TypeSArray tsa = new TypeSArray(next, e); | |
106 return tsa.semantic(loc,sc); | |
107 } | |
108 else if (t) | |
109 index = t; | |
110 else | |
96 | 111 { |
0 | 112 index.error(loc, "index is not a type or an expression"); |
96 | 113 return Type.terror; |
114 } | |
0 | 115 } |
116 else | |
117 index = index.semantic(loc,sc); | |
118 | |
135 | 119 if (index.nextOf() && !index.nextOf().isImmutable()) |
0 | 120 { |
121 index = index.constOf().mutableOf(); | |
96 | 122 static if (false) |
123 { | |
0 | 124 printf("index is %p %s\n", index, index.toChars()); |
125 index.check(); | |
126 printf("index.mod = x%x\n", index.mod); | |
127 printf("index.ito = x%x\n", index.ito); | |
128 if (index.ito) { | |
129 printf("index.ito.mod = x%x\n", index.ito.mod); | |
130 printf("index.ito.ito = x%x\n", index.ito.ito); | |
131 } | |
132 } | |
133 } | |
134 | |
135 switch (index.toBasetype().ty) | |
136 { | |
137 case Tbool: | |
138 case Tfunction: | |
139 case Tvoid: | |
140 case Tnone: | |
73 | 141 case Ttuple: |
0 | 142 error(loc, "can't have associative array key of %s", index.toBasetype().toChars()); |
96 | 143 return Type.terror; |
0 | 144 default: |
145 break; /// | |
146 } | |
147 next = next.semantic(loc,sc); | |
148 transitive(); | |
149 | |
150 switch (next.toBasetype().ty) | |
151 { | |
152 case Tfunction: | |
153 case Tnone: | |
154 error(loc, "can't have associative array of %s", next.toChars()); | |
96 | 155 return Type.terror; |
0 | 156 default: |
157 break; /// | |
158 } | |
159 if (next.isauto()) | |
96 | 160 { |
0 | 161 error(loc, "cannot have array of auto %s", next.toChars()); |
96 | 162 return Type.terror; |
163 } | |
0 | 164 return merge(); |
165 } | |
166 | |
96 | 167 StructDeclaration getImpl() |
168 { | |
169 // Do it lazily | |
170 if (!impl) | |
171 { | |
172 if (!index.reliesOnTident() && !next.reliesOnTident()) | |
173 { | |
174 /* This is really a proxy for the template instance AssocArray!(index, next) | |
175 * But the instantiation can fail if it is a template specialization field | |
176 * which has Tident's instead of real types. | |
177 */ | |
178 Objects tiargs = new Objects(); | |
111 | 179 tiargs.push(index); |
180 tiargs.push(next); | |
179 | 181 |
182 // Create .AssociativeArray!(index, next) | |
183 DotTemplateInstanceExp dti = new DotTemplateInstanceExp(loc, | |
184 new IdentifierExp(loc, Id.empty), | |
185 Id.AssociativeArray, | |
186 tiargs); | |
187 dti.semantic(sc); | |
188 TemplateInstance ti = dti.ti; | |
189 | |
96 | 190 ti.semantic(sc); |
191 ti.semantic2(sc); | |
192 ti.semantic3(sc); | |
193 impl = ti.toAlias().isStructDeclaration(); | |
194 debug | |
195 { | |
196 if (!impl) | |
197 { | |
198 Dsymbol s = ti.toAlias(); | |
199 writef("%s %s\n", s.kind(), s.toChars()); | |
200 } | |
201 } | |
202 assert(impl); | |
203 } | |
204 } | |
205 return impl; | |
206 | |
207 } | |
208 | |
72 | 209 override void resolve(Loc loc, Scope sc, Expression* pe, Type* pt, Dsymbol* ps) |
0 | 210 { |
51 | 211 //printf("TypeAArray.resolve() %s\n", toChars()); |
212 | |
213 // Deal with the case where we thought the index was a type, but | |
214 // in reality it was an expression. | |
215 if (index.ty == Tident || index.ty == Tinstance || index.ty == Tsarray) | |
216 { | |
217 Expression e; | |
218 Type t; | |
219 Dsymbol s; | |
220 | |
221 index.resolve(loc, sc, &e, &t, &s); | |
222 if (e) | |
223 { // It was an expression - | |
224 // Rewrite as a static array | |
225 | |
226 TypeSArray tsa = new TypeSArray(next, e); | |
227 return tsa.resolve(loc, sc, pe, pt, ps); | |
228 } | |
229 else if (t) | |
230 index = t; | |
231 else | |
232 index.error(loc, "index is not a type or an expression"); | |
233 } | |
234 Type.resolve(loc, sc, pe, pt, ps); | |
0 | 235 } |
236 | |
72 | 237 override void toDecoBuffer(OutBuffer buf, int flag) |
0 | 238 { |
239 Type.toDecoBuffer(buf, flag); | |
240 index.toDecoBuffer(buf); | |
241 next.toDecoBuffer(buf, (flag & 0x100) ? MOD.MODundefined : mod); | |
242 } | |
243 | |
72 | 244 override void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod) |
0 | 245 { |
68
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
246 if (mod != this.mod) |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
247 { |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
248 toCBuffer3(buf, hgs, mod); |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
249 return; |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
250 } |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
251 next.toCBuffer2(buf, hgs, this.mod); |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
252 buf.writeByte('['); |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
253 index.toCBuffer2(buf, hgs, MODundefined); |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
254 buf.writeByte(']'); |
0 | 255 } |
256 | |
72 | 257 override Expression dotExp(Scope sc, Expression e, Identifier ident) |
0 | 258 { |
259 version (LOGDOTEXP) { | |
260 printf("TypeAArray.dotExp(e = '%s', ident = '%s')\n", e.toChars(), ident.toChars()); | |
261 } | |
96 | 262 static if (false) |
263 { | |
0 | 264 if (ident == Id.length) |
265 { | |
266 Expression ec; | |
267 FuncDeclaration fd; | |
268 Expressions arguments; | |
269 | |
270 fd = FuncDeclaration.genCfunc(Type.tsize_t, Id.aaLen); | |
271 ec = new VarExp(Loc(0), fd); | |
272 arguments = new Expressions(); | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
273 arguments.push(e); |
0 | 274 e = new CallExp(e.loc, ec, arguments); |
275 e.type = (cast(TypeFunction)fd.type).next; | |
276 } | |
277 else if (ident == Id.keys) | |
278 { | |
279 Expression ec; | |
280 FuncDeclaration fd; | |
281 Expressions arguments; | |
282 int size = cast(int)index.size(e.loc); | |
283 | |
284 assert(size); | |
285 fd = FuncDeclaration.genCfunc(Type.tindex, Id.aaKeys); | |
286 ec = new VarExp(Loc(0), fd); | |
287 arguments = new Expressions(); | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
288 arguments.push(e); |
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
289 arguments.push(new IntegerExp(Loc(0), size, Type.tsize_t)); |
0 | 290 e = new CallExp(e.loc, ec, arguments); |
291 e.type = index.arrayOf(); | |
292 } | |
293 else if (ident == Id.values) | |
294 { | |
295 Expression ec; | |
296 FuncDeclaration fd; | |
297 Expressions arguments; | |
298 | |
299 fd = FuncDeclaration.genCfunc(Type.tindex, Id.aaValues); | |
300 ec = new VarExp(Loc(0), fd); | |
301 arguments = new Expressions(); | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
302 arguments.push(e); |
0 | 303 size_t keysize = cast(size_t)index.size(e.loc); |
304 keysize = (keysize + PTRSIZE - 1) & ~(PTRSIZE - 1); | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
305 arguments.push(new IntegerExp(Loc(0), keysize, Type.tsize_t)); |
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
306 arguments.push(new IntegerExp(Loc(0), next.size(e.loc), Type.tsize_t)); |
0 | 307 e = new CallExp(e.loc, ec, arguments); |
308 e.type = next.arrayOf(); | |
309 } | |
310 else if (ident == Id.rehash) | |
311 { | |
312 Expression ec; | |
313 FuncDeclaration fd; | |
314 Expressions arguments; | |
315 | |
316 fd = FuncDeclaration.genCfunc(Type.tint64, Id.aaRehash); | |
317 ec = new VarExp(Loc(0), fd); | |
318 arguments = new Expressions(); | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
319 arguments.push(e.addressOf(sc)); |
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
320 arguments.push(index.getInternalTypeInfo(sc)); |
0 | 321 e = new CallExp(e.loc, ec, arguments); |
322 e.type = this; | |
323 } | |
96 | 324 // else |
325 } // of static if (false) | |
0 | 326 { |
96 | 327 e.type = getImpl().type; |
328 e = e.type.dotExp(sc, e, ident); | |
329 //e = Type.dotExp(sc, e, ident); | |
0 | 330 } |
331 return e; | |
332 } | |
333 | |
72 | 334 override Expression defaultInit(Loc loc) |
0 | 335 { |
336 version (LOGDEFAULTINIT) { | |
337 printf("TypeAArray.defaultInit() '%s'\n", toChars()); | |
338 } | |
135 | 339 return new NullExp(loc, this); |
0 | 340 } |
341 | |
72 | 342 override MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes) |
0 | 343 { |
51 | 344 static if (false) { |
345 printf("TypeAArray.deduceType()\n"); | |
346 printf("\tthis = %d, ", ty); print(); | |
347 printf("\ttparam = %d, ", tparam.ty); tparam.print(); | |
348 } | |
349 | |
350 // Extra check that index type must match | |
351 if (tparam && tparam.ty == Taarray) | |
352 { | |
353 TypeAArray tp = cast(TypeAArray)tparam; | |
354 if (!index.deduceType(sc, tp.index, parameters, dedtypes)) | |
355 { | |
356 return MATCHnomatch; | |
357 } | |
358 } | |
359 return Type.deduceType(sc, tparam, parameters, dedtypes); | |
0 | 360 } |
361 | |
72 | 362 override bool isZeroInit(Loc loc) |
0 | 363 { |
129 | 364 return true; |
0 | 365 } |
366 | |
72 | 367 override bool checkBoolean() |
0 | 368 { |
129 | 369 return true; |
0 | 370 } |
371 | |
72 | 372 override TypeInfoDeclaration getTypeInfoDeclaration() |
0 | 373 { |
68
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
67
diff
changeset
|
374 return new TypeInfoAssociativeArrayDeclaration(this); |
0 | 375 } |
376 | |
72 | 377 override bool hasPointers() |
0 | 378 { |
379 return true; | |
380 } | |
381 | |
72 | 382 override MATCH implicitConvTo(Type to) |
0 | 383 { |
51 | 384 //printf("TypeAArray.implicitConvTo(to = %s) this = %s\n", to.toChars(), toChars()); |
385 if (equals(to)) | |
386 return MATCHexact; | |
387 | |
388 if (to.ty == Taarray) | |
389 { | |
390 TypeAArray ta = cast(TypeAArray)to; | |
391 | |
135 | 392 if (!MODimplicitConv(next.mod, ta.next.mod)) |
51 | 393 return MATCHnomatch; // not const-compatible |
394 | |
135 | 395 if (!MODimplicitConv(index.mod, ta.index.mod)) |
51 | 396 return MATCHnomatch; // not const-compatible |
397 | |
398 MATCH m = next.constConv(ta.next); | |
399 MATCH mi = index.constConv(ta.index); | |
400 if (m != MATCHnomatch && mi != MATCHnomatch) | |
401 { | |
402 if (m == MATCHexact && mod != to.mod) | |
403 m = MATCHconst; | |
404 if (mi < m) | |
405 m = mi; | |
406 return m; | |
407 } | |
408 } | |
409 return Type.implicitConvTo(to); | |
0 | 410 } |
411 | |
72 | 412 override MATCH constConv(Type to) |
0 | 413 { |
414 assert(false); | |
415 } | |
416 | |
417 version (CPP_MANGLE) { | |
418 void toCppMangle(OutBuffer buf, CppMangleState* cms) | |
419 { | |
420 assert(false); | |
421 } | |
422 } | |
423 | |
424 // Back end | |
425 /******************************************** | |
426 * Determine the right symbol to look up | |
427 * an associative array element. | |
428 * Input: | |
429 * flags 0 don't add value signature | |
430 * 1 add value signature | |
431 */ | |
432 Symbol* aaGetSymbol(const(char)* func, int flags) | |
433 in | |
434 { | |
435 assert(func); | |
436 assert((flags & ~1) == 0); | |
437 } | |
438 out (result) | |
439 { | |
440 assert(result); | |
441 } | |
442 body | |
443 { | |
444 int sz; | |
445 char* id; | |
446 type* t; | |
447 Symbol* s; | |
448 int i; | |
449 | |
450 //printf("aaGetSymbol(func = '%s', flags = %d, key = %p)\n", func, flags, key); | |
451 static if (false) { | |
452 scope OutBuffer buf = new OutBuffer(); | |
453 key.toKeyBuffer(buf); | |
454 | |
455 sz = next.size(); // it's just data, so we only care about the size | |
456 sz = (sz + 3) & ~3; // reduce proliferation of library routines | |
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:
0
diff
changeset
|
457 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:
0
diff
changeset
|
458 id = cast(char*)GC.malloc(3 + strlen(func) + buf.offset + sizeof(sz) * 3 + 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:
0
diff
changeset
|
459 else |
0 | 460 id = cast(char*)alloca(3 + strlen(func) + buf.offset + sizeof(sz) * 3 + 1); |
461 buf.writeByte(0); | |
462 if (flags & 1) | |
463 sprintf(id, "_aa%s%s%d", func, buf.data, sz); | |
464 else | |
465 sprintf(id, "_aa%s%s", func, buf.data); | |
466 } else { | |
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:
0
diff
changeset
|
467 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:
0
diff
changeset
|
468 id = cast(char*)GC.malloc(3 + strlen(func) + 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:
0
diff
changeset
|
469 else |
0 | 470 id = cast(char*)alloca(3 + strlen(func) + 1); |
471 sprintf(id, "_aa%s", func); | |
472 } | |
473 | |
474 // See if symbol is already in sarray | |
176 | 475 for (i = 0; i < global.sarray.dim; i++) |
0 | 476 { |
176 | 477 s = cast(Symbol*)global.sarray.data[i]; |
0 | 478 if (strcmp(id, s.Sident.ptr) == 0) |
479 return s; // use existing Symbol | |
480 } | |
481 | |
482 // Create new Symbol | |
483 | |
484 s = symbol_calloc(id); | |
485 slist_add(s); | |
486 s.Sclass = SCextern; | |
487 s.Ssymnum = -1; | |
488 symbol_func(s); | |
489 | |
490 t = type_alloc(TYnfunc); | |
491 t.Tflags = TFprototype | TFfixed; | |
492 t.Tmangle = mTYman_c; | |
493 t.Tparamtypes = null; | |
494 t.Tnext = next.toCtype(); | |
495 t.Tnext.Tcount++; | |
496 t.Tcount++; | |
497 s.Stype = t; | |
498 | |
176 | 499 global.sarray.push(s); // remember it |
0 | 500 return s; |
501 } | |
502 | |
72 | 503 override type* toCtype() |
0 | 504 { |
67 | 505 type* t; |
506 | |
507 if (ctype) | |
508 return ctype; | |
509 | |
510 if (0 && global.params.symdebug) | |
511 { | |
512 /* An associative array is represented by: | |
513 * struct AArray { size_t length; void* ptr; } | |
514 */ | |
515 | |
176 | 516 auto s = global.AArray_s; |
67 | 517 if (!s) |
518 { | |
176 | 519 global.AArray_s = s = symbol_calloc("_AArray"); |
67 | 520 s.Sclass = SCstruct; |
521 s.Sstruct = struct_calloc(); | |
522 s.Sstruct.Sflags |= 0; | |
523 s.Sstruct.Salignsize = alignsize(); | |
524 s.Sstruct.Sstructalign = cast(ubyte)global.structalign; | |
525 s.Sstruct.Sstructsize = cast(uint)size(Loc(0)); | |
526 slist_add(s); | |
527 | |
528 Symbol* s1 = symbol_name("length", SCmember, Type.tsize_t.toCtype()); | |
529 list_append(&s.Sstruct.Sfldlst, s1); | |
530 | |
176 | 531 Symbol* s2 = symbol_name("data", SCmember, global.tvoidptr.toCtype()); |
67 | 532 s2.Smemoff = cast(uint)Type.tsize_t.size(); |
533 list_append(&s.Sstruct.Sfldlst, s2); | |
534 } | |
535 | |
536 t = type_alloc(TYstruct); | |
537 t.Ttag = cast(Classsym*)s; // structure tag name | |
538 t.Tcount++; | |
539 s.Stype = t; | |
540 } | |
541 else | |
542 { | |
543 if (global.params.symdebug == 1) | |
544 { | |
545 /* Generate D symbolic debug info, rather than C | |
546 * Tnext: element type | |
547 * Tkey: key type | |
548 */ | |
549 t = type_allocn(TYaarray, next.toCtype()); | |
550 t.Tkey = index.toCtype(); | |
551 t.Tkey.Tcount++; | |
552 } | |
553 else | |
554 t = type_fake(TYaarray); | |
555 } | |
556 t.Tcount++; | |
557 ctype = t; | |
558 return t; | |
0 | 559 } |
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:
0
diff
changeset
|
560 } |