Extend GeneratorExtensions with previous script, implemt it for JS REPL
also refactor JS REPL for better compatibility with the generic REPL/scripting infrastructure
This commit is contained in:
+4
-4
@@ -29,14 +29,14 @@ import kotlin.script.experimental.host.ScriptingHostConfiguration
|
||||
import kotlin.script.experimental.jvm.JsDependency
|
||||
|
||||
abstract class AbstractJsReplTest : Closeable {
|
||||
protected lateinit var compilationState: JsReplCompilationState
|
||||
protected lateinit var compilerState: JsReplCompilerState
|
||||
protected lateinit var evaluationState: JsEvaluationState
|
||||
|
||||
protected abstract fun createCompilationState(): JsReplCompilationState
|
||||
protected abstract fun createCompilationState(): JsReplCompilerState
|
||||
protected abstract fun createEvaluationState(): JsEvaluationState
|
||||
|
||||
fun compile(codeLine: ReplCodeLine): ReplCompileResult {
|
||||
return JsReplCompiler(environment).compile(compilationState, codeLine)
|
||||
return JsReplCompiler(environment).compile(compilerState, codeLine)
|
||||
}
|
||||
|
||||
fun evaluate(compileResult: ReplCompileResult.CompiledClasses): ReplEvalResult {
|
||||
@@ -45,7 +45,7 @@ abstract class AbstractJsReplTest : Closeable {
|
||||
|
||||
fun reset() {
|
||||
collector.clear()
|
||||
compilationState = createCompilationState()
|
||||
compilerState = createCompilationState()
|
||||
evaluationState = createEvaluationState()
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -31,9 +31,9 @@ class JsReplTestAgainstBinaries : AbstractJsReplTest() {
|
||||
dependencyLoader.saveNames(nameTable)
|
||||
}
|
||||
|
||||
override fun createCompilationState(): JsReplCompilationState {
|
||||
override fun createCompilationState(): JsReplCompilerState {
|
||||
val replState = ReplCodeAnalyzerBase.ResettableAnalyzerState()
|
||||
return JsReplCompilationState(ReentrantReadWriteLock(), dependencyLoader.loadNames(), dependencies, replState, createSymbolTable())
|
||||
return JsReplCompilerState(ReentrantReadWriteLock(), dependencyLoader.loadNames(), dependencies, replState, createSymbolTable())
|
||||
}
|
||||
|
||||
private fun createSymbolTable(): SymbolTable =
|
||||
|
||||
+2
-2
@@ -20,14 +20,14 @@ class JsReplTestAgainstKlib : AbstractJsReplTest() {
|
||||
|
||||
private var dependencyCode: String? = null
|
||||
|
||||
override fun createCompilationState(): JsReplCompilationState {
|
||||
override fun createCompilationState(): JsReplCompilerState {
|
||||
val nameTables = NameTables(emptyList(), mappedNames = mutableMapOf())
|
||||
val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), IrFactoryImpl)
|
||||
val dependencyCompiler = JsScriptDependencyCompiler(environment.configuration, nameTables, symbolTable)
|
||||
val dependencies = readLibrariesFromConfiguration(environment.configuration)
|
||||
dependencyCode = dependencyCompiler.compile(dependencies)
|
||||
|
||||
return JsReplCompilationState(
|
||||
return JsReplCompilerState(
|
||||
ReentrantReadWriteLock(),
|
||||
nameTables,
|
||||
dependencies,
|
||||
|
||||
Reference in New Issue
Block a user