[Wasm] Major compiler and stdlib update
This commit is contained in:
@@ -46,6 +46,7 @@ fun main(args: Array<String>) {
|
||||
targetBaseDirs[KotlinTarget.JVM] = baseDir.resolveExistingDir("libraries/stdlib/jvm/src/generated")
|
||||
targetBaseDirs[KotlinTarget.JS] = baseDir.resolveExistingDir("libraries/stdlib/js/src/generated")
|
||||
targetBaseDirs[KotlinTarget.JS_IR] = baseDir.resolveExistingDir("libraries/stdlib/js-ir/src/generated")
|
||||
targetBaseDirs[KotlinTarget.WASM] = baseDir.resolveExistingDir("libraries/stdlib/wasm/src/generated")
|
||||
}
|
||||
2 -> {
|
||||
val (targetName, targetDir) = args
|
||||
@@ -65,6 +66,7 @@ fun main(args: Array<String>) {
|
||||
val targetDir = targetBaseDirs[target] ?: error("Target $target directory is not configured")
|
||||
val platformSuffix = when (val platform = target.platform) {
|
||||
Platform.Common -> ""
|
||||
Platform.Native -> if (target.backend == Backend.Wasm) "Wasm" else "Native"
|
||||
else -> platform.name.toLowerCase().capitalize()
|
||||
}
|
||||
targetDir.resolve("_${source.name.capitalize()}$platformSuffix.kt")
|
||||
|
||||
@@ -919,6 +919,9 @@ object ArrayOps : TemplateGroupBase() {
|
||||
"""
|
||||
}
|
||||
}
|
||||
on(Backend.Wasm) {
|
||||
body { """TODO("Wasm stdlib: $signature")""" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1046,6 +1049,9 @@ object ArrayOps : TemplateGroupBase() {
|
||||
return result
|
||||
"""
|
||||
}
|
||||
on(Backend.Wasm) {
|
||||
body { """TODO("Wasm stdlib: $signature")""" }
|
||||
}
|
||||
}
|
||||
|
||||
val f_copyOf = fn("copyOf()") {
|
||||
@@ -1154,6 +1160,9 @@ object ArrayOps : TemplateGroupBase() {
|
||||
}
|
||||
on(Platform.Native) {
|
||||
body { "return this.copyOfNulls(newSize)" }
|
||||
on(Backend.Wasm) {
|
||||
body { """TODO("Wasm stdlib: $signature")""" }
|
||||
}
|
||||
}
|
||||
}
|
||||
specialFor(ArraysOfPrimitives, InvariantArraysOfObjects) {
|
||||
@@ -1233,6 +1242,9 @@ object ArrayOps : TemplateGroupBase() {
|
||||
}
|
||||
on(Platform.Native) {
|
||||
body { """if (size > 1) sortArray(this, 0, size)""" }
|
||||
on(Backend.Wasm) {
|
||||
body { """TODO("Wasm stdlib: $signature")""" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1255,6 +1267,9 @@ object ArrayOps : TemplateGroupBase() {
|
||||
}
|
||||
on(Platform.Native) {
|
||||
body { """if (size > 1) sortArrayWith(this, 0, size, comparator)""" }
|
||||
on(Backend.Wasm) {
|
||||
body { """TODO("Wasm stdlib: $signature")""" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1363,6 +1378,9 @@ object ArrayOps : TemplateGroupBase() {
|
||||
sortArray(this, fromIndex, toIndex)
|
||||
"""
|
||||
}
|
||||
on(Backend.Wasm) {
|
||||
body { """TODO("Wasm stdlib: $signature")""" }
|
||||
}
|
||||
}
|
||||
on(Platform.JS) {
|
||||
since("1.4")
|
||||
@@ -1419,6 +1437,9 @@ object ArrayOps : TemplateGroupBase() {
|
||||
sortArrayWith(this, fromIndex, toIndex, comparator)
|
||||
"""
|
||||
}
|
||||
on(Backend.Wasm) {
|
||||
body { """TODO("Wasm stdlib: $signature")""" }
|
||||
}
|
||||
}
|
||||
on(Platform.JS) {
|
||||
since("1.4")
|
||||
@@ -1624,6 +1645,9 @@ object ArrayOps : TemplateGroupBase() {
|
||||
body {
|
||||
"arrayFill(this, fromIndex, toIndex, element)"
|
||||
}
|
||||
on(Backend.Wasm) {
|
||||
body { """TODO("Wasm stdlib: $signature")""" }
|
||||
}
|
||||
}
|
||||
on(Platform.Common) {
|
||||
since("1.3")
|
||||
|
||||
@@ -106,13 +106,14 @@ enum class Platform {
|
||||
Common,
|
||||
JVM,
|
||||
JS,
|
||||
Native
|
||||
Native,
|
||||
}
|
||||
|
||||
enum class Backend {
|
||||
Any,
|
||||
Legacy,
|
||||
IR
|
||||
IR,
|
||||
Wasm,
|
||||
}
|
||||
|
||||
enum class KotlinTarget(val platform: Platform, val backend: Backend) {
|
||||
@@ -120,6 +121,7 @@ enum class KotlinTarget(val platform: Platform, val backend: Backend) {
|
||||
JVM(Platform.JVM, Backend.Any),
|
||||
JS(Platform.JS, Backend.Legacy),
|
||||
JS_IR(Platform.JS, Backend.IR),
|
||||
WASM(Platform.Native, Backend.Wasm),
|
||||
Native(Platform.Native, Backend.IR);
|
||||
|
||||
val fullName get() = "Kotlin/$name"
|
||||
|
||||
@@ -159,7 +159,7 @@ class MemberBuilder(
|
||||
}
|
||||
|
||||
fun on(backend: Backend, action: () -> Unit) {
|
||||
require(target.platform == Platform.JS)
|
||||
require(target.platform == Platform.JS || target.platform == Platform.Native)
|
||||
if (target.backend == backend) action()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user