[IR][K/N] Refactored a bit SuspendFunctionLowering

This commit is contained in:
Igor Chevdar
2024-01-17 20:15:22 +02:00
committed by Space Team
parent d39a7e59a7
commit 954eade78c
2 changed files with 5 additions and 89 deletions
@@ -256,34 +256,6 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
}
}
protected open class VariablesScopeTracker : IrElementVisitorVoid {
protected val scopeStack = mutableListOf<MutableSet<IrVariable>>(mutableSetOf())
override fun visitElement(element: IrElement) {
element.acceptChildrenVoid(this)
}
override fun visitContainerExpression(expression: IrContainerExpression) {
if (!expression.isTransparentScope)
scopeStack.push(mutableSetOf())
super.visitContainerExpression(expression)
if (!expression.isTransparentScope)
scopeStack.pop()
}
override fun visitCatch(aCatch: IrCatch) {
scopeStack.push(mutableSetOf())
super.visitCatch(aCatch)
scopeStack.pop()
}
override fun visitVariable(declaration: IrVariable) {
super.visitVariable(declaration)
scopeStack.peek()!!.add(declaration)
}
}
fun IrClass.addField(name: Name, type: IrType, isMutable: Boolean): IrField {
val klass = this
return factory.buildField {