[JS IR] Support per-file mode and ES modules

This commit is contained in:
Svyatoslav Kuzmich
2021-02-23 15:44:06 +03:00
parent f479ac5c3a
commit 3f8dce4b53
140 changed files with 5136 additions and 609 deletions
@@ -1,36 +0,0 @@
// TARGET_BACKEND: JS_IR
// PROPERTY_LAZY_INITIALIZATION
// FILE: A.kt
val a = "A"
// FILE: B.kt
val b = "B".let {
it + "B"
}
val c = b
// FILE: C.kt
val d = "D".let {
it + "D"
}
val e = d
// FILE: main.kt
fun box(): String {
// Get only e to initialize all properties in file
e
return if (
js("a") === "A" &&
js("typeof b") == "undefined" &&
js("typeof c") == "undefined" &&
js("d") === "DD" &&
js("e") === "DD"
)
"OK"
else "a = ${js("a")}; typeof b = ${js("typeof b")}; typeof c = ${js("typeof c")}; d = ${js("d")}; e = ${js("e")}"
}
@@ -3,7 +3,10 @@
// PROPERTY_LAZY_INITIALIZATION
// FILE: A.kt
var result: String? = null
val a = "a".let {
result = "OK"
it + "a"
}
@@ -13,5 +16,5 @@ fun foo() =
// FILE: main.kt
fun box(): String {
val foo = foo()
return if (js("typeof a") == "string" && js("a") == "aa") "OK" else "fail"
return result!!
}
@@ -5,6 +5,7 @@
// FILE: A.kt
val a1 = "a".let {
throw Error()
it + "a"
}
@@ -39,5 +40,5 @@ fun box(): String {
C.values()
C.valueOf("OK")
val baz = b
return if (js("typeof a1") == "undefined") "OK" else "fail"
return "OK"
}