(root)/
gcc-13.2.0/
gcc/
rust/
typecheck/
rust-hir-type-check-type.h
       1  // Copyright (C) 2020-2023 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-full.h"
      24  #include "rust-substitution-mapper.h"
      25  #include "rust-hir-path-probe.h"
      26  
      27  namespace Rust {
      28  namespace Resolver {
      29  
      30  // FIXME
      31  // This simply fetches the HIR:::GenericArgs from the base class. Check to see
      32  // if we can get rid of this class
      33  class TypeCheckResolveGenericArguments : public TypeCheckBase
      34  {
      35  public:
      36    static HIR::GenericArgs resolve (HIR::TypePathSegment *segment);
      37  
      38    void visit (HIR::TypePathSegmentGeneric &generic);
      39  
      40  private:
      41    TypeCheckResolveGenericArguments (Location locus)
      42      : TypeCheckBase (), args (HIR::GenericArgs::create_empty (locus))
      43    {}
      44  
      45    HIR::GenericArgs args;
      46  };
      47  
      48  class TypeCheckType : public TypeCheckBase, public HIR::HIRTypeVisitor
      49  {
      50  public:
      51    static TyTy::BaseType *Resolve (HIR::Type *type);
      52  
      53    void visit (HIR::BareFunctionType &fntype) override;
      54    void visit (HIR::TupleType &tuple) override;
      55    void visit (HIR::TypePath &path) override;
      56    void visit (HIR::QualifiedPathInType &path) override;
      57    void visit (HIR::ArrayType &type) override;
      58    void visit (HIR::SliceType &type) override;
      59    void visit (HIR::ReferenceType &type) override;
      60    void visit (HIR::RawPointerType &type) override;
      61    void visit (HIR::InferredType &type) override;
      62    void visit (HIR::NeverType &type) override;
      63    void visit (HIR::TraitObjectType &type) override;
      64  
      65    void visit (HIR::TypePathSegmentFunction &segment) override
      66    { /* TODO */
      67    }
      68    void visit (HIR::TraitBound &bound) override
      69    { /* TODO */
      70    }
      71    void visit (HIR::ImplTraitType &type) override
      72    { /* TODO */
      73    }
      74    void visit (HIR::ParenthesisedType &type) override
      75    { /* TODO */
      76    }
      77    void visit (HIR::ImplTraitTypeOneBound &type) override
      78    { /* TODO */
      79    }
      80  
      81  private:
      82    TypeCheckType (HirId id)
      83      : TypeCheckBase (), translated (new TyTy::ErrorType (id))
      84    {}
      85  
      86    TyTy::BaseType *resolve_root_path (HIR::TypePath &path, size_t *offset,
      87  				     NodeId *root_resolved_node_id);
      88  
      89    TyTy::BaseType *resolve_segments (
      90      NodeId root_resolved_node_id, HirId expr_id,
      91      std::vector<std::unique_ptr<HIR::TypePathSegment>> &segments, size_t offset,
      92      TyTy::BaseType *tyseg, const Analysis::NodeMapping &expr_mappings,
      93      Location expr_locus);
      94  
      95    TyTy::BaseType *translated;
      96  };
      97  
      98  class TypeResolveGenericParam : public TypeCheckBase
      99  {
     100  public:
     101    static TyTy::ParamType *Resolve (HIR::GenericParam *param);
     102  
     103  protected:
     104    void visit (HIR::TypeParam &param);
     105    void visit (HIR::LifetimeParam &param);
     106    void visit (HIR::ConstGenericParam &param);
     107  
     108  private:
     109    TypeResolveGenericParam () : TypeCheckBase (), resolved (nullptr) {}
     110  
     111    TyTy::ParamType *resolved;
     112  };
     113  
     114  class ResolveWhereClauseItem : public TypeCheckBase
     115  {
     116  public:
     117    static void Resolve (HIR::WhereClauseItem &item);
     118  
     119  protected:
     120    void visit (HIR::LifetimeWhereClauseItem &item);
     121    void visit (HIR::TypeBoundWhereClauseItem &item);
     122  
     123  private:
     124    ResolveWhereClauseItem () : TypeCheckBase () {}
     125  };
     126  
     127  } // namespace Resolver
     128  } // namespace Rust
     129  
     130  #endif // RUST_HIR_TYPE_CHECK_TYPE