[JS IR] improve the hacky fix
This commit is contained in:
committed by
TeamCityServer
parent
46a23c70df
commit
3617c1388c
+6
-9
@@ -27,7 +27,8 @@ class JsGenerationContext(
|
||||
val currentFile: IrFile,
|
||||
val currentFunction: IrFunction?,
|
||||
val staticContext: JsStaticContext,
|
||||
val localNames: LocalNameGenerator? = null
|
||||
val localNames: LocalNameGenerator? = null,
|
||||
private val nameCache: MutableMap<IrElement, JsName> = mutableMapOf()
|
||||
): IrNamer by staticContext {
|
||||
fun newFile(file: IrFile, func: IrFunction? = null, localNames: LocalNameGenerator? = null): JsGenerationContext {
|
||||
return JsGenerationContext(
|
||||
@@ -35,9 +36,8 @@ class JsGenerationContext(
|
||||
currentFunction = func,
|
||||
staticContext = staticContext,
|
||||
localNames = localNames,
|
||||
).also {
|
||||
it.nameCache += nameCache
|
||||
}
|
||||
nameCache = nameCache,
|
||||
)
|
||||
}
|
||||
|
||||
fun newDeclaration(func: IrFunction? = null, localNames: LocalNameGenerator? = null): JsGenerationContext {
|
||||
@@ -46,13 +46,10 @@ class JsGenerationContext(
|
||||
currentFunction = func,
|
||||
staticContext = staticContext,
|
||||
localNames = localNames,
|
||||
).also {
|
||||
it.nameCache += nameCache
|
||||
}
|
||||
nameCache = nameCache,
|
||||
)
|
||||
}
|
||||
|
||||
private val nameCache = mutableMapOf<IrElement, JsName>()
|
||||
|
||||
fun getNameForValueDeclaration(declaration: IrDeclarationWithName): JsName {
|
||||
return nameCache.getOrPut(declaration) {
|
||||
val name = localNames!!.variableNames.names[declaration]
|
||||
|
||||
Reference in New Issue
Block a user