Skip to main content

TypeChecker

Struct TypeChecker 

Source
pub struct TypeChecker { /* private fields */ }

Implementations§

Source§

impl TypeChecker

Source

pub fn check_array_literal( &mut self, elements: &[Expr], expected_type: Option<&Type>, ) -> Result<Type>

Source

pub fn check_map_literal( &mut self, entries: &[(Expr, Expr)], expected_type: Option<&Type>, ) -> Result<Type>

Source

pub fn check_struct_literal( &mut self, span: Span, name: &str, fields: &[StructLiteralField], ) -> Result<Type>

Source

pub fn check_lambda( &mut self, params: &[(String, Option<Type>)], return_type: Option<&Type>, body: &Expr, ) -> Result<Type>

Source

pub fn check_if_expr( &mut self, condition: &Expr, then_branch: &Expr, else_branch: &Option<Box<Expr>>, ) -> Result<Type>

Source§

impl TypeChecker

Source

pub fn check_expr(&mut self, expr: &Expr) -> Result<Type>

Source

pub fn check_expr_with_hint( &mut self, expr: &Expr, expected_type: Option<&Type>, ) -> Result<Type>

Source§

impl TypeChecker

Source

pub fn check_literal(&self, lit: &Literal) -> Result<Type>

Source

pub fn check_binary_expr( &mut self, span: Span, left: &Expr, op: &BinaryOp, right: &Expr, ) -> Result<Type>

Source

pub fn check_unary_expr(&mut self, op: &UnaryOp, operand: &Expr) -> Result<Type>

Source

pub fn check_call_expr( &mut self, span: Span, callee: &Expr, args: &[Expr], ) -> Result<Type>

Source

pub fn check_method_call( &mut self, receiver: &Expr, method: &str, args: &[Expr], ) -> Result<Type>

Source

pub fn check_field_access_with_hint( &mut self, span: Span, object: &Expr, field: &str, expected_type: Option<&Type>, ) -> Result<Type>

Source

pub fn check_index_expr(&mut self, object: &Expr, index: &Expr) -> Result<Type>

Source§

impl TypeChecker

Source

pub fn validate_is_pattern( &mut self, pattern: &Pattern, scrutinee_type: &Type, ) -> Result<()>

Source

pub fn extract_type_narrowings_from_expr( &mut self, expr: &Expr, ) -> Vec<(String, Type)>

Source

pub fn extract_all_pattern_bindings_from_expr<'a>( &self, expr: &'a Expr, ) -> Vec<(&'a Expr, Pattern)>

Source

pub fn bind_pattern( &mut self, pattern: &Pattern, scrutinee_type: &Type, ) -> Result<()>

Source§

impl TypeChecker

Source

pub fn new() -> Self

Source

pub fn with_config(config: &LustConfig) -> Self

Source

pub fn check_module(&mut self, items: &[Item]) -> Result<()>

Source

pub fn check_program(&mut self, modules: &[LoadedModule]) -> Result<()>

Source

pub fn set_imports_by_module(&mut self, map: HashMap<String, ModuleImports>)

Source

pub fn take_type_info(&mut self) -> TypeCollection

Source

pub fn take_option_coercions(&mut self) -> HashMap<String, HashSet<Span>>

Source

pub fn function_signatures(&self) -> HashMap<String, FunctionSignature>

Source

pub fn struct_definitions(&self) -> HashMap<String, StructDef>

Source

pub fn enum_definitions(&self) -> HashMap<String, EnumDef>

Source

pub fn resolve_function_key(&self, name: &str) -> String

Source

pub fn resolve_value_key(&self, name: &str) -> String

Source

pub fn resolve_module_alias(&self, alias: &str) -> Option<String>

Source

pub fn register_external_struct(&mut self, def: StructDef) -> Result<()>

Source

pub fn register_external_enum(&mut self, def: EnumDef) -> Result<()>

Source

pub fn register_external_trait(&mut self, def: TraitDef) -> Result<()>

Source

pub fn register_external_function( &mut self, (name, signature): (String, FunctionSignature), ) -> Result<()>

Source

pub fn register_external_constant( &mut self, name: String, ty: Type, ) -> Result<()>

Source

pub fn register_external_impl(&mut self, impl_block: ImplBlock) -> Result<()>

Source

pub fn resolve_type_key(&self, name: &str) -> String

Source

pub fn canonicalize_type(&self, ty: &Type) -> Type

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

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

Source§

fn vzip(self) -> V