From: sean Date: Tue, 23 Sep 2008 03:21:04 +0000 (+0000) Subject: Finished flattening D1/D2 differences. Except for one or two lines, all differences... X-Git-Url: https://git.llucax.com/software/druntime.git/commitdiff_plain/1f3a9af059166187064490d1cae80bd11fb8737c?hp=0b5d833e0947d44cd5bee6562c22ed4a14ca23bb Finished flattening D1/D2 differences. Except for one or two lines, all differences between the D1 and D2 runtimes is now strictly additive. git-svn-id: http://svn.dsource.org/projects/druntime/trunk@7 4a9d5153-6564-4b3f-b5e1-7e8e9dac548f --- diff --git a/import/object.di b/import/object.di index 9508fef..7400468 100644 --- a/import/object.di +++ b/import/object.di @@ -175,5 +175,5 @@ class Exception : Object this(string msg, Exception next = null); this(string msg, string file, size_t line, Exception next = null); - string toString(); + override string toString(); } diff --git a/src/compiler/dmd/cover.d b/src/compiler/dmd/cover.d index fd33161..7d880e1 100644 --- a/src/compiler/dmd/cover.d +++ b/src/compiler/dmd/cover.d @@ -222,7 +222,7 @@ bool readFile( char[] name, inout char[] buf ) { version( Windows ) { - wchar* wnamez = toUTF16z( name ); + auto wnamez = toUTF16z( name ); HANDLE file = CreateFileW( wnamez, GENERIC_READ, FILE_SHARE_READ, diff --git a/src/compiler/dmd/dmain2.d b/src/compiler/dmd/dmain2.d index 9527929..4285db8 100644 --- a/src/compiler/dmd/dmain2.d +++ b/src/compiler/dmd/dmain2.d @@ -42,34 +42,34 @@ extern (C) void thread_joinAll(); * These functions must be defined for any D program linked * against this library. */ -extern (C) void onAssertError( char[] file, size_t line ); -extern (C) void onAssertErrorMsg( char[] file, size_t line, char[] msg ); -extern (C) void onArrayBoundsError( char[] file, size_t line ); -extern (C) void onSwitchError( char[] file, size_t line ); +extern (C) void onAssertError( string file, size_t line ); +extern (C) void onAssertErrorMsg( string file, size_t line, string msg ); +extern (C) void onArrayBoundsError( string file, size_t line ); +extern (C) void onSwitchError( string file, size_t line ); extern (C) bool runModuleUnitTests(); // this function is called from the utf module -//extern (C) void onUnicodeError( char[] msg, size_t idx ); +//extern (C) void onUnicodeError( string msg, size_t idx ); /*********************************** * These are internal callbacks for various language errors. */ -extern (C) void _d_assert( char[] file, uint line ) +extern (C) void _d_assert( string file, uint line ) { onAssertError( file, line ); } -extern (C) static void _d_assert_msg( char[] msg, char[] file, uint line ) +extern (C) static void _d_assert_msg( string msg, string file, uint line ) { onAssertErrorMsg( file, line, msg ); } -extern (C) void _d_array_bounds( char[] file, uint line ) +extern (C) void _d_array_bounds( string file, uint line ) { onArrayBoundsError( file, line ); } -extern (C) void _d_switch_error( char[] file, uint line ) +extern (C) void _d_switch_error( string file, uint line ) { onSwitchError( file, line ); } diff --git a/src/compiler/dmd/object_.d b/src/compiler/dmd/object_.d index a0ac2a0..0ffa9fb 100644 --- a/src/compiler/dmd/object_.d +++ b/src/compiler/dmd/object_.d @@ -216,7 +216,7 @@ struct OffsetTypeInfo */ class TypeInfo { - hash_t toHash() + override hash_t toHash() { hash_t hash; foreach (char c; this.toString()) @@ -224,7 +224,7 @@ class TypeInfo return hash; } - int opCmp(Object o) + override int opCmp(Object o) { if (this is o) return 0; @@ -234,7 +234,7 @@ class TypeInfo return dstrcmp(this.toString(), ti.toString()); } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { /* TypeInfo instances are singletons, but duplicates can exist * across DLL's. Therefore, comparing for a name match is @@ -286,9 +286,9 @@ class TypeInfo class TypeInfo_Typedef : TypeInfo { - string toString() { return name; } + override string toString() { return name; } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { TypeInfo_Typedef c; return this is o || @@ -297,15 +297,15 @@ class TypeInfo_Typedef : TypeInfo this.base == c.base); } - hash_t getHash(in void* p) { return base.getHash(p); } - equals_t equals(in void* p1, in void* p2) { return base.equals(p1, p2); } - int compare(in void* p1, in void* p2) { return base.compare(p1, p2); } - size_t tsize() { return base.tsize(); } - void swap(void* p1, void* p2) { return base.swap(p1, p2); } + override hash_t getHash(in void* p) { return base.getHash(p); } + override equals_t equals(in void* p1, in void* p2) { return base.equals(p1, p2); } + override int compare(in void* p1, in void* p2) { return base.compare(p1, p2); } + override size_t tsize() { return base.tsize(); } + override void swap(void* p1, void* p2) { return base.swap(p1, p2); } - TypeInfo next() { return base.next(); } - uint flags() { return base.flags(); } - void[] init() { return m_init.length ? m_init : base.init(); } + override TypeInfo next() { return base.next(); } + override uint flags() { return base.flags(); } + override void[] init() { return m_init.length ? m_init : base.init(); } TypeInfo base; string name; @@ -319,9 +319,9 @@ class TypeInfo_Enum : TypeInfo_Typedef class TypeInfo_Pointer : TypeInfo { - string toString() { return m_next.toString() ~ "*"; } + override string toString() { return m_next.toString() ~ "*"; } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { TypeInfo_Pointer c; return this is o || @@ -329,17 +329,17 @@ class TypeInfo_Pointer : TypeInfo this.m_next == c.m_next); } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return cast(hash_t)*cast(void**)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(void**)p1 == *cast(void**)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { if (*cast(void**)p1 < *cast(void**)p2) return -1; @@ -349,29 +349,29 @@ class TypeInfo_Pointer : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (void*).sizeof; } - void swap(void* p1, void* p2) + override void swap(void* p1, void* p2) { void* tmp = *cast(void**)p1; *cast(void**)p1 = *cast(void**)p2; *cast(void**)p2 = tmp; } - TypeInfo next() { return m_next; } - uint flags() { return 1; } + override TypeInfo next() { return m_next; } + override uint flags() { return 1; } TypeInfo m_next; } class TypeInfo_Array : TypeInfo { - string toString() { return value.toString() ~ "[]"; } + override string toString() { return value.toString() ~ "[]"; } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { TypeInfo_Array c; return this is o || @@ -379,7 +379,7 @@ class TypeInfo_Array : TypeInfo this.value == c.value); } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { size_t sz = value.tsize(); hash_t hash = 0; @@ -389,7 +389,7 @@ class TypeInfo_Array : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { void[] a1 = *cast(void[]*)p1; void[] a2 = *cast(void[]*)p2; @@ -404,7 +404,7 @@ class TypeInfo_Array : TypeInfo return true; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { void[] a1 = *cast(void[]*)p1; void[] a2 = *cast(void[]*)p2; @@ -422,12 +422,12 @@ class TypeInfo_Array : TypeInfo return cast(int)a1.length - cast(int)a2.length; } - size_t tsize() + override size_t tsize() { return (void[]).sizeof; } - void swap(void* p1, void* p2) + override void swap(void* p1, void* p2) { void[] tmp = *cast(void[]*)p1; *cast(void[]*)p1 = *cast(void[]*)p2; @@ -436,23 +436,23 @@ class TypeInfo_Array : TypeInfo TypeInfo value; - TypeInfo next() + override TypeInfo next() { return value; } - uint flags() { return 1; } + override uint flags() { return 1; } } class TypeInfo_StaticArray : TypeInfo { - string toString() + override string toString() { - char [10] tmp = void; - return value.toString() ~ "[" ~ tmp.intToString(len) ~ "]"; + char[10] tmp = void; + return cast(string)(value.toString() ~ "[" ~ tmp.intToString(len) ~ "]"); } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { TypeInfo_StaticArray c; return this is o || @@ -461,7 +461,7 @@ class TypeInfo_StaticArray : TypeInfo this.value == c.value); } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { size_t sz = value.tsize(); hash_t hash = 0; @@ -470,7 +470,7 @@ class TypeInfo_StaticArray : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { size_t sz = value.tsize(); @@ -482,7 +482,7 @@ class TypeInfo_StaticArray : TypeInfo return true; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { size_t sz = value.tsize(); @@ -495,12 +495,12 @@ class TypeInfo_StaticArray : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return len * value.tsize(); } - void swap(void* p1, void* p2) + override void swap(void* p1, void* p2) { void* tmp; size_t sz = value.tsize(); @@ -522,9 +522,9 @@ class TypeInfo_StaticArray : TypeInfo delete pbuffer; } - void[] init() { return value.init(); } - TypeInfo next() { return value; } - uint flags() { return value.flags(); } + override void[] init() { return value.init(); } + override TypeInfo next() { return value; } + override uint flags() { return value.flags(); } TypeInfo value; size_t len; @@ -532,12 +532,12 @@ class TypeInfo_StaticArray : TypeInfo class TypeInfo_AssociativeArray : TypeInfo { - string toString() + override string toString() { - return next.toString() ~ "[" ~ key.toString() ~ "]"; + return cast(string)(next.toString() ~ "[" ~ key.toString() ~ "]"); } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { TypeInfo_AssociativeArray c; return this is o || @@ -548,13 +548,13 @@ class TypeInfo_AssociativeArray : TypeInfo // BUG: need to add the rest of the functions - size_t tsize() + override size_t tsize() { return (char[int]).sizeof; } - TypeInfo next() { return value; } - uint flags() { return 1; } + override TypeInfo next() { return value; } + override uint flags() { return 1; } TypeInfo value; TypeInfo key; @@ -562,12 +562,12 @@ class TypeInfo_AssociativeArray : TypeInfo class TypeInfo_Function : TypeInfo { - string toString() + override string toString() { - return next.toString() ~ "()"; + return cast(string)(next.toString() ~ "()"); } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { TypeInfo_Function c; return this is o || @@ -577,7 +577,7 @@ class TypeInfo_Function : TypeInfo // BUG: need to add the rest of the functions - size_t tsize() + override size_t tsize() { return 0; // no size for functions } @@ -587,12 +587,12 @@ class TypeInfo_Function : TypeInfo class TypeInfo_Delegate : TypeInfo { - string toString() + override string toString() { - return next.toString() ~ " delegate()"; + return cast(string)(next.toString() ~ " delegate()"); } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { TypeInfo_Delegate c; return this is o || @@ -602,22 +602,22 @@ class TypeInfo_Delegate : TypeInfo // BUG: need to add the rest of the functions - size_t tsize() + override size_t tsize() { alias int delegate() dg; return dg.sizeof; } - uint flags() { return 1; } + override uint flags() { return 1; } TypeInfo next; } class TypeInfo_Class : TypeInfo { - string toString() { return info.name; } + override string toString() { return info.name; } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { TypeInfo_Class c; return this is o || @@ -625,13 +625,13 @@ class TypeInfo_Class : TypeInfo this.info.name == c.classinfo.name); } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { Object o = *cast(Object*)p; return o ? o.toHash() : 0; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { Object o1 = *cast(Object*)p1; Object o2 = *cast(Object*)p2; @@ -639,7 +639,7 @@ class TypeInfo_Class : TypeInfo return (o1 is o2) || (o1 && o1.opEquals(o2)); } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { Object o1 = *cast(Object*)p1; Object o2 = *cast(Object*)p2; @@ -661,14 +661,14 @@ class TypeInfo_Class : TypeInfo return c; } - size_t tsize() + override size_t tsize() { return Object.sizeof; } - uint flags() { return 1; } + override uint flags() { return 1; } - OffsetTypeInfo[] offTi() + override OffsetTypeInfo[] offTi() { return (info.flags & 4) ? info.offTi : null; } @@ -678,9 +678,9 @@ class TypeInfo_Class : TypeInfo class TypeInfo_Interface : TypeInfo { - string toString() { return info.name; } + override string toString() { return info.name; } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { TypeInfo_Interface c; return this is o || @@ -688,7 +688,7 @@ class TypeInfo_Interface : TypeInfo this.info.name == c.classinfo.name); } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { Interface* pi = **cast(Interface ***)*cast(void**)p; Object o = cast(Object)(*cast(void**)p - pi.offset); @@ -696,7 +696,7 @@ class TypeInfo_Interface : TypeInfo return o.toHash(); } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { Interface* pi = **cast(Interface ***)*cast(void**)p1; Object o1 = cast(Object)(*cast(void**)p1 - pi.offset); @@ -706,7 +706,7 @@ class TypeInfo_Interface : TypeInfo return o1 == o2 || (o1 && o1.opCmp(o2) == 0); } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { Interface* pi = **cast(Interface ***)*cast(void**)p1; Object o1 = cast(Object)(*cast(void**)p1 - pi.offset); @@ -730,21 +730,21 @@ class TypeInfo_Interface : TypeInfo return c; } - size_t tsize() + override size_t tsize() { return Object.sizeof; } - uint flags() { return 1; } + override uint flags() { return 1; } ClassInfo info; } class TypeInfo_Struct : TypeInfo { - string toString() { return name; } + override string toString() { return name; } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { TypeInfo_Struct s; return this is o || @@ -753,7 +753,7 @@ class TypeInfo_Struct : TypeInfo this.init.length == s.init.length); } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { assert(p); if (xtoHash) @@ -778,7 +778,7 @@ class TypeInfo_Struct : TypeInfo } } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { if (p1 == p2) return true; @@ -791,7 +791,7 @@ class TypeInfo_Struct : TypeInfo return memcmp(p1, p2, init.length) == 0; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { // Regard null references as always being "less than" if (p1 != p2) @@ -812,14 +812,14 @@ class TypeInfo_Struct : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return init.length; } - void[] init() { return m_init; } + override void[] init() { return m_init; } - uint flags() { return m_flags; } + override uint flags() { return m_flags; } string name; void[] m_init; // initializer; init.ptr == null if 0 initialize @@ -836,7 +836,7 @@ class TypeInfo_Tuple : TypeInfo { TypeInfo[] elements; - string toString() + override string toString() { string s = "("; foreach (i, element; elements) @@ -849,7 +849,7 @@ class TypeInfo_Tuple : TypeInfo return s; } - equals_t opEquals(Object o) + override equals_t opEquals(Object o) { if (this is o) return true; @@ -867,27 +867,27 @@ class TypeInfo_Tuple : TypeInfo return false; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { assert(0); } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { assert(0); } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { assert(0); } - size_t tsize() + override size_t tsize() { assert(0); } - void swap(void* p1, void* p2) + override void swap(void* p1, void* p2) { assert(0); } @@ -927,7 +927,7 @@ class Exception : Object this.info = traceContext(); } - string toString() + override string toString() { return msg; } diff --git a/src/compiler/dmd/trace.d b/src/compiler/dmd/trace.d index 469afe2..0947d57 100644 --- a/src/compiler/dmd/trace.d +++ b/src/compiler/dmd/trace.d @@ -76,10 +76,10 @@ static timer_t trace_ohd; static Symbol** psymbols; static uint nsymbols; // number of symbols -static char[] trace_logfilename = "trace.log"; +static string trace_logfilename = "trace.log"; static FILE* fplog; -static char[] trace_deffilename = "trace.def"; +static string trace_deffilename = "trace.def"; static FILE* fpdef; @@ -90,7 +90,7 @@ static FILE* fpdef; // 0 success // !=0 failure -int trace_setlogfilename(char[] name) +int trace_setlogfilename(string name) { trace_logfilename = name; return 0; @@ -103,7 +103,7 @@ int trace_setlogfilename(char[] name) // 0 success // !=0 failure -int trace_setdeffilename(char[] name) +int trace_setdeffilename(string name) { trace_deffilename = name; return 0; @@ -150,7 +150,7 @@ static void stack_free(Stack *s) ////////////////////////////////////// // Qsort() comparison routine for array of pointers to SymPair's. -static int sympair_cmp(void* e1, void* e2) +static int sympair_cmp(in void* e1, in void* e2) { SymPair** psp1; SymPair** psp2; @@ -285,7 +285,7 @@ static void trace_array(Symbol *s) ////////////////////////////////////// // Qsort() comparison routine for array of pointers to Symbol's. -static int symbol_cmp(void* e1, void* e2) +static int symbol_cmp(in void* e1, in void* e2) { Symbol** ps1; Symbol** ps2; timer_t diff; diff --git a/src/compiler/dmd/typeinfo/ti_AC.d b/src/compiler/dmd/typeinfo/ti_AC.d index 47b9074..e5eff26 100644 --- a/src/compiler/dmd/typeinfo/ti_AC.d +++ b/src/compiler/dmd/typeinfo/ti_AC.d @@ -4,7 +4,7 @@ module rt.typeinfo.ti_AC; class TypeInfo_AC : TypeInfo { - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { Object[] s = *cast(Object[]*)p; hash_t hash = 0; @@ -16,7 +16,7 @@ class TypeInfo_AC : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { Object[] s1 = *cast(Object[]*)p1; Object[] s2 = *cast(Object[]*)p2; @@ -38,7 +38,7 @@ class TypeInfo_AC : TypeInfo return false; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { Object[] s1 = *cast(Object[]*)p1; Object[] s2 = *cast(Object[]*)p2; @@ -78,17 +78,17 @@ class TypeInfo_AC : TypeInfo return c; } - size_t tsize() + override size_t tsize() { return (Object[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(Object); } diff --git a/src/compiler/dmd/typeinfo/ti_Acdouble.d b/src/compiler/dmd/typeinfo/ti_Acdouble.d index b844926..93a8512 100644 --- a/src/compiler/dmd/typeinfo/ti_Acdouble.d +++ b/src/compiler/dmd/typeinfo/ti_Acdouble.d @@ -29,9 +29,9 @@ private import typeinfo.ti_cdouble; class TypeInfo_Ar : TypeInfo { - string toString() { return "cdouble[]"; } + override string toString() { return "cdouble[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { cdouble[] s = *cast(cdouble[]*)p; size_t len = s.length; cdouble *str = s.ptr; @@ -51,7 +51,7 @@ class TypeInfo_Ar : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { cdouble[] s1 = *cast(cdouble[]*)p1; cdouble[] s2 = *cast(cdouble[]*)p2; @@ -67,7 +67,7 @@ class TypeInfo_Ar : TypeInfo return true; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { cdouble[] s1 = *cast(cdouble[]*)p1; cdouble[] s2 = *cast(cdouble[]*)p2; @@ -88,17 +88,17 @@ class TypeInfo_Ar : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (cdouble[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(cdouble); } diff --git a/src/compiler/dmd/typeinfo/ti_Acfloat.d b/src/compiler/dmd/typeinfo/ti_Acfloat.d index f15a507..069b09a 100644 --- a/src/compiler/dmd/typeinfo/ti_Acfloat.d +++ b/src/compiler/dmd/typeinfo/ti_Acfloat.d @@ -29,9 +29,9 @@ private import typeinfo.ti_cfloat; class TypeInfo_Aq : TypeInfo { - string toString() { return "cfloat[]"; } + override string toString() { return "cfloat[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { cfloat[] s = *cast(cfloat[]*)p; size_t len = s.length; cfloat *str = s.ptr; @@ -49,7 +49,7 @@ class TypeInfo_Aq : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { cfloat[] s1 = *cast(cfloat[]*)p1; cfloat[] s2 = *cast(cfloat[]*)p2; @@ -65,7 +65,7 @@ class TypeInfo_Aq : TypeInfo return true; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { cfloat[] s1 = *cast(cfloat[]*)p1; cfloat[] s2 = *cast(cfloat[]*)p2; @@ -86,17 +86,17 @@ class TypeInfo_Aq : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (cfloat[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(cfloat); } diff --git a/src/compiler/dmd/typeinfo/ti_Acreal.d b/src/compiler/dmd/typeinfo/ti_Acreal.d index 576a0cd..ba26c51 100644 --- a/src/compiler/dmd/typeinfo/ti_Acreal.d +++ b/src/compiler/dmd/typeinfo/ti_Acreal.d @@ -29,9 +29,9 @@ private import typeinfo.ti_creal; class TypeInfo_Ac : TypeInfo { - string toString() { return "creal[]"; } + override string toString() { return "creal[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { creal[] s = *cast(creal[]*)p; size_t len = s.length; creal *str = s.ptr; @@ -52,7 +52,7 @@ class TypeInfo_Ac : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { creal[] s1 = *cast(creal[]*)p1; creal[] s2 = *cast(creal[]*)p2; @@ -68,7 +68,7 @@ class TypeInfo_Ac : TypeInfo return true; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { creal[] s1 = *cast(creal[]*)p1; creal[] s2 = *cast(creal[]*)p2; @@ -89,17 +89,17 @@ class TypeInfo_Ac : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (creal[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(creal); } diff --git a/src/compiler/dmd/typeinfo/ti_Adouble.d b/src/compiler/dmd/typeinfo/ti_Adouble.d index 785f166..1b3709f 100644 --- a/src/compiler/dmd/typeinfo/ti_Adouble.d +++ b/src/compiler/dmd/typeinfo/ti_Adouble.d @@ -29,9 +29,9 @@ private import typeinfo.ti_double; class TypeInfo_Ad : TypeInfo { - string toString() { return "double[]"; } + override string toString() { return "double[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { double[] s = *cast(double[]*)p; size_t len = s.length; auto str = s.ptr; @@ -49,7 +49,7 @@ class TypeInfo_Ad : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { double[] s1 = *cast(double[]*)p1; double[] s2 = *cast(double[]*)p2; @@ -65,7 +65,7 @@ class TypeInfo_Ad : TypeInfo return true; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { double[] s1 = *cast(double[]*)p1; double[] s2 = *cast(double[]*)p2; @@ -86,17 +86,17 @@ class TypeInfo_Ad : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (double[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(double); } @@ -106,9 +106,9 @@ class TypeInfo_Ad : TypeInfo class TypeInfo_Ap : TypeInfo_Ad { - string toString() { return "idouble[]"; } + override string toString() { return "idouble[]"; } - TypeInfo next() + override TypeInfo next() { return typeid(idouble); } diff --git a/src/compiler/dmd/typeinfo/ti_Afloat.d b/src/compiler/dmd/typeinfo/ti_Afloat.d index cb937cd..312882b 100644 --- a/src/compiler/dmd/typeinfo/ti_Afloat.d +++ b/src/compiler/dmd/typeinfo/ti_Afloat.d @@ -29,9 +29,9 @@ private import typeinfo.ti_float; class TypeInfo_Af : TypeInfo { - string toString() { return "float[]"; } + override string toString() { return "float[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { float[] s = *cast(float[]*)p; size_t len = s.length; auto str = s.ptr; @@ -48,7 +48,7 @@ class TypeInfo_Af : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { float[] s1 = *cast(float[]*)p1; float[] s2 = *cast(float[]*)p2; @@ -64,7 +64,7 @@ class TypeInfo_Af : TypeInfo return true; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { float[] s1 = *cast(float[]*)p1; float[] s2 = *cast(float[]*)p2; @@ -85,17 +85,17 @@ class TypeInfo_Af : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (float[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(float); } @@ -105,9 +105,9 @@ class TypeInfo_Af : TypeInfo class TypeInfo_Ao : TypeInfo_Af { - string toString() { return "ifloat[]"; } + override string toString() { return "ifloat[]"; } - TypeInfo next() + override TypeInfo next() { return typeid(ifloat); } diff --git a/src/compiler/dmd/typeinfo/ti_Ag.d b/src/compiler/dmd/typeinfo/ti_Ag.d index daaa25b..9b935d3 100644 --- a/src/compiler/dmd/typeinfo/ti_Ag.d +++ b/src/compiler/dmd/typeinfo/ti_Ag.d @@ -8,9 +8,9 @@ private import stdc.string; class TypeInfo_Ag : TypeInfo { - string toString() { return "byte[]"; } + override string toString() { return "byte[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { byte[] s = *cast(byte[]*)p; size_t len = s.length; byte *str = s.ptr; @@ -51,7 +51,7 @@ class TypeInfo_Ag : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { byte[] s1 = *cast(byte[]*)p1; byte[] s2 = *cast(byte[]*)p2; @@ -60,7 +60,7 @@ class TypeInfo_Ag : TypeInfo memcmp(cast(byte *)s1, cast(byte *)s2, s1.length) == 0; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { byte[] s1 = *cast(byte[]*)p1; byte[] s2 = *cast(byte[]*)p2; @@ -81,17 +81,17 @@ class TypeInfo_Ag : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (byte[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(byte); } @@ -102,9 +102,9 @@ class TypeInfo_Ag : TypeInfo class TypeInfo_Ah : TypeInfo_Ag { - string toString() { return "ubyte[]"; } + override string toString() { return "ubyte[]"; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { char[] s1 = *cast(char[]*)p1; char[] s2 = *cast(char[]*)p2; @@ -112,7 +112,7 @@ class TypeInfo_Ah : TypeInfo_Ag return dstrcmp(s1, s2); } - TypeInfo next() + override TypeInfo next() { return typeid(ubyte); } @@ -122,9 +122,9 @@ class TypeInfo_Ah : TypeInfo_Ag class TypeInfo_Av : TypeInfo_Ah { - string toString() { return "void[]"; } + override string toString() { return "void[]"; } - TypeInfo next() + override TypeInfo next() { return typeid(void); } @@ -134,9 +134,9 @@ class TypeInfo_Av : TypeInfo_Ah class TypeInfo_Ab : TypeInfo_Ah { - string toString() { return "bool[]"; } + override string toString() { return "bool[]"; } - TypeInfo next() + override TypeInfo next() { return typeid(bool); } @@ -146,9 +146,9 @@ class TypeInfo_Ab : TypeInfo_Ah class TypeInfo_Aa : TypeInfo_Ag { - string toString() { return "char[]"; } + override string toString() { return "char[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { char[] s = *cast(char[]*)p; hash_t hash = 0; @@ -197,7 +197,7 @@ else return hash; } - TypeInfo next() + override TypeInfo next() { return typeid(char); } diff --git a/src/compiler/dmd/typeinfo/ti_Aint.d b/src/compiler/dmd/typeinfo/ti_Aint.d index 32b940f..9eecc17 100644 --- a/src/compiler/dmd/typeinfo/ti_Aint.d +++ b/src/compiler/dmd/typeinfo/ti_Aint.d @@ -7,9 +7,9 @@ private import stdc.string; class TypeInfo_Ai : TypeInfo { - string toString() { return "int[]"; } + override string toString() { return "int[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { int[] s = *cast(int[]*)p; auto len = s.length; auto str = s.ptr; @@ -26,7 +26,7 @@ class TypeInfo_Ai : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { int[] s1 = *cast(int[]*)p1; int[] s2 = *cast(int[]*)p2; @@ -35,7 +35,7 @@ class TypeInfo_Ai : TypeInfo memcmp(cast(void *)s1, cast(void *)s2, s1.length * int.sizeof) == 0; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { int[] s1 = *cast(int[]*)p1; int[] s2 = *cast(int[]*)p2; @@ -56,17 +56,17 @@ class TypeInfo_Ai : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (int[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(int); } @@ -87,9 +87,9 @@ unittest class TypeInfo_Ak : TypeInfo_Ai { - string toString() { return "uint[]"; } + override string toString() { return "uint[]"; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { uint[] s1 = *cast(uint[]*)p1; uint[] s2 = *cast(uint[]*)p2; @@ -110,7 +110,7 @@ class TypeInfo_Ak : TypeInfo_Ai return 0; } - TypeInfo next() + override TypeInfo next() { return typeid(uint); } @@ -120,9 +120,9 @@ class TypeInfo_Ak : TypeInfo_Ai class TypeInfo_Aw : TypeInfo_Ak { - string toString() { return "dchar[]"; } + override string toString() { return "dchar[]"; } - TypeInfo next() + override TypeInfo next() { return typeid(dchar); } diff --git a/src/compiler/dmd/typeinfo/ti_Along.d b/src/compiler/dmd/typeinfo/ti_Along.d index 0a3b7f9..2263e92 100644 --- a/src/compiler/dmd/typeinfo/ti_Along.d +++ b/src/compiler/dmd/typeinfo/ti_Along.d @@ -7,9 +7,9 @@ private import stdc.string; class TypeInfo_Al : TypeInfo { - string toString() { return "long[]"; } + override string toString() { return "long[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { long[] s = *cast(long[]*)p; size_t len = s.length; auto str = s.ptr; @@ -26,7 +26,7 @@ class TypeInfo_Al : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { long[] s1 = *cast(long[]*)p1; long[] s2 = *cast(long[]*)p2; @@ -35,7 +35,7 @@ class TypeInfo_Al : TypeInfo memcmp(cast(void *)s1, cast(void *)s2, s1.length * long.sizeof) == 0; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { long[] s1 = *cast(long[]*)p1; long[] s2 = *cast(long[]*)p2; @@ -57,17 +57,17 @@ class TypeInfo_Al : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (long[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(long); } @@ -78,9 +78,9 @@ class TypeInfo_Al : TypeInfo class TypeInfo_Am : TypeInfo_Al { - string toString() { return "ulong[]"; } + override string toString() { return "ulong[]"; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { ulong[] s1 = *cast(ulong[]*)p1; ulong[] s2 = *cast(ulong[]*)p2; @@ -102,7 +102,7 @@ class TypeInfo_Am : TypeInfo_Al return 0; } - TypeInfo next() + override TypeInfo next() { return typeid(ulong); } diff --git a/src/compiler/dmd/typeinfo/ti_Areal.d b/src/compiler/dmd/typeinfo/ti_Areal.d index 93040d9..a5d3279 100644 --- a/src/compiler/dmd/typeinfo/ti_Areal.d +++ b/src/compiler/dmd/typeinfo/ti_Areal.d @@ -29,9 +29,9 @@ private import typeinfo.ti_real; class TypeInfo_Ae : TypeInfo { - string toString() { return "real[]"; } + override string toString() { return "real[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { real[] s = *cast(real[]*)p; size_t len = s.length; auto str = s.ptr; @@ -50,7 +50,7 @@ class TypeInfo_Ae : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { real[] s1 = *cast(real[]*)p1; real[] s2 = *cast(real[]*)p2; @@ -66,7 +66,7 @@ class TypeInfo_Ae : TypeInfo return true; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { real[] s1 = *cast(real[]*)p1; real[] s2 = *cast(real[]*)p2; @@ -87,17 +87,17 @@ class TypeInfo_Ae : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (real[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(real); } @@ -107,9 +107,9 @@ class TypeInfo_Ae : TypeInfo class TypeInfo_Aj : TypeInfo_Ae { - string toString() { return "ireal[]"; } + override string toString() { return "ireal[]"; } - TypeInfo next() + override TypeInfo next() { return typeid(ireal); } diff --git a/src/compiler/dmd/typeinfo/ti_Ashort.d b/src/compiler/dmd/typeinfo/ti_Ashort.d index b5b494d..12c9f56 100644 --- a/src/compiler/dmd/typeinfo/ti_Ashort.d +++ b/src/compiler/dmd/typeinfo/ti_Ashort.d @@ -7,9 +7,9 @@ private import stdc.string; class TypeInfo_As : TypeInfo { - string toString() { return "short[]"; } + override string toString() { return "short[]"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { short[] s = *cast(short[]*)p; size_t len = s.length; short *str = s.ptr; @@ -39,7 +39,7 @@ class TypeInfo_As : TypeInfo return hash; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { short[] s1 = *cast(short[]*)p1; short[] s2 = *cast(short[]*)p2; @@ -48,7 +48,7 @@ class TypeInfo_As : TypeInfo memcmp(cast(void *)s1, cast(void *)s2, s1.length * short.sizeof) == 0; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { short[] s1 = *cast(short[]*)p1; short[] s2 = *cast(short[]*)p2; @@ -69,17 +69,17 @@ class TypeInfo_As : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (short[]).sizeof; } - uint flags() + override uint flags() { return 1; } - TypeInfo next() + override TypeInfo next() { return typeid(short); } @@ -90,9 +90,9 @@ class TypeInfo_As : TypeInfo class TypeInfo_At : TypeInfo_As { - string toString() { return "ushort[]"; } + override string toString() { return "ushort[]"; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { ushort[] s1 = *cast(ushort[]*)p1; ushort[] s2 = *cast(ushort[]*)p2; @@ -113,7 +113,7 @@ class TypeInfo_At : TypeInfo_As return 0; } - TypeInfo next() + override TypeInfo next() { return typeid(ushort); } @@ -123,9 +123,9 @@ class TypeInfo_At : TypeInfo_As class TypeInfo_Au : TypeInfo_At { - string toString() { return "wchar[]"; } + override string toString() { return "wchar[]"; } - TypeInfo next() + override TypeInfo next() { return typeid(wchar); } diff --git a/src/compiler/dmd/typeinfo/ti_C.d b/src/compiler/dmd/typeinfo/ti_C.d index 5311398..011ffb4 100644 --- a/src/compiler/dmd/typeinfo/ti_C.d +++ b/src/compiler/dmd/typeinfo/ti_C.d @@ -27,13 +27,13 @@ module rt.typeinfo.ti_C; class TypeInfo_C : TypeInfo { - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { Object o = *cast(Object*)p; return o ? o.toHash() : 0; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { Object o1 = *cast(Object*)p1; Object o2 = *cast(Object*)p2; @@ -41,7 +41,7 @@ class TypeInfo_C : TypeInfo return o1 == o2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { Object o1 = *cast(Object*)p1; Object o2 = *cast(Object*)p2; @@ -62,12 +62,12 @@ class TypeInfo_C : TypeInfo return c; } - size_t tsize() + override size_t tsize() { return Object.sizeof; } - uint flags() + override uint flags() { return 1; } diff --git a/src/compiler/dmd/typeinfo/ti_byte.d b/src/compiler/dmd/typeinfo/ti_byte.d index ef0c8f2..4ddb469 100644 --- a/src/compiler/dmd/typeinfo/ti_byte.d +++ b/src/compiler/dmd/typeinfo/ti_byte.d @@ -5,29 +5,29 @@ module rt.typeinfo.ti_byte; class TypeInfo_g : TypeInfo { - string toString() { return "byte"; } + override string toString() { return "byte"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(byte *)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(byte *)p1 == *cast(byte *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return *cast(byte *)p1 - *cast(byte *)p2; } - size_t tsize() + override size_t tsize() { return byte.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { byte t; diff --git a/src/compiler/dmd/typeinfo/ti_cdouble.d b/src/compiler/dmd/typeinfo/ti_cdouble.d index 0890360..89fa9f1 100644 --- a/src/compiler/dmd/typeinfo/ti_cdouble.d +++ b/src/compiler/dmd/typeinfo/ti_cdouble.d @@ -5,9 +5,9 @@ module rt.typeinfo.ti_cdouble; class TypeInfo_r : TypeInfo { - string toString() { return "cdouble"; } + override string toString() { return "cdouble"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return (cast(uint *)p)[0] + (cast(uint *)p)[1] + (cast(uint *)p)[2] + (cast(uint *)p)[3]; @@ -34,22 +34,22 @@ class TypeInfo_r : TypeInfo return result; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return _equals(*cast(cdouble *)p1, *cast(cdouble *)p2); } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2); } - size_t tsize() + override size_t tsize() { return cdouble.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { cdouble t; @@ -58,7 +58,7 @@ class TypeInfo_r : TypeInfo *cast(cdouble *)p2 = t; } - void[] init() + override void[] init() { static cdouble r; return (cast(cdouble *)&r)[0 .. 1]; diff --git a/src/compiler/dmd/typeinfo/ti_cfloat.d b/src/compiler/dmd/typeinfo/ti_cfloat.d index 50c7ba8..f07b96a 100644 --- a/src/compiler/dmd/typeinfo/ti_cfloat.d +++ b/src/compiler/dmd/typeinfo/ti_cfloat.d @@ -5,9 +5,9 @@ module rt.typeinfo.ti_cfloat; class TypeInfo_q : TypeInfo { - string toString() { return "cfloat"; } + override string toString() { return "cfloat"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return (cast(uint *)p)[0] + (cast(uint *)p)[1]; } @@ -33,22 +33,22 @@ class TypeInfo_q : TypeInfo return result; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return _equals(*cast(cfloat *)p1, *cast(cfloat *)p2); } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); } - size_t tsize() + override size_t tsize() { return cfloat.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { cfloat t; @@ -57,7 +57,7 @@ class TypeInfo_q : TypeInfo *cast(cfloat *)p2 = t; } - void[] init() + override void[] init() { static cfloat r; return (cast(cfloat *)&r)[0 .. 1]; diff --git a/src/compiler/dmd/typeinfo/ti_char.d b/src/compiler/dmd/typeinfo/ti_char.d index 60e49e2..774bcb2 100644 --- a/src/compiler/dmd/typeinfo/ti_char.d +++ b/src/compiler/dmd/typeinfo/ti_char.d @@ -3,29 +3,29 @@ module rt.typeinfo.ti_char; class TypeInfo_a : TypeInfo { - string toString() { return "char"; } + override string toString() { return "char"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(char *)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(char *)p1 == *cast(char *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return *cast(char *)p1 - *cast(char *)p2; } - size_t tsize() + override size_t tsize() { return char.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { char t; @@ -34,7 +34,7 @@ class TypeInfo_a : TypeInfo *cast(char *)p2 = t; } - void[] init() + override void[] init() { static char c; return (cast(char *)&c)[0 .. 1]; diff --git a/src/compiler/dmd/typeinfo/ti_creal.d b/src/compiler/dmd/typeinfo/ti_creal.d index 8221dad..1b39684 100644 --- a/src/compiler/dmd/typeinfo/ti_creal.d +++ b/src/compiler/dmd/typeinfo/ti_creal.d @@ -5,9 +5,9 @@ module rt.typeinfo.ti_creal; class TypeInfo_c : TypeInfo { - string toString() { return "creal"; } + override string toString() { return "creal"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return (cast(uint *)p)[0] + (cast(uint *)p)[1] + (cast(uint *)p)[2] + (cast(uint *)p)[3] + @@ -35,22 +35,22 @@ class TypeInfo_c : TypeInfo return result; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return _equals(*cast(creal *)p1, *cast(creal *)p2); } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return _compare(*cast(creal *)p1, *cast(creal *)p2); } - size_t tsize() + override size_t tsize() { return creal.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { creal t; @@ -59,7 +59,7 @@ class TypeInfo_c : TypeInfo *cast(creal *)p2 = t; } - void[] init() + override void[] init() { static creal r; return (cast(creal *)&r)[0 .. 1]; diff --git a/src/compiler/dmd/typeinfo/ti_dchar.d b/src/compiler/dmd/typeinfo/ti_dchar.d index fda33bf..b028a2e 100644 --- a/src/compiler/dmd/typeinfo/ti_dchar.d +++ b/src/compiler/dmd/typeinfo/ti_dchar.d @@ -5,29 +5,29 @@ module rt.typeinfo.ti_dchar; class TypeInfo_w : TypeInfo { - string toString() { return "dchar"; } + override string toString() { return "dchar"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(dchar *)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(dchar *)p1 == *cast(dchar *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return *cast(dchar *)p1 - *cast(dchar *)p2; } - size_t tsize() + override size_t tsize() { return dchar.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { dchar t; @@ -36,7 +36,7 @@ class TypeInfo_w : TypeInfo *cast(dchar *)p2 = t; } - void[] init() + override void[] init() { static dchar c; return (cast(dchar *)&c)[0 .. 1]; diff --git a/src/compiler/dmd/typeinfo/ti_delegate.d b/src/compiler/dmd/typeinfo/ti_delegate.d index c4d41df..e1c8972 100644 --- a/src/compiler/dmd/typeinfo/ti_delegate.d +++ b/src/compiler/dmd/typeinfo/ti_delegate.d @@ -7,23 +7,23 @@ alias void delegate(int) dg; class TypeInfo_D : TypeInfo { - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { long l = *cast(long *)p; return cast(uint)(l + (l >> 32)); } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(dg *)p1 == *cast(dg *)p2; } - size_t tsize() + override size_t tsize() { return dg.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { dg t; @@ -32,7 +32,7 @@ class TypeInfo_D : TypeInfo *cast(dg *)p2 = t; } - uint flags() + override uint flags() { return 1; } diff --git a/src/compiler/dmd/typeinfo/ti_double.d b/src/compiler/dmd/typeinfo/ti_double.d index db79d37..d62f4f7 100644 --- a/src/compiler/dmd/typeinfo/ti_double.d +++ b/src/compiler/dmd/typeinfo/ti_double.d @@ -5,9 +5,9 @@ module rt.typeinfo.ti_double; class TypeInfo_d : TypeInfo { - string toString() { return "double"; } + override string toString() { return "double"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return (cast(uint *)p)[0] + (cast(uint *)p)[1]; } @@ -32,22 +32,22 @@ class TypeInfo_d : TypeInfo return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1); } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return _equals(*cast(double *)p1, *cast(double *)p2); } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return _compare(*cast(double *)p1, *cast(double *)p2); } - size_t tsize() + override size_t tsize() { return double.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { double t; @@ -56,7 +56,7 @@ class TypeInfo_d : TypeInfo *cast(double *)p2 = t; } - void[] init() + override void[] init() { static double r; return (cast(double *)&r)[0 .. 1]; diff --git a/src/compiler/dmd/typeinfo/ti_float.d b/src/compiler/dmd/typeinfo/ti_float.d index 6b0688c..7d6d719 100644 --- a/src/compiler/dmd/typeinfo/ti_float.d +++ b/src/compiler/dmd/typeinfo/ti_float.d @@ -5,9 +5,9 @@ module rt.typeinfo.ti_float; class TypeInfo_f : TypeInfo { - string toString() { return "float"; } + override string toString() { return "float"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(uint *)p; } @@ -32,22 +32,22 @@ class TypeInfo_f : TypeInfo return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1); } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return _equals(*cast(float *)p1, *cast(float *)p2); } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return _compare(*cast(float *)p1, *cast(float *)p2); } - size_t tsize() + override size_t tsize() { return float.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { float t; @@ -56,7 +56,7 @@ class TypeInfo_f : TypeInfo *cast(float *)p2 = t; } - void[] init() + override void[] init() { static float r; return (cast(float *)&r)[0 .. 1]; diff --git a/src/compiler/dmd/typeinfo/ti_idouble.d b/src/compiler/dmd/typeinfo/ti_idouble.d index fbb1a02..45ad7d7 100644 --- a/src/compiler/dmd/typeinfo/ti_idouble.d +++ b/src/compiler/dmd/typeinfo/ti_idouble.d @@ -7,5 +7,5 @@ private import typeinfo.ti_double; class TypeInfo_p : TypeInfo_d { - string toString() { return "idouble"; } + override string toString() { return "idouble"; } } diff --git a/src/compiler/dmd/typeinfo/ti_ifloat.d b/src/compiler/dmd/typeinfo/ti_ifloat.d index 6b63dc6..d19646e 100644 --- a/src/compiler/dmd/typeinfo/ti_ifloat.d +++ b/src/compiler/dmd/typeinfo/ti_ifloat.d @@ -7,5 +7,5 @@ private import typeinfo.ti_float; class TypeInfo_o : TypeInfo_f { - string toString() { return "ifloat"; } + override string toString() { return "ifloat"; } } diff --git a/src/compiler/dmd/typeinfo/ti_int.d b/src/compiler/dmd/typeinfo/ti_int.d index b2d0cf8..31fb352 100644 --- a/src/compiler/dmd/typeinfo/ti_int.d +++ b/src/compiler/dmd/typeinfo/ti_int.d @@ -5,19 +5,19 @@ module rt.typeinfo.ti_int; class TypeInfo_i : TypeInfo { - string toString() { return "int"; } + override string toString() { return "int"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(uint *)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(uint *)p1 == *cast(uint *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { if (*cast(int*) p1 < *cast(int*) p2) return -1; @@ -26,12 +26,12 @@ class TypeInfo_i : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return int.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { int t; diff --git a/src/compiler/dmd/typeinfo/ti_ireal.d b/src/compiler/dmd/typeinfo/ti_ireal.d index edf6815..242d3c1 100644 --- a/src/compiler/dmd/typeinfo/ti_ireal.d +++ b/src/compiler/dmd/typeinfo/ti_ireal.d @@ -7,5 +7,5 @@ private import typeinfo.ti_real; class TypeInfo_j : TypeInfo_e { - string toString() { return "ireal"; } + override string toString() { return "ireal"; } } diff --git a/src/compiler/dmd/typeinfo/ti_long.d b/src/compiler/dmd/typeinfo/ti_long.d index ed64dae..e4912b2 100644 --- a/src/compiler/dmd/typeinfo/ti_long.d +++ b/src/compiler/dmd/typeinfo/ti_long.d @@ -5,19 +5,19 @@ module rt.typeinfo.ti_long; class TypeInfo_l : TypeInfo { - string toString() { return "long"; } + override string toString() { return "long"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(uint *)p + (cast(uint *)p)[1]; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(long *)p1 == *cast(long *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { if (*cast(long *)p1 < *cast(long *)p2) return -1; @@ -26,12 +26,12 @@ class TypeInfo_l : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return long.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { long t; diff --git a/src/compiler/dmd/typeinfo/ti_ptr.d b/src/compiler/dmd/typeinfo/ti_ptr.d index c285a64..31568ef 100644 --- a/src/compiler/dmd/typeinfo/ti_ptr.d +++ b/src/compiler/dmd/typeinfo/ti_ptr.d @@ -5,17 +5,17 @@ module rt.typeinfo.ti_ptr; class TypeInfo_P : TypeInfo { - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return cast(uint)*cast(void* *)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(void* *)p1 == *cast(void* *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { auto c = *cast(void* *)p1 - *cast(void* *)p2; if (c < 0) @@ -25,12 +25,12 @@ class TypeInfo_P : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return (void*).sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { void* t; @@ -39,7 +39,7 @@ class TypeInfo_P : TypeInfo *cast(void* *)p2 = t; } - uint flags() + override uint flags() { return 1; } diff --git a/src/compiler/dmd/typeinfo/ti_real.d b/src/compiler/dmd/typeinfo/ti_real.d index b678d2c..a117a50 100644 --- a/src/compiler/dmd/typeinfo/ti_real.d +++ b/src/compiler/dmd/typeinfo/ti_real.d @@ -5,9 +5,9 @@ module rt.typeinfo.ti_real; class TypeInfo_e : TypeInfo { - string toString() { return "real"; } + override string toString() { return "real"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return (cast(uint *)p)[0] + (cast(uint *)p)[1] + (cast(ushort *)p)[4]; } @@ -32,22 +32,22 @@ class TypeInfo_e : TypeInfo return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1); } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return _equals(*cast(real *)p1, *cast(real *)p2); } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return _compare(*cast(real *)p1, *cast(real *)p2); } - size_t tsize() + override size_t tsize() { return real.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { real t; @@ -56,7 +56,7 @@ class TypeInfo_e : TypeInfo *cast(real *)p2 = t; } - void[] init() + override void[] init() { static real r; return (cast(real *)&r)[0 .. 1]; diff --git a/src/compiler/dmd/typeinfo/ti_short.d b/src/compiler/dmd/typeinfo/ti_short.d index fa6a409..7c14ede 100644 --- a/src/compiler/dmd/typeinfo/ti_short.d +++ b/src/compiler/dmd/typeinfo/ti_short.d @@ -5,29 +5,29 @@ module rt.typeinfo.ti_short; class TypeInfo_s : TypeInfo { - string toString() { return "short"; } + override string toString() { return "short"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(short *)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(short *)p1 == *cast(short *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return *cast(short *)p1 - *cast(short *)p2; } - size_t tsize() + override size_t tsize() { return short.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { short t; diff --git a/src/compiler/dmd/typeinfo/ti_ubyte.d b/src/compiler/dmd/typeinfo/ti_ubyte.d index a555e9e..7131b44 100644 --- a/src/compiler/dmd/typeinfo/ti_ubyte.d +++ b/src/compiler/dmd/typeinfo/ti_ubyte.d @@ -5,29 +5,29 @@ module rt.typeinfo.ti_ubyte; class TypeInfo_h : TypeInfo { - string toString() { return "ubyte"; } + override string toString() { return "ubyte"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(ubyte *)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(ubyte *)p1 == *cast(ubyte *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return *cast(ubyte *)p1 - *cast(ubyte *)p2; } - size_t tsize() + override size_t tsize() { return ubyte.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { ubyte t; @@ -39,5 +39,5 @@ class TypeInfo_h : TypeInfo class TypeInfo_b : TypeInfo_h { - string toString() { return "bool"; } + override string toString() { return "bool"; } } diff --git a/src/compiler/dmd/typeinfo/ti_uint.d b/src/compiler/dmd/typeinfo/ti_uint.d index e3cf4c6..a4594d3 100644 --- a/src/compiler/dmd/typeinfo/ti_uint.d +++ b/src/compiler/dmd/typeinfo/ti_uint.d @@ -5,19 +5,19 @@ module rt.typeinfo.ti_uint; class TypeInfo_k : TypeInfo { - string toString() { return "uint"; } + override string toString() { return "uint"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(uint *)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(uint *)p1 == *cast(uint *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { if (*cast(uint*) p1 < *cast(uint*) p2) return -1; @@ -26,12 +26,12 @@ class TypeInfo_k : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return uint.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { int t; diff --git a/src/compiler/dmd/typeinfo/ti_ulong.d b/src/compiler/dmd/typeinfo/ti_ulong.d index e4ec94d..d6f54d4 100644 --- a/src/compiler/dmd/typeinfo/ti_ulong.d +++ b/src/compiler/dmd/typeinfo/ti_ulong.d @@ -5,19 +5,19 @@ module rt.typeinfo.ti_ulong; class TypeInfo_m : TypeInfo { - string toString() { return "ulong"; } + override string toString() { return "ulong"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(uint *)p + (cast(uint *)p)[1]; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(ulong *)p1 == *cast(ulong *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { if (*cast(ulong *)p1 < *cast(ulong *)p2) return -1; @@ -26,12 +26,12 @@ class TypeInfo_m : TypeInfo return 0; } - size_t tsize() + override size_t tsize() { return ulong.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { ulong t; diff --git a/src/compiler/dmd/typeinfo/ti_ushort.d b/src/compiler/dmd/typeinfo/ti_ushort.d index e5702a2..353c56c 100644 --- a/src/compiler/dmd/typeinfo/ti_ushort.d +++ b/src/compiler/dmd/typeinfo/ti_ushort.d @@ -5,29 +5,29 @@ module rt.typeinfo.ti_ushort; class TypeInfo_t : TypeInfo { - string toString() { return "ushort"; } + override string toString() { return "ushort"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(ushort *)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(ushort *)p1 == *cast(ushort *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return *cast(ushort *)p1 - *cast(ushort *)p2; } - size_t tsize() + override size_t tsize() { return ushort.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { ushort t; diff --git a/src/compiler/dmd/typeinfo/ti_void.d b/src/compiler/dmd/typeinfo/ti_void.d index 495aa1e..d0aa2da 100644 --- a/src/compiler/dmd/typeinfo/ti_void.d +++ b/src/compiler/dmd/typeinfo/ti_void.d @@ -5,29 +5,29 @@ module rt.typeinfo.ti_void; class TypeInfo_v : TypeInfo { - string toString() { return "void"; } + override string toString() { return "void"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { assert(0); } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(byte *)p1 == *cast(byte *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return *cast(byte *)p1 - *cast(byte *)p2; } - size_t tsize() + override size_t tsize() { return void.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { byte t; @@ -36,7 +36,7 @@ class TypeInfo_v : TypeInfo *cast(byte *)p2 = t; } - uint flags() + override uint flags() { return 1; } diff --git a/src/compiler/dmd/typeinfo/ti_wchar.d b/src/compiler/dmd/typeinfo/ti_wchar.d index 29c7963..875f8ca 100644 --- a/src/compiler/dmd/typeinfo/ti_wchar.d +++ b/src/compiler/dmd/typeinfo/ti_wchar.d @@ -4,29 +4,29 @@ module rt.typeinfo.ti_wchar; class TypeInfo_u : TypeInfo { - string toString() { return "wchar"; } + override string toString() { return "wchar"; } - hash_t getHash(in void* p) + override hash_t getHash(in void* p) { return *cast(wchar *)p; } - equals_t equals(in void* p1, in void* p2) + override equals_t equals(in void* p1, in void* p2) { return *cast(wchar *)p1 == *cast(wchar *)p2; } - int compare(in void* p1, in void* p2) + override int compare(in void* p1, in void* p2) { return *cast(wchar *)p1 - *cast(wchar *)p2; } - size_t tsize() + override size_t tsize() { return wchar.sizeof; } - void swap(void *p1, void *p2) + override void swap(void *p1, void *p2) { wchar t; @@ -35,7 +35,7 @@ class TypeInfo_u : TypeInfo *cast(wchar *)p2 = t; } - void[] init() + override void[] init() { static wchar c; return (cast(wchar *)&c)[0 .. 1]; diff --git a/src/compiler/dmd/util/cpuid.d b/src/compiler/dmd/util/cpuid.d index b4d9cba..cbc5a3e 100644 --- a/src/compiler/dmd/util/cpuid.d +++ b/src/compiler/dmd/util/cpuid.d @@ -47,7 +47,7 @@ version(D_InlineAsm_X86) /// Returns vendor string char[] vendor() {return vendorStr;} /// Returns processor string - char[] processor() {return processorStr;} + string processor() {return processorStr;} /// Is MMX supported? bool mmx() {return (flags&MMX_BIT)!=0;} @@ -186,8 +186,8 @@ private: uint flags, misc, exflags, apic, signature; uint _stepping, _model, _family; - char[12] vendorStr = ""; - char[] processorStr = ""; + char[12] vendorStr = 0; + string processorStr = ""; uint maxThreads=1; uint maxCores=1; @@ -250,7 +250,7 @@ private: return; // seems many intel processors prepend whitespace - processorStr = strip(toString(dst)).dup; + processorStr = cast(string)strip(toString(dst)).dup; } private void getFeatureFlags() @@ -421,9 +421,14 @@ private: return stripr(stripl(s)); } - string toString(char *s) + char[] toString(char* s) { - return s ? s[0 .. strlen(s)] : cast(char[])null; + return s ? s[0 .. strlen(s)] : null; + } + + string toString(invariant(char)* s) + { + return s ? s[0 .. strlen(s)] : null; } } } diff --git a/src/compiler/dmd/util/utf.d b/src/compiler/dmd/util/utf.d index 84ace7c..50d4a51 100644 --- a/src/compiler/dmd/util/utf.d +++ b/src/compiler/dmd/util/utf.d @@ -1,4 +1,4 @@ -// utf.d +// Written in the D programming language /* * Copyright (C) 2003-2004 by Digital Mars, www.digitalmars.com @@ -22,16 +22,38 @@ * distribution. */ -// Description of UTF-8 at: -// http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 -// http://anubis.dkuug.dk/JTC1/SC2/WG2/docs/n1335 - +/******************************************** + * Encode and decode UTF-8, UTF-16 and UTF-32 strings. + * + * For Win32 systems, the C wchar_t type is UTF-16 and corresponds to the D + * wchar type. + * For linux systems, the C wchar_t type is UTF-32 and corresponds to + * the D utf.dchar type. + * + * UTF character support is restricted to (\u0000 <= character <= \U0010FFFF). + * + * See_Also: + * $(LINK2 http://en.wikipedia.org/wiki/Unicode, Wikipedia)
+ * $(LINK http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8)
+ * $(LINK http://anubis.dkuug.dk/JTC1/SC2/WG2/docs/n1335) + * Macros: + * WIKI = Phobos/StdUtf + */ module rt.util.utf; -extern (C) void onUnicodeError( char[] msg, size_t idx ); +extern (C) void onUnicodeError( string msg, size_t idx ); +/******************************* + * Test if c is a valid UTF-32 character. + * + * \uFFFE and \uFFFF are considered valid by this function, + * as they are permitted for internal use by an application, + * but they are not allowed for interchange by the Unicode standard. + * + * Returns: true if it is, false if not. + */ bool isValidDchar(dchar c) { @@ -53,14 +75,10 @@ unittest } -/* This array gives the length of a UTF-8 sequence indexed by the value - * of the leading byte. An FF represents an illegal starting value of - * a UTF-8 sequence. - * FF is used instead of 0 to avoid having loops hang. - */ -ubyte[256] UTF8stride = +auto UTF8stride = [ + cast(ubyte) 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, @@ -79,77 +97,89 @@ ubyte[256] UTF8stride = 4,4,4,4,4,4,4,4,5,5,5,5,6,6,0xFF,0xFF, ]; -uint stride(char[] s, size_t i) +/** + * stride() returns the length of a UTF-8 sequence starting at index i + * in string s. + * Returns: + * The number of bytes in the UTF-8 sequence or + * 0xFF meaning s[i] is not the start of of UTF-8 sequence. + */ +uint stride(in char[] s, size_t i) { return UTF8stride[s[i]]; } -uint stride(wchar[] s, size_t i) +/** + * stride() returns the length of a UTF-16 sequence starting at index i + * in string s. + */ +uint stride(in wchar[] s, size_t i) { uint u = s[i]; return 1 + (u >= 0xD800 && u <= 0xDBFF); } -uint stride(dchar[] s, size_t i) +/** + * stride() returns the length of a UTF-32 sequence starting at index i + * in string s. + * Returns: The return value will always be 1. + */ +uint stride(in dchar[] s, size_t i) { return 1; } /******************************************* - * Given an index into an array of char's, - * and assuming that index is at the start of a UTF character, - * determine the number of UCS characters up to that index. + * Given an index i into an array of characters s[], + * and assuming that index i is at the start of a UTF character, + * determine the number of UCS characters up to that index i. */ -size_t toUCSindex(char[] s, size_t i) +size_t toUCSindex(in char[] s, size_t i) { size_t n; size_t j; - size_t stride; - for (j = 0; j < i; j += stride) + for (j = 0; j < i; ) { - stride = UTF8stride[s[j]]; - if (stride == 0xFF) - goto Lerr; + j += stride(s, j); n++; } if (j > i) { - Lerr: - onUnicodeError("invalid UTF-8 sequence", j); + onUnicodeError("invalid UTF-8 sequence", j); } return n; } -size_t toUCSindex(wchar[] s, size_t i) +/** ditto */ +size_t toUCSindex(in wchar[] s, size_t i) { size_t n; size_t j; for (j = 0; j < i; ) - { uint u = s[j]; - - j += 1 + (u >= 0xD800 && u <= 0xDBFF); + { + j += stride(s, j); n++; } if (j > i) { - Lerr: - onUnicodeError("invalid UTF-16 sequence", j); + onUnicodeError("invalid UTF-16 sequence", j); } return n; } -size_t toUCSindex(dchar[] s, size_t i) +/** ditto */ +size_t toUCSindex(in dchar[] s, size_t i) { return i; } /****************************************** - * Given a UCS index into an array of characters, return the UTF index. + * Given a UCS index n into an array of characters s[], return the UTF index. */ -size_t toUTFindex(char[] s, size_t n) +size_t toUTFindex(in char[] s, size_t n) { size_t i; @@ -163,7 +193,8 @@ size_t toUTFindex(char[] s, size_t n) return i; } -size_t toUTFindex(wchar[] s, size_t n) +/** ditto */ +size_t toUTFindex(in wchar[] s, size_t n) { size_t i; @@ -175,14 +206,20 @@ size_t toUTFindex(wchar[] s, size_t n) return i; } -size_t toUTFindex(dchar[] s, size_t n) +/** ditto */ +size_t toUTFindex(in dchar[] s, size_t n) { return n; } /* =================== Decode ======================= */ -dchar decode(char[] s, inout size_t idx) +/*************** + * Decodes and returns character starting at s[idx]. idx is advanced past the + * decoded character. If the character is not well formed, a UtfException is + * thrown and idx remains unchanged. + */ +dchar decode(in char[] s, inout size_t idx) in { assert(idx >= 0 && idx < s.length); @@ -275,7 +312,7 @@ unittest debug(utf) printf("utf.decode.unittest\n"); - static char[] s1 = "abcd"; + static s1 = "abcd"c; i = 0; c = decode(s1, i); assert(c == cast(dchar)'a'); @@ -284,20 +321,20 @@ unittest assert(c == cast(dchar)'b'); assert(i == 2); - static char[] s2 = "\xC2\xA9"; + static s2 = "\xC2\xA9"c; i = 0; c = decode(s2, i); assert(c == cast(dchar)'\u00A9'); assert(i == 2); - static char[] s3 = "\xE2\x89\xA0"; + static s3 = "\xE2\x89\xA0"c; i = 0; c = decode(s3, i); assert(c == cast(dchar)'\u2260'); assert(i == 3); - static char[][] s4 = - [ "\xE2\x89", // too short + static s4 = + [ "\xE2\x89"c, // too short "\xC0\x8A", "\xE0\x80\x8A", "\xF0\x80\x80\x8A", @@ -321,9 +358,9 @@ unittest } } -/********************************************************/ +/** ditto */ -dchar decode(wchar[] s, inout size_t idx) +dchar decode(in wchar[] s, inout size_t idx) in { assert(idx >= 0 && idx < s.length); @@ -334,7 +371,7 @@ dchar decode(wchar[] s, inout size_t idx) } body { - char[] msg; + string msg; dchar V; size_t i = idx; uint u = s[i]; @@ -379,9 +416,9 @@ dchar decode(wchar[] s, inout size_t idx) return cast(dchar)u; // dummy return } -/********************************************************/ +/** ditto */ -dchar decode(dchar[] s, inout size_t idx) +dchar decode(in dchar[] s, inout size_t idx) in { assert(idx >= 0 && idx < s.length); @@ -404,6 +441,9 @@ dchar decode(dchar[] s, inout size_t idx) /* =================== Encode ======================= */ +/******************************* + * Encodes character c and appends it to array s[]. + */ void encode(inout char[] s, dchar c) in { @@ -456,7 +496,7 @@ unittest { debug(utf) printf("utf.encode.unittest\n"); - char[] s = "abcd"; + char[] s = "abcd".dup; encode(s, cast(dchar)'a'); assert(s.length == 5); assert(s == "abcda"); @@ -471,7 +511,7 @@ unittest assert(s == "abcda\xC2\xA9\xE2\x89\xA0"); } -/********************************************************/ +/** ditto */ void encode(inout wchar[] s, dchar c) in @@ -497,6 +537,7 @@ void encode(inout wchar[] s, dchar c) s = r; } +/** ditto */ void encode(inout dchar[] s, dchar c) in { @@ -507,36 +548,46 @@ void encode(inout dchar[] s, dchar c) s ~= c; } -/* =================== Validation ======================= */ +/** +Returns the code length of $(D c) in the encoding using $(D C) as a +code point. The code is returned in character count, not in bytes. + */ -void validate(char[] s) +ubyte codeLength(C)(dchar c) { - size_t len = s.length; - size_t i; - for (i = 0; i < len; ) + static if (C.sizeof == 1) { - decode(s, i); - } + return + c <= 0x7F ? 1 + : c <= 0x7FF ? 2 + : c <= 0xFFFF ? 3 + : c <= 0x10FFFF ? 4 + : (assert(false), 6); } -void validate(wchar[] s) + else static if (C.sizeof == 2) { - size_t len = s.length; - size_t i; - - for (i = 0; i < len; ) + return c <= 0xFFFF ? 1 : 2; + } + else { - decode(s, i); + static assert(C.sizeof == 4); + return 1; } } -void validate(dchar[] s) -{ - size_t len = s.length; - size_t i; +/* =================== Validation ======================= */ - for (i = 0; i < len; ) +/*********************************** +Checks to see if string is well formed or not. $(D S) can be an array + of $(D char), $(D wchar), or $(D dchar). Throws a $(D UtfException) + if it is not. Use to check all untrusted input for correctness. + */ +void validate(S)(in S s) +{ + invariant len = s.length; + for (size_t i = 0; i < len; ) { decode(s, i); } @@ -580,7 +631,10 @@ char[] toUTF8(char[4] buf, dchar c) assert(0); } -char[] toUTF8(char[] s) +/******************* + * Encodes string s into UTF-8 and returns the encoded string. + */ +string toUTF8(string s) in { validate(s); @@ -590,7 +644,8 @@ char[] toUTF8(char[] s) return s; } -char[] toUTF8(wchar[] s) +/** ditto */ +string toUTF8(in wchar[] s) { char[] r; size_t i; @@ -613,10 +668,11 @@ char[] toUTF8(wchar[] s) break; } } - return r; + return cast(string)r; } -char[] toUTF8(dchar[] s) +/** ditto */ +string toUTF8(in dchar[] s) { char[] r; size_t i; @@ -639,7 +695,7 @@ char[] toUTF8(dchar[] s) break; } } - return r; + return cast(string)r; } /* =================== Conversion to UTF16 ======================= */ @@ -664,7 +720,12 @@ wchar[] toUTF16(wchar[2] buf, dchar c) } } -wchar[] toUTF16(char[] s) +/**************** + * Encodes string s into UTF-16 and returns the encoded string. + * toUTF16z() is suitable for calling the 'W' functions in the Win32 API that take + * an LPWSTR or LPCWSTR argument. + */ +wstring toUTF16(in char[] s) { wchar[] r; size_t slen = s.length; @@ -685,10 +746,12 @@ wchar[] toUTF16(char[] s) encode(r, c); } } - return r; + return cast(wstring)r; } -wchar* toUTF16z(char[] s) +alias const(wchar)* wptr; +/** ditto */ +wptr toUTF16z(in char[] s) { wchar[] r; size_t slen = s.length; @@ -713,7 +776,8 @@ wchar* toUTF16z(char[] s) return r.ptr; } -wchar[] toUTF16(wchar[] s) +/** ditto */ +wstring toUTF16(wstring s) in { validate(s); @@ -723,7 +787,8 @@ wchar[] toUTF16(wchar[] s) return s; } -wchar[] toUTF16(dchar[] s) +/** ditto */ +wstring toUTF16(in dchar[] s) { wchar[] r; size_t slen = s.length; @@ -734,12 +799,15 @@ wchar[] toUTF16(dchar[] s) { encode(r, s[i]); } - return r; + return cast(wstring)r; } /* =================== Conversion to UTF32 ======================= */ -dchar[] toUTF32(char[] s) +/***** + * Encodes string s into UTF-32 and returns the encoded string. + */ +dstring toUTF32(in char[] s) { dchar[] r; size_t slen = s.length; @@ -755,10 +823,11 @@ dchar[] toUTF32(char[] s) i++; // c is ascii, no need for decode r[j++] = c; } - return r[0 .. j]; + return cast(dstring)r[0 .. j]; } -dchar[] toUTF32(wchar[] s) +/** ditto */ +dstring toUTF32(in wchar[] s) { dchar[] r; size_t slen = s.length; @@ -774,10 +843,11 @@ dchar[] toUTF32(wchar[] s) i++; // c is ascii, no need for decode r[j++] = c; } - return r[0 .. j]; + return cast(dstring)r[0 .. j]; } -dchar[] toUTF32(dchar[] s) +/** ditto */ +dstring toUTF32(dstring s) in { validate(s); @@ -793,14 +863,10 @@ unittest { debug(utf) printf("utf.toUTF.unittest\n"); - char[] c; - wchar[] w; - dchar[] d; - - c = "hello"; - w = toUTF16(c); + auto c = "hello"c; + auto w = toUTF16(c); assert(w == "hello"); - d = toUTF32(c); + auto d = toUTF32(c); assert(d == "hello"); c = toUTF8(w); @@ -834,7 +900,7 @@ unittest c = "he\U0010AAAAllo"; w = toUTF16(c); //foreach (wchar c; w) printf("c = x%x\n", c); - //foreach (wchar c; cast(wchar[])"he\U0010AAAAllo") printf("c = x%x\n", c); + //foreach (wchar c; cast(wstring)"he\U0010AAAAllo") printf("c = x%x\n", c); assert(w == "he\U0010AAAAllo"); d = toUTF32(c); assert(d == "he\U0010AAAAllo"); diff --git a/src/core/exception.d b/src/core/exception.d index 24a5bdc..1dd603d 100644 --- a/src/core/exception.d +++ b/src/core/exception.d @@ -11,7 +11,7 @@ module exception; private { - alias void function( char[] file, size_t line, char[] msg = null ) assertHandlerType; + alias void function( string file, size_t line, string msg = null ) assertHandlerType; assertHandlerType assertHandler = null; } @@ -22,7 +22,7 @@ private */ class ArrayBoundsException : Exception { - this( char[] file, size_t line ) + this( string file, size_t line ) { super( "Array index out of bounds", file, line ); } @@ -34,12 +34,12 @@ class ArrayBoundsException : Exception */ class AssertException : Exception { - this( char[] file, size_t line ) + this( string file, size_t line ) { super( "Assertion failure", file, line ); } - this( char[] msg, char[] file, size_t line ) + this( string msg, string file, size_t line ) { super( msg, file, line ); } @@ -59,7 +59,7 @@ class FinalizeException : Exception info = c; } - string toString() + override string toString() { return "An exception was thrown while finalizing an instance of class " ~ info.name; } @@ -71,12 +71,12 @@ class FinalizeException : Exception */ class OutOfMemoryException : Exception { - this( char[] file, size_t line ) + this( string file, size_t line ) { super( "Memory allocation failed", file, line ); } - string toString() + override string toString() { return msg ? super.toString() : "Memory allocation failed"; } @@ -88,7 +88,7 @@ class OutOfMemoryException : Exception */ class SwitchException : Exception { - this( char[] file, size_t line ) + this( string file, size_t line ) { super( "No appropriate switch clause found", file, line ); } @@ -102,7 +102,7 @@ class UnicodeException : Exception { size_t idx; - this( char[] msg, size_t idx ) + this( string msg, size_t idx ) { super( msg ); this.idx = idx; @@ -141,7 +141,7 @@ void setAssertHandler( assertHandlerType h ) * file = The name of the file that signaled this error. * line = The line number on which this error occurred. */ -extern (C) void onAssertError( char[] file, size_t line ) +extern (C) void onAssertError( string file, size_t line ) { if( assertHandler is null ) throw new AssertException( file, line ); @@ -159,7 +159,7 @@ extern (C) void onAssertError( char[] file, size_t line ) * line = The line number on which this error occurred. * msg = An error message supplied by the user. */ -extern (C) void onAssertErrorMsg( char[] file, size_t line, char[] msg ) +extern (C) void onAssertErrorMsg( string file, size_t line, string msg ) { if( assertHandler is null ) throw new AssertException( msg, file, line ); @@ -183,7 +183,7 @@ extern (C) void onAssertErrorMsg( char[] file, size_t line, char[] msg ) * Throws: * ArrayBoundsException. */ -extern (C) void onArrayBoundsError( char[] file, size_t line ) +extern (C) void onArrayBoundsError( string file, size_t line ) { throw new ArrayBoundsException( file, line ); } @@ -229,7 +229,7 @@ extern (C) void onOutOfMemoryError() * Throws: * SwitchException. */ -extern (C) void onSwitchError( char[] file, size_t line ) +extern (C) void onSwitchError( string file, size_t line ) { throw new SwitchException( file, line ); } @@ -245,7 +245,7 @@ extern (C) void onSwitchError( char[] file, size_t line ) * Throws: * UnicodeException. */ -extern (C) void onUnicodeError( char[] msg, size_t idx ) +extern (C) void onUnicodeError( string msg, size_t idx ) { throw new UnicodeException( msg, idx ); } diff --git a/src/core/posix.mak b/src/core/posix.mak index 9e7c82d..2571e8c 100644 --- a/src/core/posix.mak +++ b/src/core/posix.mak @@ -112,6 +112,11 @@ core.doc : $(ALL_DOCS) bitmanip.o : bitmanip.d $(DC) -c $(DFLAGS) bitmanip.d -of$@ +### thread + +thread.o : thread.d + $(DC) -c $(DFLAGS) -d -Hf$*.di thread.d -of$@ + ###################################################### clean : diff --git a/src/core/thread.d b/src/core/thread.d index 1a912d0..846f249 100644 --- a/src/core/thread.d +++ b/src/core/thread.d @@ -22,7 +22,7 @@ version = StackGrowsDown; */ class ThreadException : Exception { - this( char[] msg ) + this( string msg ) { super( msg ); } @@ -34,7 +34,7 @@ class ThreadException : Exception */ class FiberException : Exception { - this( char[] msg ) + this( string msg ) { super( msg ); } diff --git a/src/core/win32.mak b/src/core/win32.mak index 32de084..1c0eece 100644 --- a/src/core/win32.mak +++ b/src/core/win32.mak @@ -108,6 +108,11 @@ core.doc : $(ALL_DOCS) bitmanip.obj : bitmanip.d $(DC) -c $(DFLAGS) bitmanip.d -of$@ +### thread + +thread.obj : thread.d + $(DC) -c $(DFLAGS) -d -Hf$*.di thread.d -of$@ + ###################################################### clean :