[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,15 +143,8 @@ object ArrayOps : TemplateGroupBase() {
} }
on(Platform.JS) { on(Platform.JS) {
on(Backend.Legacy) {
annotation("""@library("arrayEquals")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { "return contentEqualsInternal(other)" } body { "return contentEqualsInternal(other)" }
} }
}
on(Platform.Native) { on(Platform.Native) {
fun notEq(operand1: String, operand2: String) = when { fun notEq(operand1: String, operand2: String) = when {
primitive?.isFloatingPoint() == true -> "!$operand1.equals($operand2)" primitive?.isFloatingPoint() == true -> "!$operand1.equals($operand2)"
@@ -231,15 +224,8 @@ object ArrayOps : TemplateGroupBase() {
} }
} }
on(Platform.JS) { on(Platform.JS) {
on(Backend.Legacy) {
annotation("""@library("arrayDeepEquals")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { "return contentDeepEqualsImpl(other)" } body { "return contentDeepEqualsImpl(other)" }
} }
}
on(Platform.Native) { on(Platform.Native) {
body { "return contentDeepEqualsImpl(other)" } body { "return contentDeepEqualsImpl(other)" }
} }
@@ -286,14 +272,8 @@ 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) {
annotation("""@library("arrayToString")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { """return this?.joinToString(", ", "[", "]") ?: "null"""" } body { """return this?.joinToString(", ", "[", "]") ?: "null"""" }
} }
}
on(Platform.Native) { on(Platform.Native) {
body { """return this?.joinToString(", ", "[", "]") ?: "null"""" } body { """return this?.joinToString(", ", "[", "]") ?: "null"""" }
} }
@@ -351,14 +331,8 @@ object ArrayOps : TemplateGroupBase() {
} }
} }
on(Platform.JS) { on(Platform.JS) {
on(Backend.Legacy) {
annotation("""@library("arrayDeepToString")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { "return contentDeepToStringImpl()" } body { "return contentDeepToStringImpl()" }
} }
}
on(Platform.Native) { on(Platform.Native) {
body { "return contentDeepToStringImpl()" } body { "return contentDeepToStringImpl()" }
} }
@@ -399,14 +373,8 @@ 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) {
annotation("""@library("arrayHashCode")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { "return contentHashCodeInternal()" } body { "return contentHashCodeInternal()" }
} }
}
on(Platform.Native) { on(Platform.Native) {
body { body {
""" """
@@ -468,14 +436,8 @@ object ArrayOps : TemplateGroupBase() {
} }
} }
on(Platform.JS) { on(Platform.JS) {
on(Backend.Legacy) {
annotation("""@library("arrayDeepHashCode")""")
body { "definedExternally" }
}
on(Backend.IR) {
body { "return contentDeepHashCodeInternal()" } body { "return contentDeepHashCodeInternal()" }
} }
}
on(Platform.Native) { on(Platform.Native) {
body { "return contentDeepHashCodeImpl()" } body { "return contentDeepHashCodeImpl()" }
} }
@@ -735,12 +697,6 @@ 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) {
body {
"return fillFromCollection(this.copyOf(size + elements.size), this.size, elements)"
}
}
on(Backend.IR) {
// Don't use fillFromCollection because it treats arrays // Don't use fillFromCollection because it treats arrays
// as `dynamic` but we need to concrete types to perform // as `dynamic` but we need to concrete types to perform
// unboxing of collections elements // unboxing of collections elements
@@ -755,7 +711,6 @@ object ArrayOps : TemplateGroupBase() {
} }
} }
} }
}
on(Platform.Native) { on(Platform.Native) {
body { body {
""" """
@@ -1197,11 +1152,6 @@ object ArrayOps : TemplateGroupBase() {
} }
specialFor(ArraysOfPrimitives) { specialFor(ArraysOfPrimitives) {
if (primitive != PrimitiveType.Long) { if (primitive != PrimitiveType.Long) {
on(Backend.Legacy) {
annotation("""@library("primitiveArraySort")""")
body { "definedExternally" }
}
on(Backend.IR) {
if (primitive == PrimitiveType.Char) { if (primitive == PrimitiveType.Char) {
// Requires comparator because default comparator of 'Array.prototype.sort' compares // Requires comparator because default comparator of 'Array.prototype.sort' compares
// string representation of values // string representation of values
@@ -1209,7 +1159,6 @@ object ArrayOps : TemplateGroupBase() {
} else { } else {
body { "nativeSort()" } 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,
} }