Skip to main content

BytecodeCompiler

Struct BytecodeCompiler 

Source
pub struct BytecodeCompiler {
    pub stdlib_function_names: HashSet<String>,
    /* private fields */
}
Expand description

Compiler state

Fields§

§stdlib_function_names: HashSet<String>

Legacy cache of function names collected from stdlib-loaded modules.

Internal builtin access is now gated by per-definition declaring-module provenance, not by membership in this set.

Implementations§

Source§

impl BytecodeCompiler

Source

pub fn type_tracker(&self) -> &TypeTracker

Get the type tracker (for external configuration)

Source

pub fn type_tracker_mut(&mut self) -> &mut TypeTracker

Get mutable type tracker (for registering types)

Source§

impl BytecodeCompiler

Source

pub fn register_imported_items(&mut self, items: &[Item])

Pre-register items from an imported module (enums, struct types, functions).

Called by the LSP before compilation to make imported enums/types known to the compiler’s type tracker. Reuses register_enum as single source of truth.

Source§

impl BytecodeCompiler

Source

pub fn new() -> Self

Source

pub fn set_comptime_mode(&mut self, enabled: bool)

Enable comptime compilation mode for this compiler instance.

Source

pub fn set_blob_cache(&mut self, cache: BlobCache)

Attach a blob-level cache for incremental compilation.

When set, finalize_current_blob stores each compiled blob in the cache, and build_content_addressed_program populates the function store from cached blobs when possible.

Source

pub fn register_known_export(&mut self, function_name: &str, module_path: &str)

Register a known export for import suggestions

This enables helpful error messages like: “Unknown function ‘sma’. Did you mean to import from ‘@stdlib/finance/indicators/moving_averages’?”

Source

pub fn register_known_exports(&mut self, exports: &HashMap<String, String>)

Register multiple known exports at once

Source

pub fn suggest_import(&self, function_name: &str) -> Option<&str>

Suggest an import for an unknown function

Source

pub fn set_source(&mut self, source: &str)

Set the source text for error messages

Source

pub fn set_source_with_file(&mut self, source: &str, file_name: &str)

Set the source text and file name for error messages

Source

pub fn set_line(&mut self, line: u32)

Set the current source line (from AST span)

Source

pub fn set_line_from_span(&mut self, span: Span)

Set line from a Span (converts byte offset to line number)

Source

pub fn get_source_line(&self, line: usize) -> Option<&str>

Get a source line by line number (1-indexed)

Source

pub fn register_known_bindings(&mut self, names: &[String])

Pre-register known root-scope bindings (for REPL persistence)

Call this before compilation to register bindings from previous REPL sessions. This ensures that references to these bindings compile to LoadModuleBinding/StoreModuleBinding instructions rather than causing “Undefined variable” errors.

Source

pub fn with_schema(schema: DataFrameSchema) -> Self

Create a new compiler with a data schema for column resolution. This enables optimized GetDataField/GetDataRow opcodes.

Source

pub fn set_schema(&mut self, schema: DataFrameSchema)

Set the data schema for column resolution. Must be called before compiling data access expressions.

Source

pub fn set_source_dir(&mut self, dir: PathBuf)

Set the source directory for resolving relative source file paths.

Source

pub fn with_extensions(self, extensions: Vec<ModuleExports>) -> Self

Set extension modules for comptime execution.

Source

pub fn set_type_diagnostic_mode(&mut self, mode: TypeDiagnosticMode)

Configure how shared analyzer diagnostics are emitted.

Source

pub fn set_compile_diagnostic_mode(&mut self, mode: CompileDiagnosticMode)

Configure expression-compilation error recovery behavior.

Source

pub fn set_permission_set(&mut self, permissions: Option<PermissionSet>)

Set the active permission set for compile-time capability checking.

When set, imports that require permissions not in this set will produce compile errors. Pass None to disable checking (default).

Source§

impl BytecodeCompiler

Source

pub fn compile(self, program: &Program) -> Result<BytecodeProgram>

Compile a program to bytecode

Source

pub fn compile_with_source( self, program: &Program, source: &str, ) -> Result<BytecodeProgram>

Compile a program to bytecode with source text for error messages

Source

pub fn compile_module_ast( module_ast: &Program, ) -> Result<(BytecodeProgram, HashMap<String, usize>)>

Compile an imported module’s AST to a standalone BytecodeProgram.

This takes the Module’s AST (Program), compiles all exported functions to bytecode, and returns the compiled program along with a mapping of exported function names to their function indices in the compiled output.

The returned BytecodeProgram and function name mapping allow the import handler to resolve imported function calls to the correct bytecode indices.

Currently handles function exports only. Types and values can be added later.

Trait Implementations§

Source§

impl Default for BytecodeCompiler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more