Home Reference Source Repository
import {EvaluatorVisitor} from 'fincontracts-lib/src/fincontract-evaluator.js'
public class | source

EvaluatorVisitor

Extends:

Visitor → EvaluatorVisitor

Performs the actual evaluation of a Fincontract by analysing its description tree (See FincNode). Traverses the tree in preorder fashion and applies node evaluator functions at each node, returning the result to the parent node. The choice of node evaluator functions defines the evaluation method.

Constructor Summary

Public Constructor
public

constructor(nodeEvaluators: NodeEvaluators)

Constructs the EvaluatorVisitor object with evaluator functions

Member Summary

Public Members
public

nodeEvaluators: NodeEvaluator

Method Summary

Public Methods
public

processAndNode(node: FincNode, left: Array, right: Array): Array

Called during preorder traversal when processing FincAndNode.

public

Called during preorder traversal when processing FincGiveNode.

public

processIfNode(node: FincNode, left: Array, right: Array): Array

Called during preorder traversal when processing FincIfNode.

public

Called during preorder traversal when processing FincOneNode.

public

processOrNode(node: FincNode, left: Array, right: Array): Array

Called during preorder traversal when processing FincOrNode.

public

Called during preorder traversal when processing FincScaleNode.

public

Called during preorder traversal when processing FincScaleObsNode.

public

Called during preorder traversal when processing FincTimeboundNode.

public

Called during preorder traversal when processing an unknown node

public

Called during preorder traversal when processing FincZeroNode.

Inherited Summary

From class Visitor
public abstract

Called when processing FincAndNode.

public abstract

Called when processing FincGiveNode.

public abstract

Called when processing FincIfNode.

public abstract

Called when processing FincOneNode.

public abstract

Called when processing FincOrNode.

public abstract

Called when processing FincScaleNode.

public abstract

Called when processing FincScaleObsNode.

public abstract

Called when processing FincTimeboundNode.

public abstract

Called when processing FincZeroNode.

public

Visits current node.

Public Constructors

public constructor(nodeEvaluators: NodeEvaluators) source

Constructs the EvaluatorVisitor object with evaluator functions

Params:

NameTypeAttributeDescription
nodeEvaluators NodeEvaluators

an object with evaluator functions

Public Members

public nodeEvaluators: NodeEvaluator source

Public Methods

public processAndNode(node: FincNode, left: Array, right: Array): Array source

Called during preorder traversal when processing FincAndNode. Evaluates the current node using NodeEvaluators.and (See NodeEvaluators) evaluator function by mapping over all currencies.

Override:

Visitor#processAndNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

left Array

an array of intervals resulted from processing left child (first subtree) of the current node

right Array

an array of intervals resulted from processing right child (second subtree) of the current node

Return:

Array

an Array of intervals, where each element is an interval for a given currency indexed by Currency.Currencies

public processGiveNode(node: FincNode, child: Array): Array source

Called during preorder traversal when processing FincGiveNode. Evaluates the current node using NodeEvaluators.give (See NodeEvaluators) evaluator function by mapping over all currencies.

Override:

Visitor#processGiveNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

child Array

an Array of intervals resulted from processisng the only child (its subtree) of the current node

Return:

Array

an Array of intervals, where each element is an interval for a given currency indexed by Currency.Currencies

public processIfNode(node: FincNode, left: Array, right: Array): Array source

Called during preorder traversal when processing FincIfNode. Evaluates the current node using NodeEvaluators.if (See NodeEvaluators) evaluator function by mapping over all currencies.

Override:

Visitor#processIfNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

left Array

an array of intervals resulted from processing left child (first subtree) of the current node

right Array

an array of intervals resulted from processing right child (second subtree) of the current node

Return:

Array

an Array of intervals, where each element is an interval for a given currency indexed by Currency.Currencies

public processOneNode(node: FincNode): Array source

Called during preorder traversal when processing FincOneNode. Evaluates the current node using NodeEvaluators.one (See NodeEvaluators) evaluator function by mapping over all currencies.

Override:

Visitor#processOneNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

Return:

Array

an Array of intervals, where each element is an interval for a given currency indexed by Currency.Currencies

public processOrNode(node: FincNode, left: Array, right: Array): Array source

Called during preorder traversal when processing FincOrNode. Evaluates the current node using NodeEvaluators.or (See NodeEvaluators) evaluator function by mapping over all currencies.

Override:

Visitor#processOrNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

left Array

an array of intervals resulted from processing left child (first subtree) of the current node

right Array

an array of intervals resulted from processing right child (second subtree) of the current node

Return:

Array

an Array of intervals, where each element is an interval for a given currency indexed by Currency.Currencies

public processScaleNode(node: FincNode, child: Array): Array source

Called during preorder traversal when processing FincScaleNode. Evaluates the current node using NodeEvaluators.scale (See NodeEvaluators) evaluator function by mapping over all currencies.

Override:

Visitor#processScaleNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

child Array

an Array of intervals resulted from processisng the only child (its subtree) of the current node

Return:

Array

an Array of intervals, where each element is an interval for a given currency indexed by Currency.Currencies

public processScaleObsNode(node: FincNode, child: Array): Array source

Called during preorder traversal when processing FincScaleObsNode. Evaluates the current node using NodeEvaluators.scaleObs (See NodeEvaluators) evaluator function by mapping over all currencies.

Override:

Visitor#processScaleObsNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

child Array

an Array of intervals resulted from processisng the only child (its subtree) of the current node

Return:

Array

an Array of intervals, where each element is an interval for a given currency indexed by Currency.Currencies

public processTimeboundNode(node: FincNode, child: Array): Array source

Called during preorder traversal when processing FincTimeboundNode. Evaluates the current node using NodeEvaluators.timebound (See NodeEvaluators) evaluator function by mapping over all currencies.

Override:

Visitor#processTimeboundNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

child Array

an Array of intervals resulted from processisng the only child (its subtree) of the current node

Return:

Array

an Array of intervals, where each element is an interval for a given currency indexed by Currency.Currencies

public processUnknownNode() source

Called during preorder traversal when processing an unknown node

Throw:

Error

always

public processZeroNode(node: FincNode): Array source

Called during preorder traversal when processing FincZeroNode. Evaluates the current node using NodeEvaluators.zero (See NodeEvaluators) evaluator function by mapping over all currencies.

Override:

Visitor#processZeroNode

Params:

NameTypeAttributeDescription
node FincNode

node currently being processed

Return:

Array

an Array of intervals, where each element is an interval for a given currency indexed by Currency.Currencies