Compilation Context
A CompilationContext lasts for a module's entire compilation activity.
Author
Mark van Gulik
Parameters
The module header of the module to compile. May be null for synthetic modules (for entry points), or when parsing the header.
The current module.`
The source A_String.
The text interface for any fibers started by this compiler.
How to quickly check if the client wants to abort compilation.
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).
The ProblemHandler used for reporting compilation problems.
Constructors
Create a CompilationContext for compiling an A_Module.
Types
The abstract class for the styling state machine. A statement can be in the process of being styled while the next statement is being parsed, but before that next statement is allowed to executed, the previous styling action must complete. Otherwise, the execution of the next statement might change the stylers that are in effect while the styling of the previous statement is in progress, which is a race.
Functions
A styling activity is starting. Note that styling must always be started causally beforewhenNotStyling may be called.
Clear the cache of method -> style function. This can be done either when a new style is added within scope of this module, or just before styling a top-level statement.
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.
The current styling activity has completed. If there was a post-styling action set, run it after transitioning to NotStyling.
Flush the delayedSerializedEarlyEffects and delayedSerializedEffects to top-level functions that perform those actions.
Given a method, look up stylers visible by the current module, and choose the most specific one, or the conflict styler if there is more than one that is most specific. Answer nil if none are defined and visible to the module.
Capture the tree of PhraseNodes that describe this top-level phrase.
Record the fact that this token was encountered while parsing the current top-level statement.
Start N work units, which are about to be queued.
Apply the style for a single method send phrase, without considering its subphrases.
Process all of the phrase's subphrases recursively, then style the phrase itself, then invoke the given action.
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.
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
The CompilerDiagnostics that tracks potential errors during compilation.
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).
The AvailRuntime for the compiler. Since a compiler cannot migrate between two runtime environments, it is safe to cache it for efficient access.
The text interface for any fibers started by this compiler.