comparison runtime/internal/aaA.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 eef8ac26c66c
children a26b0c5d5942
comparison
equal deleted inserted replaced
714:1e98c99a87cb 715:30b42a283c8e
60 6_291_469UL, 25_165_843UL, 60 6_291_469UL, 25_165_843UL,
61 100_663_319UL, 402_653_189UL, 61 100_663_319UL, 402_653_189UL,
62 1_610_612_741UL, 4_294_967_291UL, 62 1_610_612_741UL, 4_294_967_291UL,
63 // 8_589_934_513UL, 17_179_869_143UL 63 // 8_589_934_513UL, 17_179_869_143UL
64 ]; 64 ];
65
66 // This is the type of the return value for dynamic arrays.
67 struct Array
68 {
69 size_t length;
70 void* ptr;
71 }
72 65
73 struct aaA 66 struct aaA
74 { 67 {
75 aaA *left; 68 aaA *left;
76 aaA *right; 69 aaA *right;
447 440
448 /******************************************** 441 /********************************************
449 * Produce array of values from aa. 442 * Produce array of values from aa.
450 */ 443 */
451 444
452 Array _aaValues(AA aa, size_t keysize, size_t valuesize) 445 void[] _aaValues(AA aa, size_t keysize, size_t valuesize)
453 in 446 in
454 { 447 {
455 assert(keysize == aligntsize(keysize)); 448 assert(keysize == aligntsize(keysize));
456 } 449 }
457 body 450 body
458 { 451 {
459 size_t resi; 452 size_t resi;
460 Array a; 453 void[] a;
461 454
462 void _aaValues_x(aaA* e) 455 void _aaValues_x(aaA* e)
463 { 456 {
464 do 457 do
465 { 458 {
478 } while (e !is null); 471 } while (e !is null);
479 } 472 }
480 473
481 if (aa) 474 if (aa)
482 { 475 {
483 a.length = _aaLen(aa); 476 auto len = _aaLen(aa);
484 a.ptr = cast(byte*) gc_malloc(a.length * valuesize, 477 auto ptr = cast(byte*) gc_malloc(len * valuesize,
485 valuesize < (void*).sizeof ? BlkAttr.NO_SCAN : 0); 478 valuesize < (void*).sizeof ? BlkAttr.NO_SCAN : 0);
479 a = ptr[0 .. len];
486 resi = 0; 480 resi = 0;
487 foreach (e; aa.b) 481 foreach (e; aa.b)
488 { 482 {
489 if (e) 483 if (e)
490 _aaValues_x(e); 484 _aaValues_x(e);
591 585
592 /******************************************** 586 /********************************************
593 * Produce array of N byte keys from aa. 587 * Produce array of N byte keys from aa.
594 */ 588 */
595 589
596 Array _aaKeys(AA aa, size_t keysize) 590 void[] _aaKeys(AA aa, size_t keysize)
597 { 591 {
598 byte[] res; 592 byte[] res;
599 size_t resi; 593 size_t resi;
600 594
601 void _aaKeys_x(aaA* e) 595 void _aaKeys_x(aaA* e)
615 } while (e !is null); 609 } while (e !is null);
616 } 610 }
617 611
618 auto len = _aaLen(aa); 612 auto len = _aaLen(aa);
619 if (!len) 613 if (!len)
620 return Array(); 614 return null;
621 res = (cast(byte*) gc_malloc(len * keysize, 615 res = (cast(byte*) gc_malloc(len * keysize,
622 !(aa.keyti.flags() & 1) ? BlkAttr.NO_SCAN : 0)) [0 .. len * keysize]; 616 !(aa.keyti.flags() & 1) ? BlkAttr.NO_SCAN : 0)) [0 .. len * keysize];
623 resi = 0; 617 resi = 0;
624 foreach (e; aa.b) 618 foreach (e; aa.b)
625 { 619 {
626 if (e) 620 if (e)
627 _aaKeys_x(e); 621 _aaKeys_x(e);
628 } 622 }
629 assert(resi == len); 623 assert(resi == len);
630 624
631 return Array(len, res.ptr); 625 return res.ptr[0 .. len];
632 } 626 }
633 627
634 628
635 /********************************************** 629 /**********************************************
636 * 'apply' for associative arrays - to support foreach 630 * 'apply' for associative arrays - to support foreach