Remove variables from frame on block leaving

This commit is contained in:
Michael Bogdanov
2016-10-26 12:08:08 +03:00
parent afe0b8a0b6
commit 4cbc5cc958
@@ -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()