[Wasm] Move intrinsic generators to generators/wasm
Reason: avoid kotlin-stdlib-gen dependency on kotlinStdlib() via wasm.ir
This commit is contained in:
@@ -24,6 +24,7 @@ fun extraSourceSet(name: String, extendMain: Boolean = true): Pair<SourceSet, Co
|
|||||||
val (builtinsSourceSet, builtinsApi) = extraSourceSet("builtins", extendMain = false)
|
val (builtinsSourceSet, builtinsApi) = extraSourceSet("builtins", extendMain = false)
|
||||||
val (evaluateSourceSet, evaluateApi) = extraSourceSet("evaluate")
|
val (evaluateSourceSet, evaluateApi) = extraSourceSet("evaluate")
|
||||||
val (interpreterSourceSet, interpreterApi) = extraSourceSet("interpreter")
|
val (interpreterSourceSet, interpreterApi) = extraSourceSet("interpreter")
|
||||||
|
val (wasmSourceSet, wasmApi) = extraSourceSet("wasm")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// for GeneratorsFileUtil
|
// for GeneratorsFileUtil
|
||||||
@@ -32,6 +33,8 @@ dependencies {
|
|||||||
|
|
||||||
builtinsApi("org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion") { isTransitive = false }
|
builtinsApi("org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion") { isTransitive = false }
|
||||||
evaluateApi(project(":core:deserialization"))
|
evaluateApi(project(":core:deserialization"))
|
||||||
|
wasmApi(project(":wasm:wasm.ir"))
|
||||||
|
wasmApi(kotlinStdlib())
|
||||||
interpreterApi(project(":compiler:ir.tree"))
|
interpreterApi(project(":compiler:ir.tree"))
|
||||||
interpreterApi(project(":compiler:ir.tree.impl"))
|
interpreterApi(project(":compiler:ir.tree.impl"))
|
||||||
|
|
||||||
@@ -96,5 +99,6 @@ val generateKeywordStrings by generator("org.jetbrains.kotlin.generators.fronten
|
|||||||
val generateBuiltins by generator("org.jetbrains.kotlin.generators.builtins.generateBuiltIns.GenerateBuiltInsKt", builtinsSourceSet)
|
val generateBuiltins by generator("org.jetbrains.kotlin.generators.builtins.generateBuiltIns.GenerateBuiltInsKt", builtinsSourceSet)
|
||||||
val generateOperationsMap by generator("org.jetbrains.kotlin.generators.evaluate.GenerateOperationsMapKt", evaluateSourceSet)
|
val generateOperationsMap by generator("org.jetbrains.kotlin.generators.evaluate.GenerateOperationsMapKt", evaluateSourceSet)
|
||||||
val generateInterpreterMap by generator("org.jetbrains.kotlin.generators.interpreter.GenerateInterpreterMapKt", interpreterSourceSet)
|
val generateInterpreterMap by generator("org.jetbrains.kotlin.generators.interpreter.GenerateInterpreterMapKt", interpreterSourceSet)
|
||||||
|
val generateWasmIntrinsics by generator("org.jetbrains.kotlin.generators.wasm.WasmIntrinsicGeneratorKt", wasmSourceSet)
|
||||||
|
|
||||||
testsJar()
|
testsJar()
|
||||||
|
|||||||
+27
-18
@@ -3,27 +3,20 @@
|
|||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package generators
|
package org.jetbrains.kotlin.generators.wasm
|
||||||
|
|
||||||
import org.jetbrains.kotlin.wasm.ir.WasmOp
|
import org.jetbrains.kotlin.wasm.ir.WasmOp
|
||||||
import templates.COMMON_AUTOGENERATED_WARNING
|
|
||||||
import templates.COPYRIGHT_NOTICE
|
|
||||||
import templates.PrimitiveType
|
|
||||||
import templates.isUnsigned
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
|
|
||||||
|
|
||||||
fun generateWasmBuiltIns(targetDir: File) {
|
|
||||||
generateWasmOps(targetDir)
|
|
||||||
generateWasmArrays(targetDir)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun FileWriter.generateStandardWasmInternalHeader() {
|
fun FileWriter.generateStandardWasmInternalHeader() {
|
||||||
appendLine(COPYRIGHT_NOTICE)
|
appendLine(File("license/COPYRIGHT.txt").readText())
|
||||||
appendLine("package kotlin.wasm.internal")
|
appendLine("package kotlin.wasm.internal")
|
||||||
appendLine()
|
appendLine()
|
||||||
appendLine(COMMON_AUTOGENERATED_WARNING)
|
appendLine("//")
|
||||||
|
appendLine("// NOTE: THIS FILE IS AUTO-GENERATED by the generators/wasm/WasmIntrinsicGenerator.kt")
|
||||||
|
appendLine("//")
|
||||||
appendLine()
|
appendLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,17 +50,27 @@ fun generateWasmArrays(targetDir: File) {
|
|||||||
writer.generateStandardWasmInternalHeader()
|
writer.generateStandardWasmInternalHeader()
|
||||||
|
|
||||||
writer.appendLine(wasmArrayForType("Any", true))
|
writer.appendLine(wasmArrayForType("Any", true))
|
||||||
PrimitiveType.descendingByDomainCapacity.reversed().forEach { primitive ->
|
val types = listOf(
|
||||||
|
"Byte",
|
||||||
|
"Char",
|
||||||
|
"Short",
|
||||||
|
"Int",
|
||||||
|
"Long",
|
||||||
|
"Float",
|
||||||
|
"Double"
|
||||||
|
)
|
||||||
|
|
||||||
|
types.forEach { primitive ->
|
||||||
val isPacked = primitive in setOf(
|
val isPacked = primitive in setOf(
|
||||||
PrimitiveType.Byte,
|
"Byte",
|
||||||
PrimitiveType.Short,
|
"Char",
|
||||||
PrimitiveType.Char,
|
"Short",
|
||||||
)
|
)
|
||||||
val isUnsigned = primitive.isUnsigned() || primitive == PrimitiveType.Char
|
val isUnsigned = primitive == "Char"
|
||||||
|
|
||||||
writer.appendLine(
|
writer.appendLine(
|
||||||
wasmArrayForType(
|
wasmArrayForType(
|
||||||
primitive.name,
|
primitive,
|
||||||
false, isPacked, isUnsigned
|
false, isPacked, isUnsigned
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -114,3 +117,9 @@ fun wasmArrayForType(
|
|||||||
|
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val targetDir = File("libraries/stdlib/wasm/src/generated")
|
||||||
|
generateWasmOps(targetDir)
|
||||||
|
generateWasmArrays(targetDir)
|
||||||
|
}
|
||||||
@@ -1,13 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package kotlin.wasm.internal
|
package kotlin.wasm.internal
|
||||||
|
|
||||||
//
|
//
|
||||||
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
// NOTE: THIS FILE IS AUTO-GENERATED by the generators/wasm/WasmIntrinsicGenerator.kt
|
||||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
|
||||||
//
|
//
|
||||||
|
|
||||||
@WasmArrayOf(Any::class, isNullable = true)
|
@WasmArrayOf(Any::class, isNullable = true)
|
||||||
|
|||||||
@@ -1,13 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package kotlin.wasm.internal
|
package kotlin.wasm.internal
|
||||||
|
|
||||||
//
|
//
|
||||||
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
// NOTE: THIS FILE IS AUTO-GENERATED by the generators/wasm/WasmIntrinsicGenerator.kt
|
||||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
|
||||||
//
|
//
|
||||||
|
|
||||||
@ExcludedFromCodegen
|
@ExcludedFromCodegen
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ sourceSets {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion"
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$bootstrapKotlinVersion"
|
||||||
compile "org.jetbrains.kotlin:kotlin-reflect:$bootstrapKotlinVersion"
|
compile "org.jetbrains.kotlin:kotlin-reflect:$bootstrapKotlinVersion"
|
||||||
compile project(":wasm:wasm.ir")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
package generators
|
package generators
|
||||||
|
|
||||||
import java.io.*
|
|
||||||
import templates.*
|
import templates.*
|
||||||
|
import java.io.File
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,8 +71,6 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
targetDir.resolve("_${source.name.capitalize()}$platformSuffix.kt")
|
targetDir.resolve("_${source.name.capitalize()}$platformSuffix.kt")
|
||||||
}
|
}
|
||||||
|
|
||||||
targetBaseDirs[KotlinTarget.WASM]?.let { generateWasmBuiltIns(it) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun File.resolveExistingDir(subpath: String) = resolve(subpath).also { it.requireExistingDir() }
|
fun File.resolveExistingDir(subpath: String) = resolve(subpath).also { it.requireExistingDir() }
|
||||||
|
|||||||
Reference in New Issue
Block a user