]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rust/backend/rust-compile-implitem.h
Update copyright years.
[thirdparty/gcc.git] / gcc / rust / backend / rust-compile-implitem.h
1 // Copyright (C) 2020-2024 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_COMPILE_IMPLITEM_H
20 #define RUST_COMPILE_IMPLITEM_H
21
22 #include "rust-compile-item.h"
23 #include "rust-compile-expr.h"
24 #include "rust-compile-fnparam.h"
25
26 namespace Rust {
27 namespace Compile {
28
29 // this is a proxy for HIR::ImplItem's back to use the normel HIR::Item path
30 class CompileInherentImplItem : public CompileItem
31 {
32 public:
33 static tree Compile (HIR::ImplItem *item, Context *ctx,
34 TyTy::BaseType *concrete = nullptr,
35 bool is_query_mode = false,
36 Location ref_locus = Location ())
37 {
38 CompileInherentImplItem compiler (ctx, concrete, ref_locus);
39 item->accept_vis (compiler);
40
41 if (is_query_mode && compiler.reference == error_mark_node)
42 rust_internal_error_at (ref_locus, "failed to compile impl item: %s",
43 item->as_string ().c_str ());
44
45 return compiler.reference;
46 }
47
48 private:
49 CompileInherentImplItem (Context *ctx, TyTy::BaseType *concrete,
50 Location ref_locus)
51 : CompileItem (ctx, concrete, ref_locus)
52 {}
53 };
54
55 class CompileTraitItem : public HIRCompileBase, public HIR::HIRTraitItemVisitor
56 {
57 public:
58 static tree Compile (HIR::TraitItem *item, Context *ctx,
59 TyTy::BaseType *concrete, bool is_query_mode = false,
60 Location ref_locus = Location ())
61 {
62 CompileTraitItem compiler (ctx, concrete, ref_locus);
63 item->accept_vis (compiler);
64
65 if (is_query_mode && compiler.reference == error_mark_node)
66 rust_internal_error_at (ref_locus, "failed to compile trait item: %s",
67 item->as_string ().c_str ());
68
69 return compiler.reference;
70 }
71
72 void visit (HIR::TraitItemConst &constant) override;
73 void visit (HIR::TraitItemFunc &func) override;
74
75 void visit (HIR::TraitItemType &typ) override {}
76
77 private:
78 CompileTraitItem (Context *ctx, TyTy::BaseType *concrete, Location ref_locus)
79 : HIRCompileBase (ctx), concrete (concrete), reference (error_mark_node),
80 ref_locus (ref_locus)
81 {}
82
83 TyTy::BaseType *concrete;
84 tree reference;
85 Location ref_locus;
86 };
87
88 } // namespace Compile
89 } // namespace Rust
90
91 #endif // RUST_COMPILE_IMPLITEM_H