CompilationContext

class CompilationContext(    val moduleHeader: ModuleHeader?,     val module: A_Module,     source: A_String,     val textInterface: TextInterface,     pollForAbort: () -> Boolean,     val progressReporter: CompilerProgressReporter,     problemHandler: ProblemHandler)

A CompilationContext lasts for a module's entire compilation activity.

Author

Mark van Gulik

Parameters

moduleHeader

The module header of the module to compile. May be null for synthetic modules (for entry points), or when parsing the header.

module

The current module.`

source

The source A_String.

textInterface

The text interface for any fibers started by this compiler.

pollForAbort

How to quickly check if the client wants to abort compilation.

progressReporter

How to report progress to the client who instigated compilation. This continuation that accepts the name of the module undergoing compilation, the line number on which the last complete statement concluded, the position of the ongoing parse (in bytes), and the size of the module (in bytes).

problemHandler

The ProblemHandler used for reporting compilation problems.

Constructors

Link copied to clipboard
fun CompilationContext(    moduleHeader: ModuleHeader?,     module: A_Module,     source: A_String,     textInterface: TextInterface,     pollForAbort: () -> Boolean,     progressReporter: CompilerProgressReporter,     problemHandler: ProblemHandler)

Create a CompilationContext for compiling an A_Module.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun evaluatePhraseThen(    expressionNode: A_Phrase,     lexingState: LexingState,     shouldSerialize: Boolean,     trackTasks: Boolean,     onSuccess: (AvailObject) -> Unit,     onFailure: (Throwable) -> Unit)

Generate a function from the specified phrase and evaluate it in the module's context; lexically enclosing variables are not considered in scope, but module variables and constants are in scope.

Link copied to clipboard
fun eventuallyDo(lexingState: LexingState, continuation: () -> Unit)

Attempt the zero-argument continuation. The implementation is free to execute it now or to put it in a bag of continuations to run later in an arbitrary order. There may be performance and/or scale benefits to processing entries in FIFO, LIFO, or some hybrid order, but the correctness is not affected by a choice of order. The implementation may run the expression in parallel with the invoking thread and other such expressions.

Link copied to clipboard
fun recordToken(token: A_Token)

Record the fact that this token was encountered while parsing the current top-level statement.

Link copied to clipboard
fun startWorkUnits(countToBeQueued: Int)

Start N work units, which are about to be queued.

Link copied to clipboard
fun <ArgType> workUnitCompletion(    lexingState: LexingState,     optionalSafetyCheck: AtomicBoolean?,     continuation: (ArgType) -> Unit): (ArgType) -> Unit

Construct and answer a function that wraps the specified continuation in logic that will increment the count of completed work units and potentially call the unambiguous statement.

Link copied to clipboard
fun <ArgType> workUnitsDo(    lexingState: LexingState,     continuations: List<(ArgType) -> Unit>,     argument: ArgType)

Eventually execute the specified List of functions as compiler work units. Note that the queued work unit count must be increased by the full amount up-front to ensure the completion of the first N tasks before the N+1st can be queued doesn't trigger execution of noMoreWorkUnits. Each continuation will be passed the same given argument.

Properties

Link copied to clipboard
val diagnostics: CompilerDiagnostics

The CompilerDiagnostics that tracks potential errors during compilation.

Link copied to clipboard
val loader: AvailLoader

The loader created and operated by this compiler to facilitate the loading of modules.

Link copied to clipboard
val module: A_Module

The Avail module undergoing compilation.

Link copied to clipboard
val moduleHeader: ModuleHeader?

The header information for the current module being parsed.

Link copied to clipboard
var noMoreWorkUnits: () -> Unit? = null

What to do when there are no more work units.

Link copied to clipboard
val progressReporter: CompilerProgressReporter

The CompilerProgressReporter that reports compilation progress at various checkpoints. It accepts the name of the module undergoing compilation, the line number on which the last complete statement concluded, the position of the ongoing parse (in bytes), and the size of the module (in bytes).

Link copied to clipboard
val runtime: AvailRuntime

The AvailRuntime for the compiler. Since a compiler cannot migrate between two runtime environments, it is safe to cache it for efficient access.

Link copied to clipboard
val serializerOutputStream: IndexedFile.ByteArrayOutputStream

The output stream on which the serializer writes.

Link copied to clipboard
val textInterface: TextInterface

The text interface for any fibers started by this compiler.

Link copied to clipboard
val workUnitsCompleted: Long

The current number of work units that have been completed.

Link copied to clipboard
val workUnitsQueued: Long

The current number of work units that have been queued.