]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rust/backend/rust-compile-implitem.h
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
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
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_COMPILE_IMPLITEM_H
20 #define RUST_COMPILE_IMPLITEM_H
22 #include "rust-compile-item.h"
23 #include "rust-compile-expr.h"
24 #include "rust-compile-fnparam.h"
29 // this is a proxy for HIR::ImplItem's back to use the normel HIR::Item path
30 class CompileInherentImplItem
: public CompileItem
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 ())
38 CompileInherentImplItem
compiler (ctx
, concrete
, ref_locus
);
39 item
->accept_vis (compiler
);
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 ());
45 return compiler
.reference
;
49 CompileInherentImplItem (Context
*ctx
, TyTy::BaseType
*concrete
,
51 : CompileItem (ctx
, concrete
, ref_locus
)
55 class CompileTraitItem
: public HIRCompileBase
, public HIR::HIRTraitItemVisitor
58 static tree
Compile (HIR::TraitItem
*item
, Context
*ctx
,
59 TyTy::BaseType
*concrete
, bool is_query_mode
= false,
60 Location ref_locus
= Location ())
62 CompileTraitItem
compiler (ctx
, concrete
, ref_locus
);
63 item
->accept_vis (compiler
);
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 ());
69 return compiler
.reference
;
72 void visit (HIR::TraitItemConst
&constant
) override
;
73 void visit (HIR::TraitItemFunc
&func
) override
;
75 void visit (HIR::TraitItemType
&typ
) override
{}
78 CompileTraitItem (Context
*ctx
, TyTy::BaseType
*concrete
, Location ref_locus
)
79 : HIRCompileBase (ctx
), concrete (concrete
), reference (error_mark_node
),
83 TyTy::BaseType
*concrete
;
88 } // namespace Compile
91 #endif // RUST_COMPILE_IMPLITEM_H