Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8df5aba

Browse files
committed
Kotlin: Add localvariabledeclstmt
1 parent e5e6225 commit 8df5aba

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinExtractorExtension.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -912,18 +912,21 @@ class X {
912912
return tw.getVariableLabelFor<DbLocalvar>(v)
913913
}
914914

915-
fun extractVariable(v: IrVariable, callable: Label<out DbCallable>) {
916-
val id = useVariable(v)
915+
fun extractVariable(v: IrVariable, callable: Label<out DbCallable>, parent: Label<out DbStmtparent>, idx: Int) {
916+
val varId = useVariable(v)
917+
val exprId = tw.getFreshIdLabel<DbLocalvariabledeclexpr>()
918+
val stmtId = tw.getFreshIdLabel<DbLocalvariabledeclstmt>()
917919
val locId = tw.getLocation(v)
918920
val type = useType(v.type)
919-
val decId = tw.getFreshIdLabel<DbLocalvariabledeclexpr>()
920-
tw.writeLocalvars(id, v.name.asString(), type.javaResult.id, decId) // TODO: KT type
921-
tw.writeHasLocation(id, locId)
922-
tw.writeExprs_localvariabledeclexpr(decId, type.javaResult.id, type.kotlinResult.id, id, 0)
923-
tw.writeHasLocation(id, locId)
921+
tw.writeLocalvars(varId, v.name.asString(), type.javaResult.id, exprId) // TODO: KT type
922+
tw.writeHasLocation(varId, locId)
923+
tw.writeExprs_localvariabledeclexpr(exprId, type.javaResult.id, type.kotlinResult.id, stmtId, 0)
924+
tw.writeHasLocation(exprId, locId)
925+
tw.writeStmts_localvariabledeclstmt(stmtId, parent, idx, callable)
926+
tw.writeHasLocation(stmtId, locId)
924927
val i = v.initializer
925928
if(i != null) {
926-
extractExpression(i, callable, decId, 0)
929+
extractExpression(i, callable, exprId, 0)
927930
}
928931
}
929932

@@ -933,7 +936,7 @@ class X {
933936
extractExpression(s, callable, parent, idx)
934937
}
935938
is IrVariable -> {
936-
extractVariable(s, callable)
939+
extractVariable(s, callable, parent, idx)
937940
}
938941
else -> {
939942
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrStatement: " + s.javaClass, s)

0 commit comments

Comments
 (0)