pub struct TypeState {
pub trait_impls: TraitImplList,
pub trace_stack: Arc<TraceStack>,
pub use_wordlenght_inference: bool,
/* private fields */
}Expand description
State of the type inference algorithm
Fields§
§trait_impls: TraitImplList§trace_stack: Arc<TraceStack>§use_wordlenght_inference: bool(Experimental) Use Affine- or Interval-Arithmetic to bounds check integers in a separate module.
Implementations§
Source§impl TypeState
impl TypeState
pub fn visit_identifier( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, ) -> Result<()>
pub fn visit_type_level_integer( &mut self, expression: &Loc<Expression>, generic_list: &GenericListToken, ctx: &Context<'_>, ) -> Result<()>
pub fn visit_pipeline_ref( &mut self, expression: &Loc<Expression>, generic_list: &GenericListToken, ctx: &Context<'_>, ) -> Result<()>
pub fn visit_int_literal( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, ) -> Result<()>
pub fn visit_bool_literal( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, ) -> Result<()>
pub fn visit_bit_literal( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, ) -> Result<()>
pub fn visit_tuple_literal( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_tuple_index( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_field_access( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_method_call( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_array_literal( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_array_shorthand_literal( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_create_ports( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, _generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_index( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_range_index( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_block_expr( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_if( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_match( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_binary_operator( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_unary_operator( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
Source§impl TypeState
impl TypeState
pub fn type_decl_to_concrete( decl: &TypeDeclaration, type_list: &TypeList, params: Vec<ConcreteType>, invert: bool, ) -> ConcreteType
pub fn type_expr_to_concrete( expr: &TypeExpression, type_list: &TypeList, generic_substitutions: &HashMap<NameID, &ConcreteType>, invert: bool, ) -> ConcreteType
pub fn type_spec_to_concrete( spec: &TypeSpec, type_list: &TypeList, generic_substitutions: &HashMap<NameID, &ConcreteType>, invert: bool, ) -> ConcreteType
pub fn inner_ungenerify_type( var: &TypeVar, symtab: &SymbolTable, type_list: &TypeList, invert: bool, ) -> Option<ConcreteType>
Sourcepub fn ungenerify_type(
var: &TypeVar,
symtab: &SymbolTable,
type_list: &TypeList,
) -> Option<ConcreteType>
pub fn ungenerify_type( var: &TypeVar, symtab: &SymbolTable, type_list: &TypeList, ) -> Option<ConcreteType>
Converts the specified type to a concrete type, returning None if it fails
Sourcepub fn concrete_type_of_infallible(
&self,
id: ExprID,
symtab: &SymbolTable,
type_list: &TypeList,
) -> ConcreteType
pub fn concrete_type_of_infallible( &self, id: ExprID, symtab: &SymbolTable, type_list: &TypeList, ) -> ConcreteType
Returns the type of the specified expression ID as a concrete type. If the type is not known, or the type is Generic, panics
Sourcepub fn concrete_type_of(
&self,
id: impl HasConcreteType,
symtab: &SymbolTable,
types: &TypeList,
) -> Result<ConcreteType, Diagnostic>
pub fn concrete_type_of( &self, id: impl HasConcreteType, symtab: &SymbolTable, types: &TypeList, ) -> Result<ConcreteType, Diagnostic>
Returns the concrete type of anything that might have a concrete type. Errors if the type is not fully known.
Sourcepub fn concrete_type_of_name(
&self,
name: &Loc<NameID>,
symtab: &SymbolTable,
types: &TypeList,
) -> Result<ConcreteType, Diagnostic>
pub fn concrete_type_of_name( &self, name: &Loc<NameID>, symtab: &SymbolTable, types: &TypeList, ) -> Result<ConcreteType, Diagnostic>
Like concrete_type_of but reports an error message that mentions names
instead of an expression
Source§impl TypeState
impl TypeState
pub fn new() -> Self
pub fn set_wordlength_inferece(self, use_wordlenght_inference: bool) -> Self
pub fn get_equations(&self) -> &TypeEquations
pub fn get_constraints(&self) -> &TypeConstraints
pub fn get_generic_list<'a>( &'a self, generic_list_token: &'a GenericListToken, ) -> &'a HashMap<NameID, TypeVar>
pub fn type_var_from_hir<'a>( &'a mut self, loc: Loc<()>, hir_type: &TypeSpec, generic_list_token: &GenericListToken, ) -> Result<TypeVar>
Sourcepub fn type_of(&self, expr: &TypedExpression) -> Result<TypeVar>
pub fn type_of(&self, expr: &TypedExpression) -> Result<TypeVar>
Returns the type of the expression with the specified id. Error if no equation for the specified expression exists
pub fn new_generic_int(&mut self, loc: Loc<()>, symtab: &SymbolTable) -> TypeVar
Sourcepub fn new_split_generic_int(
&mut self,
loc: Loc<()>,
symtab: &SymbolTable,
) -> (TypeVar, TypeVar)
pub fn new_split_generic_int( &mut self, loc: Loc<()>, symtab: &SymbolTable, ) -> (TypeVar, TypeVar)
Return a new generic int. The first returned value is int
pub fn new_split_generic_uint( &mut self, loc: Loc<()>, symtab: &SymbolTable, ) -> (TypeVar, TypeVar)
pub fn new_generic_with_meta(&mut self, loc: Loc<()>, meta: MetaType) -> TypeVar
pub fn new_generic_type(&mut self, loc: Loc<()>) -> TypeVar
pub fn new_generic_any(&mut self) -> TypeVar
pub fn new_generic_tlbool(&mut self, loc: Loc<()>) -> TypeVar
pub fn new_generic_tluint(&mut self, loc: Loc<()>) -> TypeVar
pub fn new_generic_tlint(&mut self, loc: Loc<()>) -> TypeVar
pub fn new_generic_tlnumber(&mut self, loc: Loc<()>) -> TypeVar
pub fn new_generic_number( &mut self, loc: Loc<()>, ctx: &Context<'_>, ) -> (TypeVar, TypeVar)
pub fn new_generic_with_traits( &mut self, loc: Loc<()>, traits: TraitList, ) -> TypeVar
Sourcepub fn get_pipeline_state<T>(
&self,
access_loc: &Loc<T>,
) -> Result<&PipelineState>
pub fn get_pipeline_state<T>( &self, access_loc: &Loc<T>, ) -> Result<&PipelineState>
Returns the current pipeline state. access_loc is not used to specify where to get the
state from, it is only used for the Diagnostic::bug that gets emitted if there is no
pipeline state
pub fn visit_unit( &mut self, entity: &Loc<Unit>, ctx: &Context<'_>, ) -> Result<()>
pub fn visit_expression( &mut self, expression: &Loc<Expression>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn handle_concat( &mut self, expression_id: Loc<ExprID>, source_lhs_ty: TypeVar, source_rhs_ty: TypeVar, source_result_ty: TypeVar, args: &[Argument<'_, Expression, TypeSpec>], ctx: &Context<'_>, ) -> Result<()>
pub fn handle_trunc( &mut self, expression_id: Loc<ExprID>, source_in_ty: TypeVar, source_result_ty: TypeVar, args: &[Argument<'_, Expression, TypeSpec>], ctx: &Context<'_>, ) -> Result<()>
pub fn handle_comb_mod_or_div( &mut self, n_ty: TypeVar, args: &[Argument<'_, Expression, TypeSpec>], ctx: &Context<'_>, ) -> Result<()>
pub fn handle_clocked_memory( &mut self, num_elements: TypeVar, addr_size_arg: TypeVar, args: &[Argument<'_, Expression, TypeSpec>], ctx: &Context<'_>, ) -> Result<()>
pub fn handle_read_memory( &mut self, num_elements: TypeVar, addr_size_arg: TypeVar, args: &[Argument<'_, Expression, TypeSpec>], ctx: &Context<'_>, ) -> Result<()>
pub fn create_generic_list( &mut self, source: GenericListSource<'_>, type_params: &[Loc<TypeParam>], scope_type_params: &[Loc<TypeParam>], turbofish: Option<TurbofishCtx<'_>>, where_clauses: &[Loc<WhereClause>], ) -> Result<GenericListToken>
Sourcepub fn add_mapped_generic_list(
&mut self,
source: GenericListSource<'_>,
mapping: HashMap<NameID, TypeVar>,
) -> GenericListToken
pub fn add_mapped_generic_list( &mut self, source: GenericListSource<'_>, mapping: HashMap<NameID, TypeVar>, ) -> GenericListToken
Adds a generic list with parameters already mapped to types
pub fn visit_block( &mut self, block: &Block, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_impl_blocks( &mut self, item_list: &ItemList, ) -> Result<TraitImplList>
pub fn visit_pattern( &mut self, pattern: &Loc<Pattern>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_wal_trace( &mut self, trace: &Loc<WalTrace>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_statement( &mut self, stmt: &Loc<Statement>, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_register( &mut self, reg: &Register, ctx: &Context<'_>, generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_trait_spec( &mut self, trait_spec: &Loc<TraitSpec>, generic_list: &GenericListToken, ) -> Result<Loc<TraitReq>>
pub fn visit_trait_bounds( &mut self, target: &Loc<NameID>, traits: &[Loc<TraitSpec>], generic_list: &GenericListToken, ) -> Result<()>
pub fn visit_const_generic_with_id( &mut self, gen: &Loc<ConstGenericWithId>, generic_list_token: &GenericListToken, constraint_source: ConstraintSource, ctx: &Context<'_>, ) -> Result<TypeVar>
pub fn visit_const_generic( &self, constraint: &ConstGeneric, generic_list: &GenericListToken, ) -> Result<ConstraintExpr>
Source§impl TypeState
impl TypeState
pub fn add_equation(&mut self, expression: TypedExpression, var: TypeVar)
pub fn unify( &mut self, e1: &impl HasType, e2: &impl HasType, ctx: &Context<'_>, ) -> Result<TypeVar, UnificationError>
pub fn unify_expression_generic_error( &mut self, expr: &Loc<Expression>, other: &impl HasType, ctx: &Context<'_>, ) -> Result<TypeVar>
pub fn check_requirements(&mut self, ctx: &Context<'_>) -> Result<()>
Source§impl TypeState
impl TypeState
pub fn print_equations(&self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TypeState
impl RefUnwindSafe for TypeState
impl Send for TypeState
impl Sync for TypeState
impl Unpin for TypeState
impl UnwindSafe for TypeState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.