[JS IR] Remove dead code
This commit is contained in:
committed by
Space Team
parent
47f8dedfa5
commit
5a86147e9c
@@ -27,24 +27,6 @@ import java.util.*
|
||||
import kotlin.collections.set
|
||||
import kotlin.math.abs
|
||||
|
||||
// TODO remove direct usages of [mapToKey] from [NameTable] & co and move it to scripting & REPL infrastructure. Review usages.
|
||||
private fun <T> mapToKey(declaration: T): String {
|
||||
return with(JsManglerIr) {
|
||||
if (declaration is IrDeclaration) {
|
||||
try {
|
||||
declaration.hashedMangle(compatibleMode = false).toString()
|
||||
} catch (e: Throwable) {
|
||||
// FIXME: We can't mangle some local declarations. But
|
||||
"wrong_key"
|
||||
}
|
||||
} else if (declaration is String) {
|
||||
declaration.hashMangle.toString()
|
||||
} else {
|
||||
error("Key is not generated for " + declaration?.let { it::class.simpleName })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class NameScope {
|
||||
abstract fun isReserved(name: String): Boolean
|
||||
|
||||
@@ -56,7 +38,6 @@ abstract class NameScope {
|
||||
class NameTable<T>(
|
||||
val parent: NameScope = EmptyScope,
|
||||
val reserved: MutableSet<String> = mutableSetOf(),
|
||||
val mappedNames: MutableMap<String, String>? = null,
|
||||
) : NameScope() {
|
||||
val names = mutableMapOf<T, String>()
|
||||
|
||||
@@ -69,7 +50,6 @@ class NameTable<T>(
|
||||
fun declareStableName(declaration: T, name: String) {
|
||||
names[declaration] = name
|
||||
reserved.add(name)
|
||||
mappedNames?.set(mapToKey(declaration), name)
|
||||
}
|
||||
|
||||
fun declareFreshName(declaration: T, suggestedName: String): String {
|
||||
|
||||
@@ -72,7 +72,7 @@ interface KotlinMangler<D : Any> {
|
||||
* (depending on the target platform).
|
||||
*
|
||||
* The result of this function is only used for assigning names to binary symbols of Kotlin functions in the final executable
|
||||
* produced by Kotlin/Native, and for generating stable names in the JavaScript code produced by Kotlin/JS.
|
||||
* produced by Kotlin/Native.
|
||||
* **It does not affect klib ABI.**
|
||||
*
|
||||
* @param compatibleMode If `true`, the mangled names of property backing fields are just those fields' names.
|
||||
@@ -80,16 +80,6 @@ interface KotlinMangler<D : Any> {
|
||||
*/
|
||||
fun IrDeclaration.mangleString(compatibleMode: Boolean): String
|
||||
|
||||
/**
|
||||
* Computes the hash code of the string returned by [mangleString] using the CityHash64 algorithm.
|
||||
*
|
||||
* **The result of this function does not affect klib ABI.**
|
||||
*
|
||||
* @param compatibleMode If `true`, the mangled names of property backing fields are just those fields' names.
|
||||
* Otherwise, mangles such fields exactly as their corresponding properties.
|
||||
*/
|
||||
fun IrDeclaration.hashedMangle(compatibleMode: Boolean): Long = mangleString(compatibleMode).hashMangle
|
||||
|
||||
override val manglerName: String
|
||||
get() = "Ir"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user