Move caching to after all configuration refinements and ...

move compilation cache setting to the scripting host configuration
The cache implementation can now take into account all external
dependencies that may appear during refinement.
Also change initial refinement location accordingly and rearrange
caching interfaces to make it available in scripting plugin.
This commit is contained in:
Ilya Chernikov
2019-07-24 20:34:26 +02:00
parent e41bbe9328
commit 2a5c4a2409
5 changed files with 88 additions and 49 deletions
@@ -0,0 +1,30 @@
/*
* Copyright 2010-2019 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.
*/
package kotlin.script.experimental.jvm
import kotlin.script.experimental.api.CompiledScript
import kotlin.script.experimental.api.ScriptCompilationConfiguration
import kotlin.script.experimental.api.SourceCode
import kotlin.script.experimental.util.PropertiesCollection
interface CompiledJvmScriptsCache {
fun get(script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration): CompiledScript<*>?
fun store(compiledScript: CompiledScript<*>, script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration)
object NoCache : CompiledJvmScriptsCache {
override fun get(
script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration
): CompiledScript<*>? = null
override fun store(
compiledScript: CompiledScript<*>, script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration
) {
}
}
}
val JvmScriptingHostConfigurationKeys.compilationCache by PropertiesCollection.key<CompiledJvmScriptsCache>(isTransient = true)