@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.ir.declarations.IrFile
1717import org.jetbrains.kotlin.ir.declarations.IrFunction
1818import org.jetbrains.kotlin.ir.declarations.IrValueParameter
1919import org.jetbrains.kotlin.ir.declarations.IrProperty
20+ import org.jetbrains.kotlin.ir.declarations.IrVariable
2021import org.jetbrains.kotlin.ir.util.dump
2122import org.jetbrains.kotlin.ir.util.IdSignature
2223import org.jetbrains.kotlin.ir.util.packageFqName
@@ -305,11 +306,25 @@ class KotlinFileExtractor(val tw: TrapWriter) {
305306 }
306307 }
307308
309+ fun extractVariable (v : IrVariable , parent : Label <out DbStmtparent >, idx : Int ) {
310+ val id = tw.getFreshIdLabel<DbLocalvariabledeclexpr >()
311+ val locId = tw.getLocation(v.startOffset, v.endOffset)
312+ val typeId = useType(v.type)
313+ tw.writeExprs_localvariabledeclexpr(id, typeId, parent, idx)
314+ tw.writeHasLocation(id, locId)
315+ val varId = tw.getFreshIdLabel<DbLocalvar >()
316+ tw.writeLocalvars(varId, v.name.asString(), typeId, id)
317+ tw.writeHasLocation(varId, locId)
318+ }
319+
308320 fun extractStatement (s : IrStatement , callable : Label <out DbCallable >, parent : Label <out DbStmtparent >, idx : Int ) {
309321 when (s) {
310322 is IrExpression -> {
311323 extractExpression(s, callable, parent, idx)
312324 }
325+ is IrVariable -> {
326+ extractVariable(s, parent, idx)
327+ }
313328 else -> {
314329 extractorBug(" Unrecognised IrStatement: " + s.javaClass)
315330 }
0 commit comments