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

SerializerVisitor

Extends:

Visitor → SerializerVisitor

SerializerVisitor performs the actual serialization of a FincNode description tree into String by extending Visitor.

Method Summary

Public Methods
public

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

Called during preorder traversal when processing FincAndNode.

public

Called during preorder traversal when processing FincGiveNode.

public

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

Called during preorder traversal when processing FincIfNode.

public

Called during preorder traversal when processing FincOneNode.

public

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

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 Methods

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

Called during preorder traversal when processing FincAndNode. Serializes current node with its already serialized children.

Override:

Visitor#processAndNode

Params:

NameTypeAttributeDescription
node FincNode

currently processed node

left String

a String containing result of serializing left child (first subtree) of the current node

right String

a String containing result of serializing right child (second subtree) of the current node

Return:

String

a String that serializes the current node and all of its subtrees

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

Called during preorder traversal when processing FincGiveNode. Serializes current node with its already serialized children.

Override:

Visitor#processGiveNode

Params:

NameTypeAttributeDescription
node FincNode

currently processed node

child String

a String containing result of serializing its only child (its subtree) of the current node

Return:

String

a String that serializes the current node and its subtree

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

Called during preorder traversal when processing FincIfNode. Serializes current node with its already serialized children. Gateway's address is compressed if it's a zero address to 0x0.

Override:

Visitor#processIfNode

Params:

NameTypeAttributeDescription
node FincNode

currently processed node

left String

a String containing result of serializing left child (first subtree) of the current node

right String

a String containing result of serializing right child (second subtree) of the current node

Return:

String

a String that serializes the current node and all of its subtrees

public processOneNode(node: FincNode): String source

Called during preorder traversal when processing FincOneNode. Serializes current node.

Override:

Visitor#processOneNode

Params:

NameTypeAttributeDescription
node FincNode

currently processed node

Return:

String

a String that serializes the current node.

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

Called during preorder traversal when processing FincOrNode. Serializes current node with its already serialized children.

Override:

Visitor#processOrNode

Params:

NameTypeAttributeDescription
node FincNode

currently processed node

left String

a String containing result of serializing left child (first subtree) of the current node

right String

a String containing result of serializing right child (second subtree) of the current node

Return:

String

a String that serializes the current node and all of its subtrees

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

Called during preorder traversal when processing FincScaleNode. Serializes current node with its already serialized children.

Override:

Visitor#processScaleNode

Params:

NameTypeAttributeDescription
node FincNode

currently processed node

child String

a String containing result of serializing its only child (its subtree) of the current node

Return:

String

a String that serializes the current node and its subtree

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

Called during preorder traversal when processing FincScaleObsNode. Serializes current node with its already serialized children. Gateway's address is compressed if it's a zero address to 0x0.

Override:

Visitor#processScaleObsNode

Params:

NameTypeAttributeDescription
node FincNode

currently processed node

child String

a String containing result of serializing its only child (its subtree) of the current node

Return:

String

a String that serializes the current node and its subtree

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

Called during preorder traversal when processing FincTimeboundNode. Serializes current node with its already serialized children.

Override:

Visitor#processTimeboundNode

Params:

NameTypeAttributeDescription
node FincNode

currently processed node

child String

a String containing result of serializing its only child (its subtree) of the current node

Return:

String

a String that serializes the current node and its subtree

public processUnknownNode() source

Called during preorder traversal when processing an unknown node. Throws an error.

Throw:

Error

always

public processZeroNode(): String source

Called during preorder traversal when processing FincZeroNode. Serializes current node.

Override:

Visitor#processZeroNode

Return:

String

a String that serializes the current node.