Struct ExpressionVisitor

Source
pub struct ExpressionVisitor<'a> {
    context: &'a mut CompilationContext,
    current_return_type: Option<TypeId>,
}
Expand description

Handles semantic analysis for all expression types

This visitor is responsible for analyzing expression-level constructs including binary operations, unary operations, function calls, variable references, literals, conditionals, and block expressions.

Fields§

§context: &'a mut CompilationContext§current_return_type: Option<TypeId>

Implementations§

Source§

impl<'a> ExpressionVisitor<'a>

Source

pub fn new(context: &'a mut CompilationContext) -> Self

Create a new expression visitor

§Arguments
  • context - The compilation context for type information and symbol lookup
Source

pub fn with_return_type( context: &'a mut CompilationContext, current_return_type: Option<TypeId>, ) -> Self

Create a new expression visitor with a specific return type context

§Arguments
  • context - The compilation context for type information and symbol lookup
  • current_return_type - The current function’s return type for validation
Source

pub fn set_return_type(&mut self, return_type: Option<TypeId>)

Set the current return type for function analysis

Source

fn create_type_coordinator(&self) -> TypeCheckingCoordinator<'_>

Create a type checking coordinator for this visitor’s context

Source

pub fn visit_expression(&mut self, expr: &Expression) -> SemanticResult

Visit an expression and determine its type

Source

pub fn visit_binary_expression( &mut self, bin_expr: &BinaryExpr, ) -> SemanticResult

Visit a binary expression

Source

pub fn visit_unary_expression( &mut self, unary_expr: &UnaryExpr, ) -> SemanticResult

Visit a unary expression

Source

pub fn visit_call_expression( &mut self, call_expr: &FunctionCallExpr, ) -> SemanticResult

Visit a function call expression

Source

pub fn visit_variable_expression( &mut self, var_expr: &VariableExpr, ) -> SemanticResult

Visit a variable expression

Source

pub fn visit_literal_expression( &mut self, literal_expr: &LiteralExpr, ) -> SemanticResult

Visit a literal expression

Source

pub fn visit_conditional_expression( &mut self, cond_expr: &ConditionalExpr, ) -> SemanticResult

Visit a conditional expression

Source

pub fn visit_block_expression( &mut self, block_expr: &BlockExpr, ) -> SemanticResult

Visit a block expression

Source

pub fn visit_function_type_expression( &mut self, func_type_expr: &FunctionTypeExpr, ) -> SemanticResult

Visit a function type expression

Source

fn resolve_value(&self, name: &str) -> Option<&Symbol>

Resolve a symbol that can be used as a value (variables and functions)

Auto Trait Implementations§

§

impl<'a> Freeze for ExpressionVisitor<'a>

§

impl<'a> RefUnwindSafe for ExpressionVisitor<'a>

§

impl<'a> Send for ExpressionVisitor<'a>

§

impl<'a> Sync for ExpressionVisitor<'a>

§

impl<'a> Unpin for ExpressionVisitor<'a>

§

impl<'a> !UnwindSafe for ExpressionVisitor<'a>

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, 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.