aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/ast/rust-ast.h')
-rw-r--r--gcc/rust/ast/rust-ast.h67
1 files changed, 33 insertions, 34 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 5e724d1..aa6ad50 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -57,6 +57,11 @@ public:
bool empty () const { return ident.empty (); }
+ bool operator== (const Identifier &other) const
+ {
+ return ident == other.ident;
+ }
+
private:
std::string ident;
location_t loc;
@@ -657,6 +662,9 @@ public:
// Returns whether the attribute is considered an "empty" attribute.
bool is_empty () const { return attr_input == nullptr && path.is_empty (); }
+ // Returns whether the attribute has no input
+ bool empty_input () const { return !attr_input; }
+
location_t get_locus () const { return locus; }
AttrInput &get_attr_input () const { return *attr_input; }
@@ -1015,6 +1023,7 @@ public:
}
DelimType get_delim_type () const { return delim_type; }
+ location_t get_locus () const { return locus; }
};
/* Forward decl - definition moved to rust-expr.h as it requires LiteralExpr
@@ -1260,9 +1269,20 @@ public:
Await,
AsyncBlock,
InlineAsm,
+ LlvmInlineAsm,
Identifier,
FormatArgs,
MacroInvocation,
+ Borrow,
+ Dereference,
+ ErrorPropagation,
+ Negation,
+ ArithmeticOrLogical,
+ Comparison,
+ LazyBoolean,
+ TypeCast,
+ Assignment,
+ CompoundAssignment,
};
virtual Kind get_expr_kind () const = 0;
@@ -1577,17 +1597,9 @@ public:
lifetime_name (std::move (name)), locus (locus)
{}
- // Creates an "error" lifetime.
- static Lifetime error () { return Lifetime (NAMED, ""); }
-
static Lifetime elided () { return Lifetime (WILDCARD, ""); }
// Returns true if the lifetime is in an error state.
- bool is_error () const
- {
- return lifetime_type == NAMED && lifetime_name.empty ();
- }
-
std::string as_string () const override;
void accept_vis (ASTVisitor &vis) override;
@@ -1678,15 +1690,6 @@ public:
// Returns whether the lifetime param has an outer attribute.
bool has_outer_attribute () const { return !outer_attrs.empty (); }
- // Creates an error state lifetime param.
- static LifetimeParam create_error ()
- {
- return LifetimeParam (Lifetime::error (), {}, {}, UNDEF_LOCATION);
- }
-
- // Returns whether the lifetime param is in an error state.
- bool is_error () const { return lifetime.is_error (); }
-
// Constructor
LifetimeParam (Lifetime lifetime, std::vector<Lifetime> lifetime_bounds,
AST::AttrVec outer_attrs, location_t locus)
@@ -1986,13 +1989,6 @@ public:
return std::move (item);
}
- std::unique_ptr<AssociatedItem> take_trait_item ()
- {
- rust_assert (!is_error ());
- return std::unique_ptr<AssociatedItem> (
- static_cast<AssociatedItem *> (assoc_item.release ()));
- }
-
std::unique_ptr<ExternalItem> take_external_item ()
{
rust_assert (!is_error ());
@@ -2005,16 +2001,6 @@ public:
return std::move (assoc_item);
}
- std::unique_ptr<AssociatedItem> take_impl_item ()
- {
- return take_assoc_item ();
- }
-
- std::unique_ptr<AssociatedItem> take_trait_impl_item ()
- {
- return take_assoc_item ();
- }
-
std::unique_ptr<Type> take_type ()
{
rust_assert (!is_error ());
@@ -2116,6 +2102,19 @@ template <> struct less<Rust::Identifier>
return lhs.as_string () < rhs.as_string ();
}
};
+
+template <> struct hash<Rust::Identifier>
+{
+ std::size_t operator() (const Rust::Identifier &k) const
+ {
+ using std::hash;
+ using std::size_t;
+ using std::string;
+
+ return hash<string> () (k.as_string ()) ^ (hash<int> () (k.get_locus ()));
+ }
+};
+
} // namespace std
#endif