Mercurial > projects > ldc
comparison runtime/internal/adi.d @ 486:a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Reimplemented support for nested functions/class using a new approach.
Added error on taking address of intrinsic.
Fixed problems with the ->syntaxCopy of TypeFunction delegate exp.
Removed DtoDType and replaced all uses with ->toBasetype() instead.
Removed unused inplace stuff.
Fixed a bunch of issues in the runtime unittests, not complete yet.
Added mini tests.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sun, 10 Aug 2008 08:37:38 +0200 |
parents | 44f08170f4ef |
children | 30b42a283c8e |
comparison
equal
deleted
inserted
replaced
485:50f6e2337a6b | 486:a34078905d01 |
---|---|
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) Array _adReverseChar(char[] a) | 70 extern (C) char[] _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 Array(a.length, a.ptr); | 130 return a; |
131 } | 131 } |
132 | 132 |
133 unittest | 133 unittest |
134 { | 134 { |
135 auto a = "abcd"c; | 135 char[] a = "abcd"c; |
136 | 136 |
137 auto r = a.dup.reverse; | 137 char[] r = a.dup.reverse; |
138 //writefln(r); | 138 //writefln(r); |
139 assert(r == "dcba"); | 139 assert(r == "dcba"); |
140 | 140 |
141 a = "a\u1235\u1234c"; | 141 a = "a\u1235\u1234c"; |
142 //writefln(a); | 142 //writefln(a); |
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) Array _adReverseWchar(wchar[] a) | 165 extern (C) wchar[] _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 Array(a.length, a.ptr); | 223 return a; |
224 } | 224 } |
225 | 225 |
226 unittest | 226 unittest |
227 { | 227 { |
228 wstring a = "abcd"; | 228 wchar[] a = "abcd"; |
229 wstring r; | 229 wchar[] r; |
230 | 230 |
231 r = a.dup.reverse; | 231 r = a.dup.reverse; |
232 assert(r == "dcba"); | 232 assert(r == "dcba"); |
233 | 233 |
234 a = "a\U00012356\U00012346c"; | 234 a = "a\U00012356\U00012346c"; |
329 | 329 |
330 /********************************************** | 330 /********************************************** |
331 * Sort array of chars. | 331 * Sort array of chars. |
332 */ | 332 */ |
333 | 333 |
334 extern (C) Array _adSortChar(char[] a) | 334 extern (C) char[] _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 Array(a.length, a.ptr); | 349 return a; |
350 } | 350 } |
351 | 351 |
352 /********************************************** | 352 /********************************************** |
353 * Sort array of wchars. | 353 * Sort array of wchars. |
354 */ | 354 */ |
355 | 355 |
356 extern (C) Array _adSortWchar(wchar[] a) | 356 extern (C) wchar[] _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 Array(a.length, a.ptr); | 371 return a; |
372 } | 372 } |
373 | 373 |
374 /*************************************** | 374 /*************************************** |
375 * Support for array equality test. | 375 * Support for array equality test. |
376 */ | 376 */ |
390 | 390 |
391 unittest | 391 unittest |
392 { | 392 { |
393 debug(adi) printf("array.Eq unittest\n"); | 393 debug(adi) printf("array.Eq unittest\n"); |
394 | 394 |
395 auto a = "hello"c; | 395 char[] a = "hello"c; |
396 | 396 |
397 assert(a != "hel"); | 397 assert(a != "hel"); |
398 assert(a != "helloo"); | 398 assert(a != "helloo"); |
399 assert(a != "betty"); | 399 assert(a != "betty"); |
400 assert(a == "hello"); | 400 assert(a == "hello"); |
423 | 423 |
424 unittest | 424 unittest |
425 { | 425 { |
426 debug(adi) printf("array.Cmp unittest\n"); | 426 debug(adi) printf("array.Cmp unittest\n"); |
427 | 427 |
428 auto a = "hello"c; | 428 char[] a = "hello"c; |
429 | 429 |
430 assert(a > "hel"); | 430 assert(a > "hel"); |
431 assert(a >= "hel"); | 431 assert(a >= "hel"); |
432 assert(a < "helloo"); | 432 assert(a < "helloo"); |
433 assert(a <= "helloo"); | 433 assert(a <= "helloo"); |
573 | 573 |
574 unittest | 574 unittest |
575 { | 575 { |
576 debug(adi) printf("array.CmpChar unittest\n"); | 576 debug(adi) printf("array.CmpChar unittest\n"); |
577 | 577 |
578 auto a = "hello"c; | 578 char[] a = "hello"c; |
579 | 579 |
580 assert(a > "hel"); | 580 assert(a > "hel"); |
581 assert(a >= "hel"); | 581 assert(a >= "hel"); |
582 assert(a < "helloo"); | 582 assert(a < "helloo"); |
583 assert(a <= "helloo"); | 583 assert(a <= "helloo"); |