AvailLoader

class AvailLoader(    val runtime: AvailRuntime,     val module: A_Module,     val textInterface: TextInterface)

An AvailLoader is responsible for orchestrating module-level side-effects, such as those caused by adding method, abstract, and forward definitions. Also macros, A_Lexers, A_SemanticRestrictions, A_GrammaticalRestrictions, and method seals.

Author

Todd L Smith

Mark van Gulik

Constructors

Link copied to clipboard
fun AvailLoader(    runtime: AvailRuntime,     module: A_Module,     textInterface: TextInterface)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class LexicalScanner

A class that tracks all visible A_Lexers while compiling a module.

Link copied to clipboard
enum Phase : Enum<AvailLoader.Phase>

The macro-state of the loader. During compilation from a file, a loader will ratchet between COMPILING while parsing a top-level statement, and EXECUTING_FOR_COMPILE while executing the compiled statement. Similarly, when loading from a file, the loader's phase alternates between LOADING and EXECUTING_FOR_LOAD.

Functions

Link copied to clipboard
fun addAbstractSignature(methodName: A_Atom, bodySignature: A_Type)

Add the abstract method signature. A class is considered abstract if there are any abstract methods that haven't been overridden with definitions for it.

Link copied to clipboard
fun addForwardStub(methodName: A_Atom, bodySignature: A_Type)

This is a forward declaration of a method. Insert an appropriately stubbed definition in the module's method dictionary, and add it to the list of methods needing to be declared later in this module.

Link copied to clipboard
fun addGrammaticalRestrictions(parentAtoms: A_Set, illegalArgumentMessages: A_Tuple)

The modularity scheme should prevent all inter-modular method conflicts. Precedence is specified as an array of message sets that are not allowed to be messages generating the arguments of this message. For example, <{"_+_"}, {"_+_", "_*_"}> for the "_*_" operator makes * bind tighter than +, and also groups multiple *'s left-to-right.

Link copied to clipboard
fun addMacroBody(    methodName: A_Atom,     macroBody: A_Function,     prefixFunctions: A_Tuple,     ignoreSeals: Boolean)

Add the macro definition. The precedence rules can not change after the first definition is encountered, so set them to 'no restrictions' if they're not set already.

Link copied to clipboard
fun addMethodBody(methodName: A_Atom, bodyBlock: A_Function)

Add the method definition. The precedence rules can change at any time.

Link copied to clipboard
fun addSeal(methodName: A_Atom, seal: A_Tuple)

Add a seal to the method associated with the given method name.

Link copied to clipboard
fun addSemanticRestriction(restriction: A_SemanticRestriction)

Add a semantic restriction to its associated method.

Link copied to clipboard
fun lexicalScanner(): AvailLoader.LexicalScanner

Answer the LexicalScanner used for creating tokens from source code for this AvailLoader.

Link copied to clipboard
fun lookupAtomsForName(stringName: A_String): A_Set

Look up the given string in the current module's namespace. Answer every atom associated with the string. Never create a new atom.

Link copied to clipboard
fun lookupName(stringName: A_String, isExplicitSubclassAtom: Boolean = false): A_Atom

Look up the given A_String in the current module's namespace. Answer the atom associated with the string, creating the true name if necessary. A local true name always hides other true names. If isExplicitSubclassAtom is true and we're creating a new atom, add the SpecialAtom.EXPLICIT_SUBCLASSING_KEY property.

Link copied to clipboard
fun phase(): AvailLoader.Phase

Get the current loading Phase.

Link copied to clipboard
fun prepareForCompilingModuleBody()

Set up the rootBundleTree and lexicalScanner for compiling the body of the module.

Link copied to clipboard
fun prepareForLoadingModuleBody()

Clear the rootBundleTree and lexicalScanner in preparation for loading (not compiling) the body of the module.

Link copied to clipboard
fun recordedEffects(): List<LoadingEffect>

Answer the list of LoadingEffects.

Link copied to clipboard
fun recordEffect(anEffect: LoadingEffect)

Record a LoadingEffect to ensure it will be replayed when the module which is currently being compiled is later loaded.

Link copied to clipboard
fun removeDefinition(definition: A_Definition)

Unbind the specified method definition from this loader and runtime.

Link copied to clipboard
fun removeMacro(macro: A_Macro)

Unbind the specified macro definition from this loader and runtime.

Link copied to clipboard
fun rootBundleTree(): A_BundleTree

Answer the message bundle tree that this AvailLoader is using to parse its module. It must not be null.

Link copied to clipboard
fun runUnloadFunctions(unloadFunctions: A_Tuple, afterRunning: () -> Unit)

Run the specified tuple of functions sequentially.

Link copied to clipboard
fun setPhase(newPhase: AvailLoader.Phase)

Set the current loading Phase.

Link copied to clipboard
fun startRecordingEffects()

Set a flag that indicates we are determining if the effects of running a function can be summarized, and if so into what LoadingEffects.

Link copied to clipboard
fun statementCanBeSummarized(): Boolean

Answer whether the current statement can be summarized into a sequence of LoadingEffects.

fun statementCanBeSummarized(summarizable: Boolean)

Replace the boolean that indicates whether the current statement can be summarized into a sequence of LoadingEffects. It is set to true before executing a top-level statement, and set to false if an activity is performed that cannot be summarized.

Link copied to clipboard
fun stopRecordingEffects()

Clear the flag that indicates whether we are determining if the effects of running a function can be summarized into LoadingEffects.

Properties

Link copied to clipboard
var manifestEntries: MutableList<ModuleManifestEntry>? = null

A stream on which to serialize each ModuleManifestEntry when the definition actually occurs during compilation. After compilation, the bytes of this stream are written to a record whose index is captured in the A_Module's ModuleDescriptor.ObjectSlots.ALL_MANIFEST_ENTRIES, and fetched from the repository and decoded into a pojo array when needed.

Link copied to clipboard
val module: A_Module

The Avail module undergoing loading.

Link copied to clipboard
var pendingForwards: A_Set

The currently unresolved forward method declarations.

Link copied to clipboard
val runtime: AvailRuntime

The current AvailRuntime.

Link copied to clipboard
val textInterface: TextInterface

The text interface for any fibers started by this AvailLoader.

Link copied to clipboard
var topLevelStatementBeingCompiled: A_Phrase? = null

During module compilation, this holds the top-level zero-argument block phrase that wraps the parsed statement, and is in the process of being evaluated.