Compiler

vader/pipeline/comptime_vm

2 files vader/pipeline/comptime_vm/bridge.vader, vader/pipeline/comptime_vm/resolve.vader 2 exports

Functions

resolve_vm_required_decls :: fn(loaded: LoadedProject, typed: TypedProject, evaluated: Ct.EvaluatedProject, diags: Diagnostic[]) -> void

Bake every VM-required @comptime decl into its module's comptime_decls. No-op when evaluated.vm_required is empty (the common case: most projects have no loop-bearing comptime const). Mutates evaluated in place.

The decls run in layers: a decl whose value reads another one still waiting runs once that one is baked, so each runs once, in the folder of its own source (evaluate_layer).

Parameters

loadedLoadedProject the loaded project (staging lower input).
typedTypedProject the typed project (staging lower input).
evaluatedCt.EvaluatedProject the complete evaluated project ; its modules[...].comptime_decls are mutated.
diagsDiagnostic[] comptime diagnostics: a failed staging / VM run appends C4002 (panic) here ; the decl is left un-baked.

Errors

  • C4002 when the staged callee traps in the VM ; C4001 when its result Value can't be bridged (cf. bridge.vader).
copy_baked_values :: fn(from: Ct.EvaluatedProject, into: Ct.EvaluatedProject, diags: Diagnostic[]) -> void

Copy into into the values the VM baked for the deferred decls of from, a load of the same sources under another view (HostBodies). A decl is matched by its position in the source, which both loads share; its symbol id is not.

Parameters

fromCt.EvaluatedProject the evaluated project the VM ran on.
intoCt.EvaluatedProject the evaluated project the values belong to.
diagsDiagnostic[] receives the decls of into that from did not defer.

Errors

  • C4001 for a decl from evaluated otherwise, which would otherwise be left to run in the built program.
Written by vader doc. Icons: Codicons, CC BY 4.0. Fonts: Atkinson Hyperlegible, JetBrains Mono, OFL.