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
impl TypeEnv
Sourcepub fn add_param_constraint(
&mut self,
param: InternedStr,
constraint: TypeConstraint,
)
pub fn add_param_constraint( &mut self, param: InternedStr, constraint: TypeConstraint, )
パラメータに型制約を追加
Sourcepub fn add_expr_constraint(&mut self, constraint: TypeConstraint)
pub fn add_expr_constraint(&mut self, constraint: TypeConstraint)
式に型制約を追加
Sourcepub fn add_constraint(&mut self, constraint: TypeConstraint)
pub fn add_constraint(&mut self, constraint: TypeConstraint)
汎用的な制約追加メソッド
Sourcepub fn add_return_constraint(&mut self, constraint: TypeConstraint)
pub fn add_return_constraint(&mut self, constraint: TypeConstraint)
戻り値に型制約を追加
Sourcepub fn link_expr_to_param(
&mut self,
expr_id: ExprId,
param_name: InternedStr,
context: impl Into<String>,
)
pub fn link_expr_to_param( &mut self, expr_id: ExprId, param_name: InternedStr, context: impl Into<String>, )
式をパラメータにリンク
正引き(expr_to_param)と逆引き(param_to_exprs)の両方を更新する。
Sourcepub fn get_param_constraints(
&self,
param: InternedStr,
) -> Option<&Vec<TypeConstraint>>
pub fn get_param_constraints( &self, param: InternedStr, ) -> Option<&Vec<TypeConstraint>>
パラメータの制約を取得
Sourcepub fn get_expr_constraints(
&self,
expr_id: ExprId,
) -> Option<&Vec<TypeConstraint>>
pub fn get_expr_constraints( &self, expr_id: ExprId, ) -> Option<&Vec<TypeConstraint>>
式の制約を取得
Sourcepub fn get_linked_param(&self, expr_id: ExprId) -> Option<InternedStr>
pub fn get_linked_param(&self, expr_id: ExprId) -> Option<InternedStr>
式に紐づくパラメータ名を取得
Sourcepub fn param_constraint_count(&self) -> usize
pub fn param_constraint_count(&self) -> usize
パラメータ制約の総数
Sourcepub fn expr_constraint_count(&self) -> usize
pub fn expr_constraint_count(&self) -> usize
式制約の総数
Sourcepub fn return_constraint_count(&self) -> usize
pub fn return_constraint_count(&self) -> usize
戻り値制約の数
Sourcepub fn get_return_type(&self) -> Option<&TypeRepr>
pub fn get_return_type(&self) -> Option<&TypeRepr>
戻り値の型を取得(最初の制約から)
Sourcepub fn total_constraint_count(&self) -> usize
pub fn total_constraint_count(&self) -> usize
全制約の総数
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TypeEnv
impl RefUnwindSafe for TypeEnv
impl Send for TypeEnv
impl Sync for TypeEnv
impl Unpin for TypeEnv
impl UnsafeUnpin for TypeEnv
impl UnwindSafe for TypeEnv
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