Move FunctionImpl classes from package "jet" to "kotlin"
This commit is contained in:
@@ -34,10 +34,12 @@ enum class FunctionKind(
|
||||
K_EXTENSION_FUNCTION : FunctionKind("KExtensionFunction", true, "ExtensionFunction")
|
||||
|
||||
fun getFileName() = classNamePrefix + "s.kt"
|
||||
fun getImplFileName() = classNamePrefix + "sImpl.kt"
|
||||
fun getImplFileName() = (if (isReflection()) "reflect/" else "") + classNamePrefix + "sImpl.kt"
|
||||
fun getClassName(i: Int) = classNamePrefix + i
|
||||
fun getImplClassName(i: Int) = classNamePrefix + "Impl" + i
|
||||
fun getSuperClassName(i: Int) = superClassNamePrefix?.plus(i)
|
||||
|
||||
private fun isReflection() = superClassNamePrefix != null
|
||||
}
|
||||
|
||||
abstract class GenerateFunctionsBase(out: PrintWriter, val kind: FunctionKind): BuiltInsSourceGenerator(out) {
|
||||
@@ -85,9 +87,6 @@ class GenerateFunctions(out: PrintWriter, kind: FunctionKind) : GenerateFunction
|
||||
K_FUNCTION, K_MEMBER_FUNCTION, K_EXTENSION_FUNCTION -> {
|
||||
out.println()
|
||||
}
|
||||
else -> {
|
||||
throw IllegalStateException("Unknown kind: " + kind)
|
||||
}
|
||||
}
|
||||
|
||||
fun generateInvokeSignature(i: Int) {
|
||||
@@ -103,6 +102,11 @@ class GenerateFunctions(out: PrintWriter, kind: FunctionKind) : GenerateFunction
|
||||
}
|
||||
|
||||
class GenerateFunctionsImpl(out: PrintWriter, kind: FunctionKind) : GenerateFunctionsBase(out, kind) {
|
||||
override fun getPackage() = when (kind) {
|
||||
FUNCTION, EXTENSION_FUNCTION -> "kotlin"
|
||||
K_FUNCTION, K_MEMBER_FUNCTION, K_EXTENSION_FUNCTION -> "kotlin.reflect"
|
||||
}
|
||||
|
||||
override fun generateBody() {
|
||||
for (i in 0..MAX_PARAM_COUNT) {
|
||||
out.print("public abstract class " + kind.getImplClassName(i))
|
||||
|
||||
@@ -28,18 +28,20 @@ fun assertExists(file: File): Unit =
|
||||
if (!file.exists()) error("Output dir does not exist: ${file.getAbsolutePath()}")
|
||||
|
||||
val BUILT_INS_DIR = File("core/builtins/src/jet/")
|
||||
val RUNTIME_JVM_DIR = File("core/runtime.jvm/src/jet/")
|
||||
val RUNTIME_JVM_DIR = File("core/runtime.jvm/src/kotlin/")
|
||||
|
||||
abstract class BuiltInsSourceGenerator(val out: PrintWriter) {
|
||||
protected abstract fun generateBody(): Unit
|
||||
|
||||
protected open fun getPackage(): String = "jet"
|
||||
|
||||
final fun generate() {
|
||||
out.println(File("injector-generator/copyright.txt").readText())
|
||||
// Don't include generator class name in the message: these are built-in sources,
|
||||
// and we don't want to scare users with any internal information about our project
|
||||
out.println("// Auto-generated file. DO NOT EDIT!")
|
||||
out.println()
|
||||
out.println("package jet")
|
||||
out.println("package ${getPackage()}")
|
||||
out.println()
|
||||
|
||||
generateBody()
|
||||
@@ -64,6 +66,7 @@ fun generateBuiltIns(generate: (File, (PrintWriter) -> BuiltInsSourceGenerator)
|
||||
fun main(args: Array<String>) {
|
||||
generateBuiltIns { file, generator ->
|
||||
println("generating $file")
|
||||
file.getParentFile()?.mkdirs()
|
||||
PrintWriter(file) use {
|
||||
generator(it).generate()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user