pub struct SemanticAnalyzer { /* private fields */ }Expand description
The main semantic analyzer
Implementations§
Source§impl SemanticAnalyzer
Implementation of pattern analysis methods for SemanticAnalyzer
impl SemanticAnalyzer
Implementation of pattern analysis methods for SemanticAnalyzer
Sourcepub fn list_available_patterns(&self) -> Vec<String>
pub fn list_available_patterns(&self) -> Vec<String>
Get list of all available patterns (user-defined + built-in)
Source§impl SemanticAnalyzer
impl SemanticAnalyzer
Sourcepub fn with_source(self, source: impl Into<String>) -> Self
pub fn with_source(self, source: impl Into<String>) -> Self
Set the source code for better error location reporting (builder pattern)
Sourcepub fn set_source(&mut self, source: impl Into<String>)
pub fn set_source(&mut self, source: impl Into<String>)
Set the source code for error location reporting (mutable reference)
Sourcepub fn check_expr_type(&mut self, expr: &Expr) -> Result<Type>
pub fn check_expr_type(&mut self, expr: &Expr) -> Result<Type>
Check the type of an expression using the inference engine
This is the main bridge method that replaces the legacy type checker. It infers the type and converts the result to the legacy Type enum.
Sourcepub fn register_extension_modules(&mut self, modules: &[ParsedModuleSchema])
pub fn register_extension_modules(&mut self, modules: &[ParsedModuleSchema])
Register extension module namespaces with their export type schemas. Each module becomes a Symbol::Module with a concrete Object type annotation. Must be called before analyze() so the type system recognizes modules.
Sourcepub fn error_at(&self, span: Span, message: impl Into<String>) -> ShapeError
pub fn error_at(&self, span: Span, message: impl Into<String>) -> ShapeError
Create a semantic error with location information from a span
Sourcepub fn error_at_with_hint(
&self,
span: Span,
message: impl Into<String>,
hint: impl Into<String>,
) -> ShapeError
pub fn error_at_with_hint( &self, span: Span, message: impl Into<String>, hint: impl Into<String>, ) -> ShapeError
Create a semantic error with location and a hint
Sourcepub fn add_warning(&mut self, span: Span, message: impl Into<String>)
pub fn add_warning(&mut self, span: Span, message: impl Into<String>)
Add a type warning (not an error, analysis continues)
Sourcepub fn snapshot(&self) -> SemanticSnapshot
pub fn snapshot(&self) -> SemanticSnapshot
Snapshot semantic analyzer state for resumability.
Sourcepub fn restore_from_snapshot(&mut self, snapshot: SemanticSnapshot)
pub fn restore_from_snapshot(&mut self, snapshot: SemanticSnapshot)
Restore semantic analyzer state from a snapshot.
Sourcepub fn warnings(&self) -> &[TypeWarning]
pub fn warnings(&self) -> &[TypeWarning]
Get all warnings generated during analysis
Sourcepub fn take_warnings(&mut self) -> Vec<TypeWarning>
pub fn take_warnings(&mut self) -> Vec<TypeWarning>
Take ownership of warnings (clears the internal list)
Sourcepub fn analyze(&mut self, program: &Program) -> Result<()>
pub fn analyze(&mut self, program: &Program) -> Result<()>
Analyze a complete program (script mode - isolated execution)
Creates a fresh scope for this program and pops it after analysis. Each call is isolated - no state persists between calls. Collects all semantic errors and reports them together.
Sourcepub fn analyze_incremental(&mut self, program: &Program) -> Result<()>
pub fn analyze_incremental(&mut self, program: &Program) -> Result<()>
Analyze a program incrementally (REPL mode - persistent state)
Variables and functions defined in previous calls remain visible.
Call init_repl_scope() once before the first analyze_incremental() call.
Sourcepub fn init_repl_scope(&mut self)
pub fn init_repl_scope(&mut self)
Initialize the REPL scope (call once before first analyze_incremental)
Pushes a user scope that will persist across all incremental analyses.
Sourcepub fn lookup_type_alias(&self, name: &str) -> Option<&TypeAliasEntry>
pub fn lookup_type_alias(&self, name: &str) -> Option<&TypeAliasEntry>
Look up a type alias (for runtime type resolution)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SemanticAnalyzer
impl RefUnwindSafe for SemanticAnalyzer
impl Send for SemanticAnalyzer
impl Sync for SemanticAnalyzer
impl Unpin for SemanticAnalyzer
impl UnsafeUnpin for SemanticAnalyzer
impl UnwindSafe for SemanticAnalyzer
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