Skip to main content

TypeEnv

Struct TypeEnv 

Source
pub struct TypeEnv {
    pub param_constraints: HashMap<InternedStr, Vec<TypeConstraint>>,
    pub expr_constraints: HashMap<ExprId, Vec<TypeConstraint>>,
    pub return_constraints: Vec<TypeConstraint>,
    pub expr_to_param: Vec<ParamLink>,
    pub param_to_exprs: HashMap<InternedStr, Vec<ExprId>>,
}
Expand description

型環境

マクロの型推論に使用する型制約を収集・管理する。 パラメータ、式、戻り値それぞれに対する制約を保持する。

Fields§

§param_constraints: HashMap<InternedStr, Vec<TypeConstraint>>

パラメータ名 → 型制約リスト

§expr_constraints: HashMap<ExprId, Vec<TypeConstraint>>

ExprId → 型制約リスト

§return_constraints: Vec<TypeConstraint>

戻り値の型制約

§expr_to_param: Vec<ParamLink>

ExprId → パラメータ名のリンク(正引き)

§param_to_exprs: HashMap<InternedStr, Vec<ExprId>>

パラメータ名 → ExprId リスト(逆引き)

パラメータを参照する全ての式の ExprId を保持。 引数の型推論時に、関連する式の型制約を探すために使用。

Implementations§

Source§

impl TypeEnv

Source

pub fn new() -> Self

新しい型環境を作成

Source

pub fn add_param_constraint( &mut self, param: InternedStr, constraint: TypeConstraint, )

パラメータに型制約を追加

Source

pub fn add_expr_constraint(&mut self, constraint: TypeConstraint)

式に型制約を追加

Source

pub fn add_constraint(&mut self, constraint: TypeConstraint)

汎用的な制約追加メソッド

Source

pub fn add_return_constraint(&mut self, constraint: TypeConstraint)

戻り値に型制約を追加

式をパラメータにリンク

正引き(expr_to_param)と逆引き(param_to_exprs)の両方を更新する。

Source

pub fn get_param_constraints( &self, param: InternedStr, ) -> Option<&Vec<TypeConstraint>>

パラメータの制約を取得

Source

pub fn get_expr_constraints( &self, expr_id: ExprId, ) -> Option<&Vec<TypeConstraint>>

式の制約を取得

Source

pub fn get_linked_param(&self, expr_id: ExprId) -> Option<InternedStr>

式に紐づくパラメータ名を取得

Source

pub fn param_constraint_count(&self) -> usize

パラメータ制約の総数

Source

pub fn expr_constraint_count(&self) -> usize

式制約の総数

Source

pub fn return_constraint_count(&self) -> usize

戻り値制約の数

Source

pub fn get_return_type(&self) -> Option<&TypeRepr>

戻り値の型を取得(最初の制約から)

Source

pub fn total_constraint_count(&self) -> usize

全制約の総数

Source

pub fn is_empty(&self) -> bool

環境が空かどうか

Source

pub fn merge(&mut self, other: TypeEnv)

他の型環境をマージ

Source

pub fn summary(&self) -> String

デバッグ用: 制約のサマリを文字列で取得

Trait Implementations§

Source§

impl Clone for TypeEnv

Source§

fn clone(&self) -> TypeEnv

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TypeEnv

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TypeEnv

Source§

fn default() -> TypeEnv

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.