comparison tango/lib/compiler/llvmdc/adi.d @ 240:0db62b770a49 trunk

[svn r257] Fixed: array .sort and .reverse runtime code was incorrect. Fixed: most runtime calls did not get correct param attrs.
author lindquist
date Mon, 09 Jun 2008 00:01:10 +0200
parents a168a2c3ea48
children 068cb3c60afb
comparison
equal deleted inserted replaced
239:fa691b1c0498 240:0db62b770a49
65 * Reverse array of chars. 65 * Reverse array of chars.
66 * Handled separately because embedded multibyte encodings should not be 66 * Handled separately because embedded multibyte encodings should not be
67 * reversed. 67 * reversed.
68 */ 68 */
69 69
70 extern (C) long _adReverseChar(char[] a) 70 extern (C) Array _adReverseChar(char[] a)
71 { 71 {
72 if (a.length > 1) 72 if (a.length > 1)
73 { 73 {
74 char[6] tmp; 74 char[6] tmp;
75 char[6] tmplo; 75 char[6] tmplo;
125 125
126 lo += stridehi; 126 lo += stridehi;
127 hi = hi - 1 + (stridehi - stridelo); 127 hi = hi - 1 + (stridehi - stridelo);
128 } 128 }
129 } 129 }
130 return *cast(long*)(&a); 130 return Array(a.length, a.ptr);
131 } 131 }
132 132
133 unittest 133 unittest
134 { 134 {
135 auto a = "abcd"c; 135 auto a = "abcd"c;
160 * Reverse array of wchars. 160 * Reverse array of wchars.
161 * Handled separately because embedded multiword encodings should not be 161 * Handled separately because embedded multiword encodings should not be
162 * reversed. 162 * reversed.
163 */ 163 */
164 164
165 extern (C) long _adReverseWchar(wchar[] a) 165 extern (C) Array _adReverseWchar(wchar[] a)
166 { 166 {
167 if (a.length > 1) 167 if (a.length > 1)
168 { 168 {
169 wchar[2] tmp; 169 wchar[2] tmp;
170 wchar* lo = a.ptr; 170 wchar* lo = a.ptr;
218 218
219 lo += stridehi; 219 lo += stridehi;
220 hi = hi - 1 + (stridehi - stridelo); 220 hi = hi - 1 + (stridehi - stridelo);
221 } 221 }
222 } 222 }
223 return *cast(long*)(&a); 223 return Array(a.length, a.ptr);
224 } 224 }
225 225
226 unittest 226 unittest
227 { 227 {
228 wstring a = "abcd"; 228 wstring a = "abcd";
243 243
244 /********************************************** 244 /**********************************************
245 * Support for array.reverse property. 245 * Support for array.reverse property.
246 */ 246 */
247 247
248 extern (C) long _adReverse(Array a, size_t szelem) 248 extern (C) Array _adReverse(Array a, size_t szelem)
249 out (result) 249 out (result)
250 { 250 {
251 assert(result is *cast(long*)(&a)); 251 assert(result.ptr is a.ptr);
252 } 252 }
253 body 253 body
254 { 254 {
255 if (a.length >= 2) 255 if (a.length >= 2)
256 { 256 {
285 // BUG: bad code is generate for delete pointer, tries 285 // BUG: bad code is generate for delete pointer, tries
286 // to call delclass. 286 // to call delclass.
287 //gc_free(tmp); 287 //gc_free(tmp);
288 } 288 }
289 } 289 }
290 return *cast(long*)(&a); 290 return Array(a.length, a.ptr);
291 } 291 }
292 292
293 unittest 293 unittest
294 { 294 {
295 debug(adi) printf("array.reverse.unittest\n"); 295 debug(adi) printf("array.reverse.unittest\n");
329 329
330 /********************************************** 330 /**********************************************
331 * Sort array of chars. 331 * Sort array of chars.
332 */ 332 */
333 333
334 extern (C) long _adSortChar(char[] a) 334 extern (C) Array _adSortChar(char[] a)
335 { 335 {
336 if (a.length > 1) 336 if (a.length > 1)
337 { 337 {
338 dchar[] da = toUTF32(a); 338 dchar[] da = toUTF32(a);
339 da.sort; 339 da.sort;
344 a[i .. i + t.length] = t[]; 344 a[i .. i + t.length] = t[];
345 i += t.length; 345 i += t.length;
346 } 346 }
347 delete da; 347 delete da;
348 } 348 }
349 return *cast(long*)(&a); 349 return Array(a.length, a.ptr);
350 } 350 }
351 351
352 /********************************************** 352 /**********************************************
353 * Sort array of wchars. 353 * Sort array of wchars.
354 */ 354 */
355 355
356 extern (C) long _adSortWchar(wchar[] a) 356 extern (C) Array _adSortWchar(wchar[] a)
357 { 357 {
358 if (a.length > 1) 358 if (a.length > 1)
359 { 359 {
360 dchar[] da = toUTF32(a); 360 dchar[] da = toUTF32(a);
361 da.sort; 361 da.sort;
366 a[i .. i + t.length] = t[]; 366 a[i .. i + t.length] = t[];
367 i += t.length; 367 i += t.length;
368 } 368 }
369 delete da; 369 delete da;
370 } 370 }
371 return *cast(long*)(&a); 371 return Array(a.length, a.ptr);
372 } 372 }
373 373
374 /*************************************** 374 /***************************************
375 * Support for array equality test. 375 * Support for array equality test.
376 */ 376 */