diff options
author | therealansh <tyagiansh23@hotmail.com> | 2021-03-14 11:31:21 +0530 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-03-15 10:15:15 +0000 |
commit | 73c0f6ab2ba2c1181aa757e2478bdeedc85a7269 (patch) | |
tree | 89612d4031322863b5efb26867e1b3ea1f926dc3 /gcc | |
parent | 6255b77717e982ad3edb39a19111a075d25da93b (diff) | |
download | gcc-73c0f6ab2ba2c1181aa757e2478bdeedc85a7269.zip gcc-73c0f6ab2ba2c1181aa757e2478bdeedc85a7269.tar.gz gcc-73c0f6ab2ba2c1181aa757e2478bdeedc85a7269.tar.bz2 |
refactored class TyCtx to TyVar
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-expr.h | 10 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-type.h | 14 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty-rules.h | 8 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.cc | 8 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.h | 30 |
5 files changed, 35 insertions, 35 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h index 6a4ed83..322293c 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.h +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h @@ -129,11 +129,11 @@ public: return; } - std::vector<TyTy::TyCtx> fields; + std::vector<TyTy::TyVar> fields; for (auto &elem : expr.get_tuple_elems ()) { auto field_ty = TypeCheckExpr::Resolve (elem.get (), false); - fields.push_back (TyTy::TyCtx (field_ty->get_ref ())); + fields.push_back (TyTy::TyVar (field_ty->get_ref ())); } infered = new TyTy::TupleType (expr.get_mappings ().get_hirid (), fields); } @@ -463,7 +463,7 @@ public: rust_assert (ok); infered = new TyTy::ReferenceType (expr.get_mappings ().get_hirid (), - TyTy::TyCtx (base->get_ref ())); + TyTy::TyVar (base->get_ref ())); } break; @@ -665,7 +665,7 @@ public: infered = new TyTy::ArrayType (expr.get_mappings ().get_hirid (), num_elems, - TyTy::TyCtx (infered_array_elems->get_ref ())); + TyTy::TyVar (infered_array_elems->get_ref ())); } void visit (HIR::ArrayElemsValues &elems) override @@ -895,7 +895,7 @@ public: // FIXME double_reference infered = new TyTy::ReferenceType (expr.get_mappings ().get_hirid (), - TyTy::TyCtx (resolved_base->get_ref ())); + TyTy::TyVar (resolved_base->get_ref ())); } void visit (HIR::DereferenceExpr &expr) override diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.h b/gcc/rust/typecheck/rust-hir-type-check-type.h index db7fe63..0ae24a4 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.h +++ b/gcc/rust/typecheck/rust-hir-type-check-type.h @@ -113,17 +113,17 @@ public: ? TypeCheckType::Resolve (fntype.get_return_type ().get ()) : new TyTy::UnitType (fntype.get_mappings ().get_hirid ()); - std::vector<TyTy::TyCtx> params; + std::vector<TyTy::TyVar> params; for (auto ¶m : fntype.get_function_params ()) { TyTy::BaseType *ptype = TypeCheckType::Resolve (param.get_type ().get ()); - params.push_back (TyTy::TyCtx (ptype->get_ref ())); + params.push_back (TyTy::TyVar (ptype->get_ref ())); } translated = new TyTy::FnPtr (fntype.get_mappings ().get_hirid (), std::move (params), - TyTy::TyCtx (return_type->get_ref ())); + TyTy::TyVar (return_type->get_ref ())); } void visit (HIR::TupleType &tuple) override @@ -139,11 +139,11 @@ public: return; } - std::vector<TyTy::TyCtx> fields; + std::vector<TyTy::TyVar> fields; for (auto &elem : tuple.get_elems ()) { auto field_ty = TypeCheckType::Resolve (elem.get ()); - fields.push_back (TyTy::TyCtx (field_ty->get_ref ())); + fields.push_back (TyTy::TyVar (field_ty->get_ref ())); } translated @@ -245,7 +245,7 @@ public: TyTy::BaseType *base = TypeCheckType::Resolve (type.get_element_type ()); translated = new TyTy::ArrayType (type.get_mappings ().get_hirid (), - capacity, TyTy::TyCtx (base->get_ref ())); + capacity, TyTy::TyVar (base->get_ref ())); } void visit (HIR::ReferenceType &type) override @@ -253,7 +253,7 @@ public: TyTy::BaseType *base = TypeCheckType::Resolve (type.get_base_type ().get ()); translated = new TyTy::ReferenceType (type.get_mappings ().get_hirid (), - TyTy::TyCtx (base->get_ref ())); + TyTy::TyVar (base->get_ref ())); } void visit (HIR::InferredType &type) override diff --git a/gcc/rust/typecheck/rust-tyty-rules.h b/gcc/rust/typecheck/rust-tyty-rules.h index 58018ed..86577b2 100644 --- a/gcc/rust/typecheck/rust-tyty-rules.h +++ b/gcc/rust/typecheck/rust-tyty-rules.h @@ -693,7 +693,7 @@ public: resolved = new ArrayType (type.get_ref (), type.get_ty_ref (), - type.get_capacity (), TyCtx (base_resolved->get_ref ())); + type.get_capacity (), TyVar (base_resolved->get_ref ())); } private: @@ -888,7 +888,7 @@ public: return; } - std::vector<TyCtx> fields; + std::vector<TyVar> fields; for (size_t i = 0; i < base->num_fields (); i++) { BaseType *bo = base->get_field (i); @@ -901,7 +901,7 @@ public: return; } - fields.push_back (TyCtx (unified_ty->get_ref ())); + fields.push_back (TyVar (unified_ty->get_ref ())); } resolved @@ -1018,7 +1018,7 @@ public: } resolved = new ReferenceType (base->get_ref (), base->get_ty_ref (), - TyCtx (base_resolved->get_ref ())); + TyVar (base_resolved->get_ref ())); } private: diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index e7b2216..0a6c3d5 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -27,7 +27,7 @@ namespace Rust { namespace TyTy { -TyCtx::TyCtx (HirId ref) : ref (ref) +TyVar::TyVar (HirId ref) : ref (ref) { // ensure this reference is defined within the context auto context = Resolver::TypeCheckContext::get (); @@ -37,7 +37,7 @@ TyCtx::TyCtx (HirId ref) : ref (ref) } BaseType * -TyCtx::get_tyty () const +TyVar::get_tyty () const { auto context = Resolver::TypeCheckContext::get (); BaseType *lookup = nullptr; @@ -482,9 +482,9 @@ FnPtr::is_equal (const BaseType &other) const BaseType * FnPtr::clone () { - std::vector<TyCtx> cloned_params; + std::vector<TyVar> cloned_params; for (auto &p : params) - cloned_params.push_back (TyCtx (p.get_ref ())); + cloned_params.push_back (TyVar (p.get_ref ())); return new FnPtr (get_ref (), get_ty_ref (), std::move (cloned_params), result_type, get_combined_refs ()); diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 3f22955..1168807 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -117,10 +117,10 @@ protected: }; // this is a placeholder for types that can change like inference variables -class TyCtx +class TyVar { public: - explicit TyCtx (HirId ref); + explicit TyVar (HirId ref); HirId get_ref () const { return ref; } @@ -244,12 +244,12 @@ private: class TupleType : public BaseType { public: - TupleType (HirId ref, std::vector<TyCtx> fields, + TupleType (HirId ref, std::vector<TyVar> fields, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ref, TypeKind::TUPLE, refs), fields (fields) {} - TupleType (HirId ref, HirId ty_ref, std::vector<TyCtx> fields, + TupleType (HirId ref, HirId ty_ref, std::vector<TyVar> fields, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ty_ref, TypeKind::TUPLE, refs), fields (fields) {} @@ -282,7 +282,7 @@ public: std::string get_name () const override final { return as_string (); } private: - std::vector<TyCtx> fields; + std::vector<TyVar> fields; }; class ParamType : public BaseType @@ -563,13 +563,13 @@ private: class FnPtr : public BaseType { public: - FnPtr (HirId ref, std::vector<TyCtx> params, TyCtx result_type, + FnPtr (HirId ref, std::vector<TyVar> params, TyVar result_type, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ref, TypeKind::FNPTR, refs), params (std::move (params)), result_type (result_type) {} - FnPtr (HirId ref, HirId ty_ref, std::vector<TyCtx> params, TyCtx result_type, + FnPtr (HirId ref, HirId ty_ref, std::vector<TyVar> params, TyVar result_type, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ty_ref, TypeKind::FNPTR, refs), params (params), result_type (result_type) @@ -603,20 +603,20 @@ public: } private: - std::vector<TyCtx> params; - TyCtx result_type; + std::vector<TyVar> params; + TyVar result_type; }; class ArrayType : public BaseType { public: - ArrayType (HirId ref, size_t capacity, TyCtx base, + ArrayType (HirId ref, size_t capacity, TyVar base, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ref, TypeKind::ARRAY, refs), capacity (capacity), element_type (base) {} - ArrayType (HirId ref, HirId ty_ref, size_t capacity, TyCtx base, + ArrayType (HirId ref, HirId ty_ref, size_t capacity, TyVar base, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ty_ref, TypeKind::ARRAY, refs), capacity (capacity), element_type (base) @@ -640,7 +640,7 @@ public: private: size_t capacity; - TyCtx element_type; + TyVar element_type; }; class BoolType : public BaseType @@ -844,12 +844,12 @@ public: class ReferenceType : public BaseType { public: - ReferenceType (HirId ref, TyCtx base, + ReferenceType (HirId ref, TyVar base, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ref, TypeKind::REF), base (base) {} - ReferenceType (HirId ref, HirId ty_ref, TyCtx base, + ReferenceType (HirId ref, HirId ty_ref, TyVar base, std::set<HirId> refs = std::set<HirId> ()) : BaseType (ref, ty_ref, TypeKind::REF), base (base) {} @@ -869,7 +869,7 @@ public: BaseType *clone () final override; private: - TyCtx base; + TyVar base; }; class StrType : public BaseType |