[IR] Rewrite how interpreter works with the Unit result

This way interpreter works in more correct way. Every expression
produces some result, and if we don't need it, the interpreter will
discard it.
This commit is contained in:
Ivan Kylchik
2023-07-12 14:24:18 +02:00
committed by Space Team
parent 6204119219
commit 1eca5d1a3b
3 changed files with 43 additions and 21 deletions
+1 -4
View File
@@ -1,9 +1,7 @@
@CompileTimeCalculation
class A {
const val a = <!EVALUATED: `10`!>{ 10 }()<!> // lambda is needed to avoid computions by old frontend
companion object {
const val static = <!EVALUATED: `-10`!>{ -10 }()<!>
const val static = <!EVALUATED: `-10`!>{ -10 }()<!> // lambda is needed to avoid computions by old frontend
fun getStaticNumber(): Int {
return Int.MAX_VALUE
@@ -21,7 +19,6 @@ object ObjectWithConst {
fun concat(first: String, second: Any) = "$first$second"
}
const val num = <!EVALUATED: `10`!>A().a<!>
const val numStatic = <!EVALUATED: `-10`!>A.static<!>
const val numStaticFromFun = <!EVALUATED: `2147483647`!>A.getStaticNumber()<!>
const val valFromObject = <!EVALUATED: `Value in a: 100`!>ObjectWithConst.b<!>