diff --git a/libraries/scripting/common/src/kotlin/script/experimental/repl/replCompilation.kt b/libraries/scripting/common/src/kotlin/script/experimental/repl/replCompilation.kt deleted file mode 100644 index 206138964e1..00000000000 --- a/libraries/scripting/common/src/kotlin/script/experimental/repl/replCompilation.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. - */ - -package kotlin.script.experimental.repl - -import kotlin.script.experimental.api.* - -interface ReplSnippetChecker { - - suspend operator fun invoke( - snippet: ReplSnippetSource, - state: ReplStageState<*>, - compilationConfiguration: ScriptCompilationConfiguration - ): ResultWithDiagnostics -} - -interface ReplSnippetCompiler { - - suspend operator fun invoke( - snippet: ReplSnippetSource, - state: ReplStageState<*>, - compilationConfiguration: ScriptCompilationConfiguration - ): ResultWithDiagnostics> -} - -interface CompiledReplSnippet : CompiledScript diff --git a/libraries/scripting/common/src/kotlin/script/experimental/repl/replData.kt b/libraries/scripting/common/src/kotlin/script/experimental/repl/replData.kt deleted file mode 100644 index 17404016d42..00000000000 --- a/libraries/scripting/common/src/kotlin/script/experimental/repl/replData.kt +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. - */ - -package kotlin.script.experimental.repl - -import kotlin.script.experimental.api.SourceCode - -interface ReplSnippetSource : SourceCode, ReplSnippetId - diff --git a/libraries/scripting/common/src/kotlin/script/experimental/repl/replEvaluation.kt b/libraries/scripting/common/src/kotlin/script/experimental/repl/replEvaluation.kt deleted file mode 100644 index b563cd2f6f7..00000000000 --- a/libraries/scripting/common/src/kotlin/script/experimental/repl/replEvaluation.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. - */ - -package kotlin.script.experimental.repl - -import kotlin.script.experimental.api.EvaluationResult -import kotlin.script.experimental.api.ResultWithDiagnostics -import kotlin.script.experimental.util.PropertiesCollection - -interface ReplEvaluationEnvironmentKeys - -class ReplEvaluationEnvironment(baseEvaluationEnvironments: Iterable, body: Builder.() -> Unit) : - PropertiesCollection(Builder(baseEvaluationEnvironments).apply(body).data) { - - constructor(body: Builder.() -> Unit = {}) : this(emptyList(), body) - constructor( - vararg baseEvaluationEnvironments: ReplEvaluationEnvironment, body: Builder.() -> Unit = {} - ) : this(baseEvaluationEnvironments.asIterable(), body) - - class Builder internal constructor(baseEvaluationEnvironments: Iterable) : - ReplEvaluationEnvironmentKeys, - PropertiesCollection.Builder(baseEvaluationEnvironments) - - companion object : ReplEvaluationEnvironmentKeys -} - -interface ReplSnippetEvaluator { - - suspend operator fun invoke( - compiledSnippet: CompiledReplSnippet<*>, - replEvaluationEnvironment: ReplEvaluationEnvironment - ): ResultWithDiagnostics -} diff --git a/libraries/scripting/common/src/kotlin/script/experimental/repl/replHistory.kt b/libraries/scripting/common/src/kotlin/script/experimental/repl/replHistory.kt deleted file mode 100644 index c246dc109fc..00000000000 --- a/libraries/scripting/common/src/kotlin/script/experimental/repl/replHistory.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. - */ - -package kotlin.script.experimental.repl - -import java.util.concurrent.locks.ReentrantReadWriteLock -import kotlin.concurrent.read -import kotlin.concurrent.write - -const val REPL_CODE_LINE_FIRST_NO = 1 -const val REPL_CODE_LINE_FIRST_GEN = 1 - -interface ReplSnippetId : Comparable { - val no: Int - val generation: Int -} - -data class ReplHistoryRecord(val id: ReplSnippetId, val item: T) - -interface IReplStageHistory : List> { - - fun peek(): ReplHistoryRecord? = lock.read { lastOrNull() } - - fun push(id: ReplSnippetId, item: T) - - fun pop(): ReplHistoryRecord? - - fun verifiedPop(id: ReplSnippetId): ReplHistoryRecord? = lock.write { - if (lastOrNull()?.id == id) pop() - else null - } - - fun reset(): Iterable - - fun resetTo(id: ReplSnippetId): Iterable - - val lock: ReentrantReadWriteLock -} - -interface ReplStageState { - val history: IReplStageHistory - - val lock: ReentrantReadWriteLock - - val currentGeneration: Int - - fun getNextLineNo(): Int = - history.peek()?.id?.no?.let { it + 1 } ?: REPL_CODE_LINE_FIRST_NO // TODO: it should be more robust downstream (e.g. use atomic) - - fun > asState(target: Class): StateT = - if (target.isAssignableFrom(this::class.java)) this as StateT - else throw IllegalArgumentException("$this is not an expected instance of IReplStageState") -} diff --git a/libraries/scripting/common/src/kotlin/script/experimental/repl/replHost.kt b/libraries/scripting/common/src/kotlin/script/experimental/repl/replHost.kt deleted file mode 100644 index 49c7134f8ab..00000000000 --- a/libraries/scripting/common/src/kotlin/script/experimental/repl/replHost.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. - */ - -package kotlin.script.experimental.repl - -import kotlinx.coroutines.experimental.CoroutineScope -import kotlinx.coroutines.experimental.runBlocking -import kotlin.script.experimental.api.EvaluationResult -import kotlin.script.experimental.api.ResultWithDiagnostics -import kotlin.script.experimental.api.ScriptCompilationConfiguration -import kotlin.script.experimental.util.PropertiesCollection - -interface ReplCommandProcessor { - suspend operator fun invoke( - command: String, - state: ReplStageState<*> - ): ResultWithDiagnostics -} - -data class ReplCommand(val commandName: String, val processor: ReplCommandProcessor) - -interface ReplHostEnvironmentKeys - -class ReplHostEnvironment(baseReplHostEnvironments: Iterable, body: Builder.() -> Unit) : - PropertiesCollection(Builder(baseReplHostEnvironments).apply(body).data) { - - constructor(body: Builder.() -> Unit = {}) : this(emptyList(), body) - constructor( - vararg baseReplHostEnvironments: ReplHostEnvironment, body: Builder.() -> Unit = {} - ) : this(baseReplHostEnvironments.asIterable(), body) - - class Builder internal constructor(baseReplHostEnvironments: Iterable) : - ReplHostEnvironmentKeys, - PropertiesCollection.Builder(baseReplHostEnvironments) - - companion object : ReplHostEnvironmentKeys -} - -val ReplHostEnvironmentKeys.replCommands by PropertiesCollection.key>() - -abstract class ReplHost( - val environment: ReplHostEnvironment, - val checker: ReplSnippetChecker, - val compiler: ReplSnippetCompiler, - val evaluator: ReplSnippetEvaluator -) { - open fun runInCoroutineContext(block: suspend CoroutineScope.() -> T): T = runBlocking { block() } - - abstract fun eval( - snippet: ReplSnippetSource, - state: ReplStageState<*>, - scriptCompilationConfiguration: ScriptCompilationConfiguration, - replEvaluationEnvironment: ReplEvaluationEnvironment - ): ResultWithDiagnostics -}