Review feedback on previous changes. (#64)
This commit is contained in:
@@ -194,7 +194,7 @@ task hello3(type: RunKonanTest) {
|
||||
}
|
||||
|
||||
task tostring0(type: RunKonanTest) {
|
||||
goldValue = "127\n255\n239\nA\n1122334455\n112233445566778899\n1E+27\n1E-300\ntrue\nfalse\n"
|
||||
goldValue = "127\n-1\n239\nA\n1122334455\n112233445566778899\n1E+27\n1E-300\ntrue\nfalse\n"
|
||||
source = "runtime/basic/tostring0.kt"
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ task array0(type: RunKonanTest) {
|
||||
task array1(type: RunKonanTest) {
|
||||
goldValue = "42\n1-1\n69\n83\n"
|
||||
source = "runtime/basic/array1.kt"
|
||||
}*/
|
||||
}*/
|
||||
|
||||
|
||||
task if_else(type: UnitKonanTest) {
|
||||
|
||||
@@ -7,6 +7,9 @@ fun main(args : Array<String>) {
|
||||
// println('ト'.toString())
|
||||
println(1122334455.toString())
|
||||
println(112233445566778899.toString())
|
||||
// Here we differ from Java, as have no dtoa() yet.
|
||||
println(3.14159265358.toString())
|
||||
// Here we differ from Java, as have no dtoa() yet.
|
||||
println(1e27.toFloat().toString())
|
||||
println(1e-300.toDouble().toString())
|
||||
println(true.toString())
|
||||
|
||||
@@ -87,8 +87,8 @@ ArrayHeader* Kotlin_CharArray_clone(const ArrayHeader* array) {
|
||||
ArrayHeader* result = ArrayContainer(
|
||||
theCharArrayTypeInfo, array->count_).GetPlace();
|
||||
memcpy(
|
||||
ByteArrayAddressOfElementAt(result, 0),
|
||||
ByteArrayAddressOfElementAt(array, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KChar>(result, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KChar>(array, 0),
|
||||
ArrayDataSizeBytes(array));
|
||||
return result;
|
||||
}
|
||||
@@ -115,8 +115,8 @@ ArrayHeader* Kotlin_ShortArray_clone(const ArrayHeader* array) {
|
||||
ArrayHeader* result = ArrayContainer(
|
||||
theShortArrayTypeInfo, array->count_).GetPlace();
|
||||
memcpy(
|
||||
ByteArrayAddressOfElementAt(result, 0),
|
||||
ByteArrayAddressOfElementAt(array, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KShort>(result, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KShort>(array, 0),
|
||||
ArrayDataSizeBytes(array));
|
||||
return result;
|
||||
}
|
||||
@@ -143,8 +143,8 @@ ArrayHeader* Kotlin_IntArray_clone(const ArrayHeader* array) {
|
||||
ArrayHeader* result = ArrayContainer(
|
||||
theIntArrayTypeInfo, array->count_).GetPlace();
|
||||
memcpy(
|
||||
ByteArrayAddressOfElementAt(result, 0),
|
||||
ByteArrayAddressOfElementAt(array, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KInt>(result, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KInt>(array, 0),
|
||||
ArrayDataSizeBytes(array));
|
||||
return result;
|
||||
}
|
||||
@@ -171,8 +171,8 @@ ArrayHeader* Kotlin_LongArray_clone(const ArrayHeader* array) {
|
||||
ArrayHeader* result = ArrayContainer(
|
||||
theLongArrayTypeInfo, array->count_).GetPlace();
|
||||
memcpy(
|
||||
ByteArrayAddressOfElementAt(result, 0),
|
||||
ByteArrayAddressOfElementAt(array, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KLong>(result, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KLong>(array, 0),
|
||||
ArrayDataSizeBytes(array));
|
||||
return result;
|
||||
}
|
||||
@@ -199,8 +199,8 @@ ArrayHeader* Kotlin_FloatArray_clone(const ArrayHeader* array) {
|
||||
ArrayHeader* result = ArrayContainer(
|
||||
theFloatArrayTypeInfo, array->count_).GetPlace();
|
||||
memcpy(
|
||||
ByteArrayAddressOfElementAt(result, 0),
|
||||
ByteArrayAddressOfElementAt(array, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KFloat>(result, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KFloat>(array, 0),
|
||||
ArrayDataSizeBytes(array));
|
||||
return result;
|
||||
}
|
||||
@@ -227,8 +227,8 @@ ArrayHeader* Kotlin_DoubleArray_clone(const ArrayHeader* array) {
|
||||
ArrayHeader* result = ArrayContainer(
|
||||
theDoubleArrayTypeInfo, array->count_).GetPlace();
|
||||
memcpy(
|
||||
ByteArrayAddressOfElementAt(result, 0),
|
||||
ByteArrayAddressOfElementAt(array, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KDouble>(result, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KDouble>(array, 0),
|
||||
ArrayDataSizeBytes(array));
|
||||
return result;
|
||||
}
|
||||
@@ -255,8 +255,8 @@ ArrayHeader* Kotlin_BooleanArray_clone(const ArrayHeader* array) {
|
||||
ArrayHeader* result = ArrayContainer(
|
||||
theBooleanArrayTypeInfo, array->count_).GetPlace();
|
||||
memcpy(
|
||||
ByteArrayAddressOfElementAt(result, 0),
|
||||
ByteArrayAddressOfElementAt(array, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KBoolean>(result, 0),
|
||||
PrimitiveArrayAddressOfElementAt<KBoolean>(array, 0),
|
||||
ArrayDataSizeBytes(array));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "Types.h"
|
||||
|
||||
typedef uint8_t KBoolean;
|
||||
typedef uint8_t KByte;
|
||||
typedef int8_t KByte;
|
||||
typedef uint16_t KChar;
|
||||
// Note that it is signed.
|
||||
typedef int16_t KShort;
|
||||
@@ -28,6 +28,7 @@ inline const KByte* ByteArrayAddressOfElementAt(
|
||||
return reinterpret_cast<const KByte*>(obj + 1) + index;
|
||||
}
|
||||
|
||||
// Consider aligning of base to sizeof(T).
|
||||
template <typename T>
|
||||
inline T* PrimitiveArrayAddressOfElementAt(ArrayHeader* obj, KInt index) {
|
||||
return reinterpret_cast<T*>(obj + 1) + index;
|
||||
|
||||
@@ -55,6 +55,7 @@ KString Kotlin_Long_toString(KLong value) {
|
||||
return makeString(cstring);
|
||||
}
|
||||
|
||||
// TODO: use David Gay's dtoa() here instead. It's *very* big and ugly.
|
||||
KString Kotlin_Float_toString(KFloat value) {
|
||||
char cstring[32];
|
||||
snprintf(cstring, sizeof(cstring), "%G", value);
|
||||
|
||||
Reference in New Issue
Block a user