1 /* 2 * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com 3 * Written by Walter Bright 4 * 5 * This software is provided 'as-is', without any express or implied 6 * warranty. In no event will the authors be held liable for any damages 7 * arising from the use of this software. 8 * 9 * Permission is granted to anyone to use this software for any purpose, 10 * including commercial applications, and to alter it and redistribute it 11 * freely, in both source and binary form, subject to the following 12 * restrictions: 13 * 14 * o The origin of this software must not be misrepresented; you must not 15 * claim that you wrote the original software. If you use this software 16 * in a product, an acknowledgment in the product documentation would be 17 * appreciated but is not required. 18 * o Altered source versions must be plainly marked as such, and must not 19 * be misrepresented as being the original software. 20 * o This notice may not be removed or altered from any source 21 * distribution. 22 */ 23 24 module rt.compiler.ldc.typeinfo.ti_Acdouble; 25 26 private import rt.compiler.ldc.typeinfo.ti_cdouble; 27 private import rt.compiler.util.hash; 28 // cdouble[] 29 30 class TypeInfo_Ar : TypeInfo_Array 31 { 32 override char[] toString() { return "cdouble[]"; } 33 34 override hash_t getHash(in void* p) { 35 cdouble[] s = *cast(cdouble[]*)p; 36 size_t len = s.length; 37 cdouble *str = s.ptr; 38 return rt_hash_str(str,len*cdouble.sizeof,0); 39 } 40 41 override equals_t equals(in void* p1, in void* p2) 42 { 43 cdouble[] s1 = *cast(cdouble[]*)p1; 44 cdouble[] s2 = *cast(cdouble[]*)p2; 45 size_t len = s1.length; 46 47 if (len != s2.length) 48 return false; 49 for (size_t u = 0; u < len; u++) 50 { 51 if (!TypeInfo_r._equals(s1[u], s2[u])) 52 return false; 53 } 54 return true; 55 } 56 57 override int compare(in void* p1, in void* p2) 58 { 59 cdouble[] s1 = *cast(cdouble[]*)p1; 60 cdouble[] s2 = *cast(cdouble[]*)p2; 61 size_t len = s1.length; 62 63 if (s2.length < len) 64 len = s2.length; 65 for (size_t u = 0; u < len; u++) 66 { 67 int c = TypeInfo_r._compare(s1[u], s2[u]); 68 if (c) 69 return c; 70 } 71 if (s1.length < s2.length) 72 return -1; 73 else if (s1.length > s2.length) 74 return 1; 75 return 0; 76 } 77 78 override size_t talign() 79 { 80 return (cdouble[]).alignof; 81 } 82 83 override size_t tsize() 84 { 85 return (cdouble[]).sizeof; 86 } 87 88 override uint flags() 89 { 90 return 1; 91 } 92 93 override TypeInfo next() 94 { 95 return typeid(cdouble); 96 } 97 }