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
constructor(runtime: AvailRuntime, module: A_Module, textInterface: TextInterface)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

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.

Properties

Link copied to clipboard

The LexicalScanner used for creating tokens from source code for this AvailLoader.

Link copied to clipboard

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.manifestEntries, and fetched from the repository and decoded and cached when needed.

Link copied to clipboard

The Avail module undergoing loading.

Link copied to clipboard

The NamesIndex into which to record indexing information during actual compilation. After compilation, this is written to a record whose index is captured in the A_Module.namesIndexRecord, and fetched from the repository and decoded and cached when needed.

Link copied to clipboard

The currently unresolved forward method declarations.

Link copied to clipboard

The current loading Phase.

Link copied to clipboard

The A_BundleTree that this AvailLoader is using to parse its module. Start it out as the moduleHeaderBundleRoot for parsing the header, then switch it out to parse the body.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

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.

Link copied to clipboard

A mapping from ranges where variable uses occur to ranges where the corresponding declarations occur.

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

Record a ModuleManifestEntry. Also record suitable information in the namesIndex.

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

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

Add a semantic restriction to its associated method.

Link copied to clipboard
fun addStyler(bundle: A_Bundle, stylerFunction: A_Function)

Define and install a new styler based on the given stylerFunction. Install it for the given A_Bundle's method, within the current A_Module.

Link copied to clipboard
fun addVariableUse(useToken: A_Token, declarationToken: A_Token)

A variable-use was encountered, so record information about where it is, and where its associated definition is.

Link copied to clipboard
fun <T> lockStyles(action: RunTree<String>.() -> T): T

Access the styledRanges in the action while holding the lock.

Link copied to clipboard
fun <T> lockUsesToDefinitions(action: RunTree<LongRange>.() -> T): T

Access the usesToDefinitions in the action while holding the lock.

Link copied to clipboard

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, ifNew: A_Atom.() -> Unit? = null): 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

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

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard

Answer the list of special LoadingEffects that execute before the ordinary effects can be deserialized and executed.

Link copied to clipboard

Answer the list of ordinary LoadingEffects.

Link copied to clipboard

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

Link copied to clipboard

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 runFunctions(functions: Iterator<A_Function>, purpose: String, afterFailingOne: (A_Function, Throwable, proceed: () -> Unit) -> Unit, afterRunningAll: () -> Unit)

Run the specified tuple of functions sequentially.

Link copied to clipboard

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

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

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

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

Link copied to clipboard
fun styleMethodName(stringLiteralToken: A_Token)

Helper method to style a method name. Supersedes styleStringLiteral. If the stringLiteralToken is not a well-formed method name, don't style it.

Link copied to clipboard
fun styleStringLiteral(stringLiteralToken: A_Token)

Helper method to style an ordinary string literal, i.e., one that is not also a method name.

Link copied to clipboard
fun styleToken(token: A_Token, style: StylerDescriptor.SystemStyle, overwrite: Boolean = false, editor: (String?) -> String? = { old -> when (old) { null -> style.kotlinString else -> "$old,${style.kotlinString}" } })
fun styleToken(token: A_Token, style: String?, overwrite: Boolean = false, editor: (String?) -> String? = { old -> when { old === null -> style style === null -> old else -> "$old,$style" } })

Helper method to style a token's range in a particular named style, using the specified function to merge any style information previously attached to all or parts of the token's range.

Link copied to clipboard
fun styleTokens(tokens: Iterable<A_Token>, style: StylerDescriptor.SystemStyle, overwrite: Boolean = false, editor: (String?) -> String? = { old -> when (old) { null -> style.kotlinString else -> "$old,${style.kotlinString}" } })
fun styleTokens(tokens: Iterable<A_Token>, style: String?, overwrite: Boolean = false, editor: (String?) -> String? = { old -> when { old === null -> style style === null -> old else -> "$old,$style" } })

Helper method to style a token's range in a particular named style, using the specified function to merge any style information previously attached to all or parts of the token's range.