| 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_LOWER |
| 20 |
#define RUST_HIR_LOWER |
| 21 |
|
| 22 |
#include "rust-system.h" |
| 23 |
#include "rust-ast-full-decls.h" |
| 24 |
#include "rust-hir-full-decls.h" |
| 25 |
|
| 26 |
namespace Rust { |
| 27 |
namespace HIR { |
| 28 |
|
| 29 |
/* Checks whether the name of a field already exists. Returns true |
| 30 |
and produces an error if so. */ |
| 31 |
bool |
| 32 |
struct_field_name_exists (std::vector<HIR::StructField> &fields, |
| 33 |
HIR::StructField &new_field); |
| 34 |
|
| 35 |
/** |
| 36 |
* Lowers a Visibility from the AST into an HIR Visibility, desugaring it in |
| 37 |
* the process |
| 38 |
*/ |
| 39 |
Visibility |
| 40 |
translate_visibility (const AST::Visibility &vis); |
| 41 |
|
| 42 |
/** |
| 43 |
* Main base class used for lowering AST to HIR. |
| 44 |
* |
| 45 |
* Every subclass should provide a translate() method that takes an AST node and |
| 46 |
* lowers it to some HIR stored in the TRANSLATED member. */ |
| 47 |
class ASTLowering |
| 48 |
{ |
| 49 |
public: |
| 50 |
static std::unique_ptr<HIR::Crate> Resolve (AST::Crate &astCrate); |
| 51 |
~ASTLowering (); |
| 52 |
|
| 53 |
private: |
| 54 |
ASTLowering (AST::Crate &astCrate); |
| 55 |
std::unique_ptr<HIR::Crate> go (); |
| 56 |
|
| 57 |
AST::Crate &astCrate; |
| 58 |
}; |
| 59 |
|
| 60 |
} // namespace HIR |
| 61 |
} // namespace Rust |
| 62 |
|
| 63 |
#endif // RUST_HIR_LOWER |