ProgramNode

class ProgramNode : Node, List<TopLevelDeclarationNode>

The intermediate level representation of a program.

Instances are created by elaborated.

Constructors

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

Functions

cached
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.

contains
Link copied to clipboard
open operator override fun contains(element: TopLevelDeclarationNode): Boolean
containsAll
Link copied to clipboard
open override fun containsAll(elements: Collection<TopLevelDeclarationNode>): Boolean
copy
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.

forEach
Link copied to clipboard
open fun forEach(p0: Consumer<in TopLevelDeclarationNode>)
get
Link copied to clipboard
open operator override fun get(index: Int): TopLevelDeclarationNode
indexOf
Link copied to clipboard
open override fun indexOf(element: TopLevelDeclarationNode): Int
isEmpty
Link copied to clipboard
open override fun isEmpty(): Boolean
iterator
Link copied to clipboard
open operator override fun iterator(): Iterator<TopLevelDeclarationNode>
lastIndexOf
Link copied to clipboard
open override fun lastIndexOf(element: TopLevelDeclarationNode): Int
listIterator
Link copied to clipboard
open override fun listIterator(): ListIterator<TopLevelDeclarationNode>
open override fun listIterator(index: Int): ListIterator<TopLevelDeclarationNode>
parallelStream
Link copied to clipboard
open fun parallelStream(): Stream<TopLevelDeclarationNode>
spliterator
Link copied to clipboard
open override fun spliterator(): Spliterator<TopLevelDeclarationNode>
stream
Link copied to clipboard
open fun stream(): Stream<TopLevelDeclarationNode>
subList
Link copied to clipboard
open override fun subList(fromIndex: Int, toIndex: Int): List<TopLevelDeclarationNode>
toArray
Link copied to clipboard
open fun <T : Any> toArray(p0: IntFunction<Array<T>>): Array<T>
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.

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

Returns a representation of this node in the surface syntax.

Properties

children
Link copied to clipboard
open override val children: Iterable<TopLevelDeclarationNode>
declarations
Link copied to clipboard
val declarations: PersistentList<TopLevelDeclarationNode>
functionMap
Link copied to clipboard
val functionMap: Map<FunctionName, FunctionDeclarationNode>
functions
Link copied to clipboard
val functions: Iterable<FunctionDeclarationNode>
hostDeclarations
Link copied to clipboard
val hostDeclarations: Iterable<HostDeclarationNode>
hosts
Link copied to clipboard
val hosts: Set<Host>
size
Link copied to clipboard
open override val size: Int
sourceLocation
Link copied to clipboard
open override val sourceLocation: SourceLocation
tree
Link copied to clipboard
val tree: Tree<Node, ProgramNode>

A lazily constructed Tree instance for the program.

Extensions

annotateWithProtocols
Link copied to clipboard
fun ProgramNode.annotateWithProtocols(assignment: ProtocolAssignment): ProgramNode

Annotate parameters, declarations, and let nodes with protocols.

check
Link copied to clipboard
fun ProgramNode.check()

Performs all static checks on this program.

compileToKotlin
Link copied to clipboard
fun ProgramNode.compileToKotlin(fileName: String, packageName: String, codeGenerators: List<(context: CodeGeneratorContext) -> CodeGenerator>, protocolComposer: ProtocolComposer): FileSpec
isAssignmentAnnotated
Link copied to clipboard
fun ProgramNode.isAssignmentAnnotated(): Boolean
main
Link copied to clipboard
val ProgramNode.main: FunctionDeclarationNode

Returns the declaration of mainFunction function in this program.

specialize
Link copied to clipboard
fun ProgramNode.specialize(): ProgramNode

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.