| 1 |
// This file is part of GCC. |
| 2 |
|
| 3 |
// GCC is free software; you can redistribute it and/or modify it under |
| 4 |
// the terms of the GNU General Public License as published by the Free |
| 5 |
// Software Foundation; either version 3, or (at your option) any later |
| 6 |
// version. |
| 7 |
|
| 8 |
// GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 9 |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 11 |
// for more details. |
| 12 |
|
| 13 |
// You should have received a copy of the GNU General Public License |
| 14 |
// along with GCC; see the file COPYING3. If not see |
| 15 |
// <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
#ifndef RUST_PROC_MACRO_H |
| 18 |
#define RUST_PROC_MACRO_H |
| 19 |
|
| 20 |
#include "libproc_macro_internal/proc_macro.h" |
| 21 |
#include "rust-mapping-common.h" |
| 22 |
|
| 23 |
namespace Rust { |
| 24 |
|
| 25 |
class BangProcMacro |
| 26 |
{ |
| 27 |
private: |
| 28 |
std::string name; |
| 29 |
NodeId node_id; |
| 30 |
ProcMacro::BangMacro macro; |
| 31 |
|
| 32 |
public: |
| 33 |
BangProcMacro (ProcMacro::Bang macro); |
| 34 |
BangProcMacro () = default; |
| 35 |
|
| 36 |
const std::string &get_name () const { return name; } |
| 37 |
|
| 38 |
NodeId get_node_id () const { return node_id; } |
| 39 |
|
| 40 |
ProcMacro::BangMacro get_handle () const { return macro; } |
| 41 |
}; |
| 42 |
|
| 43 |
class AttributeProcMacro |
| 44 |
{ |
| 45 |
private: |
| 46 |
std::string name; |
| 47 |
NodeId node_id; |
| 48 |
ProcMacro::AttributeMacro macro; |
| 49 |
|
| 50 |
public: |
| 51 |
AttributeProcMacro (ProcMacro::Attribute macro); |
| 52 |
AttributeProcMacro () = default; |
| 53 |
|
| 54 |
const std::string &get_name () const { return name; } |
| 55 |
|
| 56 |
NodeId get_node_id () const { return node_id; } |
| 57 |
|
| 58 |
ProcMacro::AttributeMacro get_handle () const { return macro; } |
| 59 |
}; |
| 60 |
|
| 61 |
class CustomDeriveProcMacro |
| 62 |
{ |
| 63 |
private: |
| 64 |
std::string trait_name; |
| 65 |
std::vector<std::string> attributes; |
| 66 |
NodeId node_id; |
| 67 |
ProcMacro::CustomDeriveMacro macro; |
| 68 |
|
| 69 |
public: |
| 70 |
CustomDeriveProcMacro (ProcMacro::CustomDerive macro); |
| 71 |
CustomDeriveProcMacro () = default; |
| 72 |
|
| 73 |
const std::string &get_name () const { return trait_name; } |
| 74 |
|
| 75 |
NodeId get_node_id () const { return node_id; } |
| 76 |
|
| 77 |
ProcMacro::CustomDeriveMacro get_handle () const { return macro; } |
| 78 |
}; |
| 79 |
|
| 80 |
/** |
| 81 |
* Load a procedural macro library and collect its entrypoints. |
| 82 |
* |
| 83 |
* @param The path to the shared object file to load. |
| 84 |
*/ |
| 85 |
const std::vector<ProcMacro::Procmacro> |
| 86 |
load_macros (std::string path); |
| 87 |
|
| 88 |
std::string |
| 89 |
generate_proc_macro_decls_symbol (std::uint32_t stable_crate_id); |
| 90 |
|
| 91 |
} // namespace Rust |
| 92 |
|
| 93 |
#endif /* ! RUST_PROC_MACRO_H */ |