IR: Fixed some parents
This commit is contained in:
@@ -305,6 +305,11 @@ fun IrDeclarationContainer.addChild(declaration: IrDeclaration) {
|
||||
declaration.accept(SetDeclarationsParentVisitor, this)
|
||||
}
|
||||
|
||||
fun <T: IrElement> T.setDeclarationsParent(parent: IrDeclarationParent): T {
|
||||
accept(SetDeclarationsParentVisitor, parent)
|
||||
return this
|
||||
}
|
||||
|
||||
object SetDeclarationsParentVisitor : IrElementVisitor<Unit, IrDeclarationParent> {
|
||||
override fun visitElement(element: IrElement, data: IrDeclarationParent) {
|
||||
if (element !is IrDeclarationParent) {
|
||||
|
||||
+1
@@ -86,6 +86,7 @@ class SharedVariablesLowering(val context: BackendContext) : FunctionLoweringPas
|
||||
if (declaration !in sharedVariables) return declaration
|
||||
|
||||
val newDeclaration = context.sharedVariablesManager.declareSharedVariable(declaration)
|
||||
newDeclaration.parent = irFunction
|
||||
transformedDescriptors[declaration.symbol] = newDeclaration.symbol
|
||||
|
||||
return context.sharedVariablesManager.defineSharedValue(declaration, newDeclaration)
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ private fun lowerTailRecursionCalls(context: BackendContext, irFunction: IrFunct
|
||||
irFunction.body = builder.irBlockBody {
|
||||
// Define variables containing current values of parameters:
|
||||
val parameterToVariable = parameters.associate {
|
||||
it to irTemporaryVar(irGet(it), nameHint = it.symbol.suggestVariableName(), parent = irFunction)
|
||||
it to irTemporaryVar(irGet(it), nameHint = it.symbol.suggestVariableName())
|
||||
}
|
||||
// (these variables are to be updated on any tail call).
|
||||
|
||||
@@ -65,7 +65,7 @@ private fun lowerTailRecursionCalls(context: BackendContext, irFunction: IrFunct
|
||||
// Read variables containing current values of parameters:
|
||||
val parameterToNew = parameters.associate {
|
||||
val variable = parameterToVariable[it]!!
|
||||
it to irTemporary(irGet(variable), nameHint = it.symbol.suggestVariableName()).also { it.parent = irFunction }
|
||||
it to irTemporary(irGet(variable), nameHint = it.symbol.suggestVariableName())
|
||||
}
|
||||
|
||||
val transformer = BodyTransformer(
|
||||
|
||||
Reference in New Issue
Block a user