Constant class

Construct an expression constant.

Extends

Constructors

Constant(any)

Initializes a new instance of the Constant class. Constructs an expression constant.

Properties

returnType

Expected result of evaluating the expression.

type

Type of expression.

value

Constant value. Sets constant value.

Inherited Properties

children

Children expressions.

evaluator

Evaluator of expression.

functions

Dictionary of function => ExpressionEvaluator. This is all available functions, you can add custom functions to it, but you cannot replace builtin functions. If you clear the dictionary, it will be reset to the built in functions.

Methods

deepEquals(Expression)

Determines if the current Expression instance is deep equal to another one.

toString()

Returns a string that represents the current constant object.

Inherited Methods

andExpression(Expression[])

Construct and validate an And expression.

equalsExpression(Expression[])

Construct and validate an Equals expression.

lambaExpression(EvaluateExpressionDelegate)

Construct an expression from a EvaluateExpressionDelegate

lambda((arg0: any) => any)

Construct an expression from a lamba expression over the state. Exceptions will be caught and surfaced as an error string.

lookup(string)

Lookup an ExpressionEvaluator function by name.

makeExpression(string, ExpressionEvaluator, Expression[])

Make an expression and validate it.

notExpression(Expression)

Construct and validate an Not expression.

orExpression(Expression[])

Construct and validate an Or expression.

parse(string, EvaluatorLookup)

Parse an expression string into an Expression object.

references()

Return the static reference paths to memory. Return all static paths to memory. If there is a computed element index, then the path is terminated there, but you might get other paths from the computed part as well.

referenceWalk(Expression, (arg0: Expression) => boolean)

Walking function for identifying static memory references in an expression.

setPathToValue(Expression, any)

Construct and validate an Set a property expression to a value expression.

tryEvaluate(MemoryInterface | any, Options)

Evaluate the expression.

validate()

Validate immediate expression.

validateTree()

Recursively validate the expression tree.

Constructor Details

Constant(any)

Initializes a new instance of the Constant class. Constructs an expression constant.

new Constant(value: any)

Parameters

value

any

Constant value.

Property Details

returnType

Expected result of evaluating the expression.

ReturnType returnType

Property Value

The expected result of evaluating the expression.

type

Type of expression.

string type

Property Value

string

The type of the expression.

value

Constant value. Sets constant value.

any value

Property Value

any

The value.

Inherited Property Details

children

Children expressions.

children: Expression[]

Property Value

Inherited From Expression.children

evaluator

Evaluator of expression.

evaluator: ExpressionEvaluator

Property Value

Inherited From Expression.evaluator

functions

Dictionary of function => ExpressionEvaluator. This is all available functions, you can add custom functions to it, but you cannot replace builtin functions. If you clear the dictionary, it will be reset to the built in functions.

static functions: FunctionTable = new FunctionTable()

Property Value

Inherited From Expression.functions

Method Details

deepEquals(Expression)

Determines if the current Expression instance is deep equal to another one.

function deepEquals(other: Expression): boolean

Parameters

other
Expression

The other Expression instance to compare.

Returns

boolean

A boolean value indicating whether the two expressions are deep equal (true) or not (false).

toString()

Returns a string that represents the current constant object.

function toString(): string

Returns

string

A string that represents the current constant object.

Inherited Method Details

andExpression(Expression[])

Construct and validate an And expression.

static function andExpression(children: Expression[]): Expression

Parameters

children

Expression[]

Child clauses.

Returns

New expression.

Inherited From Expression.andExpression

equalsExpression(Expression[])

Construct and validate an Equals expression.

static function equalsExpression(children: Expression[]): Expression

Parameters

children

Expression[]

Child clauses.

Returns

New expression.

Inherited From Expression.equalsExpression

lambaExpression(EvaluateExpressionDelegate)

Construct an expression from a EvaluateExpressionDelegate

static function lambaExpression(func: EvaluateExpressionDelegate): Expression

Parameters

func
EvaluateExpressionDelegate

Function to create an expression from.

Returns

The new expression.

Inherited From Expression.lambaExpression

lambda((arg0: any) => any)

Construct an expression from a lamba expression over the state. Exceptions will be caught and surfaced as an error string.

static function lambda(func: (arg0: any) => any): Expression

Parameters

func

(arg0: any) => any

ambda expression to evaluate.

Returns

New expression.

Inherited From Expression.lambda

lookup(string)

Lookup an ExpressionEvaluator function by name.

static function lookup(functionName: string): ExpressionEvaluator

Parameters

functionName

string

Name of function to lookup.

Returns

An ExpressionEvaluator corresponding to the function name.

Inherited From Expression.lookup

makeExpression(string, ExpressionEvaluator, Expression[])

Make an expression and validate it.

static function makeExpression(type: string, evaluator: ExpressionEvaluator, children: Expression[]): Expression

Parameters

type

string

Type of expression from ExpressionType.

evaluator
ExpressionEvaluator

Information about how to validate and evaluate expression.

children

Expression[]

Child expressions.

Returns

The new expression.

Inherited From Expression.makeExpression

notExpression(Expression)

Construct and validate an Not expression.

static function notExpression(child: Expression): Expression

Parameters

child
Expression

Child clauses.

Returns

New expression.

Inherited From Expression.notExpression

orExpression(Expression[])

Construct and validate an Or expression.

static function orExpression(children: Expression[]): Expression

Parameters

children

Expression[]

Child clauses.

Returns

New expression.

Inherited From Expression.orExpression

parse(string, EvaluatorLookup)

Parse an expression string into an Expression object.

static function parse(expression: string, lookup?: EvaluatorLookup): Expression

Parameters

expression

string

Expression string.

lookup
EvaluatorLookup

Optional. EvaluatorLookup function lookup when parsing the expression. Default is Expression.lookup which uses Expression.functions table.

Returns

The expression object.

Inherited From Expression.parse

references()

Return the static reference paths to memory. Return all static paths to memory. If there is a computed element index, then the path is terminated there, but you might get other paths from the computed part as well.

function references(): string[]

Returns

string[]

List of the static reference paths.

Inherited From Expression.references

referenceWalk(Expression, (arg0: Expression) => boolean)

Walking function for identifying static memory references in an expression.

function referenceWalk(expression: Expression, extension?: (arg0: Expression) => boolean): { path: string, refs: Set<string> }

Parameters

expression
Expression

Expression to analyze.

extension

(arg0: Expression) => boolean

If present, called to override lookup for things like template expansion.

Returns

{ path: string, refs: Set<string> }

Accessor path of expression.

Inherited From Expression.referenceWalk

setPathToValue(Expression, any)

Construct and validate an Set a property expression to a value expression.

static function setPathToValue(property: Expression, value: any): Expression

Parameters

property
Expression

property expression.

value

any

value expression.

Returns

New expression.

Inherited From Expression.setPathToValue

tryEvaluate(MemoryInterface | any, Options)

Evaluate the expression.

function tryEvaluate(state: MemoryInterface | any, options: Options): ValueWithError

Parameters

state

MemoryInterface | any

Global state to evaluate accessor expressions against. Can be Dictionary, otherwise reflection is used to access property and then indexer.

options
Options

Options used in the evaluation.

Returns

Computed value and an error string. If the string is non-null, then there was an evaluation error.

Inherited From Expression.tryEvaluate

validate()

Validate immediate expression.

function validate()

Inherited From Expression.validate

validateTree()

Recursively validate the expression tree.

function validateTree()

Inherited From Expression.validateTree