diff --git a/mak/DOCS b/mak/DOCS index b249d2fe68..130cd4e022 100644 --- a/mak/DOCS +++ b/mak/DOCS @@ -129,44 +129,6 @@ DOCS=\ $(DOCDIR)\rt_trace.html \ $(DOCDIR)\rt_tracegc.html \ \ - $(DOCDIR)\rt_typeinfo_ti_Acdouble.html \ - $(DOCDIR)\rt_typeinfo_ti_Acfloat.html \ - $(DOCDIR)\rt_typeinfo_ti_Acreal.html \ - $(DOCDIR)\rt_typeinfo_ti_Adouble.html \ - $(DOCDIR)\rt_typeinfo_ti_Afloat.html \ - $(DOCDIR)\rt_typeinfo_ti_Ag.html \ - $(DOCDIR)\rt_typeinfo_ti_Aint.html \ - $(DOCDIR)\rt_typeinfo_ti_Along.html \ - $(DOCDIR)\rt_typeinfo_ti_Areal.html \ - $(DOCDIR)\rt_typeinfo_ti_Ashort.html \ - $(DOCDIR)\rt_typeinfo_ti_byte.html \ - $(DOCDIR)\rt_typeinfo_ti_C.html \ - $(DOCDIR)\rt_typeinfo_ti_cdouble.html \ - $(DOCDIR)\rt_typeinfo_ti_cent.html \ - $(DOCDIR)\rt_typeinfo_ti_cfloat.html \ - $(DOCDIR)\rt_typeinfo_ti_char.html \ - $(DOCDIR)\rt_typeinfo_ti_creal.html \ - $(DOCDIR)\rt_typeinfo_ti_dchar.html \ - $(DOCDIR)\rt_typeinfo_ti_delegate.html \ - $(DOCDIR)\rt_typeinfo_ti_double.html \ - $(DOCDIR)\rt_typeinfo_ti_float.html \ - $(DOCDIR)\rt_typeinfo_ti_idouble.html \ - $(DOCDIR)\rt_typeinfo_ti_ifloat.html \ - $(DOCDIR)\rt_typeinfo_ti_int.html \ - $(DOCDIR)\rt_typeinfo_ti_ireal.html \ - $(DOCDIR)\rt_typeinfo_ti_long.html \ - $(DOCDIR)\rt_typeinfo_ti_n.html \ - $(DOCDIR)\rt_typeinfo_ti_ptr.html \ - $(DOCDIR)\rt_typeinfo_ti_real.html \ - $(DOCDIR)\rt_typeinfo_ti_short.html \ - $(DOCDIR)\rt_typeinfo_ti_ubyte.html \ - $(DOCDIR)\rt_typeinfo_ti_ucent.html \ - $(DOCDIR)\rt_typeinfo_ti_uint.html \ - $(DOCDIR)\rt_typeinfo_ti_ulong.html \ - $(DOCDIR)\rt_typeinfo_ti_ushort.html \ - $(DOCDIR)\rt_typeinfo_ti_void.html \ - $(DOCDIR)\rt_typeinfo_ti_wchar.html \ - \ $(DOCDIR)\rt_unwind.html \ \ $(DOCDIR)\rt_util_container_array.html \ diff --git a/mak/SRCS b/mak/SRCS index e69ed6f82e..0dac688712 100644 --- a/mak/SRCS +++ b/mak/SRCS @@ -544,42 +544,4 @@ SRCS=\ src\rt\util\container\hashtab.d \ src\rt\util\container\treap.d \ \ - src\rt\typeinfo\ti_Acdouble.d \ - src\rt\typeinfo\ti_Acfloat.d \ - src\rt\typeinfo\ti_Acreal.d \ - src\rt\typeinfo\ti_Adouble.d \ - src\rt\typeinfo\ti_Afloat.d \ - src\rt\typeinfo\ti_Ag.d \ - src\rt\typeinfo\ti_Aint.d \ - src\rt\typeinfo\ti_Along.d \ - src\rt\typeinfo\ti_Areal.d \ - src\rt\typeinfo\ti_Ashort.d \ - src\rt\typeinfo\ti_byte.d \ - src\rt\typeinfo\ti_C.d \ - src\rt\typeinfo\ti_cdouble.d \ - src\rt\typeinfo\ti_cent.d \ - src\rt\typeinfo\ti_cfloat.d \ - src\rt\typeinfo\ti_char.d \ - src\rt\typeinfo\ti_creal.d \ - src\rt\typeinfo\ti_dchar.d \ - src\rt\typeinfo\ti_delegate.d \ - src\rt\typeinfo\ti_double.d \ - src\rt\typeinfo\ti_float.d \ - src\rt\typeinfo\ti_idouble.d \ - src\rt\typeinfo\ti_ifloat.d \ - src\rt\typeinfo\ti_int.d \ - src\rt\typeinfo\ti_ireal.d \ - src\rt\typeinfo\ti_long.d \ - src\rt\typeinfo\ti_n.d \ - src\rt\typeinfo\ti_ptr.d \ - src\rt\typeinfo\ti_real.d \ - src\rt\typeinfo\ti_short.d \ - src\rt\typeinfo\ti_ubyte.d \ - src\rt\typeinfo\ti_ucent.d \ - src\rt\typeinfo\ti_uint.d \ - src\rt\typeinfo\ti_ulong.d \ - src\rt\typeinfo\ti_ushort.d \ - src\rt\typeinfo\ti_void.d \ - src\rt\typeinfo\ti_wchar.d \ - \ src\etc\linux\memoryerror.d diff --git a/posix.mak b/posix.mak index c8865c27c6..4d7bf155ae 100644 --- a/posix.mak +++ b/posix.mak @@ -276,7 +276,6 @@ endif .PHONY : unittest ifeq (1,$(BUILD_WAS_SPECIFIED)) unittest : $(UT_MODULES) $(addsuffix /.run,$(ADDITIONAL_TESTS)) - @echo done else unittest : unittest-debug unittest-release unittest-%: target diff --git a/src/core/internal/array/operations.d b/src/core/internal/array/operations.d index 240d1807d8..0e38d2cefa 100644 --- a/src/core/internal/array/operations.d +++ b/src/core/internal/array/operations.d @@ -228,7 +228,6 @@ else version (X86_64) unittest { - pragma(msg, vectorizeable!(double[], const(double)[], double[], "+", "=")); static assert(vectorizeable!(double[], const(double)[], double[], "+", "=")); static assert(!vectorizeable!(double[], const(ulong)[], double[], "+", "=")); // Vector type are (atm.) not implicitly convertible and would require diff --git a/src/rt/typeinfo/ti_Acdouble.d b/src/rt/typeinfo/ti_Acdouble.d deleted file mode 100644 index 50debaca25..0000000000 --- a/src/rt/typeinfo/ti_Acdouble.d +++ /dev/null @@ -1,47 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_Acdouble; - -private import rt.util.typeinfo; - -// cdouble[] - -class TypeInfo_Ar : TypeInfo_Array -{ - alias F = cdouble; - - override bool opEquals(Object o) { return TypeInfo.opEquals(o); } - - override string toString() const { return (F[]).stringof; } - - override size_t getHash(scope const void* p) @trusted const - { - return Array!F.hashOf(*cast(F[]*)p); - } - - override bool equals(in void* p1, in void* p2) const - { - return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override int compare(in void* p1, in void* p2) const - { - return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(F); - } -} diff --git a/src/rt/typeinfo/ti_Acfloat.d b/src/rt/typeinfo/ti_Acfloat.d deleted file mode 100644 index dadec10df7..0000000000 --- a/src/rt/typeinfo/ti_Acfloat.d +++ /dev/null @@ -1,47 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_Acfloat; - -private import rt.util.typeinfo; - -// cfloat[] - -class TypeInfo_Aq : TypeInfo_Array -{ - alias F = cfloat; - - override bool opEquals(Object o) { return TypeInfo.opEquals(o); } - - override string toString() const { return (F[]).stringof; } - - override size_t getHash(scope const void* p) @trusted const - { - return Array!F.hashOf(*cast(F[]*)p); - } - - override bool equals(in void* p1, in void* p2) const - { - return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override int compare(in void* p1, in void* p2) const - { - return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(F); - } -} diff --git a/src/rt/typeinfo/ti_Acreal.d b/src/rt/typeinfo/ti_Acreal.d deleted file mode 100644 index 650b89b4ed..0000000000 --- a/src/rt/typeinfo/ti_Acreal.d +++ /dev/null @@ -1,47 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_Acreal; - -private import rt.util.typeinfo; - -// creal[] - -class TypeInfo_Ac : TypeInfo_Array -{ - alias F = creal; - - override bool opEquals(Object o) { return TypeInfo.opEquals(o); } - - override string toString() const { return (F[]).stringof; } - - override size_t getHash(scope const void* p) @trusted const - { - return Array!F.hashOf(*cast(F[]*)p); - } - - override bool equals(in void* p1, in void* p2) const - { - return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override int compare(in void* p1, in void* p2) const - { - return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(F); - } -} diff --git a/src/rt/typeinfo/ti_Adouble.d b/src/rt/typeinfo/ti_Adouble.d deleted file mode 100644 index 9712f8a822..0000000000 --- a/src/rt/typeinfo/ti_Adouble.d +++ /dev/null @@ -1,61 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_Adouble; - -private import rt.util.typeinfo; - -// double[] - -class TypeInfo_Ad : TypeInfo_Array -{ - alias F = double; - - override bool opEquals(Object o) { return TypeInfo.opEquals(o); } - - override string toString() const { return (F[]).stringof; } - - override size_t getHash(scope const void* p) @trusted const - { - return Array!F.hashOf(*cast(F[]*)p); - } - - override bool equals(in void* p1, in void* p2) const - { - return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override int compare(in void* p1, in void* p2) const - { - return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(F); - } -} - -// idouble[] - -class TypeInfo_Ap : TypeInfo_Ad -{ - alias F = idouble; - - override string toString() const { return (F[]).stringof; } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(F); - } -} diff --git a/src/rt/typeinfo/ti_Afloat.d b/src/rt/typeinfo/ti_Afloat.d deleted file mode 100644 index 9a95abd3b5..0000000000 --- a/src/rt/typeinfo/ti_Afloat.d +++ /dev/null @@ -1,61 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_Afloat; - -private import rt.util.typeinfo; - -// float[] - -class TypeInfo_Af : TypeInfo_Array -{ - alias F = float; - - override bool opEquals(Object o) { return TypeInfo.opEquals(o); } - - override string toString() const { return (F[]).stringof; } - - override size_t getHash(scope const void* p) @trusted const - { - return Array!F.hashOf(*cast(F[]*)p); - } - - override bool equals(in void* p1, in void* p2) const - { - return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override int compare(in void* p1, in void* p2) const - { - return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(F); - } -} - -// ifloat[] - -class TypeInfo_Ao : TypeInfo_Af -{ - alias F = ifloat; - - override string toString() const { return (F[]).stringof; } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(F); - } -} diff --git a/src/rt/typeinfo/ti_Ag.d b/src/rt/typeinfo/ti_Ag.d deleted file mode 100644 index bdb0553698..0000000000 --- a/src/rt/typeinfo/ti_Ag.d +++ /dev/null @@ -1,154 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_Ag; - -private import core.stdc.string; -private import core.internal.string; - -// byte[] - -class TypeInfo_Ag : TypeInfo_Array -{ - override bool opEquals(Object o) { return TypeInfo.opEquals(o); } - - override string toString() const { return "byte[]"; } - - override size_t getHash(scope const void* p) @trusted const - { - const s = *cast(const void[]*)p; - return hashOf(s); - } - - override bool equals(in void* p1, in void* p2) const - { - byte[] s1 = *cast(byte[]*)p1; - byte[] s2 = *cast(byte[]*)p2; - - return s1.length == s2.length && - memcmp(cast(byte *)s1, cast(byte *)s2, s1.length) == 0; - } - - override int compare(in void* p1, in void* p2) const - { - byte[] s1 = *cast(byte[]*)p1; - byte[] s2 = *cast(byte[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - int result = s1[u] - s2[u]; - if (result) - return result; - } - if (s1.length < s2.length) - return -1; - else if (s1.length > s2.length) - return 1; - return 0; - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(byte); - } -} - - -// ubyte[] - -class TypeInfo_Ah : TypeInfo_Ag -{ - override string toString() const { return "ubyte[]"; } - - override int compare(in void* p1, in void* p2) const - { - char[] s1 = *cast(char[]*)p1; - char[] s2 = *cast(char[]*)p2; - - return dstrcmp(s1, s2); - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(ubyte); - } -} - -// void[] - -class TypeInfo_Av : TypeInfo_Ah -{ - override string toString() const { return "void[]"; } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(void); - } -} - -// bool[] - -class TypeInfo_Ab : TypeInfo_Ah -{ - override string toString() const { return "bool[]"; } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(bool); - } -} - -// char[] - -class TypeInfo_Aa : TypeInfo_Ah -{ - override string toString() const { return "char[]"; } - - override size_t getHash(scope const void* p) @trusted const - { - char[] s = *cast(char[]*)p; - return hashOf(s); - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(char); - } -} - -// string - -class TypeInfo_Aya : TypeInfo_Aa -{ - override string toString() const { return "immutable(char)[]"; } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(immutable(char)); - } -} - -// const(char)[] - -class TypeInfo_Axa : TypeInfo_Aa -{ - override string toString() const { return "const(char)[]"; } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(const(char)); - } -} diff --git a/src/rt/typeinfo/ti_Aint.d b/src/rt/typeinfo/ti_Aint.d deleted file mode 100644 index ebe8d80f93..0000000000 --- a/src/rt/typeinfo/ti_Aint.d +++ /dev/null @@ -1,151 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_Aint; - -private import core.stdc.string; - -extern (C) void[] _adSort(void[] a, TypeInfo ti); - -// int[] - -class TypeInfo_Ai : TypeInfo_Array -{ - override bool opEquals(Object o) { return TypeInfo.opEquals(o); } - - override string toString() const { return "int[]"; } - - override size_t getHash(scope const void* p) @trusted const - { - // Hash as if unsigned. - const s = *cast(const uint[]*)p; - return hashOf(s); - } - - override bool equals(in void* p1, in void* p2) const - { - int[] s1 = *cast(int[]*)p1; - int[] s2 = *cast(int[]*)p2; - - return s1.length == s2.length && - memcmp(cast(void *)s1, cast(void *)s2, s1.length * int.sizeof) == 0; - } - - override int compare(in void* p1, in void* p2) const - { - int[] s1 = *cast(int[]*)p1; - int[] s2 = *cast(int[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - if (s1[u] < s2[u]) - return -1; - else if (s1[u] > s2[u]) - return 1; - } - if (s1.length < s2.length) - return -1; - else if (s1.length > s2.length) - return 1; - return 0; - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(int); - } -} - -unittest -{ - int[][] a = [[5,3,8,7], [2,5,3,8,7]]; - _adSort(*cast(void[]*)&a, typeid(a[0])); - assert(a == [[2,5,3,8,7], [5,3,8,7]]); - - a = [[5,3,8,7], [5,3,8]]; - _adSort(*cast(void[]*)&a, typeid(a[0])); - assert(a == [[5,3,8], [5,3,8,7]]); -} - -unittest -{ - // Issue 13073: original code uses int subtraction which is susceptible to - // integer overflow, causing the following case to fail. - int[] a = [int.max, int.max]; - int[] b = [int.min, int.min]; - assert(a > b); - assert(b < a); -} - -// uint[] - -class TypeInfo_Ak : TypeInfo_Ai -{ - override string toString() const { return "uint[]"; } - - override int compare(in void* p1, in void* p2) const - { - uint[] s1 = *cast(uint[]*)p1; - uint[] s2 = *cast(uint[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - if (s1[u] < s2[u]) - return -1; - else if (s1[u] > s2[u]) - return 1; - } - if (s1.length < s2.length) - return -1; - else if (s1.length > s2.length) - return 1; - return 0; - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(uint); - } -} - -unittest -{ - // Original test case from issue 13073 - uint x = 0x22_DF_FF_FF; - uint y = 0xA2_DF_FF_FF; - assert(!(x < y && y < x)); - uint[] a = [x]; - uint[] b = [y]; - assert(!(a < b && b < a)); // Original failing case - uint[1] a1 = [x]; - uint[1] b1 = [y]; - assert(!(a1 < b1 && b1 < a1)); // Original failing case -} - -// dchar[] - -class TypeInfo_Aw : TypeInfo_Ak -{ - override string toString() const { return "dchar[]"; } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(dchar); - } -} diff --git a/src/rt/typeinfo/ti_Along.d b/src/rt/typeinfo/ti_Along.d deleted file mode 100644 index b67bb995ba..0000000000 --- a/src/rt/typeinfo/ti_Along.d +++ /dev/null @@ -1,103 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_Along; - -private import core.stdc.string; - -// long[] - -class TypeInfo_Al : TypeInfo_Array -{ - override bool opEquals(Object o) { return TypeInfo.opEquals(o); } - - override string toString() const { return "long[]"; } - - override size_t getHash(scope const void* p) @trusted const - { - // Hash as if unsigned. - const s = *cast(const ulong[]*)p; - return hashOf(s); - } - - override bool equals(in void* p1, in void* p2) const - { - long[] s1 = *cast(long[]*)p1; - long[] s2 = *cast(long[]*)p2; - - return s1.length == s2.length && - memcmp(cast(void *)s1, cast(void *)s2, s1.length * long.sizeof) == 0; - } - - override int compare(in void* p1, in void* p2) const - { - long[] s1 = *cast(long[]*)p1; - long[] s2 = *cast(long[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - if (s1[u] < s2[u]) - return -1; - else if (s1[u] > s2[u]) - return 1; - } - if (s1.length < s2.length) - return -1; - else if (s1.length > s2.length) - return 1; - return 0; - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(long); - } -} - - -// ulong[] - -class TypeInfo_Am : TypeInfo_Al -{ - override string toString() const { return "ulong[]"; } - - override int compare(in void* p1, in void* p2) const - { - ulong[] s1 = *cast(ulong[]*)p1; - ulong[] s2 = *cast(ulong[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - if (s1[u] < s2[u]) - return -1; - else if (s1[u] > s2[u]) - return 1; - } - if (s1.length < s2.length) - return -1; - else if (s1.length > s2.length) - return 1; - return 0; - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(ulong); - } -} diff --git a/src/rt/typeinfo/ti_Areal.d b/src/rt/typeinfo/ti_Areal.d deleted file mode 100644 index 5280f81fe6..0000000000 --- a/src/rt/typeinfo/ti_Areal.d +++ /dev/null @@ -1,61 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_Areal; - -private import rt.util.typeinfo; - -// real[] - -class TypeInfo_Ae : TypeInfo_Array -{ - alias F = real; - - override bool opEquals(Object o) { return TypeInfo.opEquals(o); } - - override string toString() const { return (F[]).stringof; } - - override size_t getHash(scope const void* p) @trusted const - { - return Array!F.hashOf(*cast(F[]*)p); - } - - override bool equals(in void* p1, in void* p2) const - { - return Array!F.equals(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override int compare(in void* p1, in void* p2) const - { - return Array!F.compare(*cast(F[]*)p1, *cast(F[]*)p2); - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(F); - } -} - -// ireal[] - -class TypeInfo_Aj : TypeInfo_Ae -{ - alias F = ireal; - - override string toString() const { return (F[]).stringof; } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(F); - } -} diff --git a/src/rt/typeinfo/ti_Ashort.d b/src/rt/typeinfo/ti_Ashort.d deleted file mode 100644 index aea4be7704..0000000000 --- a/src/rt/typeinfo/ti_Ashort.d +++ /dev/null @@ -1,113 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_Ashort; - -private import core.stdc.string; - -// short[] - -class TypeInfo_As : TypeInfo_Array -{ - override bool opEquals(Object o) { return TypeInfo.opEquals(o); } - - override string toString() const { return "short[]"; } - - override size_t getHash(scope const void* p) @trusted const - { - // Hash as if unsigned. - const s = *cast(const ushort[]*)p; - return hashOf(s); - } - - override bool equals(in void* p1, in void* p2) const - { - short[] s1 = *cast(short[]*)p1; - short[] s2 = *cast(short[]*)p2; - - return s1.length == s2.length && - memcmp(cast(void *)s1, cast(void *)s2, s1.length * short.sizeof) == 0; - } - - override int compare(in void* p1, in void* p2) const - { - short[] s1 = *cast(short[]*)p1; - short[] s2 = *cast(short[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - int result = s1[u] - s2[u]; - if (result) - return result; - } - if (s1.length < s2.length) - return -1; - else if (s1.length > s2.length) - return 1; - return 0; - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(short); - } -} - - -// ushort[] - -class TypeInfo_At : TypeInfo_As -{ - override string toString() const { return "ushort[]"; } - - override int compare(in void* p1, in void* p2) const - { - ushort[] s1 = *cast(ushort[]*)p1; - ushort[] s2 = *cast(ushort[]*)p2; - size_t len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - int result = s1[u] - s2[u]; - if (result) - return result; - } - if (s1.length < s2.length) - return -1; - else if (s1.length > s2.length) - return 1; - return 0; - } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(ushort); - } -} - -// wchar[] - -class TypeInfo_Au : TypeInfo_At -{ - override string toString() const { return "wchar[]"; } - - override @property inout(TypeInfo) next() inout - { - return cast(inout)typeid(wchar); - } -} diff --git a/src/rt/typeinfo/ti_C.d b/src/rt/typeinfo/ti_C.d deleted file mode 100644 index 912774cb99..0000000000 --- a/src/rt/typeinfo/ti_C.d +++ /dev/null @@ -1,75 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_C; - -// Object - -class TypeInfo_C : TypeInfo -{ - @trusted: - const: - //pure: - //nothrow: - - override size_t getHash(scope const void* p) - { - Object o = *cast(Object*)p; - return o ? o.toHash() : 0; - } - - override bool equals(in void* p1, in void* p2) - { - Object o1 = *cast(Object*)p1; - Object o2 = *cast(Object*)p2; - - return o1 == o2; - } - - override int compare(in void* p1, in void* p2) - { - Object o1 = *cast(Object*)p1; - Object o2 = *cast(Object*)p2; - int c = 0; - - // Regard null references as always being "less than" - if (!(o1 is o2)) - { - if (o1) - { - if (!o2) - c = 1; - else - c = o1.opCmp(o2); - } - else - c = -1; - } - return c; - } - - override @property size_t tsize() nothrow pure - { - return Object.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. Object.sizeof]; - } - - override @property uint flags() nothrow pure - { - return 1; - } -} diff --git a/src/rt/typeinfo/ti_byte.d b/src/rt/typeinfo/ti_byte.d deleted file mode 100644 index 9793fef65e..0000000000 --- a/src/rt/typeinfo/ti_byte.d +++ /dev/null @@ -1,62 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_byte; - -// byte - -class TypeInfo_g : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "byte"; } - - override size_t getHash(scope const void* p) - { - return *cast(const byte *)p; - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(byte *)p1 == *cast(byte *)p2; - } - - override int compare(in void* p1, in void* p2) - { - return *cast(byte *)p1 - *cast(byte *)p2; - } - - override @property size_t tsize() nothrow pure - { - return byte.sizeof; - } - - override const(void)[] initializer() @trusted - { - return (cast(void *)null)[0 .. byte.sizeof]; - } - - override void swap(void *p1, void *p2) - { - byte t; - - t = *cast(byte *)p1; - *cast(byte *)p1 = *cast(byte *)p2; - *cast(byte *)p2 = t; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_cdouble.d b/src/rt/typeinfo/ti_cdouble.d deleted file mode 100644 index e738f7b576..0000000000 --- a/src/rt/typeinfo/ti_cdouble.d +++ /dev/null @@ -1,77 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_cdouble; - -private import rt.util.typeinfo; - -// cdouble - -class TypeInfo_r : TypeInfo -{ - pure: - nothrow: - @safe: - - alias F = cdouble; - - override string toString() const { return F.stringof; } - - override size_t getHash(scope const void* p) const @trusted - { - return Floating!F.hashOf(*cast(F*)p); - } - - override bool equals(in void* p1, in void* p2) const @trusted - { - return Floating!F.equals(*cast(F*)p1, *cast(F*)p2); - } - - override int compare(in void* p1, in void* p2) const @trusted - { - return Floating!F.compare(*cast(F*)p1, *cast(F*)p2); - } - - override @property size_t tsize() const - { - return F.sizeof; - } - - override void swap(void *p1, void *p2) const @trusted - { - F t = *cast(F*)p1; - *cast(F*)p1 = *cast(F*)p2; - *cast(F*)p2 = t; - } - - override const(void)[] initializer() const @trusted - { - static immutable F r; - return (&r)[0 .. 1]; - } - - override @property size_t talign() const - { - return F.alignof; - } - - static if (__traits(hasMember, TypeInfo, "argTypes")) - override int argTypes(out TypeInfo arg1, out TypeInfo arg2) - { - arg1 = typeid(double); - arg2 = typeid(double); - return 0; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_cent.d b/src/rt/typeinfo/ti_cent.d deleted file mode 100644 index fb4766ef78..0000000000 --- a/src/rt/typeinfo/ti_cent.d +++ /dev/null @@ -1,74 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2015. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2015. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_cent; - -static if (is(cent)): - -// cent - -class TypeInfo_zi : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "cent"; } - - override size_t getHash(scope const void* p) - { - // cent & ucent hash the same if ucent.sizeof >= size_t.sizeof. - return hashOf(*cast(const ucent*) p); - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(cent *)p1 == *cast(cent *)p2; - } - - override int compare(in void* p1, in void* p2) - { - if (*cast(cent *)p1 < *cast(cent *)p2) - return -1; - else if (*cast(cent *)p1 > *cast(cent *)p2) - return 1; - return 0; - } - - override @property size_t tsize() nothrow pure - { - return cent.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. cent.sizeof]; - } - - override void swap(void *p1, void *p2) - { - cent t; - - t = *cast(cent *)p1; - *cast(cent *)p1 = *cast(cent *)p2; - *cast(cent *)p2 = t; - } - - override @property size_t talign() nothrow pure - { - return cent.alignof; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_cfloat.d b/src/rt/typeinfo/ti_cfloat.d deleted file mode 100644 index fa673715f5..0000000000 --- a/src/rt/typeinfo/ti_cfloat.d +++ /dev/null @@ -1,76 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_cfloat; - -private import rt.util.typeinfo; - -// cfloat - -class TypeInfo_q : TypeInfo -{ - pure: - nothrow: - @safe: - - alias F = cfloat; - - override string toString() const { return F.stringof; } - - override size_t getHash(scope const void* p) const @trusted - { - return Floating!F.hashOf(*cast(F*)p); - } - - override bool equals(in void* p1, in void* p2) const @trusted - { - return Floating!F.equals(*cast(F*)p1, *cast(F*)p2); - } - - override int compare(in void* p1, in void* p2) const @trusted - { - return Floating!F.compare(*cast(F*)p1, *cast(F*)p2); - } - - override @property size_t tsize() const - { - return F.sizeof; - } - - override void swap(void *p1, void *p2) const @trusted - { - F t = *cast(F*)p1; - *cast(F*)p1 = *cast(F*)p2; - *cast(F*)p2 = t; - } - - override const(void)[] initializer() const @trusted - { - static immutable F r; - return (&r)[0 .. 1]; - } - - override @property size_t talign() const - { - return F.alignof; - } - - static if (__traits(hasMember, TypeInfo, "argTypes")) - override int argTypes(out TypeInfo arg1, out TypeInfo arg2) - { - arg1 = typeid(double); - return 0; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_char.d b/src/rt/typeinfo/ti_char.d deleted file mode 100644 index 9633bb9eac..0000000000 --- a/src/rt/typeinfo/ti_char.d +++ /dev/null @@ -1,64 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_char; - -// char - -class TypeInfo_a : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "char"; } - - override size_t getHash(scope const void* p) - { - return *cast(const char *)p; - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(char *)p1 == *cast(char *)p2; - } - - override int compare(in void* p1, in void* p2) - { - return *cast(char *)p1 - *cast(char *)p2; - } - - override @property size_t tsize() nothrow pure - { - return char.sizeof; - } - - override void swap(void *p1, void *p2) - { - char t; - - t = *cast(char *)p1; - *cast(char *)p1 = *cast(char *)p2; - *cast(char *)p2 = t; - } - - override const(void)[] initializer() const @trusted - { - static immutable char c; - - return (&c)[0 .. 1]; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_creal.d b/src/rt/typeinfo/ti_creal.d deleted file mode 100644 index e2201b17d9..0000000000 --- a/src/rt/typeinfo/ti_creal.d +++ /dev/null @@ -1,77 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_creal; - -private import rt.util.typeinfo; - -// creal - -class TypeInfo_c : TypeInfo -{ - pure: - nothrow: - @safe: - - alias F = creal; - - override string toString() const { return F.stringof; } - - override size_t getHash(scope const void* p) const @trusted - { - return Floating!F.hashOf(*cast(F*)p); - } - - override bool equals(in void* p1, in void* p2) const @trusted - { - return Floating!F.equals(*cast(F*)p1, *cast(F*)p2); - } - - override int compare(in void* p1, in void* p2) const @trusted - { - return Floating!F.compare(*cast(F*)p1, *cast(F*)p2); - } - - override @property size_t tsize() const - { - return F.sizeof; - } - - override void swap(void *p1, void *p2) const @trusted - { - F t = *cast(F*)p1; - *cast(F*)p1 = *cast(F*)p2; - *cast(F*)p2 = t; - } - - override const(void)[] initializer() const @trusted - { - static immutable F r; - return (&r)[0 .. 1]; - } - - override @property size_t talign() const - { - return F.alignof; - } - - static if (__traits(hasMember, TypeInfo, "argTypes")) - override int argTypes(out TypeInfo arg1, out TypeInfo arg2) - { - arg1 = typeid(real); - arg2 = typeid(real); - return 0; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_dchar.d b/src/rt/typeinfo/ti_dchar.d deleted file mode 100644 index 7329946199..0000000000 --- a/src/rt/typeinfo/ti_dchar.d +++ /dev/null @@ -1,64 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_dchar; - -// dchar - -class TypeInfo_w : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "dchar"; } - - override size_t getHash(scope const void* p) - { - return *cast(const dchar *)p; - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(dchar *)p1 == *cast(dchar *)p2; - } - - override int compare(in void* p1, in void* p2) - { - return *cast(dchar *)p1 - *cast(dchar *)p2; - } - - override @property size_t tsize() nothrow pure - { - return dchar.sizeof; - } - - override void swap(void *p1, void *p2) - { - dchar t; - - t = *cast(dchar *)p1; - *cast(dchar *)p1 = *cast(dchar *)p2; - *cast(dchar *)p2 = t; - } - - override const(void)[] initializer() const @trusted - { - static immutable dchar c; - - return (&c)[0 .. 1]; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_delegate.d b/src/rt/typeinfo/ti_delegate.d deleted file mode 100644 index d712be08a9..0000000000 --- a/src/rt/typeinfo/ti_delegate.d +++ /dev/null @@ -1,65 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_delegate; - - -// delegate - -alias void delegate(int) dg; - -class TypeInfo_D : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override size_t getHash(scope const void* p) - { - return hashOf(*cast(dg*)p); - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(dg *)p1 == *cast(dg *)p2; - } - - override @property size_t tsize() nothrow pure - { - return dg.sizeof; - } - - override void swap(void *p1, void *p2) - { - dg t; - - t = *cast(dg *)p1; - *cast(dg *)p1 = *cast(dg *)p2; - *cast(dg *)p2 = t; - } - - override const(void)[] initializer() const @trusted - { - static immutable dg d; - - return (cast(void *)null)[0 .. dg.sizeof]; - } - - override @property uint flags() nothrow pure - { - return 1; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return RTInfo!(dg); } -} diff --git a/src/rt/typeinfo/ti_double.d b/src/rt/typeinfo/ti_double.d deleted file mode 100644 index 3aed7a09fa..0000000000 --- a/src/rt/typeinfo/ti_double.d +++ /dev/null @@ -1,72 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_double; - -private import rt.util.typeinfo; - -// double - -class TypeInfo_d : TypeInfo -{ - pure: - nothrow: - @safe: - - alias F = double; - - override string toString() const { return F.stringof; } - - override size_t getHash(scope const void* p) const @trusted - { - return Floating!F.hashOf(*cast(F*)p); - } - - override bool equals(in void* p1, in void* p2) const @trusted - { - return Floating!F.equals(*cast(F*)p1, *cast(F*)p2); - } - - override int compare(in void* p1, in void* p2) const @trusted - { - return Floating!F.compare(*cast(F*)p1, *cast(F*)p2); - } - - override @property size_t tsize() const - { - return F.sizeof; - } - - override void swap(void *p1, void *p2) const @trusted - { - F t = *cast(F*)p1; - *cast(F*)p1 = *cast(F*)p2; - *cast(F*)p2 = t; - } - - override const(void)[] initializer() const @trusted - { - static immutable F r; - return (&r)[0 .. 1]; - } - - override @property size_t talign() const - { - return F.alignof; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } - - // passed in SIMD register - override @property uint flags() const { return 2; } -} diff --git a/src/rt/typeinfo/ti_float.d b/src/rt/typeinfo/ti_float.d deleted file mode 100644 index 710ce1bd40..0000000000 --- a/src/rt/typeinfo/ti_float.d +++ /dev/null @@ -1,67 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_float; - -private import rt.util.typeinfo; - -// float - -class TypeInfo_f : TypeInfo -{ - pure: - nothrow: - @safe: - - alias F = float; - - override string toString() const { return F.stringof; } - - override size_t getHash(scope const void* p) const @trusted - { - return Floating!F.hashOf(*cast(F*)p); - } - - override bool equals(in void* p1, in void* p2) const @trusted - { - return Floating!F.equals(*cast(F*)p1, *cast(F*)p2); - } - - override int compare(in void* p1, in void* p2) const @trusted - { - return Floating!F.compare(*cast(F*)p1, *cast(F*)p2); - } - - override @property size_t tsize() const - { - return F.sizeof; - } - - override void swap(void *p1, void *p2) const @trusted - { - F t = *cast(F*)p1; - *cast(F*)p1 = *cast(F*)p2; - *cast(F*)p2 = t; - } - - override const(void)[] initializer() const @trusted - { - static immutable F r; - return (&r)[0 .. 1]; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } - - // passed in SIMD register - override @property uint flags() const { return 2; } -} diff --git a/src/rt/typeinfo/ti_idouble.d b/src/rt/typeinfo/ti_idouble.d deleted file mode 100644 index 9820cabec8..0000000000 --- a/src/rt/typeinfo/ti_idouble.d +++ /dev/null @@ -1,27 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_idouble; - -private import rt.typeinfo.ti_double; - -// idouble - -class TypeInfo_p : TypeInfo_d -{ - pure: - nothrow: - @safe: - - override string toString() const { return idouble.stringof; } -} diff --git a/src/rt/typeinfo/ti_ifloat.d b/src/rt/typeinfo/ti_ifloat.d deleted file mode 100644 index c16358522b..0000000000 --- a/src/rt/typeinfo/ti_ifloat.d +++ /dev/null @@ -1,27 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_ifloat; - -private import rt.typeinfo.ti_float; - -// ifloat - -class TypeInfo_o : TypeInfo_f -{ - pure: - nothrow: - @safe: - - override string toString() const { return ifloat.stringof; } -} diff --git a/src/rt/typeinfo/ti_int.d b/src/rt/typeinfo/ti_int.d deleted file mode 100644 index da3b5cad6f..0000000000 --- a/src/rt/typeinfo/ti_int.d +++ /dev/null @@ -1,66 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_int; - -// int - -class TypeInfo_i : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "int"; } - - override size_t getHash(scope const void* p) - { - return *cast(const int *)p; - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(uint *)p1 == *cast(uint *)p2; - } - - override int compare(in void* p1, in void* p2) - { - if (*cast(int*) p1 < *cast(int*) p2) - return -1; - else if (*cast(int*) p1 > *cast(int*) p2) - return 1; - return 0; - } - - override @property size_t tsize() nothrow pure - { - return int.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. int.sizeof]; - } - - override void swap(void *p1, void *p2) - { - int t; - - t = *cast(int *)p1; - *cast(int *)p1 = *cast(int *)p2; - *cast(int *)p2 = t; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_ireal.d b/src/rt/typeinfo/ti_ireal.d deleted file mode 100644 index 6d7dd18e4f..0000000000 --- a/src/rt/typeinfo/ti_ireal.d +++ /dev/null @@ -1,27 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_ireal; - -private import rt.typeinfo.ti_real; - -// ireal - -class TypeInfo_j : TypeInfo_e -{ - pure: - nothrow: - @safe: - - override string toString() const { return ireal.stringof; } -} diff --git a/src/rt/typeinfo/ti_long.d b/src/rt/typeinfo/ti_long.d deleted file mode 100644 index 336b99433b..0000000000 --- a/src/rt/typeinfo/ti_long.d +++ /dev/null @@ -1,75 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_long; - -// long - -class TypeInfo_l : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "long"; } - - override size_t getHash(scope const void* p) - { - static if (ulong.sizeof <= size_t.sizeof) - return *cast(const long*)p; - else - // long & ulong hash the same if ulong.sizeof > size_t.sizeof. - return hashOf(*cast(const ulong*)p); - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(long *)p1 == *cast(long *)p2; - } - - override int compare(in void* p1, in void* p2) - { - if (*cast(long *)p1 < *cast(long *)p2) - return -1; - else if (*cast(long *)p1 > *cast(long *)p2) - return 1; - return 0; - } - - override @property size_t tsize() nothrow pure - { - return long.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. long.sizeof]; - } - - override void swap(void *p1, void *p2) - { - long t; - - t = *cast(long *)p1; - *cast(long *)p1 = *cast(long *)p2; - *cast(long *)p2 = t; - } - - override @property size_t talign() nothrow pure - { - return long.alignof; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_n.d b/src/rt/typeinfo/ti_n.d deleted file mode 100644 index 3baed08350..0000000000 --- a/src/rt/typeinfo/ti_n.d +++ /dev/null @@ -1,61 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2016. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Kenji Hara - */ - -/* Copyright Digital Mars 2016. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_n; - -// typeof(null) - -class TypeInfo_n : TypeInfo -{ - override string toString() const @safe { return "typeof(null)"; } - - override size_t getHash(scope const void* p) const - { - return 0; - } - - override bool equals(in void* p1, in void* p2) const @trusted - { - //return *cast(typeof(null)*)p1 is *cast(typeof(null)*)p2; - return true; - } - - override int compare(in void* p1, in void* p2) const @trusted - { - //if (*cast(int*) p1 < *cast(int*) p2) - // return -1; - //else if (*cast(int*) p1 > *cast(int*) p2) - // return 1; - return 0; - } - - override @property size_t tsize() const - { - return typeof(null).sizeof; - } - - override const(void)[] initializer() const @trusted - { - __gshared immutable void[typeof(null).sizeof] init; - return init[]; - } - - override void swap(void *p1, void *p2) const @trusted - { - //auto t = *cast(typeof(null)*)p1; - //*cast(typeof(null)*)p1 = *cast(typeof(null)*)p2; - //*cast(typeof(null)*)p2 = t; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_ptr.d b/src/rt/typeinfo/ti_ptr.d deleted file mode 100644 index c27d907dc5..0000000000 --- a/src/rt/typeinfo/ti_ptr.d +++ /dev/null @@ -1,67 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_ptr; - -// internal typeinfo for any pointer type -// please keep in sync with TypeInfo_Pointer - -class TypeInfo_P : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override size_t getHash(scope const void* p) - { - size_t addr = cast(size_t) *cast(const void**)p; - return addr ^ (addr >> 4); - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(void**)p1 == *cast(void**)p2; - } - - override int compare(in void* p1, in void* p2) - { - if (*cast(void**)p1 < *cast(void**)p2) - return -1; - else if (*cast(void**)p1 > *cast(void**)p2) - return 1; - else - return 0; - } - - override @property size_t tsize() nothrow pure - { - return (void*).sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. (void*).sizeof]; - } - - override void swap(void *p1, void *p2) - { - void* tmp = *cast(void**)p1; - *cast(void**)p1 = *cast(void**)p2; - *cast(void**)p2 = tmp; - } - - override @property uint flags() nothrow pure const { return 1; } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoHasPointers; } -} diff --git a/src/rt/typeinfo/ti_real.d b/src/rt/typeinfo/ti_real.d deleted file mode 100644 index dfd944fbc8..0000000000 --- a/src/rt/typeinfo/ti_real.d +++ /dev/null @@ -1,75 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_real; - -private import rt.util.typeinfo; - -// real - -class TypeInfo_e : TypeInfo -{ - pure: - nothrow: - @safe: - - alias F = real; - - override string toString() const { return F.stringof; } - - override size_t getHash(scope const void* p) const @trusted - { - return Floating!F.hashOf(*cast(F*)p); - } - - override bool equals(in void* p1, in void* p2) const @trusted - { - return Floating!F.equals(*cast(F*)p1, *cast(F*)p2); - } - - override int compare(in void* p1, in void* p2) const @trusted - { - return Floating!F.compare(*cast(F*)p1, *cast(F*)p2); - } - - override @property size_t tsize() const - { - return F.sizeof; - } - - override void swap(void *p1, void *p2) const @trusted - { - F t = *cast(F*)p1; - *cast(F*)p1 = *cast(F*)p2; - *cast(F*)p2 = t; - } - - override const(void)[] initializer() const @trusted - { - static immutable F r; - return (&r)[0 .. 1]; - } - - override @property size_t talign() const - { - return F.alignof; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } - - static if (real.mant_dig != 64) // exclude 80-bit X87 - { - // passed in SIMD register - override @property uint flags() const { return 2; } - } -} diff --git a/src/rt/typeinfo/ti_short.d b/src/rt/typeinfo/ti_short.d deleted file mode 100644 index ebafe9a1df..0000000000 --- a/src/rt/typeinfo/ti_short.d +++ /dev/null @@ -1,62 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_short; - -// short - -class TypeInfo_s : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "short"; } - - override size_t getHash(scope const void* p) - { - return *cast(const short *)p; - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(short *)p1 == *cast(short *)p2; - } - - override int compare(in void* p1, in void* p2) - { - return *cast(short *)p1 - *cast(short *)p2; - } - - override @property size_t tsize() nothrow pure - { - return short.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. short.sizeof]; - } - - override void swap(void *p1, void *p2) - { - short t; - - t = *cast(short *)p1; - *cast(short *)p1 = *cast(short *)p2; - *cast(short *)p2 = t; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_ubyte.d b/src/rt/typeinfo/ti_ubyte.d deleted file mode 100644 index 860592fdf8..0000000000 --- a/src/rt/typeinfo/ti_ubyte.d +++ /dev/null @@ -1,72 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_ubyte; - -// ubyte - -class TypeInfo_h : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "ubyte"; } - - override size_t getHash(scope const void* p) - { - return *cast(const ubyte *)p; - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(ubyte *)p1 == *cast(ubyte *)p2; - } - - override int compare(in void* p1, in void* p2) - { - return *cast(ubyte *)p1 - *cast(ubyte *)p2; - } - - override @property size_t tsize() nothrow pure - { - return ubyte.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. ubyte.sizeof]; - } - - override void swap(void *p1, void *p2) - { - ubyte t; - - t = *cast(ubyte *)p1; - *cast(ubyte *)p1 = *cast(ubyte *)p2; - *cast(ubyte *)p2 = t; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} - -class TypeInfo_b : TypeInfo_h -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "bool"; } -} diff --git a/src/rt/typeinfo/ti_ucent.d b/src/rt/typeinfo/ti_ucent.d deleted file mode 100644 index 52fa8280b3..0000000000 --- a/src/rt/typeinfo/ti_ucent.d +++ /dev/null @@ -1,73 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2015. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2015. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_ucent; - -static if (is(ucent)): - -// ucent - -class TypeInfo_zk : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "ucent"; } - - override size_t getHash(scope const void* p) - { - return hashOf(*cast(const ucent*) p); - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(ucent *)p1 == *cast(ucent *)p2; - } - - override int compare(in void* p1, in void* p2) - { - if (*cast(ucent *)p1 < *cast(ucent *)p2) - return -1; - else if (*cast(ucent *)p1 > *cast(ucent *)p2) - return 1; - return 0; - } - - override @property size_t tsize() nothrow pure - { - return ucent.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. ucent.sizeof]; - } - - override void swap(void *p1, void *p2) - { - ucent t; - - t = *cast(ucent *)p1; - *cast(ucent *)p1 = *cast(ucent *)p2; - *cast(ucent *)p2 = t; - } - - override @property size_t talign() nothrow pure - { - return ucent.alignof; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_uint.d b/src/rt/typeinfo/ti_uint.d deleted file mode 100644 index 3ae043277d..0000000000 --- a/src/rt/typeinfo/ti_uint.d +++ /dev/null @@ -1,66 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_uint; - -// uint - -class TypeInfo_k : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "uint"; } - - override size_t getHash(scope const void* p) - { - return *cast(const uint *)p; - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(uint *)p1 == *cast(uint *)p2; - } - - override int compare(in void* p1, in void* p2) - { - if (*cast(uint*) p1 < *cast(uint*) p2) - return -1; - else if (*cast(uint*) p1 > *cast(uint*) p2) - return 1; - return 0; - } - - override @property size_t tsize() nothrow pure - { - return uint.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. uint.sizeof]; - } - - override void swap(void *p1, void *p2) - { - int t; - - t = *cast(uint *)p1; - *cast(uint *)p1 = *cast(uint *)p2; - *cast(uint *)p2 = t; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_ulong.d b/src/rt/typeinfo/ti_ulong.d deleted file mode 100644 index 6b067f2c49..0000000000 --- a/src/rt/typeinfo/ti_ulong.d +++ /dev/null @@ -1,75 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_ulong; - - -// ulong - -class TypeInfo_m : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "ulong"; } - - override size_t getHash(scope const void* p) - { - static if (ulong.sizeof <= size_t.sizeof) - return *cast(const ulong*)p; - else - return hashOf(*cast(const ulong*)p); - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(ulong *)p1 == *cast(ulong *)p2; - } - - override int compare(in void* p1, in void* p2) - { - if (*cast(ulong *)p1 < *cast(ulong *)p2) - return -1; - else if (*cast(ulong *)p1 > *cast(ulong *)p2) - return 1; - return 0; - } - - override @property size_t tsize() nothrow pure - { - return ulong.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. ulong.sizeof]; - } - - override void swap(void *p1, void *p2) - { - ulong t; - - t = *cast(ulong *)p1; - *cast(ulong *)p1 = *cast(ulong *)p2; - *cast(ulong *)p2 = t; - } - - override @property size_t talign() nothrow pure - { - return ulong.alignof; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_ushort.d b/src/rt/typeinfo/ti_ushort.d deleted file mode 100644 index f90b4ab972..0000000000 --- a/src/rt/typeinfo/ti_ushort.d +++ /dev/null @@ -1,62 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_ushort; - -// ushort - -class TypeInfo_t : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "ushort"; } - - override size_t getHash(scope const void* p) - { - return *cast(const ushort *)p; - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(ushort *)p1 == *cast(ushort *)p2; - } - - override int compare(in void* p1, in void* p2) - { - return *cast(ushort *)p1 - *cast(ushort *)p2; - } - - override @property size_t tsize() nothrow pure - { - return ushort.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. ushort.sizeof]; - } - - override void swap(void *p1, void *p2) - { - ushort t; - - t = *cast(ushort *)p1; - *cast(ushort *)p1 = *cast(ushort *)p2; - *cast(ushort *)p2 = t; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/typeinfo/ti_void.d b/src/rt/typeinfo/ti_void.d deleted file mode 100644 index c35de7b88d..0000000000 --- a/src/rt/typeinfo/ti_void.d +++ /dev/null @@ -1,65 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_void; - -// void - -class TypeInfo_v : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() const pure nothrow @safe { return "void"; } - - override size_t getHash(scope const void* p) - { - assert(0); - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(byte *)p1 == *cast(byte *)p2; - } - - override int compare(in void* p1, in void* p2) - { - return *cast(byte *)p1 - *cast(byte *)p2; - } - - override @property size_t tsize() nothrow pure - { - return void.sizeof; - } - - override const(void)[] initializer() const @trusted - { - return (cast(void *)null)[0 .. void.sizeof]; - } - - override void swap(void *p1, void *p2) - { - byte t; - - t = *cast(byte *)p1; - *cast(byte *)p1 = *cast(byte *)p2; - *cast(byte *)p2 = t; - } - - override @property uint flags() nothrow pure - { - return 1; - } -} diff --git a/src/rt/typeinfo/ti_wchar.d b/src/rt/typeinfo/ti_wchar.d deleted file mode 100644 index 7d278abaac..0000000000 --- a/src/rt/typeinfo/ti_wchar.d +++ /dev/null @@ -1,64 +0,0 @@ -/** - * TypeInfo support code. - * - * Copyright: Copyright Digital Mars 2004 - 2009. - * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). - * Authors: Walter Bright - */ - -/* Copyright Digital Mars 2004 - 2009. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) - */ -module rt.typeinfo.ti_wchar; - -// wchar - -class TypeInfo_u : TypeInfo -{ - @trusted: - const: - pure: - nothrow: - - override string toString() { return "wchar"; } - - override size_t getHash(scope const void* p) - { - return *cast(const wchar *)p; - } - - override bool equals(in void* p1, in void* p2) - { - return *cast(wchar *)p1 == *cast(wchar *)p2; - } - - override int compare(in void* p1, in void* p2) - { - return *cast(wchar *)p1 - *cast(wchar *)p2; - } - - override @property size_t tsize() - { - return wchar.sizeof; - } - - override void swap(void *p1, void *p2) - { - wchar t; - - t = *cast(wchar *)p1; - *cast(wchar *)p1 = *cast(wchar *)p2; - *cast(wchar *)p2 = t; - } - - override const(void)[] initializer() const @trusted - { - static immutable wchar c; - - return (&c)[0 .. 1]; - } - - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } -} diff --git a/src/rt/util/typeinfo.d b/src/rt/util/typeinfo.d index 641c721716..0a13a7513c 100644 --- a/src/rt/util/typeinfo.d +++ b/src/rt/util/typeinfo.d @@ -266,3 +266,520 @@ unittest } }(); } + +// Reduces to `T` if `cond` is `true` or `U` otherwise. +private template Select(bool cond, T, U) +{ + static if (cond) alias Select = T; + else alias Select = U; +} + +/* +TypeInfo information for built-in types. + +A `Base` type may be specified, which must be a type with the same layout, alignment, hashing, and +equality comparison as type `T`. This saves on code size because parts of `Base` will be reused. Example: +`float` and `ifloat` or `char` and `ubyte`. The implementation assumes `Base` and `T` hash the same, swap +the same, have the same ABI flags, and compare the same for equality. For ordering comparisons, we detect +during compilation whether they have different signedness and override appropriately. For initializer, we +detect if we need to override. The overriding initializer should be nonzero. +*/ +private class TypeInfoGeneric(T, Base = T) : Select!(is(T == Base), TypeInfo, TypeInfoGeneric!Base) +if (T.sizeof == Base.sizeof && T.alignof == Base.alignof) +{ + const: nothrow: pure: @trusted: + + // Returns the type name. + override string toString() const pure nothrow @safe { return T.stringof; } + + // `getHash` is the same for `Base` and `T`, introduce it just once. + static if (is(T == Base)) + override size_t getHash(scope const void* p) + { + static if (__traits(isFloating, T)) + return Floating!T.hashOf(*cast(T*)p); + else + return hashOf(*cast(const T *)p); + } + + // `equals` is the same for `Base` and `T`, introduce it just once. + static if (is(T == Base)) + override bool equals(in void* p1, in void* p2) + { + static if (__traits(isFloating, T)) + return Floating!T.equals(*cast(T*)p1, *cast(T*)p2); + else + return *cast(T *)p1 == *cast(T *)p2; + } + + // `T` and `Base` may have different signedness, so this function is introduced conditionally. + static if (is(T == Base) || (__traits(isIntegral, T) && T.max != Base.max)) + override int compare(in void* p1, in void* p2) + { + static if (__traits(isFloating, T)) + { + return Floating!T.compare(*cast(T*)p1, *cast(T*)p2); + } + else static if (T.sizeof < int.sizeof) + { + // Taking the difference will always fit in an int. + return int(*cast(T *) p1) - int(*cast(T *) p2); + } + else + { + auto lhs = *cast(T *) p1, rhs = *cast(T *) p2; + return (lhs > rhs) - (lhs < rhs); + } + } + + static if (is(T == Base)) + override @property size_t tsize() nothrow pure + { + return T.sizeof; + } + + static if (is(T == Base)) + override @property size_t talign() nothrow pure + { + return T.alignof; + } + + // Override initializer only if necessary. + static if (is(T == Base) || T.init != Base.init) + override const(void)[] initializer() @trusted + { + static if (__traits(isZeroInit, T)) + { + return (cast(void *)null)[0 .. T.sizeof]; + } + else + { + static immutable T[1] c; + return c; + } + } + + // `swap` is the same for `Base` and `T`, so introduce only once. + static if (is(T == Base)) + override void swap(void *p1, void *p2) + { + auto t = *cast(T *) p1; + *cast(T *)p1 = *cast(T *)p2; + *cast(T *)p2 = t; + } + + static if (is(T == Base) || RTInfo!T != RTInfo!Base) + override @property immutable(void)* rtInfo() nothrow pure const @safe + { + return RTInfo!T; + } + + static if (is(T == Base)) + static if (__traits(isFloating, T) && T.mant_dig != 64) + // FP types except 80-bit X87 are passed in SIMD register. + override @property uint flags() const { return 2; } +} + +unittest +{ + assert(typeid(int).toString == "int"); + + with (typeid(double)) + { + double a = 42, b = 43; + assert(equals(&a, &a)); + assert(!equals(&a, &b)); + assert(compare(&a, &a) == 0); + assert(compare(&a, &b) == -1); + assert(compare(&b, &a) == 1); + } + + with (typeid(short)) + { + short c = 42, d = 43; + assert(equals(&c, &c)); + assert(!equals(&c, &d)); + assert(compare(&c, &c) == 0); + assert(compare(&c, &d) == -1); + assert(compare(&d, &c) == 1); + assert(initializer.ptr is null); + assert(initializer.length == short.sizeof); + swap(&d, &c); + assert(c == 43 && d == 42); + } +} + +/* +TypeInfo information for arrays of built-in types. + +A `Base` type may be specified, which must be a type with the same layout, alignment, hashing, and +equality comparison as type `T`. This saves on code size because parts of `Base` will be reused. Example: +`float` and `ifloat` or `char` and `ubyte`. The implementation assumes `Base` and `T` hash the same, swap +the same, have the same ABI flags, and compare the same for equality. For ordering comparisons, we detect +during compilation whether they have different signedness and override appropriately. For initializer, we +detect if we need to override. The overriding initializer should be nonzero. +*/ +private class TypeInfoArrayGeneric(T, Base = T) : Select!(is(T == Base), TypeInfo_Array, TypeInfoArrayGeneric!Base) +{ + static if (is(T == Base)) + override bool opEquals(Object o) { return TypeInfo.opEquals(o); } + + override string toString() const { return (T[]).stringof; } + + static if (is(T == Base)) + override size_t getHash(scope const void* p) @trusted const + { + static if (__traits(isFloating, T)) + return Array!T.hashOf(*cast(T[]*)p); + else + return hashOf(*cast(const T[]*) p); + } + + static if (is(T == Base)) + override bool equals(in void* p1, in void* p2) const + { + static if (__traits(isFloating, T)) + { + return Array!T.equals(*cast(T[]*)p1, *cast(T[]*)p2); + } + else + { + import core.stdc.string; + auto s1 = *cast(T[]*)p1; + auto s2 = *cast(T[]*)p2; + return s1.length == s2.length && + memcmp(s1.ptr, s2.ptr, s1.length) == 0; + } + } + + static if (is(T == Base) || (__traits(isIntegral, T) && T.max != Base.max)) + override int compare(in void* p1, in void* p2) const + { + static if (__traits(isFloating, T)) + { + return Array!T.compare(*cast(T[]*)p1, *cast(T[]*)p2); + } + else + { + auto s1 = *cast(T[]*)p1; + auto s2 = *cast(T[]*)p2; + auto len = s1.length; + + if (s2.length < len) + len = s2.length; + for (size_t u = 0; u < len; u++) + { + if (int result = (s1[u] > s2[u]) - (s1[u] < s2[u])) + return result; + } + return (s1.length > s2.length) - (s1.length < s2.length); + } + } + + override @property inout(TypeInfo) next() inout + { + return cast(inout) typeid(T); + } +} + +unittest +{ + assert(typeid(int[]) == typeid(int[])); + assert(typeid(int[]) != typeid(uint[])); + assert(typeid(int[]).toString == "int[]"); + + with (typeid(double[])) + { + double[] a = [ 1, 2, 3 ], b = [ 2, 3 ]; + assert(equals(&a, &a)); + assert(!equals(&a, &b)); + assert(compare(&a, &a) == 0); + assert(compare(&a, &b) == -1); + assert(compare(&b, &a) == 1); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Predefined TypeInfos +//////////////////////////////////////////////////////////////////////////////// + +// void +class TypeInfo_v : TypeInfoGeneric!ubyte +{ + const: nothrow: pure: @trusted: + + override string toString() const pure nothrow @safe { return "void"; } + + override size_t getHash(scope const void* p) + { + assert(0); + } + + override @property uint flags() nothrow pure + { + return 1; + } + + unittest + { + assert(typeid(void).toString == "void"); + assert(typeid(void).flags == 1); + } +} + +// All integrals. +class TypeInfo_h : TypeInfoGeneric!ubyte {} +class TypeInfo_b : TypeInfoGeneric!(bool, ubyte) {} +class TypeInfo_g : TypeInfoGeneric!(byte, ubyte) {} +class TypeInfo_a : TypeInfoGeneric!(char, ubyte) {} +class TypeInfo_t : TypeInfoGeneric!ushort {} +class TypeInfo_s : TypeInfoGeneric!(short, ushort) {} +class TypeInfo_u : TypeInfoGeneric!(wchar, ushort) {} +class TypeInfo_w : TypeInfoGeneric!(dchar, uint) {} +class TypeInfo_k : TypeInfoGeneric!uint {} +class TypeInfo_i : TypeInfoGeneric!(int, uint) {} +class TypeInfo_m : TypeInfoGeneric!ulong {} +class TypeInfo_l : TypeInfoGeneric!(long, ulong) {} +static if (is(cent)) class TypeInfo_zi : TypeInfoGeneric!cent {} +static if (is(ucent)) class TypeInfo_zk : TypeInfoGeneric!ucent {} + +// All simple floating-point types. +class TypeInfo_f : TypeInfoGeneric!float {} +class TypeInfo_o : TypeInfoGeneric!(ifloat, float) {} +class TypeInfo_d : TypeInfoGeneric!double {} +class TypeInfo_p : TypeInfoGeneric!(idouble, double) {} +class TypeInfo_e : TypeInfoGeneric!real {} +class TypeInfo_j : TypeInfoGeneric!(ireal, real) {} + +// All complex floating-point types. + +// cfloat +class TypeInfo_q : TypeInfoGeneric!cfloat +{ + const: nothrow: pure: @trusted: + static if (__traits(hasMember, TypeInfo, "argTypes")) + override int argTypes(out TypeInfo arg1, out TypeInfo arg2) + { + arg1 = typeid(double); + return 0; + } +} + +// cdouble +class TypeInfo_r : TypeInfoGeneric!cdouble +{ + const: nothrow: pure: @trusted: + static if (__traits(hasMember, TypeInfo, "argTypes")) + override int argTypes(out TypeInfo arg1, out TypeInfo arg2) + { + arg1 = typeid(double); + arg2 = typeid(double); + return 0; + } +} + +// creal +class TypeInfo_c : TypeInfoGeneric!creal +{ + const: nothrow: pure: @trusted: + static if (__traits(hasMember, TypeInfo, "argTypes")) + override int argTypes(out TypeInfo arg1, out TypeInfo arg2) + { + arg1 = typeid(real); + arg2 = typeid(real); + return 0; + } +} + +static if (__traits(hasMember, TypeInfo, "argTypes")) + unittest + { + TypeInfo t1, t2; + assert(typeid(cfloat).argTypes(t1, t2) == 0 && t1 == typeid(double) && + t2 is null); + assert(typeid(cdouble).argTypes(t1, t2) == 0 && t1 == typeid(double) && + t2 == typeid(double)); + assert(typeid(creal).argTypes(t1, t2) == 0 && t1 == typeid(real) && + t2 == typeid(real)); + } + +// Arrays of all integrals. +class TypeInfo_Ah : TypeInfoArrayGeneric!ubyte {} +class TypeInfo_Ab : TypeInfoArrayGeneric!(bool, ubyte) {} +class TypeInfo_Ag : TypeInfoArrayGeneric!(byte, ubyte) {} +class TypeInfo_Aa : TypeInfoArrayGeneric!(char, ubyte) {} +class TypeInfo_Axa : TypeInfoArrayGeneric!(const char) {} +class TypeInfo_Aya : TypeInfoArrayGeneric!(immutable char) +{ + // Must override this, otherwise "string" is returned. + override string toString() const { return "immutable(char)[]"; } +} +class TypeInfo_At : TypeInfoArrayGeneric!ushort {} +class TypeInfo_As : TypeInfoArrayGeneric!(short, ushort) {} +class TypeInfo_Au : TypeInfoArrayGeneric!(wchar, ushort) {} +class TypeInfo_Ak : TypeInfoArrayGeneric!uint {} +class TypeInfo_Ai : TypeInfoArrayGeneric!(int, uint) {} +class TypeInfo_Aw : TypeInfoArrayGeneric!(dchar, uint) {} +class TypeInfo_Am : TypeInfoArrayGeneric!ulong {} +class TypeInfo_Al : TypeInfoArrayGeneric!(long, ulong) {} + +version (CoreUnittest) + private extern (C) void[] _adSort(void[] a, TypeInfo ti); + +unittest +{ + assert(typeid(string).toString() == "immutable(char)[]"); + int[][] a = [[5,3,8,7], [2,5,3,8,7]]; + _adSort(*cast(void[]*)&a, typeid(a[0])); + assert(a == [[2,5,3,8,7], [5,3,8,7]]); + + a = [[5,3,8,7], [5,3,8]]; + _adSort(*cast(void[]*)&a, typeid(a[0])); + assert(a == [[5,3,8], [5,3,8,7]]); +} + +unittest +{ + // https://issues.dlang.org/show_bug.cgi?id=13073: original code uses int subtraction which is susceptible to + // integer overflow, causing the following case to fail. + int[] a = [int.max, int.max]; + int[] b = [int.min, int.min]; + assert(a > b); + assert(b < a); +} + +unittest +{ + // Original test case from issue 13073 + uint x = 0x22_DF_FF_FF; + uint y = 0xA2_DF_FF_FF; + assert(!(x < y && y < x)); + uint[] a = [x]; + uint[] b = [y]; + assert(!(a < b && b < a)); // Original failing case + uint[1] a1 = [x]; + uint[1] b1 = [y]; + assert(!(a1 < b1 && b1 < a1)); // Original failing case +} + +// Arrays of all floating point types. +class TypeInfo_Af : TypeInfoArrayGeneric!float {} +class TypeInfo_Ao : TypeInfoArrayGeneric!(ifloat, float) {} +class TypeInfo_Ad : TypeInfoArrayGeneric!double {} +class TypeInfo_Ap : TypeInfoArrayGeneric!(idouble, double) {} +class TypeInfo_Ae : TypeInfoArrayGeneric!real {} +class TypeInfo_Aj : TypeInfoArrayGeneric!(ireal, real) {} +class TypeInfo_Aq : TypeInfoArrayGeneric!cfloat {} +class TypeInfo_Ar : TypeInfoArrayGeneric!cdouble {} +class TypeInfo_Ac : TypeInfoArrayGeneric!creal {} + +// void[] is a bit different, behaves like ubyte[] for comparison purposes. +class TypeInfo_Av : TypeInfo_Ah +{ + override string toString() const { return "void[]"; } + + override @property inout(TypeInfo) next() inout + { + return cast(inout) typeid(void); + } + + unittest + { + assert(typeid(void[]).toString == "void[]"); + assert(typeid(void[]).next == typeid(void)); + } +} + +// all delegates +unittest +{ + assert(typeid(void delegate(int)).flags == 1); +} + +// typeof(null) +class TypeInfo_n : TypeInfo +{ + override string toString() const @safe { return "typeof(null)"; } + + override size_t getHash(scope const void* p) const + { + return 0; + } + + override bool equals(in void* p1, in void* p2) const @trusted + { + return true; + } + + override int compare(in void* p1, in void* p2) const @trusted + { + return 0; + } + + override @property size_t tsize() const + { + return typeof(null).sizeof; + } + + override const(void)[] initializer() const @trusted + { + __gshared immutable void[typeof(null).sizeof] init; + return init; + } + + override void swap(void *p1, void *p2) const @trusted + { + } + + override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } + + unittest + { + with (typeid(typeof(null))) + { + assert(toString == "typeof(null)"); + assert(getHash(null) == 0); + assert(equals(null, null)); + assert(compare(null, null) == 0); + assert(tsize == typeof(null).sizeof); + assert(initializer == new ubyte[(void*).sizeof]); + assert(rtInfo == rtinfoNoPointers); + } + } +} + +// Test typeinfo for classes. +unittest +{ + static class Bacon + { + int sizzle = 1; + override int opCmp(Object rhs) const + { + if (auto rhsb = cast(Bacon) rhs) + return (sizzle > rhsb.sizzle) - (sizzle < rhsb.sizzle); + return 0; + } + } + Object obj = new Bacon; + Bacon obj2 = new Bacon; + obj2.sizzle = 2; + auto dummy = new Object; + with (typeid(obj)) + { + assert(toString[$ - 6 .. $] == ".Bacon"); + assert(getHash(&obj) != 0); + assert(equals(&obj, &obj)); + assert(!equals(&obj, &obj2)); + assert(compare(&obj, &dummy) == 0); + assert(compare(&obj, &obj) == 0); + assert(compare(&obj, &obj2) == -1); + assert(compare(&obj2, &obj) == 1); + assert(tsize == Object.sizeof); + assert(rtInfo == RTInfo!Bacon); + assert(tsize == Object.sizeof); + assert(initializer.ptr !is null); + assert(initializer.length == __traits(classInstanceSize, Bacon)); + assert(flags == 1); + } +}