Fix try statement extraction

This commit is contained in:
Tamas Vajk
2021-11-23 15:28:53 +01:00
committed by Ian Lynagh
parent 716b87d200
commit 4ca024f043
4 changed files with 10 additions and 7 deletions

View File

@@ -1047,17 +1047,17 @@ open class KotlinFileExtractor(
val locId = tw.getLocation(e)
tw.writeStmts_trystmt(id, stmtParent.parent, stmtParent.idx, callable)
tw.writeHasLocation(id, locId)
extractExpressionExpr(e.tryResult, callable, id, -1)
extractExpressionStmt(e.tryResult, callable, id, -1)
val finallyStmt = e.finallyExpression
if(finallyStmt != null) {
extractExpressionExpr(finallyStmt, callable, id, -2)
extractExpressionStmt(finallyStmt, callable, id, -2)
}
for((catchIdx, catchClause) in e.catches.withIndex()) {
val catchId = tw.getFreshIdLabel<DbCatchclause>()
tw.writeStmts_catchclause(catchId, id, catchIdx, callable)
// TODO: Index -1: unannotatedtypeaccess
extractTypeAccess(catchClause.catchParameter.type, callable, catchId, -1, catchClause.catchParameter)
extractVariableExpr(catchClause.catchParameter, callable, catchId, 0)
extractExpressionExpr(catchClause.result, callable, catchId, 1)
extractExpressionStmt(catchClause.result, callable, catchId, 1)
}
}
is IrContainerExpression -> {

View File

@@ -57,11 +57,9 @@
| stmts.kt:28:11:28:11 | x | VarAccess |
| stmts.kt:28:11:28:15 | ... > ... | GTExpr |
| stmts.kt:28:15:28:15 | y | VarAccess |
| stmts.kt:33:9:35:5 | <Stmt> | StmtExpr |
| stmts.kt:34:15:34:30 | new Exception(...) | ClassInstanceExpr |
| stmts.kt:34:26:34:28 | Foo | StringLiteral |
| stmts.kt:36:12:36:23 | Exception | TypeAccess |
| stmts.kt:36:12:36:23 | e | LocalVariableDeclExpr |
| stmts.kt:36:26:38:5 | <Stmt> | StmtExpr |
| stmts.kt:37:16:37:16 | 1 | IntegerLiteral |
| stmts.kt:39:13:41:5 | <Stmt> | StmtExpr |
| stmts.kt:40:16:40:16 | 2 | IntegerLiteral |

View File

@@ -0,0 +1 @@
| stmts.kt:33:5:41:5 | try ... | stmts.kt:33:9:35:5 | { ... } |

View File

@@ -0,0 +1,4 @@
import java
from TryStmt s
select s, s.getBlock()