Initial support of try as expression in JVM IR
This commit is contained in:
+17
-1
@@ -33,7 +33,6 @@ import org.jetbrains.kotlin.ir.declarations.*
|
|||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.types.isMarkedNullable
|
|
||||||
import org.jetbrains.kotlin.ir.types.toKotlinType
|
import org.jetbrains.kotlin.ir.types.toKotlinType
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
@@ -1033,6 +1032,14 @@ class ExpressionCodegen(
|
|||||||
val tryBlockStart = markNewLabel()
|
val tryBlockStart = markNewLabel()
|
||||||
mv.nop()
|
mv.nop()
|
||||||
gen(aTry.tryResult, aTry.asmType, data)
|
gen(aTry.tryResult, aTry.asmType, data)
|
||||||
|
|
||||||
|
val isExpression = true //TODO: more wise check is required
|
||||||
|
var savedValue: Local? = null
|
||||||
|
if (isExpression) {
|
||||||
|
savedValue = local(frame.enterTemp(aTry.asmType), aTry.asmType)
|
||||||
|
savedValue.store(onStack(aTry.asmType), mv)
|
||||||
|
}
|
||||||
|
|
||||||
val tryBlockEnd = markNewLabel()
|
val tryBlockEnd = markNewLabel()
|
||||||
|
|
||||||
val tryRegions = getCurrentTryIntervals(tryInfo, tryBlockStart, tryBlockEnd)
|
val tryRegions = getCurrentTryIntervals(tryInfo, tryBlockStart, tryBlockEnd)
|
||||||
@@ -1056,6 +1063,10 @@ class ExpressionCodegen(
|
|||||||
catchBody.markLineNumber(true)
|
catchBody.markLineNumber(true)
|
||||||
gen(catchBody, catchBody.asmType, data)
|
gen(catchBody, catchBody.asmType, data)
|
||||||
|
|
||||||
|
savedValue?.let {
|
||||||
|
savedValue.store(onStack(aTry.asmType), mv)
|
||||||
|
}
|
||||||
|
|
||||||
frame.leave(clause.catchParameter)
|
frame.leave(clause.catchParameter)
|
||||||
|
|
||||||
val clauseEnd = markNewLabel()
|
val clauseEnd = markNewLabel()
|
||||||
@@ -1096,6 +1107,11 @@ class ExpressionCodegen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mv.mark(tryCatchBlockEnd)
|
mv.mark(tryCatchBlockEnd)
|
||||||
|
|
||||||
|
savedValue?.let {
|
||||||
|
savedValue.put(mv)
|
||||||
|
frame.leaveTemp(aTry.asmType)
|
||||||
|
}
|
||||||
return aTry.onStack
|
return aTry.onStack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
// FILE: 1.kt
|
// FILE: 1.kt
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|||||||
Vendored
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
// FILE: 1.kt
|
// FILE: 1.kt
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|||||||
Vendored
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
// FILE: 1.kt
|
// FILE: 1.kt
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
// FILE: 1.kt
|
// FILE: 1.kt
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|||||||
Vendored
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
// FILE: 1.kt
|
// FILE: 1.kt
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|||||||
Vendored
-1
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
|
||||||
// FILE: 1.kt
|
// FILE: 1.kt
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// IGNORE_BACKEND: JVM_IR
|
||||||
fun z() {}
|
fun z() {}
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
|
|||||||
Reference in New Issue
Block a user