1 2 // cfloat 3 4 module rt.compiler.gdc.typeinfo.ti_cfloat; 5 private import rt.compiler.util.hash; 6 7 class TypeInfo_q : TypeInfo 8 { 9 override char[] toString() { return "cfloat"; } 10 11 override hash_t getHash(in void* p) 12 { 13 return rt_hash_str(p,cfloat.sizeof,0); 14 } 15 16 static equals_t _equals(cfloat f1, cfloat f2) 17 { 18 return f1 == f2; 19 } 20 21 static int _compare(cfloat f1, cfloat f2) 22 { int result; 23 24 if (f1.re < f2.re) 25 result = -1; 26 else if (f1.re > f2.re) 27 result = 1; 28 else if (f1.im < f2.im) 29 result = -1; 30 else if (f1.im > f2.im) 31 result = 1; 32 else 33 result = 0; 34 return result; 35 } 36 37 override equals_t equals(in void* p1, in void* p2) 38 { 39 return _equals(*cast(cfloat *)p1, *cast(cfloat *)p2); 40 } 41 42 override int compare(in void* p1, in void* p2) 43 { 44 return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); 45 } 46 47 override size_t talign() 48 { 49 return cfloat.alignof; 50 } 51 52 override size_t tsize() 53 { 54 return cfloat.sizeof; 55 } 56 57 override void swap(void *p1, void *p2) 58 { 59 cfloat t; 60 61 t = *cast(cfloat *)p1; 62 *cast(cfloat *)p1 = *cast(cfloat *)p2; 63 *cast(cfloat *)p2 = t; 64 } 65 66 override void[] init() 67 { static cfloat r; 68 69 return (cast(cfloat *)&r)[0 .. 1]; 70 } 71 72 version (X86_64) override int argTypes(out TypeInfo arg1, out TypeInfo arg2) 73 { 74 return 0; 75 } 76 }