Kotlin: Add support for try statements

This commit is contained in:
Ian Lynagh
2021-10-29 19:57:45 +01:00
parent 6b5663df46
commit cbd265ab7a
4 changed files with 57 additions and 4 deletions

View File

@@ -56,3 +56,11 @@
| 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 | 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

@@ -1,3 +1,4 @@
| file://:0:0:0:0 | catch (...) | CatchClause |
| stmts.kt:2:41:20:1 | { ... } | BlockStmt |
| stmts.kt:3:5:6:5 | <Expr>; | ExprStmt |
| stmts.kt:3:15:4:5 | { ... } | BlockStmt |
@@ -32,3 +33,11 @@
| stmts.kt:25:24:25:33 | break | BreakStmt |
| stmts.kt:28:5:29:16 | while (...) | WhileStmt |
| stmts.kt:29:9:29:16 | continue | ContinueStmt |
| stmts.kt:32:23:42:1 | { ... } | BlockStmt |
| stmts.kt:33:5:41:5 | try ... | TryStmt |
| stmts.kt:33:9:35:5 | { ... } | BlockStmt |
| stmts.kt:34:9:34:30 | throw ... | ThrowStmt |
| stmts.kt:36:26:38:5 | { ... } | BlockStmt |
| stmts.kt:37:9:37:16 | return ... | ReturnStmt |
| stmts.kt:39:13:41:5 | { ... } | BlockStmt |
| stmts.kt:40:9:40:16 | return ... | ReturnStmt |

View File

@@ -28,3 +28,15 @@ fun loops(x: Int, y: Int) {
while(x > y)
continue
}
fun exceptions(): Int {
try {
throw Exception("Foo")
}
catch (e: Exception) {
return 1
}
finally {
return 2
}
}