Refactor jvm evaluation to make module operations cleaner and more robust

in addition:
- hide internal configuration keys
- add keys for flags controlling evaluation
- add initial module implementation for using scripts from a classpath
This commit is contained in:
Ilya Chernikov
2019-04-04 17:41:59 +02:00
parent 90444502a6
commit a6f0bd6677
7 changed files with 170 additions and 97 deletions
@@ -50,12 +50,15 @@ val ScriptEvaluationConfigurationKeys.providedProperties by PropertiesCollection
*/
val ScriptEvaluationConfigurationKeys.constructorArgs by PropertiesCollection.key<List<Any?>>()
@Deprecated("use scriptsInstancesSharing flag instead", level = DeprecationLevel.ERROR)
val ScriptEvaluationConfigurationKeys.scriptsInstancesSharingMap by PropertiesCollection.key<MutableMap<KClass<*>, EvaluationResult>>()
/**
* A map that is used to store evaluated script instances; if provided - the evaluator will try to get imported script from the map and
* only create/evaluate instances if not found, and evaluator will put newly created instances into the map
* If enabled - the evaluator will try to get imported script from a shared container
* only create/evaluate instances if not found, and evaluator will put newly created instances into the container
* This allows to have a single instance of the script if it is imported several times via different import paths.
*/
val ScriptEvaluationConfigurationKeys.scriptsInstancesSharingMap by PropertiesCollection.key<MutableMap<KClass<*>, EvaluationResult>>()
val ScriptEvaluationConfigurationKeys.scriptsInstancesSharing by PropertiesCollection.key<Boolean>(false)
/**
* The callback that will be called on the script compilation immediately before starting the compilation
@@ -67,7 +70,7 @@ val ScriptEvaluationConfigurationKeys.refineConfigurationBeforeEvaluate by Prope
*/
fun ScriptEvaluationConfiguration.Builder.enableScriptsInstancesSharing() {
this {
scriptsInstancesSharingMap(HashMap())
scriptsInstancesSharing(true)
}
}