pub(super) struct Regular {
pub arity: usize,
pub constructors: ConstructorSet,
pub scalars: ScalarSet,
pub conclude: ConclusionRule,
}Expand description
Overload sets represented as sets of scalars and constructors.
This type represents an OverloadSet using a bitset of scalar
types and a bitset of type constructors that might be applied to
those scalars. The overload set contains a rule for every possible
combination of scalars and constructors, essentially the cartesian
product of the two sets.
For example, if the arity is 2, set of scalars is { AbstractFloat,
f32 }, and the set of constructors is { vec2, vec3 }, then
that represents the set of overloads:
- (
vec2<AbstractFloat>,vec2<AbstractFloat>) ->vec2<AbstractFloat> - (
vec2<f32>,vec2<f32>) ->vec2<f32> - (
vec3<AbstractFloat>,vec3<AbstractFloat>) ->vec3<AbstractFloat> - (
vec3<f32>,vec3<f32>) ->vec3<f32>
The conclude value says how to determine the return type from
the argument type.
Restrictions:
-
All overloads must take the same number of arguments.
-
For any given overload, all its arguments must have the same type.
Fields§
§arity: usizeThe number of arguments in the rules.
constructors: ConstructorSetThe set of type constructors to apply.
scalars: ScalarSetThe set of scalars to apply them to.
conclude: ConclusionRuleHow to determine a member rule’s return type given the type of its arguments.
Implementations§
Source§impl Regular
impl Regular
pub(super) const EMPTY: Regular
Sourcefn members(&self) -> impl Iterator<Item = (ConstructorSize, Scalar)>
fn members(&self) -> impl Iterator<Item = (ConstructorSize, Scalar)>
Return an iterator over all the argument types allowed by self.
Return an iterator that produces, for each overload in self, the
constructor and scalar of its argument types and return type.
A Regular value can only represent overload sets where, in
each overload, all the arguments have the same type, and the
return type is always going to be a determined by the argument
types, so giving the constructor and scalar is sufficient to
characterize the entire rule.
fn rules(&self) -> impl Iterator<Item = Rule>
Trait Implementations§
Source§impl ForDebugWithTypes for &Regular
impl ForDebugWithTypes for &Regular
Source§fn for_debug(
self,
types: &UniqueArena<Type>,
) -> DiagnosticDebug<(Self, &UniqueArena<Type>)>
fn for_debug( self, types: &UniqueArena<Type>, ) -> DiagnosticDebug<(Self, &UniqueArena<Type>)>
core::fmt::Debug. Read moreSource§impl From<Regular> for AnyOverloadSet
impl From<Regular> for AnyOverloadSet
Source§impl OverloadSet for Regular
impl OverloadSet for Regular
Source§fn min_arguments(&self) -> usize
fn min_arguments(&self) -> usize
Source§fn max_arguments(&self) -> usize
fn max_arguments(&self) -> usize
Source§fn arg(&self, i: usize, ty: &TypeInner, types: &UniqueArena<Type>) -> Self
fn arg(&self, i: usize, ty: &TypeInner, types: &UniqueArena<Type>) -> Self
Source§fn concrete_only(self, _types: &UniqueArena<Type>) -> Self
fn concrete_only(self, _types: &UniqueArena<Type>) -> Self
self to overloads whose arguments are all concrete types. Read moreSource§fn most_preferred(&self) -> Rule
fn most_preferred(&self) -> Rule
Source§fn overload_list(&self, _gctx: &GlobalCtx<'_>) -> Vec<Rule>
fn overload_list(&self, _gctx: &GlobalCtx<'_>) -> Vec<Rule>
self.Source§fn allowed_args(&self, i: usize, _gctx: &GlobalCtx<'_>) -> Vec<TypeResolution>
fn allowed_args(&self, i: usize, _gctx: &GlobalCtx<'_>) -> Vec<TypeResolution>
i.Source§fn for_debug(&self, types: &UniqueArena<Type>) -> impl Debug
fn for_debug(&self, types: &UniqueArena<Type>) -> impl Debug
core::fmt::Debug.