Struct gluon_check::typecheck::Typecheck
source · pub struct Typecheck<'a, 'ast> { /* private fields */ }
Expand description
Struct which provides methods to typecheck expressions.
Implementations§
source§impl<'a, 'ast> Typecheck<'a, 'ast>
impl<'a, 'ast> Typecheck<'a, 'ast>
sourcepub fn new(
module: String,
symbols: &'a mut Symbols,
environment: &'a (dyn TypecheckEnv<Type = ArcType> + 'a),
interner: &TypeCache<Symbol, ArcType>,
metadata: &'a mut FnvMap<Symbol, Arc<Metadata>>,
ast_arena: ArenaRef<'a, 'ast, Symbol>
) -> Self
pub fn new( module: String, symbols: &'a mut Symbols, environment: &'a (dyn TypecheckEnv<Type = ArcType> + 'a), interner: &TypeCache<Symbol, ArcType>, metadata: &'a mut FnvMap<Symbol, Arc<Metadata>>, ast_arena: ArenaRef<'a, 'ast, Symbol> ) -> Self
Create a new typechecker which typechecks expressions in module
sourcepub fn typecheck_expr(
&mut self,
expr: &mut SpannedExpr<'ast, Symbol>
) -> Result<ArcType, Error>
pub fn typecheck_expr( &mut self, expr: &mut SpannedExpr<'ast, Symbol> ) -> Result<ArcType, Error>
Typecheck expr
. If successful the type of the expression will be returned and all
identifiers in expr
will be filled with the inferred type
pub fn typecheck_expr_expected( &mut self, expr: &mut SpannedExpr<'ast, Symbol>, expected_type: Option<&ArcType> ) -> Result<ArcType, Error>
Trait Implementations§
source§impl<'a> TypeContext<Symbol, ArcType> for Typecheck<'a, '_>
impl<'a> TypeContext<Symbol, ArcType> for Typecheck<'a, '_>
fn intern(&mut self, typ: Type<Symbol, RcType>) -> RcType
fn intern_types( &mut self, types: impl IntoIterator<Item = RcType> ) -> <RcType as TypePtr>::Types
fn intern_generics( &mut self, types: impl IntoIterator<Item = Generic<Symbol>> ) -> <RcType as TypePtr>::Generics
fn intern_fields( &mut self, types: impl IntoIterator<Item = Field<<RcType as TypePtr>::SpannedId, RcType>> ) -> <RcType as TypePtr>::Fields
fn intern_type_fields( &mut self, types: impl IntoIterator<Item = Field<<RcType as TypePtr>::SpannedId, Alias<Symbol, RcType>>> ) -> <RcType as TypePtr>::TypeFields
fn intern_flags(&mut self, typ: Type<Symbol, RcType>, flags: Flags) -> RcType
fn builtin(&mut self, typ: BuiltinType) -> RcType
fn forall( &mut self, params: <RcType as TypePtr>::Generics, typ: RcType ) -> RcType
fn with_forall(&mut self, typ: RcType, from: &RcType) -> RcType
fn array(&mut self, typ: RcType) -> RcType
fn app(&mut self, id: RcType, args: <RcType as TypePtr>::Types) -> RcType
fn variant(&mut self, fields: <RcType as TypePtr>::Fields) -> RcType
fn poly_variant( &mut self, fields: <RcType as TypePtr>::Fields, rest: RcType ) -> RcType
fn effect(&mut self, fields: <RcType as TypePtr>::Fields) -> RcType
fn poly_effect( &mut self, fields: <RcType as TypePtr>::Fields, rest: RcType ) -> RcType
fn record( &mut self, types: <RcType as TypePtr>::TypeFields, fields: <RcType as TypePtr>::Fields ) -> RcType
fn poly_record( &mut self, types: <RcType as TypePtr>::TypeFields, fields: <RcType as TypePtr>::Fields, rest: RcType ) -> RcType
fn extend_full_row( &mut self, types: <RcType as TypePtr>::TypeFields, fields: <RcType as TypePtr>::Fields, rest: RcType ) -> RcType
fn extend_row( &mut self, fields: <RcType as TypePtr>::Fields, rest: RcType ) -> RcType
fn extend_type_row( &mut self, types: <RcType as TypePtr>::TypeFields, rest: RcType ) -> RcType
fn generic(&mut self, typ: Generic<Symbol>) -> RcType
fn skolem(&mut self, typ: Skolem<Symbol>) -> RcType
fn variable(&mut self, typ: TypeVariable) -> RcType
fn alias( &mut self, name: Symbol, args: <RcType as TypePtr>::Generics, typ: RcType ) -> RcType
fn ident(&mut self, id: KindedIdent<Symbol>) -> RcType
fn projection(&mut self, id: AppVec<Symbol>) -> RcType
fn builtin_type(&mut self, typ: BuiltinType) -> RcType
fn new_alias( &mut self, name: Symbol, args: <RcType as TypePtr>::Generics, typ: RcType ) -> Alias<Symbol, RcType>
fn new_data_alias( &mut self, data: AliasData<Symbol, RcType> ) -> Alias<Symbol, RcType>
fn alias_group( &mut self, group: Vec<AliasData<Symbol, RcType>> ) -> Vec<Alias<Symbol, RcType>>
fn hole(&mut self) -> RcType
fn opaque(&mut self) -> RcType
fn error(&mut self) -> RcType
fn array_builtin(&mut self) -> RcType
fn empty_row(&mut self) -> RcType
fn function_builtin(&mut self) -> RcType
fn string(&mut self) -> RcType
fn char(&mut self) -> RcType
fn byte(&mut self) -> RcType
fn int(&mut self) -> RcType
fn float(&mut self) -> RcType
fn unit(&mut self) -> RcType
fn tuple<S, I>(&mut self, symbols: &mut S, elems: I) -> T
fn tuple_<S, I>(&mut self, symbols: &mut S, elems: I) -> Type<Id, T>
fn function<I>(&mut self, args: I, ret: T) -> T
fn function_implicit<I>(&mut self, args: I, ret: T) -> T
fn function_type<I>(&mut self, arg_type: ArgType, args: I, ret: T) -> T
Auto Trait Implementations§
impl<'a, 'ast> !RefUnwindSafe for Typecheck<'a, 'ast>
impl<'a, 'ast> !Send for Typecheck<'a, 'ast>
impl<'a, 'ast> !Sync for Typecheck<'a, 'ast>
impl<'a, 'ast> Unpin for Typecheck<'a, 'ast>
impl<'a, 'ast> !UnwindSafe for Typecheck<'a, 'ast>
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
Mutably borrows from an owned value. Read more