Skip to content

Commit ef9a726

Browse files
committed
feat: prepare source for 2.0.0-Beta2
1 parent f47f6f2 commit ef9a726

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ build/
55
!**/src/test/**
66
src/main/resources/application.properties
77

8+
# compile artifacts
9+
.kotlin/
10+
1.9.*/
11+
2.*/
12+
indexes*.json
13+
*.log
14+
815
### STS ###
916
.apt_generated
1017
.classpath

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
55
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
66
import org.springframework.boot.gradle.tasks.bundling.BootJar
77

8-
val kotlinVersion = rootProject.properties["systemProp.kotlinVersion"]
8+
val kotlinVersion = rootProject.properties["systemProp.kotlinVersion"] ?: throw IllegalStateException("kotlinVersion is not specified")
99
val kotlinIdeVersion: String by System.getProperties()
1010
val kotlinIdeVersionSuffix: String by System.getProperties()
1111
val policy: String by System.getProperties()

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
systemProp.kotlinVersion=1.9.23
1+
systemProp.kotlinVersion=2.0.0-dev-9013
22
systemProp.kotlinIdeVersion=1.9.20-RC2-494
33
systemProp.kotlinIdeVersionSuffix=IJ8109.175
44
systemProp.policy=executor.policy

src/main/kotlin/com/compiler/server/compiler/components/KotlinToJSTranslator.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class KotlinToJSTranslator(
9393
))
9494
}
9595
.map { (outputDir / "js" / "$moduleName.js").readText() }
96-
.map { it.withMainArgumentsIr(arguments, moduleName) }
96+
.map { it.withMainArgumentsIr(arguments) }
9797
.map(::redirectOutput)
9898
}
9999
}
@@ -149,17 +149,17 @@ class KotlinToJSTranslator(
149149
}
150150
}
151151

152-
private fun String.withMainArgumentsIr(arguments: List<String>, moduleName: String): String {
153-
val postfix = """| main([]);
154-
| return _;
155-
|}(typeof $moduleName === 'undefined' ? {} : $moduleName);
156-
|""".trimMargin()
157-
if (!endsWith(postfix)) return this
158-
val objectMapper = ObjectMapper()
159-
return this.removeSuffix(postfix) + """| main([${arguments.joinToString { objectMapper.writeValueAsString(it) }}]);
160-
| return _;
161-
|}(typeof $moduleName === 'undefined' ? {} : $moduleName);
162-
|""".trimMargin()
152+
private fun String.withMainArgumentsIr(arguments: List<String>): String {
153+
val mainIrFunction = """
154+
| function mainWrapper() {
155+
| main([%s]);
156+
| }
157+
""".trimMargin()
158+
159+
return replace(
160+
String.format(mainIrFunction, ""),
161+
String.format(mainIrFunction, arguments.joinToString { ObjectMapper().writeValueAsString(it) })
162+
)
163163
}
164164

165165
data class WasmTranslationSuccessfulOutput(

0 commit comments

Comments
 (0)