AbstractScript

abstract class AbstractScript(extension: String, nullGlobalContext: Boolean) : AbstractEngine

Abstract base class for script execution that supports named variable bindings with type parameters.

Manages a map of named values and their associated type parameters, generates parameter declarations for the target language, and handles context resets between evaluations.

Parameters

extension

the file extension used to look up the script engine (e.g., "kts", "py", "java")

nullGlobalContext

if true, sets the global scope bindings to null on initialization

Constructors

Link copied to clipboard
constructor(extension: String, nullGlobalContext: Boolean)

Properties

Link copied to clipboard

The underlying JSR 223 script engine for this extension.

Functions

Link copied to clipboard
open fun add(name: String, value: Any, vararg types: KType)

Adds a named variable with an associated value and optional type parameters to the script context.

Link copied to clipboard
open fun params(name: String, types: Array<out KType> = typeMap[name]!!): String

Generates the type parameter string (e.g., <Int, String>) for the variable with the given name.

Link copied to clipboard
fun resetContext(nullGlobalContext: Boolean)

Resets the script engine context, clearing all variable and type mappings.