libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / rust / typecheck / rust-hir-dot-operator.h
blob804b18fbff24a20019f05c5a67b3a73c709ac116
1 // Copyright (C) 2020-2024 Free Software Foundation, Inc.
3 // This file is part of GCC.
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.
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.
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/>.
19 #ifndef RUST_HIR_DOT_OPERATOR
20 #define RUST_HIR_DOT_OPERATOR
22 #include "rust-hir-path-probe.h"
24 namespace Rust {
25 namespace Resolver {
27 struct MethodCandidate
29 PathProbeCandidate candidate;
30 std::vector<Adjustment> adjustments;
32 static MethodCandidate get_error ()
34 return {PathProbeCandidate::get_error (), {}};
37 bool is_error () const { return candidate.is_error (); }
39 DefId get_defid () const { return candidate.get_defid (); }
41 bool operator< (const MethodCandidate &c) const
43 return get_defid () < c.get_defid ();
47 class MethodResolver : private TypeCheckBase, protected AutoderefCycle
49 public:
50 struct predicate_candidate
52 TyTy::TypeBoundPredicateItem lookup;
53 TyTy::FnType *fntype;
56 static std::set<MethodCandidate>
57 Probe (TyTy::BaseType *receiver, const HIR::PathIdentSegment &segment_name,
58 bool autoderef_flag = false);
60 static std::set<MethodCandidate>
61 Select (std::set<MethodCandidate> &candidates, TyTy::BaseType *receiver,
62 std::vector<TyTy::BaseType *> arguments);
64 static std::vector<predicate_candidate> get_predicate_items (
65 const HIR::PathIdentSegment &segment_name, const TyTy::BaseType &receiver,
66 const std::vector<TyTy::TypeBoundPredicate> &specified_bounds);
68 protected:
69 MethodResolver (bool autoderef_flag,
70 const HIR::PathIdentSegment &segment_name);
72 void try_hook (const TyTy::BaseType &r) override;
74 bool select (TyTy::BaseType &receiver) override;
76 private:
77 std::vector<Adjustment>
78 append_adjustments (const std::vector<Adjustment> &adjustments) const;
80 private:
81 // search
82 const HIR::PathIdentSegment &segment_name;
83 std::vector<MethodResolver::predicate_candidate> predicate_items;
85 // mutable fields
86 std::set<MethodCandidate> result;
89 } // namespace Resolver
90 } // namespace Rust
92 #endif // RUST_HIR_DOT_OPERATOR