AvailBuilder

class AvailBuilder(val runtime: AvailRuntime)

An AvailBuildercompiles and installs into an Avail runtime a target module and each of its dependencies.

Author

Todd L Smith

Leslie Schultz

Mark van Gulik

Parameters

runtime

The AvailRuntime in which to load modules and execute commands.

Constructors

Link copied to clipboard
fun AvailBuilder(runtime: AvailRuntime)

Construct an AvailBuilder for the provided runtime.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class CompiledCommand

An EntryPoint represents a compiled command. It is used to disambiguate commands.

Link copied to clipboard
class LoadedModule(    val name: ResolvedModuleName,     sourceDigest: ByteArray,     module: A_Module,     version: Repository.ModuleVersion,     compilation: Repository.ModuleCompilation)

A LoadedModule holds state about what the builder knows about a currently loaded Avail module.

Functions

Link copied to clipboard
fun attemptCommand(    command: String,     onAmbiguity: (List<AvailBuilder.CompiledCommand>, (AvailBuilder.CompiledCommand?) -> Unit) -> Unit,     onSuccess: (AvailObject, (() -> Unit) -> Unit) -> Unit,     onFailure: () -> Unit)

Attempt to unambiguously parse a command. Each currently loaded module that defines at least one entry point takes a shot at parsing the command. If more than one is successful, report the ambiguity via the onFailure continuation. If none are successful, report the failure. If there was exactly one, compile it into a function and invoke it in a new fiber. If the function evaluation succeeds, run the onSuccess continuation with the function's result, except that if the function has static type ⊤ always pass nil instead of the actual value returned by the function. If the function evaluation failed, report the failure.

Link copied to clipboard
fun buildTarget(    target: ModuleName,     localTracker: CompilerProgressReporter,     globalTracker: GlobalProgressReporter,     problemHandler: ProblemHandler)

Build the target and its dependencies. Block the current Thread until it's done.

Link copied to clipboard
fun buildTargetThen(    target: ModuleName,     localTracker: CompilerProgressReporter,     globalTracker: GlobalProgressReporter,     problemHandler: ProblemHandler,     originalAfterAll: () -> Unit)

Build the target and its dependencies.

Link copied to clipboard
fun cancel()

Cancel the build at the next convenient stopping point for each module.

Link copied to clipboard
fun checkStableInvariants()

Check any invariants of the builder that should hold when it is idle.

Link copied to clipboard
fun generateDocumentation(    target: ModuleName,     documentationPath: Path,     problemHandler: ProblemHandler)

Generate Stacks documentation for the target and its dependencies.

Link copied to clipboard
fun generateGraph(    target: ResolvedModuleName,     destinationFile: File,     problemHandler: ProblemHandler)

Generate a graph.

Link copied to clipboard
fun getLoadedModule(resolvedModuleName: ResolvedModuleName): AvailBuilder.LoadedModule?

Look up the currently loaded module with the specified resolved module name. Return null if the module is not currently loaded.

Link copied to clipboard
fun loadedModulesCopy(): List<AvailBuilder.LoadedModule>

Return a list of modules that are currently loaded. The returned list is a snapshot of the state and does not change due to subsequent loads or unloads.

Link copied to clipboard
fun subscribeToModuleLoading(subscription: (AvailBuilder.LoadedModule, Boolean) -> Unit)

Record a new party to notify about module loading and unloading.

Link copied to clipboard
fun traceDirectoriesThen(action: (ResolvedModuleName, Repository.ModuleVersion, () -> Unit) -> Unit, afterAll: () -> Unit)

Scan all module files in all visible source directories, passing each ResolvedModuleName and corresponding ModuleVersion to the provided function.

Link copied to clipboard
fun unloadTarget(target: ResolvedModuleName?)

Unload the target module and its dependents. If null is provided, unload all modules.

Link copied to clipboard
fun unsubscribeToModuleLoading(subscription: (AvailBuilder.LoadedModule, Boolean) -> Unit)

No longer notify the specified party about module loading and unloading.

Properties

Link copied to clipboard
val buildProblemHandler: ProblemHandler

How to handle problems during a build.

Link copied to clipboard
val moduleGraph: Graph<ResolvedModuleName>

A Graph of ResolvedModuleNames, representing the relationships between all modules currently loaded or involved in the current build action. Modules are only added here after they have been locally traced successfully.

Link copied to clipboard
val pollForAbort: () -> Boolean

A function for polling for abort requests.

Link copied to clipboard
val runtime: AvailRuntime

The runtime into which the builder will install the target module and its dependencies.

Link copied to clipboard
val shouldStopBuild: Boolean

true iff the current build should stop, false otherwise.

Link copied to clipboard
var stopBuildReason: String?

The reason why the current build should stop, or null if a stop is not currently requested.

Link copied to clipboard
var textInterface: TextInterface

The text interface for the builder and downstream components.