From 4cbc5cc9586f855bda7cced291934b22385758c7 Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Wed, 26 Oct 2016 12:08:08 +0300 Subject: [PATCH] Remove variables from frame on block leaving --- .../kotlin/backend/jvm/codegen/ExpressionCodegen.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 349ede85691..4dd5972fac0 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -85,7 +85,7 @@ class BlockInfo private constructor(val parent: BlockInfo?) { } } -class VariableInfo(val name: String, val index: Int, val type: Type, val startLabel: Label) +class VariableInfo(val descriptor: VariableDescriptor, val index: Int, val type: Type, val startLabel: Label) @Suppress("IMPLICIT_CAST_TO_ANY") class ExpressionCodegen( @@ -142,7 +142,11 @@ class ExpressionCodegen( private fun writeLocalVariablesInTable(info: BlockInfo) { val endLabel = markNewLabel() info.variables.forEach { - mv.visitLocalVariable(it.name, it.type.descriptor, null, it.startLabel, endLabel, it.index) + mv.visitLocalVariable(it.descriptor.name.asString(), it.type.descriptor, null, it.startLabel, endLabel, it.index) + } + + info.variables.reversed().forEach { + frame.leave(it.descriptor) } } @@ -267,7 +271,7 @@ class ExpressionCodegen( } val info = VariableInfo( - declaration.descriptor.name.asString(), + declaration.descriptor, index, varType, markNewLabel()