pub struct Compiler { /* private fields */ }Expand description
A checking pipeline, and the Host API schemas it reads.
The default reads the shipped schemas and nothing else, which is what
every cove command does. An embedder adds the modules it registers.
Implementations§
Source§impl Compiler
impl Compiler
Sourcepub fn with_host_schema(self, schema: ModuleSchema) -> Compiler
pub fn with_host_schema(self, schema: ModuleSchema) -> Compiler
Adds one host module’s description.
The schema is checked against exactly as a shipped module’s is: the
module may be named by a use, no package module may shadow it,
calls into it are checked at the call site, its types may be written
and initialized, its resources answer the operations it declares, and
a function reaching it requires the capability the schema names.
Sourcepub fn with_host_schemas(
self,
schemas: impl IntoIterator<Item = ModuleSchema>,
) -> Compiler
pub fn with_host_schemas( self, schemas: impl IntoIterator<Item = ModuleSchema>, ) -> Compiler
Adds every host module in schemas.
This is what pairs a checker with a set of registered hosts in one
line: cove_runtime::HostRegistry::module_schemas hands back the
table every registered module declared itself with, and passing it
here checks the program against the same descriptions the run will
enforce.
Sourcepub fn with_schemas(self, schemas: HostSchemas) -> Compiler
pub fn with_schemas(self, schemas: HostSchemas) -> Compiler
Reads schemas and nothing else, replacing whatever this pipeline
was reading.
This is how an embedding whose registry is its own says so.
with_host_schema and
with_host_schemas add to the
shipped tables, which is right for a run that registers the shipped
hosts and some of its own. A run that registers neither wants
cove_schema::HostSchemas::only, so that a use files in a program
it is about to run is reported by the checker rather than by the
boundary:
let program = Compiler::new()
.with_schemas(HostSchemas::only(hosts.module_schemas()))
.compile(&package)?;Sourcepub fn host_schemas(&self) -> &HostSchemas
pub fn host_schemas(&self) -> &HostSchemas
The host modules this pipeline can see.
Sourcepub fn resolve(&self, package: &Package) -> Result<Program, Vec<Diagnostic>>
pub fn resolve(&self, package: &Package) -> Result<Program, Vec<Diagnostic>>
Resolves package: names, imports, capabilities, and the call graph.
Sourcepub fn check(&self, package: &Package, program: &Program) -> Vec<Diagnostic>
pub fn check(&self, package: &Package, program: &Program) -> Vec<Diagnostic>
Type-checks an already resolved package, reporting errors and
warnings together.
Sourcepub fn compile(&self, package: &Package) -> Result<Program, Vec<Diagnostic>>
pub fn compile(&self, package: &Package) -> Result<Program, Vec<Diagnostic>>
Resolves and type-checks package, which is what cove check does.
The returned program carries Program::facts: the type the checker
settled for every expression, and the declaration each resolved
method call reaches.
Warnings and notes from both halves are carried on the returned
program’s Program::notices rather than mixed into its errors, so
a caller can report them without having to decide which of them
stopped anything. A failure reports the errors first and the warnings
after, because a reader looking for what went wrong should not have
to read past what merely could.