AbstractExprEvaluator

abstract class AbstractExprEvaluator(extension: String) : AbstractEngine

Evaluates expressions with a JSR 223 script engine.

Expressions run in the host JVM. checkCode rejects common literal JVM-termination calls on a best-effort basis (see ScriptGuards), but this is not a security sandbox: do not evaluate untrusted input in-process.

The engine keeps state across evaluations, such as the Kotlin engine's REPL history, which grows with every expression until resetContext is called. AbstractExprEvaluatorPool resets an evaluator once it has been returned resetEvery times.

Parameters

extension

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

Constructors

Link copied to clipboard
constructor(extension: String)

Properties

Link copied to clipboard

The underlying JSR 223 script engine for this extension.

Functions

Link copied to clipboard
open override fun close()

Releases resources held by the engine. The default does nothing; engines that hold resources override it.

Link copied to clipboard
fun compute(expr: String): Any?

Evaluates the given expression and returns the result.

Link copied to clipboard
fun eval(expr: String): Boolean

Evaluates expr and returns its Boolean result.

Link copied to clipboard
fun resetContext(nullGlobalContext: Boolean = false)

Resets the script engine context, clearing all bindings and state.