Mercurial > projects > ldc
comparison runtime/internal/adi.d @ 715:30b42a283c8e
Removed TypeOpaque from DMD.
Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:55:33 +0200 |
parents | a34078905d01 |
children | a26b0c5d5942 |
comparison
equal
deleted
inserted
replaced
714:1e98c99a87cb | 715:30b42a283c8e |
---|---|
53 extern (C) void* gc_calloc( size_t sz, uint ba = 0 ); | 53 extern (C) void* gc_calloc( size_t sz, uint ba = 0 ); |
54 extern (C) void gc_free( void* p ); | 54 extern (C) void gc_free( void* p ); |
55 } | 55 } |
56 | 56 |
57 | 57 |
58 struct Array | |
59 { | |
60 size_t length; | |
61 void* ptr; | |
62 } | |
63 | |
64 /********************************************** | 58 /********************************************** |
65 * Reverse array of chars. | 59 * Reverse array of chars. |
66 * Handled separately because embedded multibyte encodings should not be | 60 * Handled separately because embedded multibyte encodings should not be |
67 * reversed. | 61 * reversed. |
68 */ | 62 */ |
90 hi--; | 84 hi--; |
91 continue; | 85 continue; |
92 } | 86 } |
93 | 87 |
94 uint stridelo = UTF8stride[clo]; | 88 uint stridelo = UTF8stride[clo]; |
89 // don't barf on invalid strides, just ignore it | |
90 if (stridelo == 0xFF) | |
91 stridelo = 1; | |
95 | 92 |
96 uint stridehi = 1; | 93 uint stridehi = 1; |
97 while ((chi & 0xC0) == 0x80) | 94 while ((chi & 0xC0) == 0x80) |
98 { | 95 { |
99 chi = *--hi; | 96 chi = *--hi; |
243 | 240 |
244 /********************************************** | 241 /********************************************** |
245 * Support for array.reverse property. | 242 * Support for array.reverse property. |
246 */ | 243 */ |
247 | 244 |
248 extern (C) Array _adReverse(Array a, size_t szelem) | 245 extern (C) void[] _adReverse(void[] a, size_t szelem) |
249 out (result) | 246 out (result) |
250 { | 247 { |
251 assert(result.ptr is a.ptr); | 248 assert(result.ptr is a.ptr); |
252 } | 249 } |
253 body | 250 body |
285 // BUG: bad code is generate for delete pointer, tries | 282 // BUG: bad code is generate for delete pointer, tries |
286 // to call delclass. | 283 // to call delclass. |
287 //gc_free(tmp); | 284 //gc_free(tmp); |
288 } | 285 } |
289 } | 286 } |
290 return Array(a.length, a.ptr); | 287 return a.ptr[0 .. a.length]; |
291 } | 288 } |
292 | 289 |
293 unittest | 290 unittest |
294 { | 291 { |
295 debug(adi) printf("array.reverse.unittest\n"); | 292 debug(adi) printf("array.reverse.unittest\n"); |
373 | 370 |
374 /*************************************** | 371 /*************************************** |
375 * Support for array equality test. | 372 * Support for array equality test. |
376 */ | 373 */ |
377 | 374 |
378 extern (C) int _adEq(Array a1, Array a2, TypeInfo ti) | 375 extern (C) int _adEq(void[] a1, void[] a2, TypeInfo ti) |
379 { | 376 { |
380 debug(adi) printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); | 377 debug(adi) printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); |
381 | 378 |
382 if (a1.length != a2.length) | 379 if (a1.length != a2.length) |
383 return 0; // not equal | 380 return 0; // not equal |
403 | 400 |
404 /*************************************** | 401 /*************************************** |
405 * Support for array compare test. | 402 * Support for array compare test. |
406 */ | 403 */ |
407 | 404 |
408 extern (C) int _adCmp(Array a1, Array a2, TypeInfo ti) | 405 extern (C) int _adCmp(void[] a1, void[] a2, TypeInfo ti) |
409 { | 406 { |
410 debug(adi) printf("adCmp()\n"); | 407 debug(adi) printf("adCmp()\n"); |
411 | 408 |
412 if (a1.ptr == a2.ptr && | 409 if (a1.ptr == a2.ptr && |
413 a1.length == a2.length) | 410 a1.length == a2.length) |
440 | 437 |
441 /*************************************** | 438 /*************************************** |
442 * Support for array compare test. | 439 * Support for array compare test. |
443 */ | 440 */ |
444 | 441 |
445 extern (C) int _adCmpChar(Array a1, Array a2) | 442 extern (C) int _adCmpChar(void[] a1, void[] a2) |
446 { | 443 { |
447 version(D_InlineAsm_X86) | 444 version(D_InlineAsm_X86) |
448 { | 445 { |
449 //version = Asm86; | 446 //version = Asm86; |
450 } | 447 } |