pub struct Compiler { /* private fields */ }Expand description
Compiles an AST into bytecode.
Implementations§
Source§impl Compiler
impl Compiler
Sourcepub fn compile_named_pipeline_entry(
self,
program: &[SNode],
pipeline_name: &str,
fixture_name: Option<&str>,
) -> Result<CompiledCallableEntry, CompileError>
pub fn compile_named_pipeline_entry( self, program: &[SNode], pipeline_name: &str, fixture_name: Option<&str>, ) -> Result<CompiledCallableEntry, CompileError>
Compile a named pipeline for invocation with explicit host values.
Sourcepub fn compile_named_function_entry(
self,
program: &[SNode],
function_name: &str,
) -> Result<CompiledCallableEntry, CompileError>
pub fn compile_named_function_entry( self, program: &[SNode], function_name: &str, ) -> Result<CompiledCallableEntry, CompileError>
Compile a named function as a top-level callable entry.
Source§impl Compiler
impl Compiler
Sourcepub fn compile_fn_body(
&mut self,
type_params: &[TypeParam],
params: &[TypedParam],
body: &[SNode],
source_file: Option<String>,
) -> Result<CompiledFunction, CompileError>
pub fn compile_fn_body( &mut self, type_params: &[TypeParam], params: &[TypedParam], body: &[SNode], source_file: Option<String>, ) -> Result<CompiledFunction, CompileError>
Compile an importable function with the same preamble and metadata as an in-file declaration.
Source§impl Compiler
impl Compiler
Sourcepub fn compile_portable_module(
self,
id: impl Into<String>,
program: &[SNode],
imports: Vec<PortableImport>,
exports: BTreeMap<String, PortableExportKind>,
imported_enum_candidates: &[String],
source_file: Option<String>,
) -> Result<CompiledPortableModule, CompileError>
pub fn compile_portable_module( self, id: impl Into<String>, program: &[SNode], imports: Vec<PortableImport>, exports: BTreeMap<String, PortableExportKind>, imported_enum_candidates: &[String], source_file: Option<String>, ) -> Result<CompiledPortableModule, CompileError>
Compile a module’s initialization and callable declarations using the canonical compiler context. This is deliberately pure: callers own source loading, graph resolution, and export policy.
Source§impl Compiler
impl Compiler
pub fn new() -> Self
Sourcepub fn new_trusted_host_dispatch() -> Self
pub fn new_trusted_host_dispatch() -> Self
Compiler for an explicitly embedder-owned host-dispatch source.
This grants only privileged-wire builtin exposure. Callers must keep the resulting bytecode behind a provenance-separated runtime loader.
Sourcepub fn with_imported_enum_candidates(
self,
candidates: impl IntoIterator<Item = String>,
) -> Self
pub fn with_imported_enum_candidates( self, candidates: impl IntoIterator<Item = String>, ) -> Self
Seed syntax-sensitive import metadata before compiling a source file.
The parser intentionally keeps Color.Ready(value) ambiguous: it can
be a method call or an enum constructor. The module graph resolves
that ambiguity for imported enums, including wildcard imports, so
callers that compile a file outside the module-artifact path can pass
the same public export contract here.
pub fn with_options(options: CompilerOptions) -> Self
Sourcepub fn compile_public_type_schema_initializers(
program: &[SNode],
source_file: Option<String>,
) -> Result<Vec<Chunk>, CompileError>
pub fn compile_public_type_schema_initializers( program: &[SNode], source_file: Option<String>, ) -> Result<Vec<Chunk>, CompileError>
Compile each exported type schema into an independently addressable module initializer. Running these after imports makes referenced imported schemas ordinary lexical inputs while keeping the cached artifact immutable and relocatable. A module may export more schema bytecode than one u16-addressed chunk can hold; declaration-sized chunks remove that package-wide limit without weakening any schema.
Sourcepub fn compile_selected_public_type_schema_initializers(
program: &[SNode],
source_file: Option<String>,
selected_names: Option<&BTreeSet<String>>,
) -> Result<Vec<Chunk>, CompileError>
pub fn compile_selected_public_type_schema_initializers( program: &[SNode], source_file: Option<String>, selected_names: Option<&BTreeSet<String>>, ) -> Result<Vec<Chunk>, CompileError>
Compile the selected exported type schemas. None preserves the
caller-independent full-module behavior; a closed-program linker passes
the exact runtime type names its consumers can observe.
Sourcepub fn compile(self, program: &[SNode]) -> Result<Chunk, CompileError>
pub fn compile(self, program: &[SNode]) -> Result<Chunk, CompileError>
Compile a program (list of top-level nodes) into a Chunk. Finds the entry pipeline and compiles its body, including inherited bodies.
Sourcepub fn compile_named(
self,
program: &[SNode],
pipeline_name: &str,
) -> Result<Chunk, CompileError>
pub fn compile_named( self, program: &[SNode], pipeline_name: &str, ) -> Result<Chunk, CompileError>
Compile a specific named pipeline (for test runners).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Compiler
impl RefUnwindSafe for Compiler
impl Send for Compiler
impl Sync for Compiler
impl Unpin for Compiler
impl UnsafeUnpin for Compiler
impl UnwindSafe for Compiler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);