Some work for string concatenation. (#40)
This commit is contained in:
@@ -2,19 +2,15 @@
|
|||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
First, build Kotlin IR branch tree with:
|
Download dependencies:
|
||||||
|
|
||||||
pushd backend.native/kotlin-ir
|
|
||||||
ant -f ./update_dependencies.xml jb_update
|
|
||||||
ant -f ./build.xml
|
|
||||||
popd
|
|
||||||
|
|
||||||
Then, download dependencies:
|
|
||||||
|
|
||||||
gradle :dependencies:update
|
gradle :dependencies:update
|
||||||
|
|
||||||
To build native translator just use:
|
To run native translator just use:
|
||||||
|
|
||||||
gradle :backend.native:run
|
gradle :backend.native:run
|
||||||
|
|
||||||
And it will run simple example (currently prints out IR of test file).
|
And it will run simple example (currently prints out IR of test file).
|
||||||
|
For more tests, use:
|
||||||
|
|
||||||
|
gradle :backend.native:tests:run
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ abstract class KonanTest extends DefaultTask {
|
|||||||
|
|
||||||
|
|
||||||
abstract void compileTest(File sourceS, File runtimeS, File out)
|
abstract void compileTest(File sourceS, File runtimeS, File out)
|
||||||
|
|
||||||
private File kt2bc(String ktSource) {
|
private File kt2bc(String ktSource) {
|
||||||
def sourceKt = project.file(ktSource)
|
def sourceKt = project.file(ktSource)
|
||||||
def sourceBc = new File("${sourceKt.absolutePath}.bc")
|
def sourceBc = new File("${sourceKt.absolutePath}.bc")
|
||||||
@@ -167,6 +167,13 @@ task hello1(type: RunKonanTest) {
|
|||||||
source = "runtime/basic/hello1.kt"
|
source = "runtime/basic/hello1.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: enable, once calling plus operator is implemented.
|
||||||
|
task hello2(type: RunKonanTest) {
|
||||||
|
goldValue = "Hello World"
|
||||||
|
testData = "Hello World"
|
||||||
|
source = "runtime/basic/hello2.kt"
|
||||||
|
} */
|
||||||
|
|
||||||
// TODO: waiting for boolean to be implemented
|
// TODO: waiting for boolean to be implemented
|
||||||
//task bool_yes(type: KonanTest) {
|
//task bool_yes(type: KonanTest) {
|
||||||
// source = "codegen/function/boolean.kt"
|
// source = "codegen/function/boolean.kt"
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// TODO: remove kotlin_native.io once overrides are in place.
|
||||||
|
fun main(args : Array<String>) {
|
||||||
|
print("you entered '" + readLine() + "'")
|
||||||
|
}
|
||||||
@@ -226,4 +226,10 @@ KInt Kotlin_String_hashCode(const ArrayHeader* thiz) {
|
|||||||
return CityHash64(ByteArrayAddressOfElementAt(thiz, 0), thiz->count_);
|
return CityHash64(ByteArrayAddressOfElementAt(thiz, 0), thiz->count_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KRef Kotlin_String_subSequence(
|
||||||
|
const ArrayHeader* thiz, KInt startIndex, KInt endIndex) {
|
||||||
|
RuntimeAssert(false, "Unsupported operation");
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // extern "C"
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ ArrayHeader* Kotlin_String_fromUtf8Array(const ArrayHeader* array);
|
|||||||
ArrayHeader* Kotlin_String_plusImpl(
|
ArrayHeader* Kotlin_String_plusImpl(
|
||||||
const ArrayHeader* thiz, const ArrayHeader* other);
|
const ArrayHeader* thiz, const ArrayHeader* other);
|
||||||
KInt Kotlin_String_getStringLength(const ArrayHeader* thiz);
|
KInt Kotlin_String_getStringLength(const ArrayHeader* thiz);
|
||||||
|
KRef Kotlin_String_subSequence(
|
||||||
|
const ArrayHeader* thiz, KInt startIndex, KInt endIndex);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package kotlin
|
|||||||
|
|
||||||
@ExportTypeInfo("theAnyTypeInfo")
|
@ExportTypeInfo("theAnyTypeInfo")
|
||||||
public open class Any {
|
public open class Any {
|
||||||
// @SymbolName("Kotlin_Any_equals")
|
@SymbolName("Kotlin_Any_equals")
|
||||||
// external public open operator fun equals0(other: Any0?): Boolean
|
external public open operator fun equals(other: Any?): Boolean
|
||||||
|
|
||||||
// TODO: do we need that in Any?
|
// TODO: do we need that in Any?
|
||||||
@SymbolName("Kotlin_Any_hashCode")
|
@SymbolName("Kotlin_Any_hashCode")
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package kotlin
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a readable sequence of [Char] values.
|
||||||
|
*/
|
||||||
|
public interface CharSequence {
|
||||||
|
/**
|
||||||
|
* Returns the length of this character sequence.
|
||||||
|
*/
|
||||||
|
public val length: Int
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the character at the specified [index] in this character sequence.
|
||||||
|
*/
|
||||||
|
public operator fun get(index: Int): Char
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new character sequence that is a subsequence of this character sequence,
|
||||||
|
* starting at the specified [startIndex] and ending right before the specified [endIndex].
|
||||||
|
*
|
||||||
|
* @param startIndex the start index (inclusive).
|
||||||
|
* @param endIndex the end index (exclusive).
|
||||||
|
*/
|
||||||
|
public fun subSequence(startIndex: Int, endIndex: Int): CharSequence
|
||||||
|
}
|
||||||
@@ -4,27 +4,32 @@ package kotlin
|
|||||||
external fun fromUtf8Array(array: ByteArray) : String
|
external fun fromUtf8Array(array: ByteArray) : String
|
||||||
|
|
||||||
@ExportTypeInfo("theStringTypeInfo")
|
@ExportTypeInfo("theStringTypeInfo")
|
||||||
class String {
|
class String : Comparable<String>/* , CharSequence */ {
|
||||||
@SymbolName("Kotlin_String_hashCode")
|
@SymbolName("Kotlin_String_hashCode")
|
||||||
external public override fun hashCode(): Int
|
external public override fun hashCode(): Int
|
||||||
|
|
||||||
/* TODO: calling to virtual method (plusImpl) results in link error; uncomment after supporting
|
// TODO: make it Any?
|
||||||
calling virtual methods in translator
|
public operator fun plus(other: Any): String {
|
||||||
public operator fun plus(other: Any?): String {
|
|
||||||
return plusImpl(other.toString())
|
return plusImpl(other.toString())
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
public val length: Int
|
/*
|
||||||
|
public fun override toString(): String {
|
||||||
|
return this
|
||||||
|
} */
|
||||||
|
|
||||||
|
public /* override */ val length: Int
|
||||||
get() = getStringLength()
|
get() = getStringLength()
|
||||||
|
|
||||||
// Can be O(N).
|
// Can be O(N).
|
||||||
@SymbolName("Kotlin_String_get")
|
@SymbolName("Kotlin_String_get")
|
||||||
external public fun get(index: Int): Char
|
external /* override */ public fun get(index: Int): Char
|
||||||
|
|
||||||
|
@SymbolName("Kotlin_String_subSequence")
|
||||||
|
external /* override */ public fun subSequence(startIndex: Int, endIndex: Int): CharSequence
|
||||||
|
|
||||||
// external public fun subSequence(startIndex: Int, endIndex: Int): CharSequence
|
|
||||||
@SymbolName("Kotlin_String_compareTo")
|
@SymbolName("Kotlin_String_compareTo")
|
||||||
external public fun compareTo(other: String): Int
|
override external public fun compareTo(other: String): Int
|
||||||
|
|
||||||
@SymbolName("Kotlin_String_getStringLength")
|
@SymbolName("Kotlin_String_getStringLength")
|
||||||
external private fun getStringLength(): Int
|
external private fun getStringLength(): Int
|
||||||
@@ -33,5 +38,5 @@ calling virtual methods in translator
|
|||||||
external private fun plusImpl(other:Any): String
|
external private fun plusImpl(other:Any): String
|
||||||
|
|
||||||
@SymbolName("Kotlin_String_equals")
|
@SymbolName("Kotlin_String_equals")
|
||||||
external public override operator fun equals(other: Any?): Boolean
|
external public override fun equals(other: Any?): Boolean
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package kotlin
|
package kotlin
|
||||||
|
|
||||||
public object Unit {
|
public object Unit {
|
||||||
// override fun toString() = "kotlin.Unit"
|
override fun toString() = "kotlin.Unit"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user