ValueEvaluator

open class ValueEvaluator(val cannotEvaluate: (Node?, ValueEvaluator) -> Any? = { node: Node?, _: ValueEvaluator -> // end of the line, lets just keep the expression name if (node != null) { "{${node.name}}" } else { CouldNotResolve() } })

The value evaluator tries to evaluate the (constant) value of an Expression basically by following DFG edges until we reach a Literal. It also evaluates simple binary operations, such as arithmetic operations, as well as simple string concatenations.

The result can be retrieved in two ways:

  • The result of the resolve function is a JVM object which represents the constant value

  • Furthermore, after the execution of evaluateInternal, the latest evaluation path can be retrieved in the path property of the evaluator.

It contains some advanced mechanics such as resolution of values of arrays, if they contain literal values. Furthermore, its behaviour can be adjusted by implementing the cannotEvaluate function, which is called when the default behaviour would not be able to resolve the value. This way, language specific features such as string formatting can be modelled.

Inheritors

Constructors

Link copied to clipboard
constructor(cannotEvaluate: (Node?, ValueEvaluator) -> Any? = { node: Node?, _: ValueEvaluator -> // end of the line, lets just keep the expression name if (node != null) { "{${node.name}}" } else { CouldNotResolve() } })

Properties

Link copied to clipboard

Contains a reference to a function that gets called if the value cannot be resolved by the standard behaviour.

Link copied to clipboard

This property contains the path of the latest execution of evaluateInternal.

Functions

Link copied to clipboard
fun clearPath()
Link copied to clipboard
open fun evaluate(node: Any?): Any?