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
impl BytecodeCompiler
Sourcepub fn type_tracker(&self) -> &TypeTracker
pub fn type_tracker(&self) -> &TypeTracker
Get the type tracker (for external configuration)
Sourcepub fn type_tracker_mut(&mut self) -> &mut TypeTracker
pub fn type_tracker_mut(&mut self) -> &mut TypeTracker
Get mutable type tracker (for registering types)
Source§impl BytecodeCompiler
impl BytecodeCompiler
Sourcepub fn register_imported_items(&mut self, items: &[Item])
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
impl BytecodeCompiler
pub fn new() -> Self
Sourcepub fn set_comptime_mode(&mut self, enabled: bool)
pub fn set_comptime_mode(&mut self, enabled: bool)
Enable comptime compilation mode for this compiler instance.
Sourcepub fn set_blob_cache(&mut self, cache: BlobCache)
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.
Sourcepub fn register_known_export(&mut self, function_name: &str, module_path: &str)
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’?”
Sourcepub fn register_known_exports(&mut self, exports: &HashMap<String, String>)
pub fn register_known_exports(&mut self, exports: &HashMap<String, String>)
Register multiple known exports at once
Sourcepub fn suggest_import(&self, function_name: &str) -> Option<&str>
pub fn suggest_import(&self, function_name: &str) -> Option<&str>
Suggest an import for an unknown function
Sourcepub fn set_source(&mut self, source: &str)
pub fn set_source(&mut self, source: &str)
Set the source text for error messages
Sourcepub fn set_source_with_file(&mut self, source: &str, file_name: &str)
pub fn set_source_with_file(&mut self, source: &str, file_name: &str)
Set the source text and file name for error messages
Sourcepub fn set_line_from_span(&mut self, span: Span)
pub fn set_line_from_span(&mut self, span: Span)
Set line from a Span (converts byte offset to line number)
Sourcepub fn get_source_line(&self, line: usize) -> Option<&str>
pub fn get_source_line(&self, line: usize) -> Option<&str>
Get a source line by line number (1-indexed)
Sourcepub fn register_known_bindings(&mut self, names: &[String])
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.
Sourcepub fn with_schema(schema: DataFrameSchema) -> Self
pub fn with_schema(schema: DataFrameSchema) -> Self
Create a new compiler with a data schema for column resolution. This enables optimized GetDataField/GetDataRow opcodes.
Sourcepub fn set_schema(&mut self, schema: DataFrameSchema)
pub fn set_schema(&mut self, schema: DataFrameSchema)
Set the data schema for column resolution. Must be called before compiling data access expressions.
Sourcepub fn set_source_dir(&mut self, dir: PathBuf)
pub fn set_source_dir(&mut self, dir: PathBuf)
Set the source directory for resolving relative source file paths.
Sourcepub fn with_extensions(self, extensions: Vec<ModuleExports>) -> Self
pub fn with_extensions(self, extensions: Vec<ModuleExports>) -> Self
Set extension modules for comptime execution.
Sourcepub fn set_type_diagnostic_mode(&mut self, mode: TypeDiagnosticMode)
pub fn set_type_diagnostic_mode(&mut self, mode: TypeDiagnosticMode)
Configure how shared analyzer diagnostics are emitted.
Sourcepub fn set_compile_diagnostic_mode(&mut self, mode: CompileDiagnosticMode)
pub fn set_compile_diagnostic_mode(&mut self, mode: CompileDiagnosticMode)
Configure expression-compilation error recovery behavior.
Sourcepub fn set_permission_set(&mut self, permissions: Option<PermissionSet>)
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
impl BytecodeCompiler
Sourcepub fn compile(self, program: &Program) -> Result<BytecodeProgram>
pub fn compile(self, program: &Program) -> Result<BytecodeProgram>
Compile a program to bytecode
Sourcepub fn compile_with_source(
self,
program: &Program,
source: &str,
) -> Result<BytecodeProgram>
pub fn compile_with_source( self, program: &Program, source: &str, ) -> Result<BytecodeProgram>
Compile a program to bytecode with source text for error messages
Sourcepub fn compile_module_ast(
module_ast: &Program,
) -> Result<(BytecodeProgram, HashMap<String, usize>)>
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§
Auto Trait Implementations§
impl Freeze for BytecodeCompiler
impl !RefUnwindSafe for BytecodeCompiler
impl Send for BytecodeCompiler
impl Sync for BytecodeCompiler
impl Unpin for BytecodeCompiler
impl UnsafeUnpin for BytecodeCompiler
impl !UnwindSafe for BytecodeCompiler
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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