Skip to main content

Compiler

Struct Compiler 

Source
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

Source

pub fn new() -> Result<Self, IntegrationError>

Source

pub fn catalog_identity(&self) -> CatalogIdentity

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.