25. ちょっとコード
kotlinc.bat
rem based on scalac.bat from the Scala distribution
・・・(中略)・・・
if not "%_KOTLIN_RUNNER%"=="" (
"%_JAVACMD%" %_JAVA_OPTS%
"-Dkotlin.home=%_KOTLIN_HOME%" -cp
"%_KOTLIN_HOME%libkotlin-runner.jar" ^
org.jetbrains.kotlin.runner.Main %*
)
27. object Main {
private val KOTLIN_HOME: File
init {
val home = System.getProperty("kotlin.home")
if (home == null) {
System.err.println("error: no kotlin.home system property
was passed")
System.exit(1)
}
KOTLIN_HOME = File(home)
ちょっとコード
org.jetbrains.kotlin.runner.Main.kt(一部抜粋)
28. private fun run(args: Array<String>) {
val classpath = Classpath()
var runner: Runner? = null
var collectingArguments = false
val arguments = arrayListOf<String>()
var noReflect = false
classpath.add(".")
var i = 0
ちょっとコード
org.jetbrains.kotlin.runner.Main.kt(一部抜粋)
34. eval4j
・evalします
・Javaのバイトコードのインタプリタ。デバッガで使うためのも
のらしい
(eval4j is a Java byte code interpreter written in Java. Its primary use
case is implementing expression evaluation in debuggers.)
https://github.com/abreslav/eval4j
・基本的にJavaのスタックマシンの命令セットの
ハンドリングと実行をしているように見えます
eval4jモジュール
35. fun boxType(value: Value): Value {
val method = when (value.asmType) {
Type.INT_TYPE -> MethodDescription("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false)
Type.BYTE_TYPE -> MethodDescription("java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false)
Type.SHORT_TYPE -> MethodDescription("java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false)
Type.LONG_TYPE -> MethodDescription("java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false)
Type.BOOLEAN_TYPE -> MethodDescription("java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;",
false)
// ・・・・・(中略)・・・・・
false)
else -> throw UnsupportedOperationException("Couldn't box non primitive type
${value.asmType.internalName}")
}
return invokeStaticMethod(method, listOf(value))
}
ちょっとコード
47. idea-runner
This module exists for the sole purpose of providing the classpath for the
IDEA run configuration. This run configuration takes a plugin from the
KotlinPlugin artifact instead of the project's 'out' directory, which makes
it possible for our plugin to depend on other plugins such as JUnit plugin. If
you want to debug some patch to IDEA, you can add copy of IDEA class
into this module and modify.
ということでIntelliJ IDEAのプロジェクト構成の場合にKotlin
を動かすというものらしいです
idea-runnerモジュール