| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef RUST_HIR_VISIBILITY_H |
| 20 |
#define RUST_HIR_VISIBILITY_H |
| 21 |
|
| 22 |
#include "rust-hir-simple-path.h" |
| 23 |
|
| 24 |
namespace Rust { |
| 25 |
namespace HIR { |
| 26 |
|
| 27 |
struct Visibility |
| 28 |
{ |
| 29 |
public: |
| 30 |
enum VisType |
| 31 |
{ |
| 32 |
PRIVATE, |
| 33 |
PUBLIC, |
| 34 |
RESTRICTED, |
| 35 |
ERROR, |
| 36 |
}; |
| 37 |
|
| 38 |
private: |
| 39 |
VisType vis_type; |
| 40 |
HIR::SimplePath path; |
| 41 |
location_t locus; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public: |
| 46 |
Visibility (VisType vis_type, |
| 47 |
HIR::SimplePath path = HIR::SimplePath::create_empty (), |
| 48 |
location_t locus = UNDEF_LOCATION) |
| 49 |
: vis_type (vis_type), path (std::move (path)), locus (locus) |
| 50 |
{} |
| 51 |
|
| 52 |
|
| 53 |
bool is_error () const { return vis_type == ERROR; } |
| 54 |
|
| 55 |
|
| 56 |
bool is_public () const { return vis_type == PUBLIC; } |
| 57 |
|
| 58 |
|
| 59 |
bool is_restricted () const { return vis_type == RESTRICTED; } |
| 60 |
|
| 61 |
|
| 62 |
static Visibility create_error () |
| 63 |
{ |
| 64 |
return Visibility (ERROR, HIR::SimplePath::create_empty ()); |
| 65 |
} |
| 66 |
|
| 67 |
VisType get_vis_type () const { return vis_type; } |
| 68 |
|
| 69 |
const HIR::SimplePath &get_path () const |
| 70 |
{ |
| 71 |
rust_assert (!is_error ()); |
| 72 |
return path; |
| 73 |
} |
| 74 |
|
| 75 |
std::string as_string () const; |
| 76 |
}; |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
#endif |