[stdlib] Remove generator templates for js legacy

This commit is contained in:
Ilya Gorbunov
2023-10-06 21:34:58 +02:00
committed by Space Team
parent 1d232c69d6
commit ff2254db69
2 changed files with 22 additions and 74 deletions
@@ -143,14 +143,7 @@ object ArrayOps : TemplateGroupBase() {
} }
on(Platform.JS) { on(Platform.JS) {
on(Backend.Legacy) { body { "return contentEqualsInternal(other)" }
annotation("""@library("arrayEquals")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { "return contentEqualsInternal(other)" }
}
} }
on(Platform.Native) { on(Platform.Native) {
fun notEq(operand1: String, operand2: String) = when { fun notEq(operand1: String, operand2: String) = when {
@@ -231,14 +224,7 @@ object ArrayOps : TemplateGroupBase() {
} }
} }
on(Platform.JS) { on(Platform.JS) {
on(Backend.Legacy) { body { "return contentDeepEqualsImpl(other)" }
annotation("""@library("arrayDeepEquals")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { "return contentDeepEqualsImpl(other)" }
}
} }
on(Platform.Native) { on(Platform.Native) {
body { "return contentDeepEqualsImpl(other)" } body { "return contentDeepEqualsImpl(other)" }
@@ -286,13 +272,7 @@ object ArrayOps : TemplateGroupBase() {
body { "return java.util.Arrays.toString(this)" } body { "return java.util.Arrays.toString(this)" }
} }
on(Platform.JS) { on(Platform.JS) {
on(Backend.Legacy) { body { """return this?.joinToString(", ", "[", "]") ?: "null"""" }
annotation("""@library("arrayToString")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { """return this?.joinToString(", ", "[", "]") ?: "null"""" }
}
} }
on(Platform.Native) { on(Platform.Native) {
body { """return this?.joinToString(", ", "[", "]") ?: "null"""" } body { """return this?.joinToString(", ", "[", "]") ?: "null"""" }
@@ -351,13 +331,7 @@ object ArrayOps : TemplateGroupBase() {
} }
} }
on(Platform.JS) { on(Platform.JS) {
on(Backend.Legacy) { body { "return contentDeepToStringImpl()" }
annotation("""@library("arrayDeepToString")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { "return contentDeepToStringImpl()" }
}
} }
on(Platform.Native) { on(Platform.Native) {
body { "return contentDeepToStringImpl()" } body { "return contentDeepToStringImpl()" }
@@ -399,13 +373,7 @@ object ArrayOps : TemplateGroupBase() {
body { "return java.util.Arrays.hashCode(this)" } body { "return java.util.Arrays.hashCode(this)" }
} }
on(Platform.JS) { on(Platform.JS) {
on(Backend.Legacy) { body { "return contentHashCodeInternal()" }
annotation("""@library("arrayHashCode")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { "return contentHashCodeInternal()" }
}
} }
on(Platform.Native) { on(Platform.Native) {
body { body {
@@ -468,13 +436,7 @@ object ArrayOps : TemplateGroupBase() {
} }
} }
on(Platform.JS) { on(Platform.JS) {
on(Backend.Legacy) { body { "return contentDeepHashCodeInternal()" }
annotation("""@library("arrayDeepHashCode")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { "return contentDeepHashCodeInternal()" }
}
} }
on(Platform.Native) { on(Platform.Native) {
body { "return contentDeepHashCodeImpl()" } body { "return contentDeepHashCodeImpl()" }
@@ -735,23 +697,16 @@ object ArrayOps : TemplateGroupBase() {
null, PrimitiveType.Boolean, PrimitiveType.Long -> null, PrimitiveType.Boolean, PrimitiveType.Long ->
body { "return arrayPlusCollection(this, elements)" } body { "return arrayPlusCollection(this, elements)" }
else -> { else -> {
on(Backend.Legacy) { // Don't use fillFromCollection because it treats arrays
body { // as `dynamic` but we need to concrete types to perform
"return fillFromCollection(this.copyOf(size + elements.size), this.size, elements)" // unboxing of collections elements
} body {
} """
on(Backend.IR) { var index = size
// Don't use fillFromCollection because it treats arrays val result = this.copyOf(size + elements.size)
// as `dynamic` but we need to concrete types to perform for (element in elements) result[index++] = element
// unboxing of collections elements return result
body { """
"""
var index = size
val result = this.copyOf(size + elements.size)
for (element in elements) result[index++] = element
return result
"""
}
} }
} }
} }
@@ -1197,18 +1152,12 @@ object ArrayOps : TemplateGroupBase() {
} }
specialFor(ArraysOfPrimitives) { specialFor(ArraysOfPrimitives) {
if (primitive != PrimitiveType.Long) { if (primitive != PrimitiveType.Long) {
on(Backend.Legacy) { if (primitive == PrimitiveType.Char) {
annotation("""@library("primitiveArraySort")""") // Requires comparator because default comparator of 'Array.prototype.sort' compares
body { "definedExternally" } // string representation of values
} body { "nativeSort(::primitiveCompareTo)" }
on(Backend.IR) { } else {
if (primitive == PrimitiveType.Char) { body { "nativeSort()" }
// Requires comparator because default comparator of 'Array.prototype.sort' compares
// string representation of values
body { "nativeSort(::primitiveCompareTo)" }
} else {
body { "nativeSort()" }
}
} }
} else { } else {
body { body {
@@ -112,7 +112,6 @@ enum class Platform {
enum class Backend { enum class Backend {
Any, Any,
Legacy,
IR, IR,
Wasm, Wasm,
} }