Fix Any.toString().

This commit is contained in:
Nikolay Igotti
2017-02-01 18:15:11 +03:00
parent 6192dc254a
commit bb43b6ab09
2 changed files with 16 additions and 13 deletions
-5
View File
@@ -22,11 +22,6 @@ KInt Kotlin_Any_hashCode(KConstRef thiz) {
return reinterpret_cast<uintptr_t>(thiz); return reinterpret_cast<uintptr_t>(thiz);
} }
OBJ_GETTER(Kotlin_Any_toString, KConstRef thiz) {
// TODO: make it more sensible, such as address and type info.
return nullptr;
}
// io/Console.kt // io/Console.kt
void Kotlin_io_Console_print(KString message) { void Kotlin_io_Console_print(KString message) {
RuntimeAssert(message->type_info() == theStringTypeInfo, "Must use a string"); RuntimeAssert(message->type_info() == theStringTypeInfo, "Must use a string");
+8
View File
@@ -24,6 +24,14 @@ OBJ_GETTER(makeString, const char* cstring) {
extern "C" { extern "C" {
OBJ_GETTER(Kotlin_Any_toString, KConstRef thiz) {
char cstring[80];
snprintf(cstring, sizeof(cstring), "%s %p type %p",
IsArray(thiz) ? "array" : "object",
thiz, thiz->type_info_);
RETURN_RESULT_OF(makeString, cstring);
}
OBJ_GETTER(Kotlin_Byte_toString, KByte value) { OBJ_GETTER(Kotlin_Byte_toString, KByte value) {
char cstring[8]; char cstring[8];
snprintf(cstring, sizeof(cstring), "%d", value); snprintf(cstring, sizeof(cstring), "%d", value);