Node

abstract class Node : TreeNode<Node> , HasSourceLocation, PrettyPrintable

A node in the intermediate language abstract syntax tree.

The intermediate language is similar to the surface language, but with the following changes:

  • For and while loops are elaborated into loop-until-break statements.

  • Expressions are in A-normal form. Briefly, this means all intermediate results are stored in immutable temporary variables.

  • Every loop and break statement has a JumpLabel.

  • All Variables within a process have unique names.

Constructors

Node
Link copied to clipboard
fun Node()

Functions

copy
Link copied to clipboard
abstract fun copy(children: List<Node> = this.children.toList()): Node

Returns a shallow copy of this node where the child nodes are replaced by children.

toDocument
Link copied to clipboard
override fun toDocument(): Document
toDocumentWithMetadata
Link copied to clipboard
fun toDocumentWithMetadata(metadata: Metadata): Document

Returns a pretty representation of this Node where each descendant is decorated using metadata.

toSurfaceNode
Link copied to clipboard
abstract fun toSurfaceNode(metadata: Metadata = mapOf()): Node

Returns a representation of this node in the surface syntax.

Properties

children
Link copied to clipboard
abstract val children: Iterable<Node>
sourceLocation
Link copied to clipboard
abstract val sourceLocation: SourceLocation

Inheritors

ExpressionNode
Link copied to clipboard
ProgramNode
Link copied to clipboard
StatementNode
Link copied to clipboard
OutParameterInitializerNode
Link copied to clipboard
FunctionArgumentNode
Link copied to clipboard
TopLevelDeclarationNode
Link copied to clipboard
ParameterNode
Link copied to clipboard

Extensions

deepCopy
Link copied to clipboard
fun Node.deepCopy(): Node

Like Node.copy, but recursively copies all descendant nodes also.

descendants
Link copied to clipboard
fun Node.descendants(): Sequence<Node>

Returns this node and all its descendants in post order.

descendantsIsInstance
Link copied to clipboard
inline fun <T : Node> Node.descendantsIsInstance(): Sequence<T>

Returns all instances of T contained in this node (which may include this node).

freshVariableNameGenerator
Link copied to clipboard
fun Node.freshVariableNameGenerator(): FreshNameGenerator

A FreshNameGenerator that will avoid all Variable names in this node.