diff 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
line wrap: on
line diff
--- a/runtime/internal/aaA.d	Wed Oct 22 13:48:54 2008 +0200
+++ b/runtime/internal/aaA.d	Wed Oct 22 14:55:33 2008 +0200
@@ -63,13 +63,6 @@
 //  8_589_934_513UL, 17_179_869_143UL
 ];
 
-// This is the type of the return value for dynamic arrays.
-struct Array
-{
-    size_t length;
-    void* ptr;
-}
-
 struct aaA
 {
     aaA *left;
@@ -449,7 +442,7 @@
  * Produce array of values from aa.
  */
 
-Array _aaValues(AA aa, size_t keysize, size_t valuesize)
+void[] _aaValues(AA aa, size_t keysize, size_t valuesize)
 in
 {
     assert(keysize == aligntsize(keysize));
@@ -457,7 +450,7 @@
 body
 {
     size_t resi;
-    Array a;
+    void[] a;
 
     void _aaValues_x(aaA* e)
     {
@@ -480,9 +473,10 @@
 
     if (aa)
     {
-        a.length = _aaLen(aa);
-        a.ptr = cast(byte*) gc_malloc(a.length * valuesize,
+        auto len = _aaLen(aa);
+        auto ptr = cast(byte*) gc_malloc(len * valuesize,
                                       valuesize < (void*).sizeof ? BlkAttr.NO_SCAN : 0);
+        a = ptr[0 .. len];
         resi = 0;
         foreach (e; aa.b)
         {
@@ -593,7 +587,7 @@
  * Produce array of N byte keys from aa.
  */
 
-Array _aaKeys(AA aa, size_t keysize)
+void[] _aaKeys(AA aa, size_t keysize)
 {
     byte[] res;
     size_t resi;
@@ -617,7 +611,7 @@
 
     auto len = _aaLen(aa);
     if (!len)
-        return Array();
+        return null;
     res = (cast(byte*) gc_malloc(len * keysize,
                                  !(aa.keyti.flags() & 1) ? BlkAttr.NO_SCAN : 0)) [0 .. len * keysize];
     resi = 0;
@@ -628,7 +622,7 @@
     }
     assert(resi == len);
 
-    return Array(len, res.ptr);
+    return res.ptr[0 .. len];
 }