pub struct Compiler { /* private fields */ }Expand description
The compiler-facing integration object. Construction validates the public manifest/catalog contract once and exposes the pinned catalog identity.
Implementations§
Source§impl Compiler
impl Compiler
pub fn new() -> Result<Self, IntegrationError>
pub fn catalog_identity(&self) -> CatalogIdentity
pub fn link_report(&self) -> LinkReport
Sourcepub fn compile_hir(
&self,
hir: &Program,
) -> Result<CompilationArtifact, IntegrationError>
pub fn compile_hir( &self, hir: &Program, ) -> Result<CompilationArtifact, IntegrationError>
Lower a resolved OPY HIR program into the canonical Workshop Program, validate it
against the canonical catalog, and emit deterministic en-US Workshop.
Sourcepub fn compile_hir_with_locale(
&self,
hir: &Program,
locale: &Locale,
) -> Result<CompilationArtifact, IntegrationError>
pub fn compile_hir_with_locale( &self, hir: &Program, locale: &Locale, ) -> Result<CompilationArtifact, IntegrationError>
Lower and emit using a locale declared by the canonical catalog.
Sourcepub fn compile_hir_mapped(
&self,
hir: &Program,
) -> Result<(CompilationArtifact, MappedText), IntegrationError>
pub fn compile_hir_mapped( &self, hir: &Program, ) -> Result<(CompilationArtifact, MappedText), IntegrationError>
Lower, validate, and emit hir, then pair the emitted Workshop text
with the source map of its authored origin (workshop-rs/mapped-text-v1)
in the same operation.
The map is built from this call’s own compilation, so the artifact and its map can never come from different compiles. Diagnostics on the artifact keep macro definition provenance while the map attributes macro-expanded code to its invocation site.
Sourcepub fn compile_hir_mapped_with_locale(
&self,
hir: &Program,
locale: &Locale,
) -> Result<(CompilationArtifact, MappedText), IntegrationError>
pub fn compile_hir_mapped_with_locale( &self, hir: &Program, locale: &Locale, ) -> Result<(CompilationArtifact, MappedText), IntegrationError>
Self::compile_hir_mapped using a locale declared by the canonical
catalog.
Sourcepub fn compile_source(
&self,
source: &str,
main_path: &str,
root: &Path,
) -> Result<CompileOutput, IntegrationError>
pub fn compile_source( &self, source: &str, main_path: &str, root: &Path, ) -> Result<CompileOutput, IntegrationError>
Compile source using the default en-US catalog locale.
This is the ordinary embedding API. It returns Workshop text and does
not require callers to construct a workshop-rs locale or understand
canonical Workshop types.
Sourcepub fn compile_source_with_language(
&self,
source: &str,
main_path: &str,
root: &Path,
language: &str,
) -> Result<CompileOutput, IntegrationError>
pub fn compile_source_with_language( &self, source: &str, main_path: &str, root: &Path, language: &str, ) -> Result<CompileOutput, IntegrationError>
Compile source using a catalog locale name without exposing the
workshop-rs locale type to ordinary embedding callers.
Sourcepub fn compile_source_with_locale(
&self,
source: &str,
main_path: &str,
root: &Path,
locale: &Locale,
) -> Result<CompilationArtifact, IntegrationError>
pub fn compile_source_with_locale( &self, source: &str, main_path: &str, root: &Path, locale: &Locale, ) -> Result<CompilationArtifact, IntegrationError>
Compile source with an explicit canonical Workshop locale.
This is an advanced integration API. Use Self::compile_source or
Self::compile_source_with_language for ordinary embedding.
Sourcepub fn compile_source_artifact(
&self,
source: &str,
main_path: &str,
root: &Path,
) -> Result<CompilationArtifact, IntegrationError>
pub fn compile_source_artifact( &self, source: &str, main_path: &str, root: &Path, ) -> Result<CompilationArtifact, IntegrationError>
Compile source and return the canonical Workshop artifact for advanced integrations.
Sourcepub fn compile_source_report(
&self,
source: &str,
main_path: &str,
root: &Path,
) -> CompileReport
pub fn compile_source_report( &self, source: &str, main_path: &str, root: &Path, ) -> CompileReport
Compile source into the versioned machine-readable result contract
using the default en-US catalog locale.
Sourcepub fn compile_source_report_with_language(
&self,
source: &str,
main_path: &str,
root: &Path,
language: &str,
) -> CompileReport
pub fn compile_source_report_with_language( &self, source: &str, main_path: &str, root: &Path, language: &str, ) -> CompileReport
Compile source into the versioned machine-readable result contract using a catalog locale name.
Sourcepub fn compile_source_report_with_locale(
&self,
source: &str,
main_path: &str,
root: &Path,
locale: &Locale,
) -> CompileReport
pub fn compile_source_report_with_locale( &self, source: &str, main_path: &str, root: &Path, locale: &Locale, ) -> CompileReport
Compile source into the report contract with an explicit canonical Workshop locale. This is an advanced integration API.
Sourcepub fn compile_source_report_mapped_with_language(
&self,
source: &str,
main_path: &str,
root: &Path,
language: &str,
) -> (CompileReport, Option<MappedText>)
pub fn compile_source_report_mapped_with_language( &self, source: &str, main_path: &str, root: &Path, language: &str, ) -> (CompileReport, Option<MappedText>)
Like Compiler::compile_source_report_with_language, and on success
also returns the mapped Workshop text of the same compile.