Branch data Line data Source code
1 : : // Copyright (C) 2020-2025 Free Software Foundation, Inc.
2 : :
3 : : // This file is part of GCC.
4 : :
5 : : // GCC is free software; you can redistribute it and/or modify it under
6 : : // the terms of the GNU General Public License as published by the Free
7 : : // Software Foundation; either version 3, or (at your option) any later
8 : : // version.
9 : :
10 : : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 : : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 : : // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 : : // for more details.
14 : :
15 : : // You should have received a copy of the GNU General Public License
16 : : // along with GCC; see the file COPYING3. If not see
17 : : // <http://www.gnu.org/licenses/>.
18 : :
19 : : #ifndef RUST_HIR_TYPE_CHECK_TYPE
20 : : #define RUST_HIR_TYPE_CHECK_TYPE
21 : :
22 : : #include "rust-hir-type-check-base.h"
23 : : #include "rust-hir-visitor.h"
24 : :
25 : : namespace Rust {
26 : : namespace Resolver {
27 : :
28 : : // FIXME
29 : : // This simply fetches the HIR:::GenericArgs from the base class. Check to see
30 : : // if we can get rid of this class
31 : 0 : class TypeCheckResolveGenericArguments : public TypeCheckBase
32 : : {
33 : : public:
34 : : static HIR::GenericArgs resolve (HIR::TypePathSegment *segment);
35 : :
36 : : void visit (HIR::TypePathSegmentGeneric &generic);
37 : :
38 : : private:
39 : 0 : TypeCheckResolveGenericArguments (location_t locus)
40 : 0 : : TypeCheckBase (), args (HIR::GenericArgs::create_empty (locus))
41 : 0 : {}
42 : :
43 : : HIR::GenericArgs args;
44 : : };
45 : :
46 : 35360 : class TypeCheckType : public TypeCheckBase, public HIR::HIRTypeVisitor
47 : : {
48 : : public:
49 : : static TyTy::BaseType *Resolve (HIR::Type *type);
50 : :
51 : : void visit (HIR::BareFunctionType &fntype) override;
52 : : void visit (HIR::TupleType &tuple) override;
53 : : void visit (HIR::TypePath &path) override;
54 : : void visit (HIR::QualifiedPathInType &path) override;
55 : : void visit (HIR::ArrayType &type) override;
56 : : void visit (HIR::SliceType &type) override;
57 : : void visit (HIR::ReferenceType &type) override;
58 : : void visit (HIR::RawPointerType &type) override;
59 : : void visit (HIR::InferredType &type) override;
60 : : void visit (HIR::NeverType &type) override;
61 : : void visit (HIR::TraitObjectType &type) override;
62 : :
63 : 0 : void visit (HIR::TypePathSegmentFunction &segment) override
64 : : { /* TODO */
65 : 0 : }
66 : 0 : void visit (HIR::TraitBound &bound) override
67 : : { /* TODO */
68 : 0 : }
69 : 0 : void visit (HIR::ImplTraitType &type) override
70 : : { /* TODO */
71 : 0 : }
72 : 0 : void visit (HIR::ParenthesisedType &type) override
73 : : { /* TODO */
74 : 0 : }
75 : 0 : void visit (HIR::ImplTraitTypeOneBound &type) override
76 : : { /* TODO */
77 : 0 : }
78 : :
79 : : private:
80 : 35360 : TypeCheckType (HirId id)
81 : 35360 : : TypeCheckBase (), translated (new TyTy::ErrorType (id))
82 : 35360 : {}
83 : :
84 : : TyTy::BaseType *resolve_root_path (HIR::TypePath &path, size_t *offset,
85 : : NodeId *root_resolved_node_id);
86 : :
87 : : TyTy::BaseType *resolve_segments (
88 : : NodeId root_resolved_node_id, HirId expr_id,
89 : : std::vector<std::unique_ptr<HIR::TypePathSegment>> &segments, size_t offset,
90 : : TyTy::BaseType *tyseg, const Analysis::NodeMapping &expr_mappings,
91 : : location_t expr_locus);
92 : :
93 : : TyTy::BaseType *translated;
94 : : };
95 : :
96 : 8433 : class TypeResolveGenericParam : public TypeCheckBase
97 : : {
98 : : public:
99 : : static TyTy::ParamType *Resolve (HIR::GenericParam *param,
100 : : bool apply_sized = true);
101 : :
102 : : protected:
103 : : void visit (HIR::TypeParam ¶m);
104 : : void visit (HIR::LifetimeParam ¶m);
105 : : void visit (HIR::ConstGenericParam ¶m);
106 : :
107 : : private:
108 : 8435 : TypeResolveGenericParam (bool apply_sized)
109 : 8435 : : TypeCheckBase (), resolved (nullptr), apply_sized (apply_sized)
110 : : {}
111 : :
112 : : TyTy::ParamType *resolved;
113 : : bool apply_sized;
114 : : };
115 : :
116 : 436 : class ResolveWhereClauseItem : public TypeCheckBase
117 : : {
118 : : // pair(a, b) => a: b
119 : : TyTy::RegionConstraints ®ion_constraints;
120 : :
121 : : public:
122 : : static void Resolve (HIR::WhereClauseItem &item,
123 : : TyTy::RegionConstraints ®ion_constraints);
124 : :
125 : : protected:
126 : : void visit (HIR::LifetimeWhereClauseItem &item);
127 : : void visit (HIR::TypeBoundWhereClauseItem &item);
128 : :
129 : : private:
130 : 436 : ResolveWhereClauseItem (TyTy::RegionConstraints ®ion_constraints)
131 : 436 : : region_constraints (region_constraints)
132 : : {}
133 : : };
134 : :
135 : : } // namespace Resolver
136 : : } // namespace Rust
137 : :
138 : : #endif // RUST_HIR_TYPE_CHECK_TYPE
|