ProgramNode

The intermediate level representation of a program.

Instances are created by elaborated.

Constructors

Link copied to clipboard
fun ProgramNode(declarations: List<TopLevelDeclarationNode>, sourceLocation: SourceLocation)

Functions

Link copied to clipboard
fun <T> cached(function: (ProgramNode) -> T): T

Applies function to this program and returns the results. The result is cached, so future calls with the same function do not evaluate function.

Link copied to clipboard
open operator override fun contains(element: TopLevelDeclarationNode): Boolean
Link copied to clipboard
open override fun containsAll(elements: Collection<TopLevelDeclarationNode>): Boolean
Link copied to clipboard
open override fun copy(children: List<Node>): ProgramNode

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

Link copied to clipboard
Link copied to clipboard
open operator override fun get(index: Int): TopLevelDeclarationNode
Link copied to clipboard
open override fun indexOf(element: TopLevelDeclarationNode): Int
Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open operator override fun iterator(): Iterator<TopLevelDeclarationNode>
Link copied to clipboard
open override fun lastIndexOf(element: TopLevelDeclarationNode): Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun subList(fromIndex: Int, toIndex: Int): List<TopLevelDeclarationNode>
Link copied to clipboard
open fun <T : Any> toArray(p0: IntFunction<Array<T>>): Array<T>
Link copied to clipboard
override fun toDocument(): Document
Link copied to clipboard

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

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun toSurfaceNode(metadata: Metadata): ProgramNode

Returns a representation of this node in the surface syntax.

Properties

Link copied to clipboard

The list of all children nodes. This is empty for leaf nodes.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val hosts: Set<Host>
Link copied to clipboard
open override val size: Int
Link copied to clipboard
open override val sourceLocation: SourceLocation
Link copied to clipboard

A lazily constructed Tree instance for the program.

Extensions

Link copied to clipboard

Annotate parameters, declarations, and let nodes with protocols.

Link copied to clipboard

Performs all static checks on this program.

Link copied to clipboard
fun ProgramNode.compileToKotlin(fileName: String, packageName: String, codeGenerator: (context: CodeGeneratorContext) -> CodeGenerator, protocolComposer: ProtocolComposer): FileSpec
Link copied to clipboard

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

Link copied to clipboard

Returns this node and all its descendants in post order.

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard

Returns the declaration of mainFunction function in this program.

Link copied to clipboard

Returns an AST where every call site is specialized into new functions as much as possible. This allows for the most liberal protocol selection possible, at the cost of redundancy. The specializer will not specialize (mutually) recursive functions to prevent unbounded specialization.

Link copied to clipboard

Combines back ends for different protocols into one that supports all.

Combines multiple protocol composers into one.

fun <K, V> Iterable<Map<K, V>>.unions(): Map<K, V>

Returns the union of all given maps.

fun <T> Iterable<Set<T>>.unions(): Set<T>

Returns the union of all given sets.

Combines code generators for different protocols into one generator that can handle all protocols.

Combines given factories into a single factory that returns protocols from all of them.