aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-31 16:54:37 +0000
committerGitHub <noreply@github.com>2021-05-31 16:54:37 +0000
commit75de60e68b46c555a87822a78d20c7197bddffb5 (patch)
tree06f5ef0fb27db2d41f2d44254a2fc160fd5aa7be
parent0a3696a4a810e2b9f372b0dc4f79c044ff59811b (diff)
parenta3539302cd0b144eeec4aa5113c0d479ac96f2d5 (diff)
downloadgcc-75de60e68b46c555a87822a78d20c7197bddffb5.zip
gcc-75de60e68b46c555a87822a78d20c7197bddffb5.tar.gz
gcc-75de60e68b46c555a87822a78d20c7197bddffb5.tar.bz2
Merge #453
453: reusing AST::Attribute and remove HIR::Attribute r=philberty a=thomasyonug Deleting HIR::Attribute and reusing AST::Attribute. Some relative reusing classes below: 1. DelimTokenTree 2. AttrInputMetaItemContainer 3. AttrInputLiteral 4. MetaItemLitExpr 5. MetaItemPathLit 6. MetaItemPath 7. MetaItemSeq 8. MetaWord 9. MetaNameValueStr 10. MetaListPath 11. MetaListNameValueStr 12. Attrbute 13. AttrInput 14. MacroParser Co-authored-by: Thomas Young <wenzhang5800@gmail.com>
-rw-r--r--gcc/rust/analysis/rust-hir-liveness-base.h11
-rw-r--r--gcc/rust/ast/rust-ast-full-test.cc8
-rw-r--r--gcc/rust/ast/rust-ast.h8
-rw-r--r--gcc/rust/backend/rust-compile-base.h15
-rw-r--r--gcc/rust/expand/rust-macro-expand.cc9
-rw-r--r--gcc/rust/expand/rust-macro-expand.h6
-rw-r--r--gcc/rust/hir/rust-ast-lower-block.h2
-rw-r--r--gcc/rust/hir/rust-ast-lower-expr.h38
-rw-r--r--gcc/rust/hir/rust-ast-lower-implitem.h6
-rw-r--r--gcc/rust/hir/rust-ast-lower-item.h20
-rw-r--r--gcc/rust/hir/rust-ast-lower-stmt.h2
-rw-r--r--gcc/rust/hir/rust-ast-lower-type.h2
-rw-r--r--gcc/rust/hir/rust-ast-lower.cc8
-rw-r--r--gcc/rust/hir/tree/rust-hir-cond-compilation.h7
-rw-r--r--gcc/rust/hir/tree/rust-hir-expr.h240
-rw-r--r--gcc/rust/hir/tree/rust-hir-full-decls.h17
-rw-r--r--gcc/rust/hir/tree/rust-hir-full-test.cc774
-rw-r--r--gcc/rust/hir/tree/rust-hir-item.h150
-rw-r--r--gcc/rust/hir/tree/rust-hir-macro.h259
-rw-r--r--gcc/rust/hir/tree/rust-hir-path.h15
-rw-r--r--gcc/rust/hir/tree/rust-hir-pattern.h18
-rw-r--r--gcc/rust/hir/tree/rust-hir-stmt.h4
-rw-r--r--gcc/rust/hir/tree/rust-hir-visitor.h22
-rw-r--r--gcc/rust/hir/tree/rust-hir.h510
-rw-r--r--gcc/rust/parse/rust-parse-impl.h505
-rw-r--r--gcc/rust/parse/rust-parse.h332
-rw-r--r--gcc/rust/rust-session-manager.cc2
-rw-r--r--gcc/rust/typecheck/rust-hir-const-fold-base.h11
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-base.h11
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check.cc2
30 files changed, 664 insertions, 2350 deletions
diff --git a/gcc/rust/analysis/rust-hir-liveness-base.h b/gcc/rust/analysis/rust-hir-liveness-base.h
index 483b9c9..1a58f1a 100644
--- a/gcc/rust/analysis/rust-hir-liveness-base.h
+++ b/gcc/rust/analysis/rust-hir-liveness-base.h
@@ -33,8 +33,6 @@ class LivenessBase : public HIR::HIRVisitor
public:
virtual ~LivenessBase () {}
virtual void visit (HIR::Token &) override {}
- virtual void visit (HIR::DelimTokenTree &) override {}
- virtual void visit (HIR::AttrInputMetaItemContainer &) override {}
virtual void visit (HIR::IdentifierExpr &) override {}
virtual void visit (HIR::Lifetime &) override {}
virtual void visit (HIR::LifetimeParam &) override {}
@@ -47,9 +45,6 @@ public:
virtual void visit (HIR::QualifiedPathInType &) override {}
virtual void visit (HIR::LiteralExpr &) override {}
- virtual void visit (HIR::AttrInputLiteral &) override {}
- virtual void visit (HIR::MetaItemLitExpr &) override {}
- virtual void visit (HIR::MetaItemPathLit &) override {}
virtual void visit (HIR::BorrowExpr &) override {}
virtual void visit (HIR::DereferenceExpr &) override {}
virtual void visit (HIR::ErrorPropagationExpr &) override {}
@@ -161,12 +156,6 @@ public:
virtual void visit (HIR::MacroMatcher &) override {}
virtual void visit (HIR::MacroRulesDefinition &) override {}
virtual void visit (HIR::MacroInvocation &) override {}
- virtual void visit (HIR::MetaItemPath &) override {}
- virtual void visit (HIR::MetaItemSeq &) override {}
- virtual void visit (HIR::MetaWord &) override {}
- virtual void visit (HIR::MetaNameValueStr &) override {}
- virtual void visit (HIR::MetaListPaths &) override {}
- virtual void visit (HIR::MetaListNameValueStr &) override {}
virtual void visit (HIR::LiteralPattern &) override {}
virtual void visit (HIR::IdentifierPattern &) override {}
diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc
index f17d269..9b57484 100644
--- a/gcc/rust/ast/rust-ast-full-test.cc
+++ b/gcc/rust/ast/rust-ast-full-test.cc
@@ -3998,6 +3998,14 @@ MaybeNamedParam::as_string () const
return str;
}
+MetaItemInner::~MetaItemInner () = default;
+
+std::unique_ptr<MetaNameValueStr>
+MetaItemInner::to_meta_name_value_str () const
+{
+ return nullptr;
+}
+
std::string
MetaItemSeq::as_string () const
{
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index b6d3401..08f29d1 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -38,6 +38,7 @@ struct Session;
namespace AST {
// foward decl: ast visitor
class ASTVisitor;
+using AttrVec = std::vector<Attribute>;
// Delimiter types - used in macros and whatever.
enum DelimType
@@ -583,7 +584,7 @@ public:
return std::unique_ptr<MetaItemInner> (clone_meta_item_inner_impl ());
}
- virtual ~MetaItemInner () {}
+ virtual ~MetaItemInner ();
virtual std::string as_string () const = 0;
@@ -591,10 +592,7 @@ public:
/* HACK: used to simplify parsing - creates a copy of that type, or returns
* null */
- virtual std::unique_ptr<MetaNameValueStr> to_meta_name_value_str () const
- {
- return nullptr;
- }
+ virtual std::unique_ptr<MetaNameValueStr> to_meta_name_value_str () const;
// HACK: used to simplify parsing - same thing
virtual SimplePath to_path_item () const
diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h
index ec7c13a..24a7ccc 100644
--- a/gcc/rust/backend/rust-compile-base.h
+++ b/gcc/rust/backend/rust-compile-base.h
@@ -32,13 +32,7 @@ public:
virtual ~HIRCompileBase () {}
// rust-ast.h
- // virtual void visit(AttrInput& attr_input) {}
- // virtual void visit(TokenTree& token_tree) {}
- // virtual void visit(MacroMatch& macro_match) {}
virtual void visit (HIR::Token &tok) {}
- virtual void visit (HIR::DelimTokenTree &delim_tok_tree) {}
- virtual void visit (HIR::AttrInputMetaItemContainer &input) {}
- // virtual void visit(MetaItem& meta_item) {}
// virtual void visit(Stmt& stmt) {}
// virtual void visit(Expr& expr) {}
virtual void visit (HIR::IdentifierExpr &ident_expr) {}
@@ -63,9 +57,6 @@ public:
// rust-expr.h
virtual void visit (HIR::LiteralExpr &expr) {}
- virtual void visit (HIR::AttrInputLiteral &attr_input) {}
- virtual void visit (HIR::MetaItemLitExpr &meta_item) {}
- virtual void visit (HIR::MetaItemPathLit &meta_item) {}
virtual void visit (HIR::BorrowExpr &expr) {}
virtual void visit (HIR::DereferenceExpr &expr) {}
virtual void visit (HIR::ErrorPropagationExpr &expr) {}
@@ -179,12 +170,6 @@ public:
virtual void visit (HIR::MacroMatcher &matcher) {}
virtual void visit (HIR::MacroRulesDefinition &rules_def) {}
virtual void visit (HIR::MacroInvocation &macro_invoc) {}
- virtual void visit (HIR::MetaItemPath &meta_item) {}
- virtual void visit (HIR::MetaItemSeq &meta_item) {}
- virtual void visit (HIR::MetaWord &meta_item) {}
- virtual void visit (HIR::MetaNameValueStr &meta_item) {}
- virtual void visit (HIR::MetaListPaths &meta_item) {}
- virtual void visit (HIR::MetaListNameValueStr &meta_item) {}
// rust-pattern.h
virtual void visit (HIR::LiteralPattern &pattern) {}
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc
index e52cb7b..27b85e9 100644
--- a/gcc/rust/expand/rust-macro-expand.cc
+++ b/gcc/rust/expand/rust-macro-expand.cc
@@ -3273,7 +3273,7 @@ MacroExpander::expand_invoc (std::unique_ptr<AST::MacroInvocation> &invoc)
/* Determines whether any cfg predicate is false and hence item with attributes
* should be stripped. Note that attributes must be expanded before calling. */
bool
-MacroExpander::fails_cfg (const std::vector<AST::Attribute> &attrs) const
+MacroExpander::fails_cfg (const AST::AttrVec &attrs) const
{
for (const auto &attr : attrs)
{
@@ -3286,7 +3286,7 @@ MacroExpander::fails_cfg (const std::vector<AST::Attribute> &attrs) const
/* Determines whether any cfg predicate is false and hence item with attributes
* should be stripped. Will expand attributes as well. */
bool
-MacroExpander::fails_cfg_with_expand (std::vector<AST::Attribute> &attrs) const
+MacroExpander::fails_cfg_with_expand (AST::AttrVec &attrs) const
{
// TODO: maybe have something that strips cfg attributes that evaluate true?
for (auto &attr : attrs)
@@ -3329,7 +3329,7 @@ MacroExpander::fails_cfg_with_expand (std::vector<AST::Attribute> &attrs) const
// Expands cfg_attr attributes.
void
-MacroExpander::expand_cfg_attrs (std::vector<AST::Attribute> &attrs)
+MacroExpander::expand_cfg_attrs (AST::AttrVec &attrs)
{
for (std::size_t i = 0; i < attrs.size (); i++)
{
@@ -3342,8 +3342,7 @@ MacroExpander::expand_cfg_attrs (std::vector<AST::Attribute> &attrs)
if (attr.check_cfg_predicate (session))
{
// split off cfg_attr
- std::vector<AST::Attribute> new_attrs
- = attr.separate_cfg_attrs ();
+ AST::AttrVec new_attrs = attr.separate_cfg_attrs ();
// remove attr from vector
attrs.erase (attrs.begin () + i);
diff --git a/gcc/rust/expand/rust-macro-expand.h b/gcc/rust/expand/rust-macro-expand.h
index 89e3171..a458b0d 100644
--- a/gcc/rust/expand/rust-macro-expand.h
+++ b/gcc/rust/expand/rust-macro-expand.h
@@ -67,9 +67,9 @@ struct MacroExpander
AST::ASTFragment expand_decl_macro (AST::MacroInvocData &invoc,
AST::MacroRulesDefinition &rules_def);
- void expand_cfg_attrs (std::vector<AST::Attribute> &attrs);
- bool fails_cfg (const std::vector<AST::Attribute> &attr) const;
- bool fails_cfg_with_expand (std::vector<AST::Attribute> &attrs) const;
+ void expand_cfg_attrs (AST::AttrVec &attrs);
+ bool fails_cfg (const AST::AttrVec &attr) const;
+ bool fails_cfg_with_expand (AST::AttrVec &attrs) const;
// Expand the data of a cfg! macro.
void parse_macro_to_meta_item (AST::MacroInvocData &invoc);
diff --git a/gcc/rust/hir/rust-ast-lower-block.h b/gcc/rust/hir/rust-ast-lower-block.h
index 25c3583..77ca50d 100644
--- a/gcc/rust/hir/rust-ast-lower-block.h
+++ b/gcc/rust/hir/rust-ast-lower-block.h
@@ -142,7 +142,7 @@ public:
void visit (AST::LoopExpr &expr) override
{
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::BlockExpr *loop_block
= ASTLoweringBlock::translate (expr.get_loop_block ().get (),
&terminated);
diff --git a/gcc/rust/hir/rust-ast-lower-expr.h b/gcc/rust/hir/rust-ast-lower-expr.h
index 33fc45b..0aeaf09 100644
--- a/gcc/rust/hir/rust-ast-lower-expr.h
+++ b/gcc/rust/hir/rust-ast-lower-expr.h
@@ -80,7 +80,7 @@ public:
void visit (AST::TupleIndexExpr &expr) override
{
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::Expr *tuple_expr
= ASTLoweringExpr::translate (expr.get_tuple_expr ().get (), &terminated);
@@ -99,8 +99,8 @@ public:
void visit (AST::TupleExpr &expr) override
{
- std::vector<HIR::Attribute> inner_attribs;
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec inner_attribs;
+ AST::AttrVec outer_attribs;
std::vector<std::unique_ptr<HIR::Expr> > tuple_elements;
for (auto &e : expr.get_tuple_elems ())
{
@@ -163,7 +163,7 @@ public:
void visit (AST::CallExpr &expr) override
{
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::Expr *func
= ASTLoweringExpr::translate (expr.get_function_expr ().get ());
std::vector<std::unique_ptr<HIR::Expr> > params;
@@ -186,7 +186,7 @@ public:
void visit (AST::MethodCallExpr &expr) override
{
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::PathExprSegment method_path
= lower_path_expr_seg (expr.get_method_name ());
@@ -240,8 +240,8 @@ public:
void visit (AST::ArrayExpr &expr) override
{
- std::vector<HIR::Attribute> outer_attribs;
- std::vector<HIR::Attribute> inner_attribs;
+ AST::AttrVec outer_attribs;
+ AST::AttrVec inner_attribs;
expr.get_array_elems ()->accept_vis (*this);
rust_assert (translated_array_elems != nullptr);
@@ -259,7 +259,7 @@ public:
void visit (AST::ArrayIndexExpr &expr) override
{
- std::vector<Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::Expr *array_expr
= ASTLoweringExpr::translate (expr.get_array_expr ().get ());
HIR::Expr *array_index_expr
@@ -402,7 +402,7 @@ public:
void visit (AST::NegationExpr &expr) override
{
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::Expr *negated_value
= ASTLoweringExpr::translate (expr.get_negated_expr ().get ());
@@ -482,8 +482,8 @@ public:
void visit (AST::StructExprStructFields &struct_expr) override
{
- std::vector<HIR::Attribute> inner_attribs;
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec inner_attribs;
+ AST::AttrVec outer_attribs;
// bit of a hack for now
HIR::PathInExpression *path
@@ -522,8 +522,8 @@ public:
void visit (AST::GroupedExpr &expr) override
{
- std::vector<HIR::Attribute> inner_attribs;
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec inner_attribs;
+ AST::AttrVec outer_attribs;
HIR::Expr *paren_expr
= ASTLoweringExpr::translate (expr.get_expr_in_parens ().get ());
@@ -541,8 +541,8 @@ public:
void visit (AST::FieldAccessExpr &expr) override
{
- std::vector<HIR::Attribute> inner_attribs;
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec inner_attribs;
+ AST::AttrVec outer_attribs;
HIR::Expr *receiver
= ASTLoweringExpr::translate (expr.get_receiver_expr ().get ());
@@ -570,7 +570,7 @@ public:
void visit (AST::BreakExpr &expr) override
{
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::Lifetime break_label = lower_lifetime (expr.get_label ());
HIR::Expr *break_expr
= expr.has_break_expr ()
@@ -590,7 +590,7 @@ public:
void visit (AST::ContinueExpr &expr) override
{
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::Lifetime break_label = lower_lifetime (expr.get_label ());
auto crate_num = mappings->get_current_crate ();
@@ -605,7 +605,7 @@ public:
void visit (AST::BorrowExpr &expr) override
{
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::Expr *borrow_lvalue
= ASTLoweringExpr::translate (expr.get_borrowed_expr ().get ());
@@ -624,7 +624,7 @@ public:
void visit (AST::DereferenceExpr &expr) override
{
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::Expr *dref_lvalue
= ASTLoweringExpr::translate (expr.get_dereferenced_expr ().get ());
diff --git a/gcc/rust/hir/rust-ast-lower-implitem.h b/gcc/rust/hir/rust-ast-lower-implitem.h
index 2581d68e..43cc256 100644
--- a/gcc/rust/hir/rust-ast-lower-implitem.h
+++ b/gcc/rust/hir/rust-ast-lower-implitem.h
@@ -60,7 +60,7 @@ public:
void visit (AST::ConstantItem &constant) override
{
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
HIR::Visibility vis = HIR::Visibility::create_public ();
HIR::Type *type = ASTLoweringType::translate (constant.get_type ().get ());
@@ -86,7 +86,7 @@ public:
void visit (AST::Function &function) override
{
// ignore for now and leave empty
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::FunctionQualifiers qualifiers (
@@ -169,7 +169,7 @@ public:
void visit (AST::Method &method) override
{
// ignore for now and leave empty
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::FunctionQualifiers qualifiers (
diff --git a/gcc/rust/hir/rust-ast-lower-item.h b/gcc/rust/hir/rust-ast-lower-item.h
index fe0b791..10ec203 100644
--- a/gcc/rust/hir/rust-ast-lower-item.h
+++ b/gcc/rust/hir/rust-ast-lower-item.h
@@ -58,7 +58,7 @@ public:
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::Visibility vis = HIR::Visibility::create_public ();
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
std::vector<std::unique_ptr<HIR::GenericParam> > generic_params;
if (alias.has_generics ())
@@ -98,11 +98,11 @@ public:
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::Visibility vis = HIR::Visibility::create_public ();
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
std::vector<HIR::TupleField> fields;
struct_decl.iterate ([&] (AST::TupleField &field) mutable -> bool {
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
HIR::Visibility vis = HIR::Visibility::create_public ();
HIR::Type *type
= ASTLoweringType::translate (field.get_field_type ().get ());
@@ -154,12 +154,12 @@ public:
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::Visibility vis = HIR::Visibility::create_public ();
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
bool is_unit = struct_decl.is_unit_struct ();
std::vector<HIR::StructField> fields;
struct_decl.iterate ([&] (AST::StructField &field) mutable -> bool {
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
HIR::Visibility vis = HIR::Visibility::create_public ();
HIR::Type *type
= ASTLoweringType::translate (field.get_field_type ().get ());
@@ -201,7 +201,7 @@ public:
void visit (AST::StaticItem &var) override
{
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
HIR::Visibility vis = HIR::Visibility::create_public ();
HIR::Type *type = ASTLoweringType::translate (var.get_type ().get ());
@@ -227,7 +227,7 @@ public:
void visit (AST::ConstantItem &constant) override
{
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
HIR::Visibility vis = HIR::Visibility::create_public ();
HIR::Type *type = ASTLoweringType::translate (constant.get_type ().get ());
@@ -253,7 +253,7 @@ public:
void visit (AST::Function &function) override
{
// ignore for now and leave empty
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
HIR::FunctionQualifiers qualifiers (
@@ -337,8 +337,8 @@ public:
void visit (AST::InherentImpl &impl_block) override
{
- std::vector<HIR::Attribute> inner_attrs;
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec inner_attrs;
+ AST::AttrVec outer_attrs;
std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items;
HIR::WhereClause where_clause (std::move (where_clause_items));
diff --git a/gcc/rust/hir/rust-ast-lower-stmt.h b/gcc/rust/hir/rust-ast-lower-stmt.h
index 2d3f59d..0534749 100644
--- a/gcc/rust/hir/rust-ast-lower-stmt.h
+++ b/gcc/rust/hir/rust-ast-lower-stmt.h
@@ -86,7 +86,7 @@ public:
void visit (AST::LetStmt &stmt) override
{
- std::vector<HIR::Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
HIR::Pattern *variables
= ASTLoweringPattern::translate (stmt.get_pattern ().get ());
HIR::Type *type = stmt.has_type ()
diff --git a/gcc/rust/hir/rust-ast-lower-type.h b/gcc/rust/hir/rust-ast-lower-type.h
index e647337..635c018 100644
--- a/gcc/rust/hir/rust-ast-lower-type.h
+++ b/gcc/rust/hir/rust-ast-lower-type.h
@@ -295,7 +295,7 @@ public:
void visit (AST::TypeParam &param) override
{
- HIR::Attribute outer_attr = HIR::Attribute::create_empty ();
+ AST::Attribute outer_attr = AST::Attribute::create_empty ();
std::vector<std::unique_ptr<HIR::TypeParamBound> > type_param_bounds;
HIR::Type *type = param.has_type ()
? ASTLoweringType::translate (param.get_type ().get ())
diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc
index f1129ab..b436089 100644
--- a/gcc/rust/hir/rust-ast-lower.cc
+++ b/gcc/rust/hir/rust-ast-lower.cc
@@ -40,7 +40,7 @@ HIR::Crate
ASTLowering::go ()
{
std::vector<std::unique_ptr<HIR::Item> > items;
- std::vector<HIR::Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
bool has_utf8bom = false;
bool has_shebang = false;
@@ -65,8 +65,8 @@ ASTLowering::go ()
void
ASTLoweringBlock::visit (AST::BlockExpr &expr)
{
- std::vector<HIR::Attribute> inner_attribs;
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec inner_attribs;
+ AST::AttrVec outer_attribs;
std::vector<std::unique_ptr<HIR::Stmt> > block_stmts;
bool block_did_terminate = false;
@@ -240,7 +240,7 @@ ASTLowerStructExprField::visit (AST::StructExprFieldIdentifier &field)
void
ASTLoweringExprWithBlock::visit (AST::WhileLoopExpr &expr)
{
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
HIR::BlockExpr *loop_block
= ASTLoweringBlock::translate (expr.get_loop_block ().get (), &terminated);
diff --git a/gcc/rust/hir/tree/rust-hir-cond-compilation.h b/gcc/rust/hir/tree/rust-hir-cond-compilation.h
index 3a1ddf2..f39c859 100644
--- a/gcc/rust/hir/tree/rust-hir-cond-compilation.h
+++ b/gcc/rust/hir/tree/rust-hir-cond-compilation.h
@@ -19,6 +19,7 @@
#ifndef RUST_AST_CONDCOMPILATION
#define RUST_AST_CONDCOMPILATION
+#include "rust-ast-full-decls.h"
#include "rust-hir.h"
namespace Rust {
@@ -206,18 +207,18 @@ public:
// TODO: inline
struct CfgAttrs
{
- std::vector<Attribute> cfg_attrs;
+ AST::AttrVec cfg_attrs;
};
// TODO: relationship to other attributes?
class CfgAttrAttribute
{
std::unique_ptr<ConfigurationPredicate> config_to_include;
- std::vector<Attribute> cfg_attrs;
+ AST::AttrVec cfg_attrs;
public:
CfgAttrAttribute (ConfigurationPredicate *config_to_include,
- std::vector<Attribute> cfg_attrs)
+ AST::AttrVec cfg_attrs)
: config_to_include (config_to_include), cfg_attrs (cfg_attrs)
{}
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h
index 50f1eb8..7a5227a 100644
--- a/gcc/rust/hir/tree/rust-hir-expr.h
+++ b/gcc/rust/hir/tree/rust-hir-expr.h
@@ -19,6 +19,7 @@
#ifndef RUST_HIR_EXPR_H
#define RUST_HIR_EXPR_H
+#include "rust-ast-full-decls.h"
#include "rust-hir.h"
#include "rust-hir-path.h"
#include "operator.h"
@@ -32,7 +33,7 @@ class ExprWithBlock : public Expr
// TODO: should this mean that a BlockExpr should be a member variable?
protected:
ExprWithBlock (Analysis::NodeMapping mappings,
- std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: Expr (std::move (mappings), std::move (outer_attrs))
{}
@@ -72,14 +73,13 @@ public:
LiteralExpr (Analysis::NodeMapping mappings, std::string value_as_string,
Literal::LitType type, PrimitiveCoreType type_hint,
- Location locus,
- std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ Location locus, AST::AttrVec outer_attrs = AST::AttrVec ())
: ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
literal (std::move (value_as_string), type, type_hint), locus (locus)
{}
LiteralExpr (Analysis::NodeMapping mappings, Literal literal, Location locus,
- std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
literal (std::move (literal)), locus (locus)
{}
@@ -120,86 +120,6 @@ protected:
}
};
-// Literal expression attribute body (non-macro attribute)
-class AttrInputLiteral : public AttrInput
-{
- // Literal expression WITHOUT SUFFIX
- // std::unique_ptr<LiteralExpr> literal_expr;
- LiteralExpr
- literal_expr; // as not using polymorphic behaviour, doesn't require pointer
- // TODO: will require pointer if LiteralExpr is changed to have subclassing
-
- // TODO: should this store location data?
-
-public:
- AttrInputLiteral (LiteralExpr lit_expr) : literal_expr (std::move (lit_expr))
- {}
-
- std::string as_string () const override
- {
- return " = " + literal_expr.as_string ();
- }
-
- void accept_vis (HIRVisitor &vis) override;
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- AttrInputLiteral *clone_attr_input_impl () const override
- {
- return new AttrInputLiteral (*this);
- }
-};
-
-/* literal expr only meta item inner - TODO possibly replace with inheritance of
- * LiteralExpr itself? */
-class MetaItemLitExpr : public MetaItemInner
-{
- LiteralExpr lit_expr;
-
-public:
- MetaItemLitExpr (LiteralExpr lit_expr) : lit_expr (std::move (lit_expr)) {}
-
- std::string as_string () const override { return lit_expr.as_string (); }
-
- void accept_vis (HIRVisitor &vis) override;
-
-protected:
- // Use covariance to implement clone function as returning this type
- MetaItemLitExpr *clone_meta_item_inner_impl () const override
- {
- return new MetaItemLitExpr (*this);
- }
-};
-
-// more generic meta item "path = lit" form
-class MetaItemPathLit : public MetaItem
-{
- SimplePath path;
- LiteralExpr lit;
-
-public:
- MetaItemPathLit (SimplePath path, LiteralExpr lit_expr)
- : path (std::move (path)), lit (std::move (lit_expr))
- {}
-
- std::string as_string () const override
- {
- return path.as_string () + " = " + lit.as_string ();
- }
-
- void accept_vis (HIRVisitor &vis) override;
-
- Attribute to_attribute () const override;
-
-protected:
- // Use covariance to implement clone function as returning this type
- MetaItemPathLit *clone_meta_item_inner_impl () const override
- {
- return new MetaItemPathLit (*this);
- }
-};
-
/* Represents an expression using unary or binary operators as HIR node. Can be
* overloaded. */
class OperatorExpr : public ExprWithoutBlock
@@ -216,7 +136,7 @@ protected:
// Constructor (only for initialisation of expr purposes)
OperatorExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> main_or_left_expr,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
locus (locus), main_or_left_expr (std::move (main_or_left_expr))
{}
@@ -261,8 +181,7 @@ public:
BorrowExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> borrow_lvalue, bool is_mut_borrow,
- bool is_double_borrow, std::vector<Attribute> outer_attribs,
- Location locus)
+ bool is_double_borrow, AST::AttrVec outer_attribs, Location locus)
: OperatorExpr (std::move (mappings), std::move (borrow_lvalue),
std::move (outer_attribs), locus),
is_mut (is_mut_borrow), double_borrow (is_double_borrow)
@@ -298,7 +217,7 @@ public:
// Constructor calls OperatorExpr's protected constructor
DereferenceExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> deref_lvalue,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: OperatorExpr (std::move (mappings), std::move (deref_lvalue),
std::move (outer_attribs), locus)
{}
@@ -330,7 +249,7 @@ public:
// Constructor calls OperatorExpr's protected constructor
ErrorPropagationExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> potential_error_value,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: OperatorExpr (std::move (mappings), std::move (potential_error_value),
std::move (outer_attribs), locus)
{}
@@ -373,7 +292,7 @@ public:
// Constructor calls OperatorExpr's protected constructor
NegationExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> negated_value, ExprType expr_kind,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: OperatorExpr (std::move (mappings), std::move (negated_value),
std::move (outer_attribs), locus),
expr_type (expr_kind)
@@ -422,7 +341,7 @@ public:
std::unique_ptr<Expr> right_value,
ExprType expr_kind, Location locus)
: OperatorExpr (std::move (mappings), std::move (left_value),
- std::vector<Attribute> (), locus),
+ AST::AttrVec (), locus),
expr_type (expr_kind), right_expr (std::move (right_value))
{}
// outer attributes not allowed
@@ -496,7 +415,7 @@ public:
std::unique_ptr<Expr> right_value, ExprType comparison_kind,
Location locus)
: OperatorExpr (std::move (mappings), std::move (left_value),
- std::vector<Attribute> (), locus),
+ AST::AttrVec (), locus),
expr_type (comparison_kind), right_expr (std::move (right_value))
{}
// outer attributes not allowed
@@ -566,7 +485,7 @@ public:
std::unique_ptr<Expr> right_bool_expr, ExprType expr_kind,
Location locus)
: OperatorExpr (std::move (mappings), std::move (left_bool_expr),
- std::vector<Attribute> (), locus),
+ AST::AttrVec (), locus),
expr_type (expr_kind), right_expr (std::move (right_bool_expr))
{}
// outer attributes not allowed
@@ -632,7 +551,7 @@ public:
std::unique_ptr<Expr> expr_to_cast,
std::unique_ptr<TypeNoBounds> type_to_cast_to, Location locus)
: OperatorExpr (std::move (mappings), std::move (expr_to_cast),
- std::vector<Attribute> (), locus),
+ AST::AttrVec (), locus),
type_to_convert_to (std::move (type_to_cast_to))
{}
// outer attributes not allowed
@@ -688,7 +607,7 @@ public:
std::unique_ptr<Expr> value_to_assign_to,
std::unique_ptr<Expr> value_to_assign, Location locus)
: OperatorExpr (std::move (mappings), std::move (value_to_assign_to),
- std::vector<Attribute> (), locus),
+ AST::AttrVec (), locus),
right_expr (std::move (value_to_assign))
{}
// outer attributes not allowed
@@ -740,7 +659,7 @@ protected:
// Expression in parentheses (i.e. like literally just any 3 + (2 * 6))
class GroupedExpr : public ExprWithoutBlock
{
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
std::unique_ptr<Expr> expr_in_parens;
Location locus;
@@ -748,12 +667,12 @@ class GroupedExpr : public ExprWithoutBlock
public:
std::string as_string () const override;
- std::vector<Attribute> get_inner_attrs () const { return inner_attrs; }
+ AST::AttrVec get_inner_attrs () const { return inner_attrs; }
GroupedExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> parenthesised_expr,
- std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
+ Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)),
expr_in_parens (std::move (parenthesised_expr)), locus (locus)
@@ -937,7 +856,7 @@ protected:
// Array definition-ish expression
class ArrayExpr : public ExprWithoutBlock
{
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
std::unique_ptr<ArrayElems> internal_elements;
Location locus;
@@ -945,7 +864,7 @@ class ArrayExpr : public ExprWithoutBlock
public:
std::string as_string () const override;
- std::vector<Attribute> get_inner_attrs () const { return inner_attrs; }
+ AST::AttrVec get_inner_attrs () const { return inner_attrs; }
// Returns whether array expr has array elems or if it is just empty.
bool has_array_elems () const { return internal_elements != nullptr; }
@@ -953,8 +872,8 @@ public:
// Constructor requires ArrayElems pointer
ArrayExpr (Analysis::NodeMapping mappings,
std::unique_ptr<ArrayElems> array_elems,
- std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
+ Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)),
internal_elements (std::move (array_elems)), locus (locus)
@@ -1024,7 +943,7 @@ public:
ArrayIndexExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> array_expr,
std::unique_ptr<Expr> array_index_expr,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
array_expr (std::move (array_expr)),
index_expr (std::move (array_index_expr)), locus (locus)
@@ -1079,7 +998,7 @@ protected:
// HIR representation of a tuple
class TupleExpr : public ExprWithoutBlock
{
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
std::vector<std::unique_ptr<Expr> > tuple_elems;
// replaces (inlined version of) TupleElements
@@ -1089,12 +1008,12 @@ class TupleExpr : public ExprWithoutBlock
public:
std::string as_string () const override;
- std::vector<Attribute> get_inner_attrs () const { return inner_attrs; }
+ AST::AttrVec get_inner_attrs () const { return inner_attrs; }
TupleExpr (Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<Expr> > tuple_elements,
- std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
+ Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)),
tuple_elems (std::move (tuple_elements)), locus (locus)
@@ -1179,7 +1098,7 @@ public:
TupleIndexExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> tuple_expr, TupleIndex index,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
tuple_expr (std::move (tuple_expr)), tuple_index (index), locus (locus)
{}
@@ -1241,7 +1160,7 @@ protected:
// Protected constructor to allow initialising struct_name
StructExpr (Analysis::NodeMapping mappings, PathInExpression struct_path,
- std::vector<Attribute> outer_attribs)
+ AST::AttrVec outer_attribs)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
struct_name (std::move (struct_path))
{}
@@ -1255,20 +1174,19 @@ public:
// Actual HIR node of the struct creator (with no fields). Not abstract!
class StructExprStruct : public StructExpr
{
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
Location locus;
public:
std::string as_string () const override;
- std::vector<Attribute> get_inner_attrs () const { return inner_attrs; }
+ AST::AttrVec get_inner_attrs () const { return inner_attrs; }
// Constructor has to call protected constructor of base class
StructExprStruct (Analysis::NodeMapping mappings,
- PathInExpression struct_path,
- std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ PathInExpression struct_path, AST::AttrVec inner_attribs,
+ AST::AttrVec outer_attribs, Location locus)
: StructExpr (std::move (mappings), std::move (struct_path),
std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)), locus (locus)
@@ -1520,9 +1438,8 @@ public:
StructExprStructFields (
Analysis::NodeMapping mappings, PathInExpression struct_path,
std::vector<std::unique_ptr<StructExprField> > expr_fields, Location locus,
- StructBase *base_struct,
- std::vector<Attribute> inner_attribs = std::vector<Attribute> (),
- std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ StructBase *base_struct, AST::AttrVec inner_attribs = AST::AttrVec (),
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: StructExprStruct (std::move (mappings), std::move (struct_path),
std::move (inner_attribs), std::move (outer_attribs),
locus),
@@ -1617,8 +1534,8 @@ public:
StructExprStructBase (Analysis::NodeMapping mappings,
PathInExpression struct_path, StructBase base_struct,
- std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
+ Location locus)
: StructExprStruct (std::move (mappings), std::move (struct_path),
std::move (inner_attribs), std::move (outer_attribs),
locus),
@@ -1647,7 +1564,7 @@ protected:
// HIR node of a tuple struct creator
class StructExprTuple : public StructExpr
{
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
std::vector<std::unique_ptr<Expr> > exprs;
Location locus;
@@ -1655,7 +1572,7 @@ class StructExprTuple : public StructExpr
public:
std::string as_string () const override;
- const std::vector<Attribute> &get_inner_attrs () const { return inner_attrs; }
+ const AST::AttrVec &get_inner_attrs () const { return inner_attrs; }
/*inline std::vector<std::unique_ptr<Expr>> get_exprs() const {
return exprs;
@@ -1663,8 +1580,8 @@ public:
StructExprTuple (Analysis::NodeMapping mappings, PathInExpression struct_path,
std::vector<std::unique_ptr<Expr> > tuple_exprs,
- std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
+ Location locus)
: StructExpr (std::move (mappings), std::move (struct_path),
std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)), exprs (std::move (tuple_exprs)),
@@ -1728,7 +1645,7 @@ public:
std::string as_string () const override { return struct_name.as_string (); }
StructExprUnit (Analysis::NodeMapping mappings, PathInExpression struct_path,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: StructExpr (std::move (mappings), std::move (struct_path),
std::move (outer_attribs)),
locus (locus)
@@ -1765,7 +1682,7 @@ protected:
// Protected constructor for initialising enum_variant_path
EnumVariantExpr (Analysis::NodeMapping mappings,
PathInExpression path_to_enum_variant,
- std::vector<Attribute> outer_attribs)
+ AST::AttrVec outer_attribs)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
enum_variant_path (std::move (path_to_enum_variant))
{}
@@ -1920,7 +1837,7 @@ public:
EnumExprStruct (Analysis::NodeMapping mappings,
PathInExpression enum_variant_path,
std::vector<std::unique_ptr<EnumExprField> > variant_fields,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: EnumVariantExpr (std::move (mappings), std::move (enum_variant_path),
std::move (outer_attribs)),
fields (std::move (variant_fields)), locus (locus)
@@ -1990,7 +1907,7 @@ public:
EnumExprTuple (Analysis::NodeMapping mappings,
PathInExpression enum_variant_path,
std::vector<std::unique_ptr<Expr> > variant_values,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: EnumVariantExpr (std::move (mappings), std::move (enum_variant_path),
std::move (outer_attribs)),
values (std::move (variant_values)), locus (locus)
@@ -2057,7 +1974,7 @@ public:
EnumExprFieldless (Analysis::NodeMapping mappings,
PathInExpression enum_variant_path,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: EnumVariantExpr (std::move (mappings), std::move (enum_variant_path),
std::move (outer_attribs)),
locus (locus)
@@ -2101,7 +2018,7 @@ public:
CallExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> function_expr,
std::vector<std::unique_ptr<Expr> > function_params,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
function (std::move (function_expr)),
params (std::move (function_params)), locus (locus)
@@ -2192,7 +2109,7 @@ public:
std::unique_ptr<Expr> call_receiver,
PathExprSegment method_path,
std::vector<std::unique_ptr<Expr> > method_params,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
receiver (std::move (call_receiver)),
method_name (std::move (method_path)), params (std::move (method_params)),
@@ -2286,7 +2203,7 @@ public:
FieldAccessExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> field_access_receiver,
- Identifier field_name, std::vector<Attribute> outer_attribs,
+ Identifier field_name, AST::AttrVec outer_attribs,
Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
receiver (std::move (field_access_receiver)),
@@ -2411,7 +2328,7 @@ class ClosureExpr : public ExprWithoutBlock
protected:
ClosureExpr (Analysis::NodeMapping mappings,
std::vector<ClosureParam> closure_params, bool has_move,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
has_move (has_move), params (std::move (closure_params)), locus (locus)
{}
@@ -2436,8 +2353,7 @@ public:
std::unique_ptr<Expr> closure_inner_expr,
std::vector<ClosureParam> closure_params, Location locus,
bool is_move = false,
- std::vector<Attribute> outer_attribs
- = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: ClosureExpr (std::move (mappings), std::move (closure_params), is_move,
std::move (outer_attribs), locus),
closure_inner (std::move (closure_inner_expr))
@@ -2486,7 +2402,7 @@ protected:
class BlockExpr : public ExprWithBlock
{
public:
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
std::vector<std::unique_ptr<Stmt> > statements;
std::unique_ptr<Expr> expr; // inlined from Statements
@@ -2507,8 +2423,8 @@ public:
BlockExpr (Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<Stmt> > block_statements,
std::unique_ptr<Expr> block_expr, bool tail_reachable,
- std::vector<Attribute> inner_attribs,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec inner_attribs, AST::AttrVec outer_attribs,
+ Location locus)
: ExprWithBlock (std::move (mappings), std::move (outer_attribs)),
inner_attrs (std::move (inner_attribs)),
statements (std::move (block_statements)), expr (std::move (block_expr)),
@@ -2623,8 +2539,7 @@ public:
std::unique_ptr<BlockExpr> closure_expr,
std::vector<ClosureParam> closure_params,
Location locus, bool is_move = false,
- std::vector<Attribute> outer_attribs
- = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: ClosureExpr (std::move (mappings), std::move (closure_params), is_move,
std::move (outer_attribs), locus),
return_type (std::move (closure_return_type)),
@@ -2687,8 +2602,7 @@ public:
// Constructor for a ContinueExpr with a label.
ContinueExpr (Analysis::NodeMapping mappings, Location locus, Lifetime label,
- std::vector<Attribute> outer_attribs
- = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
label (std::move (label)), locus (locus)
{}
@@ -2742,7 +2656,7 @@ public:
BreakExpr (Analysis::NodeMapping mappings, Location locus,
Lifetime break_label,
std::unique_ptr<Expr> expr_in_break = nullptr,
- std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
label (std::move (break_label)), break_expr (std::move (expr_in_break)),
locus (locus)
@@ -2803,8 +2717,7 @@ class RangeExpr : public ExprWithoutBlock
protected:
// outer attributes not allowed before range expressions
RangeExpr (Analysis::NodeMapping mappings, Location locus)
- : ExprWithoutBlock (std::move (mappings), std::vector<Attribute> ()),
- locus (locus)
+ : ExprWithoutBlock (std::move (mappings), AST::AttrVec ()), locus (locus)
{}
public:
@@ -3122,7 +3035,7 @@ public:
// Constructor for ReturnExpr.
ReturnExpr (Analysis::NodeMapping mappings, Location locus,
std::unique_ptr<Expr> returned_expr = nullptr,
- std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs)),
return_expr (std::move (returned_expr)), locus (locus)
{}
@@ -3190,7 +3103,7 @@ public:
UnsafeBlockExpr (Analysis::NodeMapping mappings,
std::unique_ptr<BlockExpr> block_expr,
- std::vector<Attribute> outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: ExprWithBlock (std::move (mappings), std::move (outer_attribs)),
expr (std::move (block_expr)), locus (locus)
{}
@@ -3282,8 +3195,7 @@ protected:
BaseLoopExpr (Analysis::NodeMapping mappings,
std::unique_ptr<BlockExpr> loop_block, Location locus,
LoopLabel loop_label,
- std::vector<Attribute> outer_attribs
- = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: ExprWithBlock (std::move (mappings), std::move (outer_attribs)),
loop_label (std::move (loop_label)), loop_block (std::move (loop_block)),
locus (locus)
@@ -3331,8 +3243,7 @@ public:
// Constructor for LoopExpr
LoopExpr (Analysis::NodeMapping mappings,
std::unique_ptr<BlockExpr> loop_block, Location locus,
- LoopLabel loop_label,
- std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ LoopLabel loop_label, AST::AttrVec outer_attribs = AST::AttrVec ())
: BaseLoopExpr (std::move (mappings), std::move (loop_block), locus,
std::move (loop_label), std::move (outer_attribs))
{}
@@ -3365,8 +3276,7 @@ public:
std::unique_ptr<Expr> loop_condition,
std::unique_ptr<BlockExpr> loop_block, Location locus,
LoopLabel loop_label,
- std::vector<Attribute> outer_attribs
- = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: BaseLoopExpr (std::move (mappings), std::move (loop_block), locus,
std::move (loop_label), std::move (outer_attribs)),
condition (std::move (loop_condition))
@@ -3429,8 +3339,7 @@ public:
std::unique_ptr<Expr> condition,
std::unique_ptr<BlockExpr> loop_block, Location locus,
LoopLabel loop_label,
- std::vector<Attribute> outer_attribs
- = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: BaseLoopExpr (std::move (mappings), std::move (loop_block), locus,
std::move (loop_label), std::move (outer_attribs)),
match_arm_patterns (std::move (match_arm_patterns)),
@@ -3502,7 +3411,7 @@ public:
std::unique_ptr<Expr> iterator_expr,
std::unique_ptr<BlockExpr> loop_body, Location locus,
LoopLabel loop_label,
- std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: BaseLoopExpr (std::move (mappings), std::move (loop_body), locus,
std::move (loop_label), std::move (outer_attribs)),
pattern (std::move (loop_pattern)),
@@ -3566,7 +3475,7 @@ public:
IfExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> condition,
std::unique_ptr<BlockExpr> if_block, Location locus)
- : ExprWithBlock (std::move (mappings), std::vector<Attribute> ()),
+ : ExprWithBlock (std::move (mappings), AST::AttrVec ()),
condition (std::move (condition)), if_block (std::move (if_block)),
locus (locus)
{}
@@ -3784,7 +3693,7 @@ public:
std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block,
Location locus)
- : ExprWithBlock (std::move (mappings), std::vector<Attribute> ()),
+ : ExprWithBlock (std::move (mappings), AST::AttrVec ()),
match_arm_patterns (std::move (match_arm_patterns)),
value (std::move (value)), if_block (std::move (if_block)), locus (locus)
{}
@@ -4119,7 +4028,7 @@ protected:
struct MatchArm
{
private:
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
// MatchArmPatterns patterns;
std::vector<std::unique_ptr<Pattern> > match_arm_patterns; // inlined
@@ -4136,7 +4045,7 @@ public:
// Constructor for match arm with a guard expression
MatchArm (std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
std::unique_ptr<Expr> guard_expr = nullptr,
- std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: outer_attrs (std::move (outer_attrs)),
match_arm_patterns (std::move (match_arm_patterns)),
guard_expr (std::move (guard_expr))
@@ -4346,7 +4255,7 @@ protected:
class MatchExpr : public ExprWithBlock
{
std::unique_ptr<Expr> branch_value;
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
// bool has_match_arms;
// MatchArms match_arms;
@@ -4364,9 +4273,8 @@ public:
MatchExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> branch_value,
// std::vector<std::unique_ptr<MatchCase> > match_arms,
- std::vector<MatchCase> match_arms,
- std::vector<Attribute> inner_attrs,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::vector<MatchCase> match_arms, AST::AttrVec inner_attrs,
+ AST::AttrVec outer_attrs, Location locus)
: ExprWithBlock (std::move (mappings), std::move (outer_attrs)),
branch_value (std::move (branch_value)),
inner_attrs (std::move (inner_attrs)),
@@ -4433,7 +4341,7 @@ class AwaitExpr : public ExprWithoutBlock
public:
// TODO: ensure outer attributes are actually allowed
AwaitExpr (Analysis::NodeMapping mappings, std::unique_ptr<Expr> awaited_expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
awaited_expr (std::move (awaited_expr)), locus (locus)
{}
@@ -4486,7 +4394,7 @@ class AsyncBlockExpr : public ExprWithBlock
public:
AsyncBlockExpr (Analysis::NodeMapping mappings,
std::unique_ptr<BlockExpr> block_expr, bool has_move,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: ExprWithBlock (std::move (mappings), std::move (outer_attrs)),
has_move (has_move), block_expr (std::move (block_expr)), locus (locus)
{}
diff --git a/gcc/rust/hir/tree/rust-hir-full-decls.h b/gcc/rust/hir/tree/rust-hir-full-decls.h
index 8295e89..cdbc0a0 100644
--- a/gcc/rust/hir/tree/rust-hir-full-decls.h
+++ b/gcc/rust/hir/tree/rust-hir-full-decls.h
@@ -24,19 +24,10 @@
namespace Rust {
namespace HIR {
// rust-ast.h
-class AttrInput;
class TokenTree;
class MacroMatch;
class Token;
struct Literal;
-class DelimTokenTree;
-class PathSegment;
-class SimplePathSegment;
-class SimplePath;
-struct Attribute;
-class MetaItemInner;
-class AttrInputMetaItemContainer;
-class MetaItem;
class Stmt;
class Item;
class Expr;
@@ -76,8 +67,6 @@ class QualifiedPathInType;
class ExprWithBlock;
class LiteralExpr;
class AttrInputLiteral;
-class MetaItemLitExpr;
-class MetaItemPathLit;
class OperatorExpr;
class BorrowExpr;
class DereferenceExpr;
@@ -227,12 +216,6 @@ struct MacroTranscriber;
struct MacroRule;
class MacroRulesDefinition;
class MacroInvocation;
-class MetaItemPath;
-class MetaItemSeq;
-class MetaWord;
-class MetaNameValueStr;
-class MetaListPaths;
-class MetaListNameValueStr;
// rust-pattern.h
class LiteralPattern;
diff --git a/gcc/rust/hir/tree/rust-hir-full-test.cc b/gcc/rust/hir/tree/rust-hir-full-test.cc
index 093fcef..dce85f3 100644
--- a/gcc/rust/hir/tree/rust-hir-full-test.cc
+++ b/gcc/rust/hir/tree/rust-hir-full-test.cc
@@ -16,6 +16,7 @@
// along with GCC; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+#include "rust-ast-full.h"
#include "rust-hir-full.h"
#include "rust-hir-visitor.h"
#include "rust-diagnostics.h"
@@ -52,15 +53,15 @@ indent_spaces (enum indent_mode mode)
// Gets a string in a certain delim type.
std::string
-get_string_in_delims (std::string str_input, DelimType delim_type)
+get_string_in_delims (std::string str_input, AST::DelimType delim_type)
{
switch (delim_type)
{
- case PARENS:
+ case AST::DelimType::PARENS:
return "(" + str_input + ")";
- case SQUARE:
+ case AST::DelimType::SQUARE:
return "[" + str_input + "]";
- case CURLY:
+ case AST::DelimType::CURLY:
return "{" + str_input + "}";
default:
return "ERROR-MARK-STRING (delims)";
@@ -163,67 +164,6 @@ Crate::as_string () const
}
std::string
-Attribute::as_string () const
-{
- std::string path_str = path.as_string ();
- if (attr_input == nullptr)
- {
- return path_str;
- }
- else
- {
- return path_str + attr_input->as_string ();
- }
-}
-
-std::string
-DelimTokenTree::as_string () const
-{
- std::string start_delim;
- std::string end_delim;
- switch (delim_type)
- {
- case PARENS:
- start_delim = "(";
- end_delim = ")";
- break;
- case SQUARE:
- start_delim = "[";
- end_delim = "]";
- break;
- case CURLY:
- start_delim = "{";
- end_delim = "}";
- break;
- default:
- fprintf (stderr, "Invalid delimiter type, "
- "Should be PARENS, SQUARE, or CURLY.");
- return "Invalid delimiter type";
- }
- std::string str = start_delim;
- if (!token_trees.empty ())
- {
- for (const auto &tree : token_trees)
- {
- // DEBUG: null pointer check
- if (tree == nullptr)
- {
- fprintf (
- stderr,
- "something really terrible has gone wrong - null pointer "
- "token tree in delim token tree.");
- return "nullptr_POINTER_MARK";
- }
-
- str += tree->as_string ();
- }
- }
- str += end_delim;
-
- return str;
-}
-
-std::string
Token::as_string () const
{
/* FIXME: only works when not identifier or literal or whatever, i.e. when
@@ -236,49 +176,6 @@ Token::as_string () const
}
std::string
-SimplePathSegment::as_string () const
-{
- return segment_name;
-}
-
-std::string
-SimplePath::as_string () const
-{
- std::string path;
- if (has_opening_scope_resolution)
- {
- path = "::";
- }
-
- // crappy hack because doing proper for loop would be more code
- bool first_time = true;
- for (const auto &segment : segments)
- {
- if (first_time)
- {
- path += segment.as_string ();
- first_time = false;
- }
- else
- {
- path += "::" + segment.as_string ();
- }
-
- // DEBUG: remove later. Checks for path error.
- if (segment.is_error ())
- {
- fprintf (stderr,
- "segment in path is error - this should've been filtered "
- "out. first segment "
- "was '%s' \n",
- segments.at (0).as_string ().c_str ());
- }
- }
-
- return path;
-}
-
-std::string
Visibility::as_string () const
{
switch (public_vis_type)
@@ -1456,13 +1353,13 @@ MacroRulesDefinition::as_string () const
str += "\n Delim type: ";
switch (delim_type)
{
- case PARENS:
+ case AST::DelimType::PARENS:
str += "parentheses";
break;
- case SQUARE:
+ case AST::DelimType::SQUARE:
str += "square";
break;
- case CURLY:
+ case AST::DelimType::CURLY:
str += "curly";
break;
default:
@@ -2460,13 +2357,13 @@ MacroMatcher::as_string () const
switch (delim_type)
{
- case PARENS:
+ case AST::DelimType::PARENS:
str += "parentheses";
break;
- case SQUARE:
+ case AST::DelimType::SQUARE:
str += "square";
break;
- case CURLY:
+ case AST::DelimType::CURLY:
str += "curly";
break;
default:
@@ -2677,16 +2574,16 @@ TypeParam::as_string () const
return str;
}
-SimplePath
+AST::SimplePath
PathPattern::convert_to_simple_path (bool with_opening_scope_resolution) const
{
if (!has_segments ())
{
- return SimplePath::create_empty ();
+ return AST::SimplePath::create_empty ();
}
// create vector of reserved size (to minimise reallocations)
- std::vector<SimplePathSegment> simple_segments;
+ std::vector<AST::SimplePathSegment> simple_segments;
simple_segments.reserve (segments.size ());
for (const auto &segment : segments)
@@ -2694,13 +2591,13 @@ PathPattern::convert_to_simple_path (bool with_opening_scope_resolution) const
// return empty path if doesn't meet simple path segment requirements
if (segment.has_generic_args () || segment.as_string () == "Self")
{
- return SimplePath::create_empty ();
+ return AST::SimplePath::create_empty ();
}
// create segment and add to vector
std::string segment_str = segment.as_string ();
simple_segments.push_back (
- SimplePathSegment (std::move (segment_str), segment.get_locus ()));
+ AST::SimplePathSegment (std::move (segment_str), segment.get_locus ()));
}
// kind of a HACK to get locus depending on opening scope resolution
@@ -2714,20 +2611,20 @@ PathPattern::convert_to_simple_path (bool with_opening_scope_resolution) const
locus = simple_segments[0].get_locus ();
}
- return SimplePath (std::move (simple_segments), with_opening_scope_resolution,
- locus);
+ return AST::SimplePath (std::move (simple_segments),
+ with_opening_scope_resolution, locus);
}
-SimplePath
+AST::SimplePath
TypePath::as_simple_path () const
{
if (segments.empty ())
{
- return SimplePath::create_empty ();
+ return AST::SimplePath::create_empty ();
}
// create vector of reserved size (to minimise reallocations)
- std::vector<SimplePathSegment> simple_segments;
+ std::vector<AST::SimplePathSegment> simple_segments;
simple_segments.reserve (segments.size ());
for (const auto &segment : segments)
@@ -2736,17 +2633,18 @@ TypePath::as_simple_path () const
if (segment == nullptr || segment->is_error ()
|| !segment->is_ident_only () || segment->as_string () == "Self")
{
- return SimplePath::create_empty ();
+ return AST::SimplePath::create_empty ();
}
// create segment and add to vector
std::string segment_str = segment->as_string ();
simple_segments.push_back (
- SimplePathSegment (std::move (segment_str), segment->get_locus ()));
+ AST::SimplePathSegment (std::move (segment_str),
+ segment->get_locus ()));
}
- return SimplePath (std::move (simple_segments), has_opening_scope_resolution,
- locus);
+ return AST::SimplePath (std::move (simple_segments),
+ has_opening_scope_resolution, locus);
}
std::string
@@ -4391,78 +4289,6 @@ MaybeNamedParam::as_string () const
return str;
}
-std::string
-MetaItemSeq::as_string () const
-{
- std::string path_str = path.as_string () + "(";
-
- auto i = seq.begin ();
- auto e = seq.end ();
-
- for (; i != e; i++)
- {
- path_str += (*i)->as_string ();
- if (e != i + 1)
- path_str += ", ";
- }
-
- return path_str + ")";
-}
-
-std::string
-MetaListPaths::as_string () const
-{
- std::string str = ident + "(";
-
- auto i = paths.begin ();
- auto e = paths.end ();
-
- for (; i != e; i++)
- {
- str += (*i).as_string ();
- if (e != i + 1)
- str += ", ";
- }
-
- return str + ")";
-}
-
-std::string
-MetaListNameValueStr::as_string () const
-{
- std::string str = ident + "(";
-
- auto i = strs.begin ();
- auto e = strs.end ();
-
- for (; i != e; i++)
- {
- str += (*i).as_string ();
- if (e != i + 1)
- str += ", ";
- }
-
- return str + ")";
-}
-
-std::string
-AttrInputMetaItemContainer::as_string () const
-{
- std::string str = "(";
-
- auto i = items.begin ();
- auto e = items.end ();
-
- for (; i != e; i++)
- {
- str += (*i)->as_string ();
- if (e != i + 1)
- str += ", ";
- }
-
- return str + ")";
-}
-
/* Override that calls the function recursively on all items contained within
* the module. */
void
@@ -4475,412 +4301,6 @@ ModuleBodied::add_crate_name (std::vector<std::string> &names) const
item->add_crate_name (names);
}
-void
-Attribute::parse_attr_to_meta_item ()
-{
- // only parse if has attribute input
- if (!has_attr_input ())
- return;
-
- std::unique_ptr<AttrInput> converted_input (
- attr_input->parse_to_meta_item ());
-
- if (converted_input != nullptr)
- attr_input = std::move (converted_input);
-}
-
-AttrInput *
-DelimTokenTree::parse_to_meta_item () const
-{
- // must have token trees
- if (token_trees.empty ())
- return nullptr;
-
- /* assume top-level delim token tree in attribute - convert all nested ones
- * to token stream */
- std::vector<std::unique_ptr<Token> > token_stream = to_token_stream ();
-
- MacroParser parser (std::move (token_stream));
- std::vector<std::unique_ptr<MetaItemInner> > meta_items (
- parser.parse_meta_item_seq ());
-
- return new AttrInputMetaItemContainer (std::move (meta_items));
-}
-
-std::unique_ptr<MetaItemInner>
-MacroParser::parse_meta_item_inner ()
-{
- // if first tok not identifier, not a "special" case one
- if (peek_token ()->get_id () != IDENTIFIER)
- {
- switch (peek_token ()->get_id ())
- {
- case CHAR_LITERAL:
- case STRING_LITERAL:
- case BYTE_CHAR_LITERAL:
- case BYTE_STRING_LITERAL:
- case INT_LITERAL:
- case FLOAT_LITERAL:
- case TRUE_LITERAL:
- case FALSE_LITERAL:
- // stream_pos++;
- return parse_meta_item_lit ();
- case SUPER:
- case SELF:
- case CRATE:
- case DOLLAR_SIGN:
- case SCOPE_RESOLUTION: {
- return parse_path_meta_item ();
- }
- default:
- rust_error_at (peek_token ()->get_locus (),
- "unrecognised token '%s' in meta item",
- get_token_description (peek_token ()->get_id ()));
- return nullptr;
- }
- }
-
- // else, check for path
- if (peek_token (1)->get_id () == SCOPE_RESOLUTION)
- {
- // path
- return parse_path_meta_item ();
- }
-
- Identifier ident = peek_token ()->as_string ();
- if (is_end_meta_item_tok (peek_token (1)->get_id ()))
- {
- // meta word syntax
- skip_token ();
- return std::unique_ptr<MetaWord> (new MetaWord (std::move (ident)));
- }
-
- if (peek_token (1)->get_id () == EQUAL)
- {
- // maybe meta name value str syntax - check next 2 tokens
- if (peek_token (2)->get_id () == STRING_LITERAL
- && is_end_meta_item_tok (peek_token (3)->get_id ()))
- {
- // meta name value str syntax
- std::string value = peek_token (2)->as_string ();
-
- skip_token (2);
-
- return std::unique_ptr<MetaNameValueStr> (
- new MetaNameValueStr (std::move (ident), std::move (value)));
- }
- else
- {
- // just interpret as path-based meta item
- return parse_path_meta_item ();
- }
- }
-
- if (peek_token (1)->get_id () != LEFT_PAREN)
- {
- rust_error_at (peek_token (1)->get_locus (),
- "unexpected token '%s' after identifier in attribute",
- get_token_description (peek_token (1)->get_id ()));
- return nullptr;
- }
-
- /* HACK: parse parenthesised sequence, and then try conversions to other
- * stuff */
- std::vector<std::unique_ptr<MetaItemInner> > meta_items
- = parse_meta_item_seq ();
-
- // pass for meta name value str
- std::vector<MetaNameValueStr> meta_name_value_str_items;
- for (const auto &item : meta_items)
- {
- std::unique_ptr<MetaNameValueStr> converted_item
- = item->to_meta_name_value_str ();
- if (converted_item == nullptr)
- {
- meta_name_value_str_items.clear ();
- break;
- }
- meta_name_value_str_items.push_back (std::move (*converted_item));
- }
- // if valid, return this
- if (!meta_name_value_str_items.empty ())
- {
- return std::unique_ptr<MetaListNameValueStr> (
- new MetaListNameValueStr (std::move (ident),
- std::move (meta_name_value_str_items)));
- }
-
- // pass for meta list idents
- /*std::vector<Identifier> ident_items;
- for (const auto& item : meta_items) {
- std::unique_ptr<Identifier> converted_ident(item->to_ident_item());
- if (converted_ident == nullptr) {
- ident_items.clear();
- break;
- }
- ident_items.push_back(std::move(*converted_ident));
- }
- // if valid return this
- if (!ident_items.empty()) {
- return std::unique_ptr<MetaListIdents>(new
- MetaListIdents(std::move(ident),
- std::move(ident_items)));
- }*/
- // as currently no meta list ident, currently no path. may change in future
-
- // pass for meta list paths
- std::vector<SimplePath> path_items;
- for (const auto &item : meta_items)
- {
- SimplePath converted_path (item->to_path_item ());
- if (converted_path.is_empty ())
- {
- path_items.clear ();
- break;
- }
- path_items.push_back (std::move (converted_path));
- }
- if (!path_items.empty ())
- {
- return std::unique_ptr<MetaListPaths> (
- new MetaListPaths (std::move (ident), std::move (path_items)));
- }
-
- rust_error_at (Linemap::unknown_location (),
- "failed to parse any meta item inner");
- return nullptr;
-}
-
-bool
-MacroParser::is_end_meta_item_tok (TokenId id) const
-{
- return id == COMMA || id == RIGHT_PAREN;
-}
-
-std::unique_ptr<MetaItem>
-MacroParser::parse_path_meta_item ()
-{
- SimplePath path = parse_simple_path ();
- if (path.is_empty ())
- {
- rust_error_at (peek_token ()->get_locus (),
- "failed to parse simple path in attribute");
- return nullptr;
- }
-
- switch (peek_token ()->get_id ())
- {
- case LEFT_PAREN: {
- std::vector<std::unique_ptr<MetaItemInner> > meta_items
- = parse_meta_item_seq ();
-
- return std::unique_ptr<MetaItemSeq> (
- new MetaItemSeq (std::move (path), std::move (meta_items)));
- }
- case EQUAL: {
- skip_token ();
-
- Location locus = peek_token ()->get_locus ();
- Literal lit = parse_literal ();
- if (lit.is_error ())
- {
- rust_error_at (peek_token ()->get_locus (),
- "failed to parse literal in attribute");
- return nullptr;
- }
- LiteralExpr expr (Analysis::NodeMapping::get_error (), std::move (lit),
- locus);
- // stream_pos++;
- /* shouldn't be required anymore due to parsing literal actually
- * skipping the token */
- return std::unique_ptr<MetaItemPathLit> (
- new MetaItemPathLit (std::move (path), std::move (expr)));
- }
- case COMMA:
- // just simple path
- return std::unique_ptr<MetaItemPath> (
- new MetaItemPath (std::move (path)));
- default:
- rust_error_at (peek_token ()->get_locus (),
- "unrecognised token '%s' in meta item",
- get_token_description (peek_token ()->get_id ()));
- return nullptr;
- }
-}
-
-/* Parses a parenthesised sequence of meta item inners. Parentheses are
- * required here. */
-std::vector<std::unique_ptr<MetaItemInner> >
-MacroParser::parse_meta_item_seq ()
-{
- if (stream_pos != 0)
- {
- // warning?
- fprintf (stderr,
- "WARNING: stream pos for parse_meta_item_seq is not 0!\n");
- }
-
- // int i = 0;
- int vec_length = token_stream.size ();
- std::vector<std::unique_ptr<MetaItemInner> > meta_items;
-
- if (peek_token ()->get_id () != LEFT_PAREN)
- {
- rust_error_at (peek_token ()->get_locus (),
- "missing left paren in delim token tree");
- return {};
- }
- skip_token ();
-
- while (stream_pos < vec_length && peek_token ()->get_id () != RIGHT_PAREN)
- {
- std::unique_ptr<MetaItemInner> inner = parse_meta_item_inner ();
- if (inner == nullptr)
- {
- rust_error_at (peek_token ()->get_locus (),
- "failed to parse inner meta item in attribute");
- return {};
- }
- meta_items.push_back (std::move (inner));
-
- if (peek_token ()->get_id () != COMMA)
- {
- break;
- }
- skip_token ();
- }
-
- if (peek_token ()->get_id () != RIGHT_PAREN)
- {
- rust_error_at (peek_token ()->get_locus (),
- "missing right paren in delim token tree");
- return {};
- }
- skip_token ();
-
- return meta_items;
-}
-
-/* Collects any nested token trees into a flat token stream, suitable for
- * parsing. */
-std::vector<std::unique_ptr<Token> >
-DelimTokenTree::to_token_stream () const
-{
- std::vector<std::unique_ptr<Token> > tokens;
-
- // simulate presence of delimiters
- tokens.push_back (
- std::unique_ptr<Token> (new Token (LEFT_PAREN, Linemap::unknown_location (),
- "", CORETYPE_UNKNOWN)));
-
- for (const auto &tree : token_trees)
- {
- std::vector<std::unique_ptr<Token> > stream = tree->to_token_stream ();
-
- tokens.insert (tokens.end (), std::make_move_iterator (stream.begin ()),
- std::make_move_iterator (stream.end ()));
- }
-
- tokens.push_back (std::unique_ptr<Token> (
- new Token (RIGHT_PAREN, Linemap::unknown_location (), "",
- CORETYPE_UNKNOWN)));
-
- tokens.shrink_to_fit ();
-
- return tokens;
-}
-
-Literal
-MacroParser::parse_literal ()
-{
- // marcos need to be removed from HIR
- gcc_unreachable ();
-}
-
-SimplePath
-MacroParser::parse_simple_path ()
-{
- bool has_opening_scope_res = false;
- if (peek_token ()->get_id () == SCOPE_RESOLUTION)
- {
- has_opening_scope_res = true;
- skip_token ();
- }
-
- std::vector<SimplePathSegment> segments;
-
- SimplePathSegment segment = parse_simple_path_segment ();
- if (segment.is_error ())
- {
- rust_error_at (
- peek_token ()->get_locus (),
- "failed to parse simple path segment in attribute simple path");
- return SimplePath::create_empty ();
- }
- segments.push_back (std::move (segment));
-
- while (peek_token ()->get_id () == SCOPE_RESOLUTION)
- {
- skip_token ();
-
- SimplePathSegment segment = parse_simple_path_segment ();
- if (segment.is_error ())
- {
- rust_error_at (
- peek_token ()->get_locus (),
- "failed to parse simple path segment in attribute simple path");
- return SimplePath::create_empty ();
- }
- segments.push_back (std::move (segment));
- }
- segments.shrink_to_fit ();
-
- return SimplePath (std::move (segments), has_opening_scope_res);
-}
-
-SimplePathSegment
-MacroParser::parse_simple_path_segment ()
-{
- const std::unique_ptr<Token> &tok = peek_token ();
- switch (tok->get_id ())
- {
- case IDENTIFIER:
- skip_token ();
- return SimplePathSegment (tok->as_string (), tok->get_locus ());
- case SUPER:
- skip_token ();
- return SimplePathSegment ("super", tok->get_locus ());
- case SELF:
- skip_token ();
- return SimplePathSegment ("self", tok->get_locus ());
- case CRATE:
- skip_token ();
- return SimplePathSegment ("crate", tok->get_locus ());
- case DOLLAR_SIGN:
- if (peek_token (1)->get_id () == CRATE)
- {
- skip_token (1);
- return SimplePathSegment ("$crate", tok->get_locus ());
- }
- gcc_fallthrough ();
- default:
- rust_error_at (tok->get_locus (),
- "unexpected token '%s' in simple path segment",
- get_token_description (tok->get_id ()));
- return SimplePathSegment::create_error ();
- }
-}
-
-std::unique_ptr<MetaItemLitExpr>
-MacroParser::parse_meta_item_lit ()
-{
- Location locus = peek_token ()->get_locus ();
- LiteralExpr lit_expr (Analysis::NodeMapping::get_error (), parse_literal (),
- locus);
- return std::unique_ptr<MetaItemLitExpr> (
- new MetaItemLitExpr (std::move (lit_expr)));
-}
-
std::vector<std::unique_ptr<Token> >
Token::to_token_stream () const
{
@@ -4892,83 +4312,6 @@ Token::to_token_stream () const
return dummy_vector;
}
-Attribute
-MetaNameValueStr::to_attribute () const
-{
- LiteralExpr lit_expr (Analysis::NodeMapping::get_error (), str,
- Literal::LitType::STRING,
- PrimitiveCoreType::CORETYPE_STR, Location ());
- return Attribute (SimplePath::from_str (ident),
- std::unique_ptr<AttrInputLiteral> (
- new AttrInputLiteral (std::move (lit_expr))));
-}
-
-Attribute
-MetaItemPath::to_attribute () const
-{
- return Attribute (path, nullptr);
-}
-
-Attribute
-MetaItemSeq::to_attribute () const
-{
- std::vector<std::unique_ptr<MetaItemInner> > new_seq;
- new_seq.reserve (seq.size ());
- for (const auto &e : seq)
- new_seq.push_back (e->clone_meta_item_inner ());
-
- std::unique_ptr<AttrInputMetaItemContainer> new_seq_container (
- new AttrInputMetaItemContainer (std::move (new_seq)));
- return Attribute (path, std::move (new_seq_container));
-}
-
-Attribute
-MetaWord::to_attribute () const
-{
- return Attribute (SimplePath::from_str (ident), nullptr);
-}
-
-Attribute
-MetaListPaths::to_attribute () const
-{
- /* probably one of the most annoying conversions - have to lose specificity by
- * turning it into just AttrInputMetaItemContainer (i.e. paths-only nature is
- * no longer known). If conversions back are required, might have to do a
- * "check all are paths" pass or something. */
-
- std::vector<std::unique_ptr<MetaItemInner> > new_seq;
- new_seq.reserve (paths.size ());
- for (const auto &e : paths)
- new_seq.push_back (std::unique_ptr<MetaItemPath> (new MetaItemPath (e)));
-
- std::unique_ptr<AttrInputMetaItemContainer> new_seq_container (
- new AttrInputMetaItemContainer (std::move (new_seq)));
- return Attribute (SimplePath::from_str (ident),
- std::move (new_seq_container));
-}
-
-Attribute
-MetaListNameValueStr::to_attribute () const
-{
- std::vector<std::unique_ptr<MetaItemInner> > new_seq;
- new_seq.reserve (strs.size ());
- for (const auto &e : strs)
- new_seq.push_back (
- std::unique_ptr<MetaNameValueStr> (new MetaNameValueStr (e)));
-
- std::unique_ptr<AttrInputMetaItemContainer> new_seq_container (
- new AttrInputMetaItemContainer (std::move (new_seq)));
- return Attribute (SimplePath::from_str (ident),
- std::move (new_seq_container));
-}
-
-Attribute
-MetaItemPathLit::to_attribute () const
-{
- return Attribute (path, std::unique_ptr<AttrInputLiteral> (
- new AttrInputLiteral (lit)));
-}
-
/* Visitor implementations - these are short but inlining can't happen anyway
* due to virtual functions and I didn't want to make the ast header includes
* any longer than they already are. */
@@ -4980,12 +4323,6 @@ Token::accept_vis (HIRVisitor &vis)
}
void
-DelimTokenTree::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
IdentifierExpr::accept_vis (HIRVisitor &vis)
{
vis.visit (*this);
@@ -5052,24 +4389,6 @@ LiteralExpr::accept_vis (HIRVisitor &vis)
}
void
-AttrInputLiteral::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
-MetaItemLitExpr::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
-MetaItemPathLit::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
BorrowExpr::accept_vis (HIRVisitor &vis)
{
vis.visit (*this);
@@ -5903,46 +5222,5 @@ BareFunctionType::accept_vis (HIRVisitor &vis)
vis.visit (*this);
}
-void
-MetaItemSeq::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
-MetaItemPath::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
-MetaListPaths::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
-MetaNameValueStr::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
-MetaListNameValueStr::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
-AttrInputMetaItemContainer::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
-MetaWord::accept_vis (HIRVisitor &vis)
-{
- vis.visit (*this);
-}
} // namespace HIR
} // namespace Rust
diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h
index fc67d60..6ac936c 100644
--- a/gcc/rust/hir/tree/rust-hir-item.h
+++ b/gcc/rust/hir/tree/rust-hir-item.h
@@ -19,6 +19,7 @@
#ifndef RUST_HIR_ITEM_H
#define RUST_HIR_ITEM_H
+#include "rust-ast-full-decls.h"
#include "rust-hir.h"
#include "rust-hir-path.h"
@@ -33,7 +34,7 @@ class TypeParam : public GenericParam
{
// bool has_outer_attribute;
// std::unique_ptr<Attribute> outer_attr;
- Attribute outer_attr;
+ AST::Attribute outer_attr;
Identifier type_representation;
@@ -62,7 +63,7 @@ public:
std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds
= std::vector<std::unique_ptr<TypeParamBound> > (),
std::unique_ptr<Type> type = nullptr,
- Attribute outer_attr = Attribute::create_empty ())
+ AST::Attribute outer_attr = AST::Attribute::create_empty ())
: GenericParam (mappings), outer_attr (std::move (outer_attr)),
type_representation (std::move (type_representation)),
type_param_bounds (std::move (type_param_bounds)),
@@ -504,13 +505,13 @@ private:
// if vis is public, one of these
PublicVisType public_vis_type;
// Only assigned if public_vis_type is IN_PATH
- SimplePath in_path;
+ AST::SimplePath in_path;
// should this store location info?
public:
// Creates a Visibility - TODO make constructor protected or private?
- Visibility (PublicVisType public_vis_type, SimplePath in_path)
+ Visibility (PublicVisType public_vis_type, AST::SimplePath in_path)
: public_vis_type (public_vis_type), in_path (std::move (in_path))
{}
@@ -523,7 +524,7 @@ public:
// Creates an error visibility.
static Visibility create_error ()
{
- return Visibility (IN_PATH, SimplePath::create_empty ());
+ return Visibility (IN_PATH, AST::SimplePath::create_empty ());
}
// Unique pointer custom clone function
@@ -537,30 +538,30 @@ public:
// Creates a public visibility with no further features/arguments.
static Visibility create_public ()
{
- return Visibility (NONE, SimplePath::create_empty ());
+ return Visibility (NONE, AST::SimplePath::create_empty ());
}
// Creates a public visibility with crate-relative paths or whatever.
static Visibility create_crate ()
{
- return Visibility (CRATE, SimplePath::create_empty ());
+ return Visibility (CRATE, AST::SimplePath::create_empty ());
}
// Creates a public visibility with self-relative paths or whatever.
static Visibility create_self ()
{
- return Visibility (SELF, SimplePath::create_empty ());
+ return Visibility (SELF, AST::SimplePath::create_empty ());
}
// Creates a public visibility with parent module-relative paths or
// whatever.
static Visibility create_super ()
{
- return Visibility (SUPER, SimplePath::create_empty ());
+ return Visibility (SUPER, AST::SimplePath::create_empty ());
}
// Creates a public visibility with a given path or whatever.
- static Visibility create_in_path (SimplePath in_path)
+ static Visibility create_in_path (AST::SimplePath in_path)
{
return Visibility (IN_PATH, std::move (in_path));
}
@@ -582,7 +583,7 @@ class Method : public InherentImplItem, public TraitImplItem
Analysis::NodeMapping mappings;
// moved from impl items for consistency
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
Visibility vis;
FunctionQualifiers qualifiers;
@@ -632,7 +633,7 @@ public:
SelfParam self_param, std::vector<FunctionParam> function_params,
std::unique_ptr<Type> return_type, WhereClause where_clause,
std::unique_ptr<BlockExpr> function_body, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus = Location ())
+ AST::AttrVec outer_attrs, Location locus = Location ())
: mappings (mappings), outer_attrs (std::move (outer_attrs)),
vis (std::move (vis)), qualifiers (std::move (qualifiers)),
method_name (std::move (method_name)),
@@ -777,7 +778,7 @@ class VisItem : public Item
protected:
// Visibility constructor
VisItem (Analysis::NodeMapping mappings, Visibility visibility,
- std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: Item (std::move (mappings), std::move (outer_attrs)),
visibility (std::move (visibility))
{}
@@ -820,7 +821,7 @@ protected:
// Protected constructor
Module (Analysis::NodeMapping mappings, Identifier module_name,
Visibility visibility, Location locus,
- std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: VisItem (std::move (mappings), std::move (visibility),
std::move (outer_attrs)),
module_name (module_name), locus (locus)
@@ -836,7 +837,7 @@ public:
class ModuleBodied : public Module
{
// bool has_inner_attrs;
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
// bool has_items;
std::vector<std::unique_ptr<Item> > items;
@@ -854,8 +855,8 @@ public:
std::vector<std::unique_ptr<Item> > items
= std::vector<std::unique_ptr<Item> > (),
Visibility visibility = Visibility::create_error (),
- std::vector<Attribute> inner_attrs = std::vector<Attribute> (),
- std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ AST::AttrVec inner_attrs = AST::AttrVec (),
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: Module (std::move (mappings), std::move (name), std::move (visibility),
locus, std::move (outer_attrs)),
inner_attrs (std::move (inner_attrs)), items (std::move (items))
@@ -916,8 +917,7 @@ public:
// Full constructor
ModuleNoBody (Analysis::NodeMapping mappings, Identifier name,
- Visibility visibility, std::vector<Attribute> outer_attrs,
- Location locus)
+ Visibility visibility, AST::AttrVec outer_attrs, Location locus)
: Module (std::move (mappings), std::move (name), std::move (visibility),
locus, std::move (outer_attrs))
{}
@@ -967,8 +967,8 @@ public:
// Constructor
ExternCrate (Analysis::NodeMapping mappings, std::string referenced_crate,
- Visibility visibility, std::vector<Attribute> outer_attrs,
- Location locus, std::string as_clause_name = std::string ())
+ Visibility visibility, AST::AttrVec outer_attrs, Location locus,
+ std::string as_clause_name = std::string ())
: VisItem (std::move (mappings), std::move (visibility),
std::move (outer_attrs)),
referenced_crate (std::move (referenced_crate)),
@@ -1040,10 +1040,10 @@ public:
private:
PathType glob_type;
- SimplePath path;
+ AST::SimplePath path;
public:
- UseTreeGlob (PathType glob_type, SimplePath path, Location locus)
+ UseTreeGlob (PathType glob_type, AST::SimplePath path, Location locus)
: UseTree (locus), glob_type (glob_type), path (std::move (path))
{
if (this->glob_type != PATH_PREFIXED)
@@ -1088,12 +1088,12 @@ public:
private:
PathType path_type;
- SimplePath path;
+ AST::SimplePath path;
std::vector<std::unique_ptr<UseTree> > trees;
public:
- UseTreeList (PathType path_type, SimplePath path,
+ UseTreeList (PathType path_type, AST::SimplePath path,
std::vector<std::unique_ptr<UseTree> > trees, Location locus)
: UseTree (locus), path_type (path_type), path (std::move (path)),
trees (std::move (trees))
@@ -1168,13 +1168,13 @@ public:
};
private:
- SimplePath path;
+ AST::SimplePath path;
NewBindType bind_type;
Identifier identifier; // only if NewBindType is IDENTIFIER
public:
- UseTreeRebind (NewBindType bind_type, SimplePath path, Location locus,
+ UseTreeRebind (NewBindType bind_type, AST::SimplePath path, Location locus,
Identifier identifier = std::string ())
: UseTree (locus), path (std::move (path)), bind_type (bind_type),
identifier (std::move (identifier))
@@ -1212,7 +1212,7 @@ public:
UseDeclaration (Analysis::NodeMapping mappings,
std::unique_ptr<UseTree> use_tree, Visibility visibility,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: VisItem (std::move (mappings), std::move (visibility),
std::move (outer_attrs)),
use_tree (std::move (use_tree)), locus (locus)
@@ -1312,7 +1312,7 @@ public:
std::vector<FunctionParam> function_params,
std::unique_ptr<Type> return_type, WhereClause where_clause,
std::unique_ptr<BlockExpr> function_body, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
qualifiers (std::move (qualifiers)),
function_name (std::move (function_name)),
@@ -1474,7 +1474,7 @@ public:
TypeAlias (Analysis::NodeMapping mappings, Identifier new_type_name,
std::vector<std::unique_ptr<GenericParam> > generic_params,
WhereClause where_clause, std::unique_ptr<Type> existing_type,
- Visibility vis, std::vector<Attribute> outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec outer_attrs, Location locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
new_type_name (std::move (new_type_name)),
generic_params (std::move (generic_params)),
@@ -1600,7 +1600,7 @@ protected:
Struct (Analysis::NodeMapping mappings, Identifier struct_name,
std::vector<std::unique_ptr<GenericParam> > generic_params,
WhereClause where_clause, Visibility vis, Location locus,
- std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
struct_name (std::move (struct_name)),
generic_params (std::move (generic_params)),
@@ -1642,7 +1642,7 @@ struct StructField
{
public:
// bool has_outer_attributes;
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
// bool has_visibility;
Visibility visibility;
@@ -1664,7 +1664,7 @@ public:
StructField (Analysis::NodeMapping mappings, Identifier field_name,
std::unique_ptr<Type> field_type, Visibility vis, Location locus,
- std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)),
field_name (std::move (field_name)), field_type (std::move (field_type)),
mappings (mappings), locus (locus)
@@ -1724,7 +1724,7 @@ public:
Identifier struct_name,
std::vector<std::unique_ptr<GenericParam> > generic_params,
WhereClause where_clause, bool is_unit, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: Struct (std::move (mappings), std::move (struct_name),
std::move (generic_params), std::move (where_clause),
std::move (vis), locus, std::move (outer_attrs)),
@@ -1735,7 +1735,7 @@ public:
StructStruct (Analysis::NodeMapping mappings, Identifier struct_name,
std::vector<std::unique_ptr<GenericParam> > generic_params,
WhereClause where_clause, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: Struct (std::move (mappings), std::move (struct_name),
std::move (generic_params), std::move (where_clause),
std::move (vis), locus, std::move (outer_attrs)),
@@ -1779,7 +1779,7 @@ struct TupleField
{
private:
// bool has_outer_attributes;
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
// bool has_visibility;
Visibility visibility;
@@ -1801,7 +1801,7 @@ public:
// Complete constructor
TupleField (Analysis::NodeMapping mapping, std::unique_ptr<Type> field_type,
Visibility vis, Location locus,
- std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)),
field_type (std::move (field_type)), locus (locus), mappings (mapping)
{}
@@ -1856,7 +1856,7 @@ public:
Identifier struct_name,
std::vector<std::unique_ptr<GenericParam> > generic_params,
WhereClause where_clause, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: Struct (std::move (mappings), std::move (struct_name),
std::move (generic_params), std::move (where_clause),
std::move (vis), locus, std::move (outer_attrs)),
@@ -1897,7 +1897,7 @@ protected:
class EnumItem
{
// bool has_attrs;
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
Identifier variant_name;
@@ -1909,8 +1909,7 @@ public:
// Returns whether enum item has outer attributes.
bool has_outer_attrs () const { return !outer_attrs.empty (); }
- EnumItem (Identifier variant_name, std::vector<Attribute> outer_attrs,
- Location locus)
+ EnumItem (Identifier variant_name, AST::AttrVec outer_attrs, Location locus)
: outer_attrs (std::move (outer_attrs)),
variant_name (std::move (variant_name)), locus (locus)
{}
@@ -1945,7 +1944,7 @@ public:
bool has_tuple_fields () const { return !tuple_fields.empty (); }
EnumItemTuple (Identifier variant_name, std::vector<TupleField> tuple_fields,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: EnumItem (std::move (variant_name), std::move (outer_attrs), locus),
tuple_fields (std::move (tuple_fields))
{}
@@ -1974,7 +1973,7 @@ public:
EnumItemStruct (Identifier variant_name,
std::vector<StructField> struct_fields,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: EnumItem (std::move (variant_name), std::move (outer_attrs), locus),
struct_fields (std::move (struct_fields))
{}
@@ -1998,7 +1997,7 @@ class EnumItemDiscriminant : public EnumItem
public:
EnumItemDiscriminant (Identifier variant_name, std::unique_ptr<Expr> expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: EnumItem (std::move (variant_name), std::move (outer_attrs), locus),
expression (std::move (expr))
{}
@@ -2068,7 +2067,7 @@ public:
Enum (Analysis::NodeMapping mappings, Identifier enum_name, Visibility vis,
std::vector<std::unique_ptr<GenericParam> > generic_params,
WhereClause where_clause, std::vector<std::unique_ptr<EnumItem> > items,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
enum_name (std::move (enum_name)),
generic_params (std::move (generic_params)),
@@ -2159,7 +2158,7 @@ public:
Union (Analysis::NodeMapping mappings, Identifier union_name, Visibility vis,
std::vector<std::unique_ptr<GenericParam> > generic_params,
WhereClause where_clause, std::vector<StructField> variants,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
union_name (std::move (union_name)),
generic_params (std::move (generic_params)),
@@ -2235,8 +2234,8 @@ public:
ConstantItem (Analysis::NodeMapping mappings, Identifier ident,
Visibility vis, std::unique_ptr<Type> type,
- std::unique_ptr<Expr> const_expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::unique_ptr<Expr> const_expr, AST::AttrVec outer_attrs,
+ Location locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
identifier (std::move (ident)), type (std::move (type)),
const_expr (std::move (const_expr)), locus (locus)
@@ -2329,8 +2328,7 @@ public:
StaticItem (Analysis::NodeMapping mappings, Identifier name, bool is_mut,
std::unique_ptr<Type> type, std::unique_ptr<Expr> expr,
- Visibility vis, std::vector<Attribute> outer_attrs,
- Location locus)
+ Visibility vis, AST::AttrVec outer_attrs, Location locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
has_mut (is_mut), name (std::move (name)), type (std::move (type)),
expr (std::move (expr)), locus (locus)
@@ -2478,7 +2476,7 @@ public:
// Actual trait item function declaration within traits
class TraitItemFunc : public TraitItem
{
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
TraitFunctionDecl decl;
std::unique_ptr<BlockExpr> block_expr;
Location locus;
@@ -2488,7 +2486,7 @@ public:
bool has_definition () const { return block_expr != nullptr; }
TraitItemFunc (TraitFunctionDecl decl, std::unique_ptr<BlockExpr> block_expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: outer_attrs (std::move (outer_attrs)), decl (std::move (decl)),
block_expr (std::move (block_expr)), locus (locus)
{}
@@ -2629,7 +2627,7 @@ public:
// Actual trait item method declaration within traits
class TraitItemMethod : public TraitItem
{
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
TraitMethodDecl decl;
std::unique_ptr<BlockExpr> block_expr;
Location locus;
@@ -2639,7 +2637,7 @@ public:
bool has_definition () const { return block_expr != nullptr; }
TraitItemMethod (TraitMethodDecl decl, std::unique_ptr<BlockExpr> block_expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: outer_attrs (std::move (outer_attrs)), decl (std::move (decl)),
block_expr (std::move (block_expr)), locus (locus)
{}
@@ -2685,7 +2683,7 @@ protected:
// Constant item within traits
class TraitItemConst : public TraitItem
{
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
Identifier name;
std::unique_ptr<Type> type;
@@ -2699,8 +2697,8 @@ public:
bool has_expression () const { return expr != nullptr; }
TraitItemConst (Identifier name, std::unique_ptr<Type> type,
- std::unique_ptr<Expr> expr,
- std::vector<Attribute> outer_attrs, Location locus)
+ std::unique_ptr<Expr> expr, AST::AttrVec outer_attrs,
+ Location locus)
: outer_attrs (std::move (outer_attrs)), name (std::move (name)),
type (std::move (type)), expr (std::move (expr)), locus (locus)
{}
@@ -2746,7 +2744,7 @@ protected:
// Type items within traits
class TraitItemType : public TraitItem
{
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
Identifier name;
@@ -2764,7 +2762,7 @@ public:
TraitItemType (
Identifier name,
std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: outer_attrs (std::move (outer_attrs)), name (std::move (name)),
type_param_bounds (std::move (type_param_bounds)), locus (locus)
{}
@@ -2856,7 +2854,7 @@ public:
std::vector<std::unique_ptr<TypeParamBound> > type_param_bounds,
WhereClause where_clause,
std::vector<std::unique_ptr<TraitItem> > trait_items, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
has_unsafe (is_unsafe), name (std::move (name)),
generic_params (std::move (generic_params)),
@@ -2942,7 +2940,7 @@ protected:
WhereClause where_clause;
// bool has_inner_attrs;
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
private:
// doesn't really need to be protected as write access probably not needed
@@ -2972,8 +2970,8 @@ protected:
Impl (Analysis::NodeMapping mappings,
std::vector<std::unique_ptr<GenericParam> > generic_params,
std::unique_ptr<Type> trait_type, WhereClause where_clause,
- Visibility vis, std::vector<Attribute> inner_attrs,
- std::vector<Attribute> outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec inner_attrs, AST::AttrVec outer_attrs,
+ Location locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
generic_params (std::move (generic_params)),
trait_type (std::move (trait_type)),
@@ -3030,8 +3028,8 @@ public:
std::vector<std::unique_ptr<InherentImplItem> > impl_items,
std::vector<std::unique_ptr<GenericParam> > generic_params,
std::unique_ptr<Type> trait_type, WhereClause where_clause,
- Visibility vis, std::vector<Attribute> inner_attrs,
- std::vector<Attribute> outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec inner_attrs,
+ AST::AttrVec outer_attrs, Location locus)
: Impl (std::move (mappings), std::move (generic_params),
std::move (trait_type), std::move (where_clause), std::move (vis),
std::move (inner_attrs), std::move (outer_attrs), locus),
@@ -3111,8 +3109,8 @@ public:
std::vector<std::unique_ptr<TraitImplItem> > impl_items,
std::vector<std::unique_ptr<GenericParam> > generic_params,
std::unique_ptr<Type> trait_type, WhereClause where_clause,
- Visibility vis, std::vector<Attribute> inner_attrs,
- std::vector<Attribute> outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec inner_attrs, AST::AttrVec outer_attrs,
+ Location locus)
: Impl (std::move (mappings), std::move (generic_params),
std::move (trait_type), std::move (where_clause), std::move (vis),
std::move (inner_attrs), std::move (outer_attrs), locus),
@@ -3173,7 +3171,7 @@ protected:
class ExternalItem
{
// bool has_outer_attrs;
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
// bool has_visibility;
Visibility visibility;
@@ -3203,8 +3201,8 @@ public:
virtual void accept_vis (HIRVisitor &vis) = 0;
protected:
- ExternalItem (Identifier item_name, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ ExternalItem (Identifier item_name, Visibility vis, AST::AttrVec outer_attrs,
+ Location locus)
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)),
item_name (std::move (item_name)), locus (locus)
{}
@@ -3245,8 +3243,8 @@ class ExternalStaticItem : public ExternalItem
public:
ExternalStaticItem (Identifier item_name, std::unique_ptr<Type> item_type,
- bool is_mut, Visibility vis,
- std::vector<Attribute> outer_attrs, Location locus)
+ bool is_mut, Visibility vis, AST::AttrVec outer_attrs,
+ Location locus)
: ExternalItem (std::move (item_name), std::move (vis),
std::move (outer_attrs), locus),
has_mut (is_mut), item_type (std::move (item_type))
@@ -3374,7 +3372,7 @@ public:
std::vector<std::unique_ptr<GenericParam> > generic_params,
std::unique_ptr<Type> return_type, WhereClause where_clause,
std::vector<NamedFunctionParam> function_params, bool has_variadics,
- Visibility vis, std::vector<Attribute> outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec outer_attrs, Location locus)
: ExternalItem (std::move (item_name), std::move (vis),
std::move (outer_attrs), locus),
generic_params (std::move (generic_params)),
@@ -3436,7 +3434,7 @@ class ExternBlock : public VisItem
std::string abi;
// bool has_inner_attrs;
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
// bool has_extern_items;
std::vector<std::unique_ptr<ExternalItem> > extern_items;
@@ -3457,8 +3455,8 @@ public:
ExternBlock (Analysis::NodeMapping mappings, std::string abi,
std::vector<std::unique_ptr<ExternalItem> > extern_items,
- Visibility vis, std::vector<Attribute> inner_attrs,
- std::vector<Attribute> outer_attrs, Location locus)
+ Visibility vis, AST::AttrVec inner_attrs,
+ AST::AttrVec outer_attrs, Location locus)
: VisItem (std::move (mappings), std::move (vis), std::move (outer_attrs)),
abi (std::move (abi)), inner_attrs (std::move (inner_attrs)),
extern_items (std::move (extern_items)), locus (locus)
diff --git a/gcc/rust/hir/tree/rust-hir-macro.h b/gcc/rust/hir/tree/rust-hir-macro.h
index 13f0d22..775c92f 100644
--- a/gcc/rust/hir/tree/rust-hir-macro.h
+++ b/gcc/rust/hir/tree/rust-hir-macro.h
@@ -19,6 +19,7 @@
#ifndef RUST_HIR_MACRO_H
#define RUST_HIR_MACRO_H
+#include "rust-ast-full-decls.h"
#include "rust-hir.h"
namespace Rust {
@@ -190,7 +191,7 @@ protected:
// can't inline due to polymorphism
class MacroMatcher : public MacroMatch
{
- DelimType delim_type;
+ AST::DelimType delim_type;
std::vector<std::unique_ptr<MacroMatch> > matches;
// TODO: think of way to mark invalid that doesn't take up more space
@@ -199,7 +200,7 @@ class MacroMatcher : public MacroMatch
// TODO: should store location information?
public:
- MacroMatcher (DelimType delim_type,
+ MacroMatcher (AST::DelimType delim_type,
std::vector<std::unique_ptr<MacroMatch> > matches)
: delim_type (delim_type), matches (std::move (matches)), is_invalid (false)
{}
@@ -247,7 +248,8 @@ protected:
}
// constructor only used to create error matcher
- MacroMatcher (bool is_invalid) : delim_type (PARENS), is_invalid (is_invalid)
+ MacroMatcher (bool is_invalid)
+ : delim_type (AST::DelimType::PARENS), is_invalid (is_invalid)
{}
};
@@ -255,12 +257,12 @@ protected:
struct MacroTranscriber
{
private:
- DelimTokenTree token_tree;
+ AST::DelimTokenTree token_tree;
// TODO: should store location information?
public:
- MacroTranscriber (DelimTokenTree token_tree)
+ MacroTranscriber (AST::DelimTokenTree token_tree)
: token_tree (std::move (token_tree))
{}
@@ -288,7 +290,7 @@ public:
static MacroRule create_error ()
{
return MacroRule (MacroMatcher::create_error (),
- MacroTranscriber (DelimTokenTree::create_empty ()));
+ MacroTranscriber (AST::DelimTokenTree::create_empty ()));
}
std::string as_string () const;
@@ -300,7 +302,7 @@ class MacroRulesDefinition : public MacroItem
Identifier rule_name;
// MacroRulesDef rules_def; // TODO: inline
// only curly without required semicolon at end
- DelimType delim_type;
+ AST::DelimType delim_type;
// MacroRules rules;
std::vector<MacroRule> rules; // inlined form
@@ -310,8 +312,8 @@ public:
std::string as_string () const override;
MacroRulesDefinition (Analysis::NodeMapping mappings, Identifier rule_name,
- DelimType delim_type, std::vector<MacroRule> rules,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::DelimType delim_type, std::vector<MacroRule> rules,
+ AST::AttrVec outer_attrs, Location locus)
: MacroItem (std::move (mappings), std::move (outer_attrs)),
rule_name (std::move (rule_name)), delim_type (delim_type),
rules (std::move (rules)), locus (locus)
@@ -334,16 +336,16 @@ class MacroInvocation : public TypeNoBounds,
public Pattern,
public ExprWithoutBlock
{
- SimplePath path;
- DelimTokenTree token_tree;
+ AST::SimplePath path;
+ AST::DelimTokenTree token_tree;
Location locus;
public:
std::string as_string () const override;
- MacroInvocation (Analysis::NodeMapping mappings, SimplePath path,
- DelimTokenTree token_tree,
- std::vector<Attribute> outer_attrs, Location locus)
+ MacroInvocation (Analysis::NodeMapping mappings, AST::SimplePath path,
+ AST::DelimTokenTree token_tree, AST::AttrVec outer_attrs,
+ Location locus)
: TypeNoBounds (mappings),
ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
path (std::move (path)), token_tree (std::move (token_tree)),
@@ -392,235 +394,6 @@ protected:
}
};
-// more generic meta item path-only form
-class MetaItemPath : public MetaItem
-{
- SimplePath path;
-
-public:
- MetaItemPath (SimplePath path) : path (std::move (path)) {}
-
- std::string as_string () const override { return path.as_string (); }
-
- void accept_vis (HIRVisitor &vis) override;
-
- // HACK: used to simplify parsing - returns non-empty only in this case
- SimplePath to_path_item () const override
- {
- // this should copy construct - TODO ensure it does
- return path;
- }
-
- Attribute to_attribute () const override;
-
-protected:
- // Use covariance to implement clone function as returning this type
- MetaItemPath *clone_meta_item_inner_impl () const override
- {
- return new MetaItemPath (*this);
- }
-};
-
-// more generic meta item sequence form
-class MetaItemSeq : public MetaItem
-{
- SimplePath path;
- std::vector<std::unique_ptr<MetaItemInner> > seq;
-
-public:
- MetaItemSeq (SimplePath path,
- std::vector<std::unique_ptr<MetaItemInner> > seq)
- : path (std::move (path)), seq (std::move (seq))
- {}
-
- // copy constructor with vector clone
- MetaItemSeq (const MetaItemSeq &other) : path (other.path)
- {
- seq.reserve (other.seq.size ());
- for (const auto &e : other.seq)
- seq.push_back (e->clone_meta_item_inner ());
- }
-
- // overloaded assignment operator with vector clone
- MetaItemSeq &operator= (const MetaItemSeq &other)
- {
- MetaItem::operator= (other);
- path = other.path;
-
- seq.reserve (other.seq.size ());
- for (const auto &e : other.seq)
- seq.push_back (e->clone_meta_item_inner ());
-
- return *this;
- }
-
- // default move constructors
- MetaItemSeq (MetaItemSeq &&other) = default;
- MetaItemSeq &operator= (MetaItemSeq &&other) = default;
-
- std::string as_string () const override;
-
- void accept_vis (HIRVisitor &vis) override;
-
- Attribute to_attribute () const override;
-
-protected:
- // Use covariance to implement clone function as returning this type
- MetaItemSeq *clone_meta_item_inner_impl () const override
- {
- return new MetaItemSeq (*this);
- }
-};
-
-// Preferred specialisation for single-identifier meta items.
-class MetaWord : public MetaItem
-{
- Identifier ident;
-
-public:
- MetaWord (Identifier ident) : ident (std::move (ident)) {}
-
- std::string as_string () const override { return ident; }
-
- void accept_vis (HIRVisitor &vis) override;
-
- Attribute to_attribute () const override;
-
-protected:
- // Use covariance to implement clone function as returning this type
- MetaWord *clone_meta_item_inner_impl () const override
- {
- return new MetaWord (*this);
- }
-};
-
-// Preferred specialisation for "identifier '=' string literal" meta items.
-class MetaNameValueStr : public MetaItem
-{
- Identifier ident;
- std::string str;
-
-public:
- MetaNameValueStr (Identifier ident, std::string str)
- : ident (std::move (ident)), str (std::move (str))
- {}
-
- std::string as_string () const override { return ident + " = " + str; }
-
- void accept_vis (HIRVisitor &vis) override;
-
- // HACK: used to simplify parsing - creates a copy of this
- std::unique_ptr<MetaNameValueStr> to_meta_name_value_str () const override
- {
- return std::unique_ptr<MetaNameValueStr> (clone_meta_item_inner_impl ());
- }
-
- Attribute to_attribute () const override;
-
-protected:
- // Use covariance to implement clone function as returning this type
- MetaNameValueStr *clone_meta_item_inner_impl () const override
- {
- return new MetaNameValueStr (*this);
- }
-};
-
-// doubles up as MetaListIdents - determine via iterating through each path?
-// Preferred specialisation for "identifier '(' SimplePath, SimplePath, ... ')'"
-class MetaListPaths : public MetaItem
-{
- Identifier ident;
- std::vector<SimplePath> paths;
-
-public:
- MetaListPaths (Identifier ident, std::vector<SimplePath> paths)
- : ident (std::move (ident)), paths (std::move (paths))
- {}
-
- std::string as_string () const override;
-
- void accept_vis (HIRVisitor &vis) override;
-
- Attribute to_attribute () const override;
-
-protected:
- // Use covariance to implement clone function as returning this type
- MetaListPaths *clone_meta_item_inner_impl () const override
- {
- return new MetaListPaths (*this);
- }
-};
-
-// Preferred specialisation for "identifier '(' MetaNameValueStr, ... ')'"
-class MetaListNameValueStr : public MetaItem
-{
- Identifier ident;
- std::vector<MetaNameValueStr> strs;
-
-public:
- MetaListNameValueStr (Identifier ident, std::vector<MetaNameValueStr> strs)
- : ident (std::move (ident)), strs (std::move (strs))
- {}
-
- std::string as_string () const override;
-
- void accept_vis (HIRVisitor &vis) override;
-
- Attribute to_attribute () const override;
-
-protected:
- // Use covariance to implement clone function as returning this type
- MetaListNameValueStr *clone_meta_item_inner_impl () const override
- {
- return new MetaListNameValueStr (*this);
- }
-};
-
-// Object that parses macros from a token stream.
-struct MacroParser
-{
-private:
- std::vector<std::unique_ptr<Token> > token_stream;
- /* probably have to make this mutable (mutable int stream_pos) otherwise const
- * has to be removed up to DelimTokenTree or further ok since this changing
- * would have an effect on the results of the methods run (i.e. not logically
- * const), the parsing methods shouldn't be const */
- int stream_pos;
-
-public:
- MacroParser (std::vector<std::unique_ptr<Token> > token_stream,
- int stream_start_pos = 0)
- : token_stream (std::move (token_stream)), stream_pos (stream_start_pos)
- {}
-
- ~MacroParser () = default;
-
- std::vector<std::unique_ptr<MetaItemInner> > parse_meta_item_seq ();
-
-private:
- // Parses a MetaItemInner.
- std::unique_ptr<MetaItemInner> parse_meta_item_inner ();
- // Returns whether token can end a meta item.
- bool is_end_meta_item_tok (TokenId id) const;
- // Parses a simple path.
- SimplePath parse_simple_path ();
- // Parses a segment of a simple path (but not scope resolution operator).
- SimplePathSegment parse_simple_path_segment ();
- // Parses a MetaItemLitExpr.
- std::unique_ptr<MetaItemLitExpr> parse_meta_item_lit ();
- // Parses a literal.
- Literal parse_literal ();
- // Parses a meta item that begins with a simple path.
- std::unique_ptr<MetaItem> parse_path_meta_item ();
-
- // TODO: should this be const?
- std::unique_ptr<Token> &peek_token (int i = 0)
- {
- return token_stream[stream_pos + i];
- }
-
- void skip_token (int i = 0) { stream_pos += 1 + i; }
-};
} // namespace HIR
} // namespace Rust
diff --git a/gcc/rust/hir/tree/rust-hir-path.h b/gcc/rust/hir/tree/rust-hir-path.h
index c163487..84f3e96 100644
--- a/gcc/rust/hir/tree/rust-hir-path.h
+++ b/gcc/rust/hir/tree/rust-hir-path.h
@@ -243,7 +243,8 @@ protected:
/* Converts path segments to their equivalent SimplePath segments if possible,
* and creates a SimplePath from them. */
- SimplePath convert_to_simple_path (bool with_opening_scope_resolution) const;
+ AST::SimplePath
+ convert_to_simple_path (bool with_opening_scope_resolution) const;
public:
/* Returns whether the path is a single segment (excluding qualified path
@@ -285,8 +286,8 @@ public:
std::vector<PathExprSegment> path_segments,
Location locus = Location (),
bool has_opening_scope_resolution = false,
- std::vector<Attribute> outer_attrs
- = std::vector<Attribute> ())
+ std::vector<AST::Attribute> outer_attrs
+ = std::vector<AST::Attribute> ())
: PathPattern (std::move (path_segments)),
PathExpr (std::move (mappings), std::move (outer_attrs)),
has_opening_scope_resolution (has_opening_scope_resolution), locus (locus)
@@ -304,7 +305,7 @@ public:
/* Converts PathInExpression to SimplePath if possible (i.e. no generic
* arguments). Otherwise returns an empty SimplePath. */
- SimplePath as_simple_path () const
+ AST::SimplePath as_simple_path () const
{
/* delegate to parent class as can't access segments. however,
* QualifiedPathInExpression conversion to simple path wouldn't make sense,
@@ -655,7 +656,7 @@ public:
/* Converts TypePath to SimplePath if possible (i.e. no generic or function
* arguments). Otherwise returns an empty SimplePath. */
- SimplePath as_simple_path () const;
+ AST::SimplePath as_simple_path () const;
// Creates a trait bound with a clone of this type path as its only element.
TraitBound *to_trait_bound (bool in_parens) const override;
@@ -750,8 +751,8 @@ public:
QualifiedPathType qual_path_type,
std::vector<PathExprSegment> path_segments,
Location locus = Location (),
- std::vector<Attribute> outer_attrs
- = std::vector<Attribute> ())
+ std::vector<AST::Attribute> outer_attrs
+ = std::vector<AST::Attribute> ())
: PathPattern (std::move (path_segments)),
PathExpr (std::move (mappings), std::move (outer_attrs)),
path_type (std::move (qual_path_type)), locus (locus)
diff --git a/gcc/rust/hir/tree/rust-hir-pattern.h b/gcc/rust/hir/tree/rust-hir-pattern.h
index d18d8db..13177f2 100644
--- a/gcc/rust/hir/tree/rust-hir-pattern.h
+++ b/gcc/rust/hir/tree/rust-hir-pattern.h
@@ -376,26 +376,26 @@ protected:
struct StructPatternEtc
{
private:
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
// should this store location data?
public:
- StructPatternEtc (std::vector<Attribute> outer_attribs)
+ StructPatternEtc (AST::AttrVec outer_attribs)
: outer_attrs (std::move (outer_attribs))
{}
// Creates an empty StructPatternEtc
static StructPatternEtc create_empty ()
{
- return StructPatternEtc (std::vector<Attribute> ());
+ return StructPatternEtc (AST::AttrVec ());
}
};
// Base class for a single field in a struct pattern - abstract
class StructPatternField
{
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
Location locus;
public:
@@ -415,7 +415,7 @@ public:
virtual void accept_vis (HIRVisitor &vis) = 0;
protected:
- StructPatternField (std::vector<Attribute> outer_attribs, Location locus)
+ StructPatternField (AST::AttrVec outer_attribs, Location locus)
: outer_attrs (std::move (outer_attribs)), locus (locus)
{}
@@ -432,8 +432,7 @@ class StructPatternFieldTuplePat : public StructPatternField
public:
StructPatternFieldTuplePat (TupleIndex index,
std::unique_ptr<Pattern> tuple_pattern,
- std::vector<Attribute> outer_attribs,
- Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: StructPatternField (std::move (outer_attribs), locus), index (index),
tuple_pattern (std::move (tuple_pattern))
{}
@@ -483,8 +482,7 @@ class StructPatternFieldIdentPat : public StructPatternField
public:
StructPatternFieldIdentPat (Identifier ident,
std::unique_ptr<Pattern> ident_pattern,
- std::vector<Attribute> outer_attrs,
- Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: StructPatternField (std::move (outer_attrs), locus),
ident (std::move (ident)), ident_pattern (std::move (ident_pattern))
{}
@@ -534,7 +532,7 @@ class StructPatternFieldIdent : public StructPatternField
public:
StructPatternFieldIdent (Identifier ident, bool is_ref, bool is_mut,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: StructPatternField (std::move (outer_attrs), locus), has_ref (is_ref),
has_mut (is_mut), ident (std::move (ident))
{}
diff --git a/gcc/rust/hir/tree/rust-hir-stmt.h b/gcc/rust/hir/tree/rust-hir-stmt.h
index e34fa7e..584b0e3 100644
--- a/gcc/rust/hir/tree/rust-hir-stmt.h
+++ b/gcc/rust/hir/tree/rust-hir-stmt.h
@@ -52,7 +52,7 @@ protected:
class LetStmt : public Stmt
{
// bool has_outer_attrs;
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
std::unique_ptr<Pattern> variables_pattern;
@@ -79,7 +79,7 @@ public:
LetStmt (Analysis::NodeMapping mappings,
std::unique_ptr<Pattern> variables_pattern,
std::unique_ptr<Expr> init_expr, std::unique_ptr<Type> type,
- std::vector<Attribute> outer_attrs, Location locus)
+ AST::AttrVec outer_attrs, Location locus)
: Stmt (std::move (mappings)), outer_attrs (std::move (outer_attrs)),
variables_pattern (std::move (variables_pattern)),
type (std::move (type)), init_expr (std::move (init_expr)), locus (locus)
diff --git a/gcc/rust/hir/tree/rust-hir-visitor.h b/gcc/rust/hir/tree/rust-hir-visitor.h
index a7b9791..7e6752b 100644
--- a/gcc/rust/hir/tree/rust-hir-visitor.h
+++ b/gcc/rust/hir/tree/rust-hir-visitor.h
@@ -37,8 +37,8 @@ public:
// virtual void visit(TokenTree& token_tree) = 0;
// virtual void visit(MacroMatch& macro_match) = 0;
virtual void visit (Token &tok) = 0;
- virtual void visit (DelimTokenTree &delim_tok_tree) = 0;
- virtual void visit (AttrInputMetaItemContainer &input) = 0;
+ // virtual void visit (DelimTokenTree &delim_tok_tree) = 0;
+ // virtual void visit (AttrInputMetaItemContainer &input) = 0;
// virtual void visit(MetaItem& meta_item) = 0;
// virtual void visit(Stmt& stmt) = 0;
// virtual void visit(Expr& expr) = 0;
@@ -64,9 +64,9 @@ public:
// rust-expr.h
virtual void visit (LiteralExpr &expr) = 0;
- virtual void visit (AttrInputLiteral &attr_input) = 0;
- virtual void visit (MetaItemLitExpr &meta_item) = 0;
- virtual void visit (MetaItemPathLit &meta_item) = 0;
+ // virtual void visit (AttrInputLiteral &attr_input) = 0;
+ // virtual void visit (MetaItemLitExpr &meta_item) = 0;
+ // virtual void visit (MetaItemPathLit &meta_item) = 0;
virtual void visit (BorrowExpr &expr) = 0;
virtual void visit (DereferenceExpr &expr) = 0;
virtual void visit (ErrorPropagationExpr &expr) = 0;
@@ -179,12 +179,12 @@ public:
virtual void visit (MacroMatcher &matcher) = 0;
virtual void visit (MacroRulesDefinition &rules_def) = 0;
virtual void visit (MacroInvocation &macro_invoc) = 0;
- virtual void visit (MetaItemPath &meta_item) = 0;
- virtual void visit (MetaItemSeq &meta_item) = 0;
- virtual void visit (MetaWord &meta_item) = 0;
- virtual void visit (MetaNameValueStr &meta_item) = 0;
- virtual void visit (MetaListPaths &meta_item) = 0;
- virtual void visit (MetaListNameValueStr &meta_item) = 0;
+ // virtual void visit (MetaItemPath &meta_item) = 0;
+ // virtual void visit (MetaItemSeq &meta_item) = 0;
+ // virtual void visit (MetaWord &meta_item) = 0;
+ // virtual void visit (MetaNameValueStr &meta_item) = 0;
+ // virtual void visit (MetaListPaths &meta_item) = 0;
+ // virtual void visit (MetaListNameValueStr &meta_item) = 0;
// rust-pattern.h
virtual void visit (LiteralPattern &pattern) = 0;
diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h
index f6fa62d..decf0c9 100644
--- a/gcc/rust/hir/tree/rust-hir.h
+++ b/gcc/rust/hir/tree/rust-hir.h
@@ -19,6 +19,7 @@
#ifndef RUST_HIR_BASE_H
#define RUST_HIR_BASE_H
+#include "rust-ast.h"
#include "rust-system.h"
#include "rust-token.h"
#include "rust-location.h"
@@ -32,38 +33,6 @@ namespace HIR {
// foward decl: ast visitor
class HIRVisitor;
-// Delimiter types - used in macros and whatever.
-enum DelimType
-{
- PARENS,
- SQUARE,
- CURLY
-};
-
-// Attribute body - abstract base class
-class AttrInput
-{
-public:
- virtual ~AttrInput () {}
-
- // Unique pointer custom clone function
- std::unique_ptr<AttrInput> clone_attr_input () const
- {
- return std::unique_ptr<AttrInput> (clone_attr_input_impl ());
- }
-
- virtual std::string as_string () const = 0;
-
- virtual void accept_vis (HIRVisitor &vis) = 0;
-
- // Parse attribute input to meta item, if possible
- virtual AttrInput *parse_to_meta_item () const { return nullptr; }
-
-protected:
- // pure virtual clone implementation
- virtual AttrInput *clone_attr_input_impl () const = 0;
-};
-
// forward decl for use in token tree method
class Token;
@@ -263,445 +232,6 @@ public:
bool is_error () const { return value_as_string == ""; }
};
-// A token tree with delimiters
-class DelimTokenTree : public TokenTree, public AttrInput
-{
- DelimType delim_type;
- std::vector<std::unique_ptr<TokenTree> > token_trees;
- Location locus;
-
-protected:
- DelimTokenTree *clone_delim_tok_tree_impl () const
- {
- return new DelimTokenTree (*this);
- }
-
- /* Use covariance to implement clone function as returning a DelimTokenTree
- * object */
- DelimTokenTree *clone_attr_input_impl () const override
- {
- return clone_delim_tok_tree_impl ();
- }
-
- /* Use covariance to implement clone function as returning a DelimTokenTree
- * object */
- DelimTokenTree *clone_token_tree_impl () const override
- {
- return clone_delim_tok_tree_impl ();
- }
-
-public:
- DelimTokenTree (DelimType delim_type,
- std::vector<std::unique_ptr<TokenTree> > token_trees
- = std::vector<std::unique_ptr<TokenTree> > (),
- Location locus = Location ())
- : delim_type (delim_type), token_trees (std::move (token_trees)),
- locus (locus)
- {}
-
- // Copy constructor with vector clone
- DelimTokenTree (DelimTokenTree const &other)
- : delim_type (other.delim_type), locus (other.locus)
- {
- token_trees.reserve (other.token_trees.size ());
- for (const auto &e : other.token_trees)
- token_trees.push_back (e->clone_token_tree ());
- }
-
- // overloaded assignment operator with vector clone
- DelimTokenTree &operator= (DelimTokenTree const &other)
- {
- delim_type = other.delim_type;
- locus = other.locus;
-
- token_trees.reserve (other.token_trees.size ());
- for (const auto &e : other.token_trees)
- token_trees.push_back (e->clone_token_tree ());
-
- return *this;
- }
-
- // move constructors
- DelimTokenTree (DelimTokenTree &&other) = default;
- DelimTokenTree &operator= (DelimTokenTree &&other) = default;
-
- static DelimTokenTree create_empty () { return DelimTokenTree (PARENS); }
-
- std::string as_string () const override;
-
- void accept_vis (HIRVisitor &vis) override;
-
- AttrInput *parse_to_meta_item () const override;
-
- std::vector<std::unique_ptr<Token> > to_token_stream () const override;
-
- std::unique_ptr<DelimTokenTree> clone_delim_token_tree () const
- {
- return std::unique_ptr<DelimTokenTree> (clone_delim_tok_tree_impl ());
- }
-};
-
-/* Forward decl - definition moved to rust-expr.h as it requires LiteralExpr to
- * be defined */
-class AttrInputLiteral;
-
-/* TODO: move applicable stuff into here or just don't include it because
- * nothing uses it A segment of a path (maybe) */
-class PathSegment
-{
-public:
- virtual ~PathSegment () {}
-
- virtual std::string as_string () const = 0;
-
- // TODO: add visitor here?
-};
-
-// A segment of a simple path without generic or type arguments
-class SimplePathSegment : public PathSegment
-{
- std::string segment_name;
- Location locus;
-
- // only allow identifiers, "super", "self", "crate", or "$crate"
-public:
- // TODO: put checks in constructor to enforce this rule?
- SimplePathSegment (std::string segment_name, Location locus = Location ())
- : segment_name (std::move (segment_name)), locus (locus)
- {}
-
- /* Returns whether simple path segment is in an invalid state (currently, if
- * empty). */
- bool is_error () const { return segment_name.empty (); }
-
- // Creates an error SimplePathSegment
- static SimplePathSegment create_error ()
- {
- return SimplePathSegment (std::string (""));
- }
-
- std::string as_string () const override;
-
- Location get_locus () const { return locus; }
-
- // TODO: visitor pattern?
-};
-
-// A simple path without generic or type arguments
-class SimplePath
-{
- bool has_opening_scope_resolution;
- std::vector<SimplePathSegment> segments;
- Location locus;
-
-public:
- // Constructor
- SimplePath (std::vector<SimplePathSegment> path_segments,
- bool has_opening_scope_resolution = false,
- Location locus = Location ())
- : has_opening_scope_resolution (has_opening_scope_resolution),
- segments (std::move (path_segments)), locus (locus)
- {}
-
- // Creates an empty SimplePath.
- static SimplePath create_empty ()
- {
- return SimplePath (std::vector<SimplePathSegment> ());
- }
-
- // Returns whether the SimplePath is empty, i.e. has path segments.
- bool is_empty () const { return segments.empty (); }
-
- std::string as_string () const;
-
- Location get_locus () const { return locus; }
-
- // does this need visitor if not polymorphic? probably not
-
- // path-to-string comparison operator
- bool operator== (const std::string &rhs)
- {
- return !has_opening_scope_resolution && segments.size () == 1
- && segments[0].as_string () == rhs;
- }
-
- /* Creates a single-segment SimplePath from a string. This will not check to
- * ensure that this is a valid identifier in path, so be careful. Also, this
- * will have no location data.
- * TODO have checks? */
- static SimplePath from_str (std::string str)
- {
- std::vector<HIR::SimplePathSegment> single_segments
- = {HIR::SimplePathSegment (std::move (str))};
- return SimplePath (std::move (single_segments));
- }
-};
-
-// aka Attr
-// Attribute HIR representation
-struct Attribute
-{
-private:
- SimplePath path;
-
- // bool has_attr_input;
- std::unique_ptr<AttrInput> attr_input;
-
- Location locus;
-
- // TODO: maybe a variable storing whether attr input is parsed or not
-
-public:
- // Returns whether Attribute has AttrInput
- bool has_attr_input () const { return attr_input != nullptr; }
-
- // Constructor has pointer AttrInput for polymorphism reasons
- Attribute (SimplePath path, std::unique_ptr<AttrInput> input,
- Location locus = Location ())
- : path (std::move (path)), attr_input (std::move (input)), locus (locus)
- {}
-
- // default destructor
- ~Attribute () = default;
-
- // Copy constructor must deep copy attr_input as unique pointer
- Attribute (Attribute const &other) : path (other.path), locus (other.locus)
- {
- // guard to protect from null pointer dereference
- if (other.attr_input != nullptr)
- attr_input = other.attr_input->clone_attr_input ();
- }
-
- // overload assignment operator to use custom clone method
- Attribute &operator= (Attribute const &other)
- {
- path = other.path;
- locus = other.locus;
- // guard to protect from null pointer dereference
- if (other.attr_input != nullptr)
- attr_input = other.attr_input->clone_attr_input ();
-
- return *this;
- }
-
- // default move semantics
- Attribute (Attribute &&other) = default;
- Attribute &operator= (Attribute &&other) = default;
-
- // Unique pointer custom clone function
- std::unique_ptr<Attribute> clone_attribute () const
- {
- return std::unique_ptr<Attribute> (clone_attribute_impl ());
- }
-
- // Creates an empty attribute (which is invalid)
- static Attribute create_empty ()
- {
- return Attribute (SimplePath::create_empty (), nullptr);
- }
-
- // Returns whether the attribute is considered an "empty" attribute.
- bool is_empty () const { return attr_input == nullptr && path.is_empty (); }
-
- /* e.g.:
- #![crate_type = "lib"]
- #[test]
- #[cfg(target_os = "linux")]
- #[allow(non_camel_case_types)]
- #![allow(unused_variables)]
- */
-
- // Full built-in attribute list:
- /* cfg
- * cfg_attr
- * test
- * ignore
- * should_panic
- * derive
- * macro_export
- * macro_use
- * proc_macro
- * proc_macro_derive
- * proc_macro_attribute
- * allow
- * warn
- * deny
- * forbid
- * deprecated
- * must_use
- * link
- * link_name
- * no_link
- * repr
- * crate_type
- * no_main
- * export_name
- * link_section
- * no_mangle
- * used
- * crate_name
- * inline
- * cold
- * no_builtins
- * target_feature
- * doc
- * no_std
- * no_implicit_prelude
- * path
- * recursion_limit
- * type_length_limit
- * panic_handler
- * global_allocator
- * windows_subsystem
- * feature */
-
- std::string as_string () const;
-
- // TODO: does this require visitor pattern as not polymorphic?
-
- // Maybe change to const-reference in future
- SimplePath get_path () const { return path; }
-
- // Call to parse attribute body to meta item syntax.
- void parse_attr_to_meta_item ();
-
-protected:
- // not virtual as currently no subclasses of Attribute, but could be in future
- /*virtual*/ Attribute *clone_attribute_impl () const
- {
- return new Attribute (*this);
- }
-};
-
-// Forward decl - defined in rust-macro.h
-class MetaNameValueStr;
-
-// abstract base meta item inner class
-class MetaItemInner
-{
-protected:
- // pure virtual as MetaItemInner
- virtual MetaItemInner *clone_meta_item_inner_impl () const = 0;
-
-public:
- // Unique pointer custom clone function
- std::unique_ptr<MetaItemInner> clone_meta_item_inner () const
- {
- return std::unique_ptr<MetaItemInner> (clone_meta_item_inner_impl ());
- }
-
- virtual ~MetaItemInner () {}
-
- virtual std::string as_string () const = 0;
-
- virtual void accept_vis (HIRVisitor &vis) = 0;
-
- /* HACK: used to simplify parsing - creates a copy of that type, or returns
- * null */
- virtual std::unique_ptr<MetaNameValueStr> to_meta_name_value_str () const
- {
- return nullptr;
- }
-
- // HACK: used to simplify parsing - same thing
- virtual SimplePath to_path_item () const
- {
- return SimplePath::create_empty ();
- }
-
- virtual Attribute to_attribute () const { return Attribute::create_empty (); }
-};
-
-// Container used to store MetaItems as AttrInput (bridge-ish kinda thing)
-class AttrInputMetaItemContainer : public AttrInput
-{
- std::vector<std::unique_ptr<MetaItemInner> > items;
-
-public:
- AttrInputMetaItemContainer (
- std::vector<std::unique_ptr<MetaItemInner> > items)
- : items (std::move (items))
- {}
-
- // no destructor definition required
-
- // default move constructors
- AttrInputMetaItemContainer (AttrInputMetaItemContainer &&other) = default;
- AttrInputMetaItemContainer &operator= (AttrInputMetaItemContainer &&other)
- = default;
-
- std::string as_string () const override;
-
- void accept_vis (HIRVisitor &vis) override;
-
- // Clones this object.
- std::unique_ptr<AttrInputMetaItemContainer>
- clone_attr_input_meta_item_container () const
- {
- return std::unique_ptr<AttrInputMetaItemContainer> (
- clone_attr_input_meta_item_container_impl ());
- }
-
-protected:
- // Use covariance to implement clone function as returning this type
- AttrInputMetaItemContainer *clone_attr_input_impl () const override
- {
- return clone_attr_input_meta_item_container_impl ();
- }
-
- AttrInputMetaItemContainer *clone_attr_input_meta_item_container_impl () const
- {
- return new AttrInputMetaItemContainer (*this);
- }
-
- // copy constructor with vector clone
- AttrInputMetaItemContainer (const AttrInputMetaItemContainer &other)
- {
- items.reserve (other.items.size ());
- for (const auto &e : other.items)
- items.push_back (e->clone_meta_item_inner ());
- }
-
- // copy assignment operator with vector clone
- AttrInputMetaItemContainer &
- operator= (const AttrInputMetaItemContainer &other)
- {
- AttrInput::operator= (other);
-
- items.reserve (other.items.size ());
- for (const auto &e : other.items)
- items.push_back (e->clone_meta_item_inner ());
-
- return *this;
- }
-};
-
-// abstract base meta item class
-class MetaItem : public MetaItemInner
-{
-};
-
-// Forward decl - defined in rust-expr.h
-class MetaItemLitExpr;
-
-// Forward decl - defined in rust-expr.h
-class MetaItemPathLit;
-
-// Forward decl - defined in rust-macro.h
-class MetaItemPath;
-
-// Forward decl - defined in rust-macro.h
-class MetaItemSeq;
-
-// Forward decl - defined in rust-macro.h
-class MetaWord;
-
-// Forward decl - defined in rust-macro.h
-class MetaListPaths;
-
-// Forward decl - defined in rust-macro.h
-struct MetaListNameValueStr;
-
/* Base statement abstract class. Note that most "statements" are not allowed in
* top-level module scope - only a subclass of statements called "items" are. */
class Stmt
@@ -739,7 +269,7 @@ protected:
// Rust "item" HIR node (declaration of top-level/module-level allowed stuff)
class Item : public Stmt
{
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
// TODO: should outer attrs be defined here or in each derived class?
@@ -763,7 +293,7 @@ public:
protected:
// Constructor
Item (Analysis::NodeMapping mappings,
- std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: Stmt (std::move (mappings)), outer_attrs (std::move (outer_attribs))
{}
@@ -783,12 +313,12 @@ class ExprWithoutBlock;
class Expr
{
// TODO: move outer attribute data to derived classes?
- std::vector<Attribute> outer_attrs;
+ AST::AttrVec outer_attrs;
Analysis::NodeMapping mappings;
public:
- const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
+ const AST::AttrVec &get_outer_attrs () const { return outer_attrs; }
// Unique pointer custom clone function
std::unique_ptr<Expr> clone_expr () const
@@ -827,13 +357,13 @@ public:
protected:
// Constructor
Expr (Analysis::NodeMapping mappings,
- std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: outer_attrs (std::move (outer_attribs)), mappings (std::move (mappings))
{}
// TODO: think of less hacky way to implement this kind of thing
// Sets outer attributes.
- void set_outer_attrs (std::vector<Attribute> outer_attrs_to_set)
+ void set_outer_attrs (AST::AttrVec outer_attrs_to_set)
{
outer_attrs = std::move (outer_attrs_to_set);
}
@@ -845,8 +375,7 @@ class ExprWithoutBlock : public Expr
protected:
// Constructor
ExprWithoutBlock (Analysis::NodeMapping mappings,
- std::vector<Attribute> outer_attribs
- = std::vector<Attribute> ())
+ AST::AttrVec outer_attribs = AST::AttrVec ())
: Expr (std::move (mappings), std::move (outer_attribs))
{}
@@ -891,8 +420,7 @@ public:
IdentifierExpr (Analysis::NodeMapping mappings, Identifier ident,
Location locus = Location (),
- std::vector<Attribute> outer_attrs
- = std::vector<Attribute> ())
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: ExprWithoutBlock (std::move (mappings), std::move (outer_attrs)),
ident (std::move (ident)), locus (locus)
{}
@@ -1155,7 +683,7 @@ class LifetimeParam : public GenericParam
// bool has_outer_attribute;
// std::unique_ptr<Attribute> outer_attr;
- Attribute outer_attr;
+ AST::Attribute outer_attr;
Location locus;
@@ -1176,7 +704,7 @@ public:
Location locus = Location (),
std::vector<Lifetime> lifetime_bounds
= std::vector<Lifetime> (),
- Attribute outer_attr = Attribute::create_empty ())
+ AST::Attribute outer_attr = AST::Attribute::create_empty ())
: GenericParam (mappings, GenericKind::LIFETIME),
lifetime (std::move (lifetime)),
lifetime_bounds (std::move (lifetime_bounds)),
@@ -1231,8 +759,7 @@ class MacroItem : public Item
/*public:
std::string as_string() const;*/
protected:
- MacroItem (Analysis::NodeMapping mappings,
- std::vector<Attribute> outer_attribs)
+ MacroItem (Analysis::NodeMapping mappings, AST::AttrVec outer_attribs)
: Item (std::move (mappings), std::move (outer_attribs))
{}
};
@@ -1325,7 +852,7 @@ struct Crate
bool has_utf8bom;
bool has_shebang;
- std::vector<Attribute> inner_attrs;
+ AST::AttrVec inner_attrs;
// dodgy spacing required here
/* TODO: is it better to have a vector of items here or a module (implicit
* top-level one)? */
@@ -1335,9 +862,9 @@ struct Crate
public:
// Constructor
- Crate (std::vector<std::unique_ptr<Item> > items,
- std::vector<Attribute> inner_attrs, Analysis::NodeMapping mappings,
- bool has_utf8bom = false, bool has_shebang = false)
+ Crate (std::vector<std::unique_ptr<Item> > items, AST::AttrVec inner_attrs,
+ Analysis::NodeMapping mappings, bool has_utf8bom = false,
+ bool has_shebang = false)
: has_utf8bom (has_utf8bom), has_shebang (has_shebang),
inner_attrs (std::move (inner_attrs)), items (std::move (items)),
mappings (mappings)
@@ -1384,8 +911,7 @@ public:
class PathExpr : public ExprWithoutBlock
{
protected:
- PathExpr (Analysis::NodeMapping mappings,
- std::vector<Attribute> outer_attribs)
+ PathExpr (Analysis::NodeMapping mappings, AST::AttrVec outer_attribs)
: ExprWithoutBlock (std::move (mappings), std::move (outer_attribs))
{}
@@ -1394,7 +920,7 @@ public:
/* Replaces the outer attributes of this path expression with the given outer
* attributes. */
- void replace_outer_attrs (std::vector<Attribute> outer_attrs)
+ void replace_outer_attrs (AST::AttrVec outer_attrs)
{
set_outer_attrs (std::move (outer_attrs));
}
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index dc8c773..7ea779a 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -402,7 +402,7 @@ Parser<ManagedTokenSource>::parse_crate ()
bool has_shebang = false;
// parse inner attributes
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse items
std::vector<std::unique_ptr<AST::Item>> items;
@@ -437,10 +437,10 @@ Parser<ManagedTokenSource>::parse_crate ()
// Parse a contiguous block of inner attributes.
template <typename ManagedTokenSource>
-std::vector<AST::Attribute>
+AST::AttrVec
Parser<ManagedTokenSource>::parse_inner_attributes ()
{
- std::vector<AST::Attribute> inner_attributes;
+ AST::AttrVec inner_attributes;
// only try to parse it if it starts with "#!" not only "#"
while (lexer.peek_token ()->get_id () == HASH
@@ -1018,7 +1018,7 @@ Parser<ManagedTokenSource>::parse_item (bool called_from_statement)
// has a "called_from_statement" parameter for better error message handling
// parse outer attributes for item
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// TODO: decide how to deal with VisItem vs MacroItem dichotomy
/* best current solution: catch all keywords that would imply a VisItem in a
@@ -1096,10 +1096,10 @@ Parser<ManagedTokenSource>::parse_item (bool called_from_statement)
// Parses a contiguous block of outer attributes.
template <typename ManagedTokenSource>
-std::vector<AST::Attribute>
+AST::AttrVec
Parser<ManagedTokenSource>::parse_outer_attributes ()
{
- std::vector<AST::Attribute> outer_attributes;
+ AST::AttrVec outer_attributes;
while (lexer.peek_token ()->get_id () == HASH)
{
@@ -1168,8 +1168,7 @@ Parser<ManagedTokenSource>::parse_outer_attribute ()
// Parses a VisItem (item that can have non-default visibility).
template <typename ManagedTokenSource>
std::unique_ptr<AST::VisItem>
-Parser<ManagedTokenSource>::parse_vis_item (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_vis_item (AST::AttrVec outer_attrs)
{
// parse visibility, which may or may not exist
AST::Visibility vis = parse_visibility ();
@@ -1306,8 +1305,7 @@ Parser<ManagedTokenSource>::parse_vis_item (
// Parses a MacroItem (either a MacroInvocationSemi or MacroRulesDefinition).
template <typename ManagedTokenSource>
std::unique_ptr<AST::MacroItem>
-Parser<ManagedTokenSource>::parse_macro_item (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_macro_item (AST::AttrVec outer_attrs)
{
const_TokenPtr t = lexer.peek_token ();
@@ -1345,8 +1343,7 @@ Parser<ManagedTokenSource>::parse_macro_item (
// Parses a macro rules definition syntax extension whatever thing.
template <typename ManagedTokenSource>
std::unique_ptr<AST::MacroRulesDefinition>
-Parser<ManagedTokenSource>::parse_macro_rules_def (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_macro_rules_def (AST::AttrVec outer_attrs)
{
// ensure that first token is identifier saying "macro_rules"
const_TokenPtr t = lexer.peek_token ();
@@ -1510,7 +1507,7 @@ Parser<ManagedTokenSource>::parse_macro_rules_def (
template <typename ManagedTokenSource>
std::unique_ptr<AST::MacroInvocationSemi>
Parser<ManagedTokenSource>::parse_macro_invocation_semi (
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
Location macro_locus = lexer.peek_token ()->get_locus ();
AST::SimplePath path = parse_simple_path ();
@@ -1628,8 +1625,7 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi (
// Parses a non-semicoloned macro invocation (i.e. as pattern or expression).
template <typename ManagedTokenSource>
std::unique_ptr<AST::MacroInvocation>
-Parser<ManagedTokenSource>::parse_macro_invocation (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_macro_invocation (AST::AttrVec outer_attrs)
{
// parse macro path
AST::SimplePath macro_path = parse_simple_path ();
@@ -2065,8 +2061,8 @@ Parser<ManagedTokenSource>::parse_visibility ()
// Parses a module - either a bodied module or a module defined in another file.
template <typename ManagedTokenSource>
std::unique_ptr<AST::Module>
-Parser<ManagedTokenSource>::parse_module (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_module (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (MOD);
@@ -2093,7 +2089,7 @@ Parser<ManagedTokenSource>::parse_module (
lexer.skip_token ();
// parse inner attributes
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse items
std::vector<std::unique_ptr<AST::Item>> items;
@@ -2140,8 +2136,8 @@ Parser<ManagedTokenSource>::parse_module (
// Parses an extern crate declaration (dependency on external crate)
template <typename ManagedTokenSource>
std::unique_ptr<AST::ExternCrate>
-Parser<ManagedTokenSource>::parse_extern_crate (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_extern_crate (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
if (!skip_token (EXTERN_TOK))
@@ -2236,8 +2232,8 @@ Parser<ManagedTokenSource>::parse_extern_crate (
// Parses a use declaration.
template <typename ManagedTokenSource>
std::unique_ptr<AST::UseDeclaration>
-Parser<ManagedTokenSource>::parse_use_decl (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_use_decl (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
if (!skip_token (USE))
@@ -2509,8 +2505,8 @@ Parser<ManagedTokenSource>::parse_use_tree ()
// Parses a function (not a method).
template <typename ManagedTokenSource>
std::unique_ptr<AST::Function>
-Parser<ManagedTokenSource>::parse_function (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_function (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
// Get qualifiers for function if they exist
@@ -3431,7 +3427,7 @@ AST::FunctionParam
Parser<ManagedTokenSource>::parse_function_param ()
{
// parse outer attributes if they exist
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// TODO: should saved location be at start of outer attributes or pattern?
Location locus = lexer.peek_token ()->get_locus ();
@@ -3902,8 +3898,8 @@ Parser<ManagedTokenSource>::parse_lifetime ()
// Parses a "type alias" (typedef) item.
template <typename ManagedTokenSource>
std::unique_ptr<AST::TypeAlias>
-Parser<ManagedTokenSource>::parse_type_alias (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_type_alias (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (TYPE);
@@ -3951,8 +3947,8 @@ Parser<ManagedTokenSource>::parse_type_alias (
// Parse a struct item AST node.
template <typename ManagedTokenSource>
std::unique_ptr<AST::Struct>
-Parser<ManagedTokenSource>::parse_struct (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_struct (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
/* TODO: determine best way to parse the proper struct vs tuple struct - share
* most of initial constructs so lookahead might be impossible, and if not
@@ -4154,7 +4150,7 @@ AST::StructField
Parser<ManagedTokenSource>::parse_struct_field ()
{
// parse outer attributes, if they exist
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// parse visibility, if it exists
AST::Visibility vis = parse_visibility ();
@@ -4254,7 +4250,7 @@ AST::TupleField
Parser<ManagedTokenSource>::parse_tuple_field ()
{
// parse outer attributes if they exist
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// parse visibility if it exists
AST::Visibility vis = parse_visibility ();
@@ -4280,7 +4276,7 @@ Parser<ManagedTokenSource>::parse_tuple_field ()
template <typename ManagedTokenSource>
std::unique_ptr<AST::Enum>
Parser<ManagedTokenSource>::parse_enum (AST::Visibility vis,
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (ENUM_TOK);
@@ -4404,7 +4400,7 @@ std::unique_ptr<AST::EnumItem>
Parser<ManagedTokenSource>::parse_enum_item ()
{
// parse outer attributes if they exist
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// parse name for enum item, which is required
const_TokenPtr item_name_tok = lexer.peek_token ();
@@ -4476,8 +4472,8 @@ Parser<ManagedTokenSource>::parse_enum_item ()
// Parses a C-style (and C-compat) untagged union declaration.
template <typename ManagedTokenSource>
std::unique_ptr<AST::Union>
-Parser<ManagedTokenSource>::parse_union (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_union (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
/* hack - "weak keyword" by finding identifier called "union" (lookahead in
* item switch) */
@@ -4529,8 +4525,8 @@ Parser<ManagedTokenSource>::parse_union (
* the program - like constexpr). */
template <typename ManagedTokenSource>
std::unique_ptr<AST::ConstantItem>
-Parser<ManagedTokenSource>::parse_const_item (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_const_item (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (CONST);
@@ -4593,8 +4589,8 @@ Parser<ManagedTokenSource>::parse_const_item (
// Parses a "static item" (static storage item, with 'static lifetime).
template <typename ManagedTokenSource>
std::unique_ptr<AST::StaticItem>
-Parser<ManagedTokenSource>::parse_static_item (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_static_item (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (STATIC_TOK);
@@ -4643,8 +4639,8 @@ Parser<ManagedTokenSource>::parse_static_item (
// Parses a trait definition item, including unsafe ones.
template <typename ManagedTokenSource>
std::unique_ptr<AST::Trait>
-Parser<ManagedTokenSource>::parse_trait (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_trait (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
bool is_unsafe = false;
@@ -4687,7 +4683,7 @@ Parser<ManagedTokenSource>::parse_trait (
}
// parse inner attrs (if they exist)
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse trait items
std::vector<std::unique_ptr<AST::TraitItem>> trait_items;
@@ -4730,7 +4726,7 @@ std::unique_ptr<AST::TraitItem>
Parser<ManagedTokenSource>::parse_trait_item ()
{
// parse outer attributes (if they exist)
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// lookahead to determine what type of trait item to parse
const_TokenPtr tok = lexer.peek_token ();
@@ -4889,8 +4885,7 @@ Parser<ManagedTokenSource>::parse_trait_item ()
// Parse a typedef trait item.
template <typename ManagedTokenSource>
std::unique_ptr<AST::TraitItemType>
-Parser<ManagedTokenSource>::parse_trait_type (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_trait_type (AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (TYPE);
@@ -4925,8 +4920,7 @@ Parser<ManagedTokenSource>::parse_trait_type (
// Parses a constant trait item.
template <typename ManagedTokenSource>
std::unique_ptr<AST::TraitItemConst>
-Parser<ManagedTokenSource>::parse_trait_const (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_trait_const (AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (CONST);
@@ -4971,7 +4965,7 @@ Parser<ManagedTokenSource>::parse_trait_const (
template <typename ManagedTokenSource>
std::unique_ptr<AST::Impl>
Parser<ManagedTokenSource>::parse_impl (AST::Visibility vis,
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
/* Note that only trait impls are allowed to be unsafe. So if unsafe, it must
* be a trait impl. However, this isn't enough for full disambiguation, so
@@ -5041,7 +5035,7 @@ Parser<ManagedTokenSource>::parse_impl (AST::Visibility vis,
}
// parse inner attributes (optional)
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse inherent impl items
std::vector<std::unique_ptr<AST::InherentImplItem>> impl_items;
@@ -5116,7 +5110,7 @@ Parser<ManagedTokenSource>::parse_impl (AST::Visibility vis,
}
// parse inner attributes (optional)
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse trait impl items
std::vector<std::unique_ptr<AST::TraitImplItem>> impl_items;
@@ -5172,7 +5166,7 @@ std::unique_ptr<AST::InherentImplItem>
Parser<ManagedTokenSource>::parse_inherent_impl_item ()
{
// parse outer attributes (if they exist)
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// TODO: cleanup - currently an unreadable mess
@@ -5288,7 +5282,7 @@ Parser<ManagedTokenSource>::parse_inherent_impl_item ()
template <typename ManagedTokenSource>
std::unique_ptr<AST::InherentImplItem>
Parser<ManagedTokenSource>::parse_inherent_impl_function_or_method (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+ AST::Visibility vis, AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
// parse function or method qualifiers
@@ -5393,7 +5387,7 @@ std::unique_ptr<AST::TraitImplItem>
Parser<ManagedTokenSource>::parse_trait_impl_item ()
{
// parse outer attributes (if they exist)
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// TODO: clean this function up, it is basically unreadable hacks
@@ -5511,7 +5505,7 @@ Parser<ManagedTokenSource>::parse_trait_impl_item ()
template <typename ManagedTokenSource>
std::unique_ptr<AST::TraitImplItem>
Parser<ManagedTokenSource>::parse_trait_impl_function_or_method (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+ AST::Visibility vis, AST::AttrVec outer_attrs)
{
// this shares virtually all logic with parse_inherent_impl_function_or_method
// - template?
@@ -5670,8 +5664,8 @@ Parser<ManagedTokenSource>::parse_trait_impl_function_or_method (
// Parses an extern block of declarations.
template <typename ManagedTokenSource>
std::unique_ptr<AST::ExternBlock>
-Parser<ManagedTokenSource>::parse_extern_block (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_extern_block (AST::Visibility vis,
+ AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (EXTERN_TOK);
@@ -5691,7 +5685,7 @@ Parser<ManagedTokenSource>::parse_extern_block (
return nullptr;
}
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse declarations inside extern block
std::vector<std::unique_ptr<AST::ExternalItem>> extern_items;
@@ -5736,7 +5730,7 @@ std::unique_ptr<AST::ExternalItem>
Parser<ManagedTokenSource>::parse_external_item ()
{
// parse optional outer attributes
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
Location locus = lexer.peek_token ()->get_locus ();
@@ -5823,13 +5817,12 @@ Parser<ManagedTokenSource>::parse_external_item ()
// parse parameters
std::vector<AST::NamedFunctionParam> function_params;
bool is_variadic = false;
- std::vector<AST::Attribute> variadic_attrs;
+ AST::AttrVec variadic_attrs;
const_TokenPtr t = lexer.peek_token ();
while (t->get_id () != RIGHT_PAREN)
{
- std::vector<AST::Attribute> maybe_variadic_attrs
- = parse_outer_attributes ();
+ AST::AttrVec maybe_variadic_attrs = parse_outer_attributes ();
if (lexer.peek_token ()->get_id () == ELLIPSIS)
{
// variadic - use attrs for this
@@ -5920,7 +5913,7 @@ Parser<ManagedTokenSource>::parse_external_item ()
template <typename ManagedTokenSource>
AST::NamedFunctionParam
Parser<ManagedTokenSource>::parse_named_function_param (
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
// parse identifier/_
std::string name;
@@ -5979,7 +5972,7 @@ Parser<ManagedTokenSource>::parse_stmt ()
}
// parse outer attributes
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// parsing this will be annoying because of the many different possibilities
/* best may be just to copy paste in parse_item switch, and failing that try
@@ -6054,8 +6047,7 @@ Parser<ManagedTokenSource>::parse_stmt ()
// Parses a let statement.
template <typename ManagedTokenSource>
std::unique_ptr<AST::LetStmt>
-Parser<ManagedTokenSource>::parse_let_stmt (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_let_stmt (AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (LET);
@@ -6951,16 +6943,14 @@ Parser<ManagedTokenSource>::parse_method ()
std::move (generic_params), std::move (self_param),
std::move (function_params), std::move (return_type),
std::move (where_clause), std::move (block_expr),
- AST::Visibility::create_error (),
- std::vector<AST::Attribute> (), locus);
+ AST::Visibility::create_error (), AST::AttrVec (), locus);
}
/* Parses an expression statement (disambiguates to expression with or without
* block statement). */
template <typename ManagedTokenSource>
std::unique_ptr<AST::ExprStmt>
-Parser<ManagedTokenSource>::parse_expr_stmt (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_expr_stmt (AST::AttrVec outer_attrs)
{
/* potential thoughts - define new virtual method "has_block()" on expr. parse
* expr and then determine whether semicolon is needed as a result of this
@@ -7026,8 +7016,7 @@ Parser<ManagedTokenSource>::parse_expr_stmt (
template <typename ManagedTokenSource>
std::unique_ptr<AST::ExprWithBlock>
-Parser<ManagedTokenSource>::parse_expr_with_block (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_expr_with_block (AST::AttrVec outer_attrs)
{
std::unique_ptr<AST::ExprWithBlock> expr_parsed = nullptr;
@@ -7121,7 +7110,7 @@ Parser<ManagedTokenSource>::parse_expr_with_block (
template <typename ManagedTokenSource>
std::unique_ptr<AST::ExprStmtWithBlock>
Parser<ManagedTokenSource>::parse_expr_stmt_with_block (
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
auto expr_parsed = parse_expr_with_block (std::move (outer_attrs));
auto locus = expr_parsed->get_locus ();
@@ -7137,7 +7126,7 @@ Parser<ManagedTokenSource>::parse_expr_stmt_with_block (
template <typename ManagedTokenSource>
std::unique_ptr<AST::ExprStmtWithoutBlock>
Parser<ManagedTokenSource>::parse_expr_stmt_without_block (
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
/* TODO: maybe move more logic for expr without block in here for better error
* handling */
@@ -7172,8 +7161,7 @@ Parser<ManagedTokenSource>::parse_expr_stmt_without_block (
* disambiguates). */
template <typename ManagedTokenSource>
std::unique_ptr<AST::ExprWithoutBlock>
-Parser<ManagedTokenSource>::parse_expr_without_block (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_expr_without_block (AST::AttrVec outer_attrs)
{
/* Notes on types of expr without block:
* - literal expr tokens that are literals
@@ -7278,8 +7266,8 @@ Parser<ManagedTokenSource>::parse_expr_without_block (
// Parses a block expression, including the curly braces at start and end.
template <typename ManagedTokenSource>
std::unique_ptr<AST::BlockExpr>
-Parser<ManagedTokenSource>::parse_block_expr (
- std::vector<AST::Attribute> outer_attrs, bool pratt_parse)
+Parser<ManagedTokenSource>::parse_block_expr (AST::AttrVec outer_attrs,
+ bool pratt_parse)
{
Location locus = Linemap::unknown_location ();
if (!pratt_parse)
@@ -7296,7 +7284,7 @@ Parser<ManagedTokenSource>::parse_block_expr (
locus = lexer.peek_token ()->get_locus () - 1;
}
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse statements and expression
std::vector<std::unique_ptr<AST::Stmt>> stmts;
@@ -7355,13 +7343,12 @@ Parser<ManagedTokenSource>::parse_block_expr (
* precedence. */
template <typename ManagedTokenSource>
std::unique_ptr<AST::GroupedExpr>
-Parser<ManagedTokenSource>::parse_grouped_expr (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_grouped_expr (AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (LEFT_PAREN);
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse required expr inside parentheses
std::unique_ptr<AST::Expr> expr_in_parens = parse_expr ();
@@ -7386,8 +7373,7 @@ Parser<ManagedTokenSource>::parse_grouped_expr (
// Parses a closure expression (closure definition).
template <typename ManagedTokenSource>
std::unique_ptr<AST::ClosureExpr>
-Parser<ManagedTokenSource>::parse_closure_expr (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_closure_expr (AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
// detect optional "move"
@@ -7511,8 +7497,7 @@ Parser<ManagedTokenSource>::parse_closure_expr (
// Parses a literal token (to literal expression).
template <typename ManagedTokenSource>
std::unique_ptr<AST::LiteralExpr>
-Parser<ManagedTokenSource>::parse_literal_expr (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_literal_expr (AST::AttrVec outer_attrs)
{
// TODO: change if literal representation in lexer changes
@@ -7588,8 +7573,8 @@ Parser<ManagedTokenSource>::parse_literal_expr (
// Parses a return expression (including any expression to return).
template <typename ManagedTokenSource>
std::unique_ptr<AST::ReturnExpr>
-Parser<ManagedTokenSource>::parse_return_expr (
- std::vector<AST::Attribute> outer_attrs, bool pratt_parse)
+Parser<ManagedTokenSource>::parse_return_expr (AST::AttrVec outer_attrs,
+ bool pratt_parse)
{
Location locus = Linemap::unknown_location ();
if (!pratt_parse)
@@ -7609,7 +7594,7 @@ Parser<ManagedTokenSource>::parse_return_expr (
ParseRestrictions restrictions;
restrictions.expr_can_be_null = true;
std::unique_ptr<AST::Expr> returned_expr
- = parse_expr (std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (AST::AttrVec (), restrictions);
return std::unique_ptr<AST::ReturnExpr> (
new AST::ReturnExpr (std::move (returned_expr), std::move (outer_attrs),
@@ -7620,8 +7605,8 @@ Parser<ManagedTokenSource>::parse_return_expr (
* expression). */
template <typename ManagedTokenSource>
std::unique_ptr<AST::BreakExpr>
-Parser<ManagedTokenSource>::parse_break_expr (
- std::vector<AST::Attribute> outer_attrs, bool pratt_parse)
+Parser<ManagedTokenSource>::parse_break_expr (AST::AttrVec outer_attrs,
+ bool pratt_parse)
{
Location locus = Linemap::unknown_location ();
if (!pratt_parse)
@@ -7648,7 +7633,7 @@ Parser<ManagedTokenSource>::parse_break_expr (
ParseRestrictions restrictions;
restrictions.expr_can_be_null = true;
std::unique_ptr<AST::Expr> return_expr
- = parse_expr (std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (AST::AttrVec (), restrictions);
return std::unique_ptr<AST::BreakExpr> (
new AST::BreakExpr (std::move (label), std::move (return_expr),
@@ -7658,8 +7643,8 @@ Parser<ManagedTokenSource>::parse_break_expr (
// Parses a continue expression (including any label to continue from).
template <typename ManagedTokenSource>
std::unique_ptr<AST::ContinueExpr>
-Parser<ManagedTokenSource>::parse_continue_expr (
- std::vector<AST::Attribute> outer_attrs, bool pratt_parse)
+Parser<ManagedTokenSource>::parse_continue_expr (AST::AttrVec outer_attrs,
+ bool pratt_parse)
{
Location locus = Linemap::unknown_location ();
if (!pratt_parse)
@@ -7716,8 +7701,8 @@ Parser<ManagedTokenSource>::parse_loop_label ()
* expressions don't support them. */
template <typename ManagedTokenSource>
std::unique_ptr<AST::IfExpr>
-Parser<ManagedTokenSource>::parse_if_expr (
- std::vector<AST::Attribute> outer_attrs, bool pratt_parse)
+Parser<ManagedTokenSource>::parse_if_expr (AST::AttrVec outer_attrs,
+ bool pratt_parse)
{
// TODO: make having outer attributes an error?
Location locus = Linemap::unknown_location ();
@@ -7878,8 +7863,8 @@ Parser<ManagedTokenSource>::parse_if_expr (
* expressions don't support them. */
template <typename ManagedTokenSource>
std::unique_ptr<AST::IfLetExpr>
-Parser<ManagedTokenSource>::parse_if_let_expr (
- std::vector<AST::Attribute> outer_attrs, bool pratt_parse)
+Parser<ManagedTokenSource>::parse_if_let_expr (AST::AttrVec outer_attrs,
+ bool pratt_parse)
{
// TODO: make having outer attributes an error?
Location locus = Linemap::unknown_location ();
@@ -8069,9 +8054,9 @@ Parser<ManagedTokenSource>::parse_if_let_expr (
* parsed via parse_labelled_loop_expr, which would call this. */
template <typename ManagedTokenSource>
std::unique_ptr<AST::LoopExpr>
-Parser<ManagedTokenSource>::parse_loop_expr (
- std::vector<AST::Attribute> outer_attrs, AST::LoopLabel label,
- bool pratt_parse)
+Parser<ManagedTokenSource>::parse_loop_expr (AST::AttrVec outer_attrs,
+ AST::LoopLabel label,
+ bool pratt_parse)
{
Location locus = Linemap::unknown_location ();
if (!pratt_parse)
@@ -8115,9 +8100,9 @@ Parser<ManagedTokenSource>::parse_loop_expr (
* via parse_labelled_loop_expr, which would call this. */
template <typename ManagedTokenSource>
std::unique_ptr<AST::WhileLoopExpr>
-Parser<ManagedTokenSource>::parse_while_loop_expr (
- std::vector<AST::Attribute> outer_attrs, AST::LoopLabel label,
- bool pratt_parse)
+Parser<ManagedTokenSource>::parse_while_loop_expr (AST::AttrVec outer_attrs,
+ AST::LoopLabel label,
+ bool pratt_parse)
{
Location locus = Linemap::unknown_location ();
if (!pratt_parse)
@@ -8190,8 +8175,8 @@ Parser<ManagedTokenSource>::parse_while_loop_expr (
* parsed via parse_labelled_loop_expr, which would call this. */
template <typename ManagedTokenSource>
std::unique_ptr<AST::WhileLetLoopExpr>
-Parser<ManagedTokenSource>::parse_while_let_loop_expr (
- std::vector<AST::Attribute> outer_attrs, AST::LoopLabel label)
+Parser<ManagedTokenSource>::parse_while_let_loop_expr (AST::AttrVec outer_attrs,
+ AST::LoopLabel label)
{
Location locus = Linemap::unknown_location ();
if (label.is_error ())
@@ -8264,8 +8249,8 @@ Parser<ManagedTokenSource>::parse_while_let_loop_expr (
* parse_labelled_loop_expr, which would call this. */
template <typename ManagedTokenSource>
std::unique_ptr<AST::ForLoopExpr>
-Parser<ManagedTokenSource>::parse_for_loop_expr (
- std::vector<AST::Attribute> outer_attrs, AST::LoopLabel label)
+Parser<ManagedTokenSource>::parse_for_loop_expr (AST::AttrVec outer_attrs,
+ AST::LoopLabel label)
{
Location locus = Linemap::unknown_location ();
if (label.is_error ())
@@ -8329,8 +8314,7 @@ Parser<ManagedTokenSource>::parse_for_loop_expr (
// Parses a loop expression with label (any kind of loop - disambiguates).
template <typename ManagedTokenSource>
std::unique_ptr<AST::BaseLoopExpr>
-Parser<ManagedTokenSource>::parse_labelled_loop_expr (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_labelled_loop_expr (AST::AttrVec outer_attrs)
{
/* TODO: decide whether it should not work if there is no label, or parse it
* with no label at the moment, I will make it not work with no label because
@@ -8394,8 +8378,8 @@ Parser<ManagedTokenSource>::parse_labelled_loop_expr (
// Parses a match expression.
template <typename ManagedTokenSource>
std::unique_ptr<AST::MatchExpr>
-Parser<ManagedTokenSource>::parse_match_expr (
- std::vector<AST::Attribute> outer_attrs, bool pratt_parse)
+Parser<ManagedTokenSource>::parse_match_expr (AST::AttrVec outer_attrs,
+ bool pratt_parse)
{
Location locus = Linemap::unknown_location ();
if (!pratt_parse)
@@ -8435,7 +8419,7 @@ Parser<ManagedTokenSource>::parse_match_expr (
}
// parse inner attributes (if they exist)
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse match arms (if they exist)
// std::vector<std::unique_ptr<AST::MatchCase> > match_arms;
@@ -8526,7 +8510,7 @@ AST::MatchArm
Parser<ManagedTokenSource>::parse_match_arm ()
{
// parse optional outer attributes
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// DEBUG
fprintf (stderr, "about to start parsing match arm patterns\n");
@@ -8648,8 +8632,7 @@ Parser<ManagedTokenSource>::parse_match_arm_patterns (TokenId end_token_id)
// Parses an async block expression.
template <typename ManagedTokenSource>
std::unique_ptr<AST::AsyncBlockExpr>
-Parser<ManagedTokenSource>::parse_async_block_expr (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_async_block_expr (AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (ASYNC);
@@ -8683,8 +8666,7 @@ Parser<ManagedTokenSource>::parse_async_block_expr (
// Parses an unsafe block expression.
template <typename ManagedTokenSource>
std::unique_ptr<AST::UnsafeBlockExpr>
-Parser<ManagedTokenSource>::parse_unsafe_block_expr (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_unsafe_block_expr (AST::AttrVec outer_attrs)
{
Location locus = lexer.peek_token ()->get_locus ();
skip_token (UNSAFE);
@@ -8710,8 +8692,8 @@ Parser<ManagedTokenSource>::parse_unsafe_block_expr (
// Parses an array definition expression.
template <typename ManagedTokenSource>
std::unique_ptr<AST::ArrayExpr>
-Parser<ManagedTokenSource>::parse_array_expr (
- std::vector<AST::Attribute> outer_attrs, bool pratt_parse)
+Parser<ManagedTokenSource>::parse_array_expr (AST::AttrVec outer_attrs,
+ bool pratt_parse)
{
Location locus = Linemap::unknown_location ();
if (!pratt_parse)
@@ -8726,7 +8708,7 @@ Parser<ManagedTokenSource>::parse_array_expr (
}
// parse optional inner attributes
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse the "array elements" section, which is optional
if (lexer.peek_token ()->get_id () == RIGHT_SQUARE)
@@ -8863,7 +8845,7 @@ template <typename ManagedTokenSource>
AST::ClosureParam
Parser<ManagedTokenSource>::parse_closure_param ()
{
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// parse pattern (which is required)
std::unique_ptr<AST::Pattern> pattern = parse_pattern ();
@@ -8900,7 +8882,7 @@ Parser<ManagedTokenSource>::parse_closure_param ()
template <typename ManagedTokenSource>
std::unique_ptr<AST::ExprWithoutBlock>
Parser<ManagedTokenSource>::parse_grouped_or_tuple_expr (
- std::vector<AST::Attribute> outer_attrs, bool pratt_parse)
+ AST::AttrVec outer_attrs, bool pratt_parse)
{
// adjustment to allow Pratt parsing to reuse function without copy-paste
Location locus = Linemap::unknown_location ();
@@ -8916,7 +8898,7 @@ Parser<ManagedTokenSource>::parse_grouped_or_tuple_expr (
}
// parse optional inner attributes
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
if (lexer.peek_token ()->get_id () == RIGHT_PAREN)
{
@@ -9571,8 +9553,7 @@ Parser<ManagedTokenSource>::parse_for_prefixed_type ()
// Parses a maybe named param used in bare function types.
template <typename ManagedTokenSource>
AST::MaybeNamedParam
-Parser<ManagedTokenSource>::parse_maybe_named_param (
- std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_maybe_named_param (AST::AttrVec outer_attrs)
{
/* Basically guess that param is named if first token is identifier or
* underscore and second token is semicolon. This should probably have no
@@ -9635,12 +9616,12 @@ Parser<ManagedTokenSource>::parse_bare_function_type (
// parse function params, if they exist
std::vector<AST::MaybeNamedParam> params;
bool is_variadic = false;
- std::vector<AST::Attribute> variadic_attrs;
+ AST::AttrVec variadic_attrs;
const_TokenPtr t = lexer.peek_token ();
while (t->get_id () != RIGHT_PAREN)
{
- std::vector<AST::Attribute> temp_attrs = parse_outer_attributes ();
+ AST::AttrVec temp_attrs = parse_outer_attributes ();
if (lexer.peek_token ()->get_id () == ELLIPSIS)
{
@@ -10562,8 +10543,8 @@ Parser<ManagedTokenSource>::parse_pattern ()
Linemap::unknown_location (), has_ellipsis_syntax));
}
case EXCLAM:
- return parse_macro_invocation_partial (
- std::move (path), std::vector<AST::Attribute> ());
+ return parse_macro_invocation_partial (std::move (path),
+ AST::AttrVec ());
case LEFT_PAREN: {
// tuple struct
lexer.skip_token ();
@@ -11006,8 +10987,7 @@ Parser<ManagedTokenSource>::parse_ident_leading_pattern ()
switch (t->get_id ())
{
case EXCLAM:
- return parse_macro_invocation_partial (std::move (path),
- std::vector<AST::Attribute> ());
+ return parse_macro_invocation_partial (std::move (path), AST::AttrVec ());
case LEFT_PAREN: {
// tuple struct
lexer.skip_token ();
@@ -11273,14 +11253,14 @@ Parser<ManagedTokenSource>::parse_struct_pattern_elems ()
{
std::vector<std::unique_ptr<AST::StructPatternField>> fields;
- std::vector<AST::Attribute> etc_attrs;
+ AST::AttrVec etc_attrs;
bool has_etc = false;
// try parsing struct pattern fields
const_TokenPtr t = lexer.peek_token ();
while (t->get_id () != RIGHT_CURLY)
{
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// parse etc (must be last in struct pattern, so breaks)
if (lexer.peek_token ()->get_id () == DOT_DOT)
@@ -11326,7 +11306,7 @@ std::unique_ptr<AST::StructPatternField>
Parser<ManagedTokenSource>::parse_struct_pattern_field ()
{
// parse outer attributes (if they exist)
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
return parse_struct_pattern_field_partial (std::move (outer_attrs));
}
@@ -11336,7 +11316,7 @@ Parser<ManagedTokenSource>::parse_struct_pattern_field ()
template <typename ManagedTokenSource>
std::unique_ptr<AST::StructPatternField>
Parser<ManagedTokenSource>::parse_struct_pattern_field_partial (
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
// branch based on next token
const_TokenPtr t = lexer.peek_token ();
@@ -11455,7 +11435,7 @@ Parser<ManagedTokenSource>::parse_struct_pattern_field_partial (
template <typename ManagedTokenSource>
ExprOrStmt
Parser<ManagedTokenSource>::parse_stmt_or_expr_with_block (
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
auto expr = parse_expr_with_block (std::move (outer_attrs));
if (expr == nullptr)
@@ -11496,7 +11476,7 @@ Parser<ManagedTokenSource>::parse_stmt_or_expr_without_block ()
}
// parse outer attributes
- std::vector<AST::Attribute> outer_attrs = parse_outer_attributes ();
+ AST::AttrVec outer_attrs = parse_outer_attributes ();
// parsing this will be annoying because of the many different possibilities
/* best may be just to copy paste in parse_item switch, and failing that try
@@ -11724,7 +11704,7 @@ Parser<ManagedTokenSource>::parse_stmt_or_expr_without_block ()
template <typename ManagedTokenSource>
ExprOrStmt
Parser<ManagedTokenSource>::parse_path_based_stmt_or_expr (
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
// attempt to parse path
Location stmt_or_expr_loc = lexer.peek_token ()->get_locus ();
@@ -12049,7 +12029,7 @@ Parser<ManagedTokenSource>::parse_struct_expr_field ()
template <typename ManagedTokenSource>
ExprOrStmt
Parser<ManagedTokenSource>::parse_macro_invocation_maybe_semi (
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
Location macro_locus = lexer.peek_token ()->get_locus ();
AST::SimplePath macro_path = parse_simple_path ();
@@ -12328,7 +12308,7 @@ Parser<ManagedTokenSource>::skip_after_end_attribute ()
template <typename ManagedTokenSource>
std::unique_ptr<AST::Expr>
Parser<ManagedTokenSource>::parse_expr (int right_binding_power,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions)
{
const_TokenPtr current_token = lexer.peek_token ();
@@ -12352,8 +12332,8 @@ Parser<ManagedTokenSource>::parse_expr (int right_binding_power,
current_token = lexer.peek_token ();
lexer.skip_token ();
- expr = left_denotation (current_token, std::move (expr),
- std::vector<AST::Attribute> (), restrictions);
+ expr = left_denotation (current_token, std::move (expr), AST::AttrVec (),
+ restrictions);
if (expr == nullptr)
{
@@ -12371,7 +12351,7 @@ Parser<ManagedTokenSource>::parse_expr (int right_binding_power,
// Parse expression with lowest left binding power.
template <typename ManagedTokenSource>
std::unique_ptr<AST::Expr>
-Parser<ManagedTokenSource>::parse_expr (std::vector<AST::Attribute> outer_attrs,
+Parser<ManagedTokenSource>::parse_expr (AST::AttrVec outer_attrs,
ParseRestrictions restrictions)
{
return parse_expr (LBP_LOWEST, std::move (outer_attrs), restrictions);
@@ -12383,9 +12363,9 @@ Parser<ManagedTokenSource>::parse_expr (std::vector<AST::Attribute> outer_attrs,
* simplify stuff. */
template <typename ManagedTokenSource>
std::unique_ptr<AST::Expr>
-Parser<ManagedTokenSource>::null_denotation (
- const_TokenPtr tok, std::vector<AST::Attribute> outer_attrs,
- ParseRestrictions restrictions)
+Parser<ManagedTokenSource>::null_denotation (const_TokenPtr tok,
+ AST::AttrVec outer_attrs,
+ ParseRestrictions restrictions)
{
/* note: tok is previous character in input stream, not current one, as
* parse_expr skips it before passing it in */
@@ -12823,9 +12803,10 @@ Parser<ManagedTokenSource>::null_denotation (
* that implements the left denotation for the token given. */
template <typename ManagedTokenSource>
std::unique_ptr<AST::Expr>
-Parser<ManagedTokenSource>::left_denotation (
- const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs, ParseRestrictions restrictions)
+Parser<ManagedTokenSource>::left_denotation (const_TokenPtr tok,
+ std::unique_ptr<AST::Expr> left,
+ AST::AttrVec outer_attrs,
+ ParseRestrictions restrictions)
{
// Token passed in has already been skipped, so peek gives "next" token
switch (tok->get_id ())
@@ -13182,14 +13163,14 @@ get_lbp_for_arithmetic_or_logical_expr (
template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_arithmetic_or_logical_expr (
- const_TokenPtr, std::unique_ptr<AST::Expr> left, std::vector<AST::Attribute>,
+ const_TokenPtr, std::unique_ptr<AST::Expr> left, AST::AttrVec,
AST::ArithmeticOrLogicalExpr::ExprType expr_type,
ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
= parse_expr (get_lbp_for_arithmetic_or_logical_expr (expr_type),
- std::vector<AST::Attribute> (), restrictions);
+ AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13206,12 +13187,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_binary_plus_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_PLUS, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_PLUS, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13228,12 +13208,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_binary_minus_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_MINUS, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_MINUS, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13251,12 +13230,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_binary_mult_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_MUL, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_MUL, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13274,12 +13252,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_binary_div_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_DIV, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_DIV, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13297,12 +13274,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_binary_mod_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_MOD, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_MOD, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13321,12 +13297,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_bitwise_and_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_AMP, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_AMP, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13345,12 +13320,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_bitwise_or_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_PIPE, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_PIPE, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13369,12 +13343,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_bitwise_xor_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_CARET, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_CARET, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13392,12 +13365,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_left_shift_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_L_SHIFT, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_L_SHIFT, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13415,12 +13387,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
Parser<ManagedTokenSource>::parse_right_shift_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_R_SHIFT, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_R_SHIFT, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13466,13 +13437,13 @@ get_lbp_for_comparison_expr (AST::ComparisonExpr::ExprType expr_type)
template <typename ManagedTokenSource>
std::unique_ptr<AST::ComparisonExpr>
Parser<ManagedTokenSource>::parse_comparison_expr (
- const_TokenPtr, std::unique_ptr<AST::Expr> left, std::vector<AST::Attribute>,
+ const_TokenPtr, std::unique_ptr<AST::Expr> left, AST::AttrVec,
AST::ComparisonExpr::ExprType expr_type, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (get_lbp_for_comparison_expr (expr_type),
- std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (get_lbp_for_comparison_expr (expr_type), AST::AttrVec (),
+ restrictions);
if (right == nullptr)
return nullptr;
@@ -13489,12 +13460,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ComparisonExpr>
Parser<ManagedTokenSource>::parse_binary_equal_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_EQUAL, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_EQUAL, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13511,12 +13481,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ComparisonExpr>
Parser<ManagedTokenSource>::parse_binary_not_equal_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_NOT_EQUAL, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_NOT_EQUAL, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13533,13 +13502,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ComparisonExpr>
Parser<ManagedTokenSource>::parse_binary_greater_than_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_GREATER_THAN, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_GREATER_THAN, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13556,13 +13523,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ComparisonExpr>
Parser<ManagedTokenSource>::parse_binary_less_than_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_SMALLER_THAN, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_SMALLER_THAN, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13579,13 +13544,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ComparisonExpr>
Parser<ManagedTokenSource>::parse_binary_greater_equal_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_GREATER_EQUAL, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_GREATER_EQUAL, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13602,13 +13565,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ComparisonExpr>
Parser<ManagedTokenSource>::parse_binary_less_equal_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_SMALLER_EQUAL, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_SMALLER_EQUAL, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13625,12 +13586,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::LazyBooleanExpr>
Parser<ManagedTokenSource>::parse_lazy_or_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_LOGICAL_OR, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_LOGICAL_OR, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13647,13 +13607,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::LazyBooleanExpr>
Parser<ManagedTokenSource>::parse_lazy_and_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_LOGICAL_AND, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_LOGICAL_AND, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
@@ -13670,7 +13628,7 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::TypeCastExpr>
Parser<ManagedTokenSource>::parse_type_cast_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> expr_to_cast,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED,
ParseRestrictions restrictions ATTRIBUTE_UNUSED)
{
// parse RHS (as tok has already been consumed in parse_expression)
@@ -13691,12 +13649,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::AssignmentExpr>
Parser<ManagedTokenSource>::parse_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_ASSIG - 1, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13748,14 +13705,14 @@ get_lbp_for_compound_assignment_expr (
template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_compound_assignment_expr (
- const_TokenPtr, std::unique_ptr<AST::Expr> left, std::vector<AST::Attribute>,
+ const_TokenPtr, std::unique_ptr<AST::Expr> left, AST::AttrVec,
AST::CompoundAssignmentExpr::ExprType expr_type,
ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
= parse_expr (get_lbp_for_compound_assignment_expr (expr_type) - 1,
- std::vector<AST::Attribute> (), restrictions);
+ AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13773,13 +13730,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_plus_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_PLUS_ASSIG - 1, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_PLUS_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13797,13 +13752,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_minus_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_MINUS_ASSIG - 1, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_MINUS_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13822,13 +13775,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_mult_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_MULT_ASSIG - 1, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_MULT_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13847,13 +13798,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_div_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_DIV_ASSIG - 1, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_DIV_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13872,13 +13821,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_mod_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_MOD_ASSIG - 1, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_MOD_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13897,13 +13844,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_and_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_AMP_ASSIG - 1, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_AMP_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13922,13 +13867,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_or_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_PIPE_ASSIG - 1, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_PIPE_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13947,13 +13890,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_xor_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_CARET_ASSIG - 1, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_CARET_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13972,13 +13913,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_left_shift_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_L_SHIFT_ASSIG - 1, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_L_SHIFT_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -13997,13 +13936,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CompoundAssignmentExpr>
Parser<ManagedTokenSource>::parse_right_shift_assig_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_R_SHIFT_ASSIG - 1, std::vector<AST::Attribute> (),
- restrictions);
+ = parse_expr (LBP_R_SHIFT_ASSIG - 1, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: ensure right-associativity for this - 'LBP - 1' may do this?
@@ -14022,7 +13959,7 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::AwaitExpr>
Parser<ManagedTokenSource>::parse_await_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> expr_to_await,
- std::vector<AST::Attribute> outer_attrs)
+ AST::AttrVec outer_attrs)
{
/* skip "await" identifier (as "." has already been consumed in
* parse_expression) this assumes that the identifier was already identified
@@ -14051,13 +13988,12 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::RangeExpr>
Parser<ManagedTokenSource>::parse_led_range_exclusive_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// FIXME: this probably parses expressions accidently or whatever
// try parsing RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_DOT_DOT, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_DOT_DOT, AST::AttrVec (), restrictions);
Location locus = left->get_locus_slow ();
@@ -14080,12 +14016,11 @@ Parser<ManagedTokenSource>::parse_led_range_exclusive_expr (
template <typename ManagedTokenSource>
std::unique_ptr<AST::RangeExpr>
Parser<ManagedTokenSource>::parse_nud_range_exclusive_expr (
- const_TokenPtr tok, std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED)
+ const_TokenPtr tok, AST::AttrVec outer_attrs ATTRIBUTE_UNUSED)
{
// FIXME: this probably parses expressions accidently or whatever
// try parsing RHS (as tok has already been consumed in parse_expression)
- std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_DOT_DOT, std::vector<AST::Attribute> ());
+ std::unique_ptr<AST::Expr> right = parse_expr (LBP_DOT_DOT, AST::AttrVec ());
Location locus = tok->get_locus ();
@@ -14108,12 +14043,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::RangeFromToInclExpr>
Parser<ManagedTokenSource>::parse_range_inclusive_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED,
- ParseRestrictions restrictions)
+ AST::AttrVec outer_attrs ATTRIBUTE_UNUSED, ParseRestrictions restrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right
- = parse_expr (LBP_DOT_DOT_EQ, std::vector<AST::Attribute> (), restrictions);
+ = parse_expr (LBP_DOT_DOT_EQ, AST::AttrVec (), restrictions);
if (right == nullptr)
return nullptr;
// FIXME: make non-associative
@@ -14129,7 +14063,7 @@ Parser<ManagedTokenSource>::parse_range_inclusive_expr (
template <typename ManagedTokenSource>
std::unique_ptr<AST::RangeToInclExpr>
Parser<ManagedTokenSource>::parse_range_to_inclusive_expr (
- const_TokenPtr tok, std::vector<AST::Attribute> outer_attrs ATTRIBUTE_UNUSED)
+ const_TokenPtr tok, AST::AttrVec outer_attrs ATTRIBUTE_UNUSED)
{
// parse RHS (as tok has already been consumed in parse_expression)
std::unique_ptr<AST::Expr> right = parse_expr (LBP_DOT_DOT_EQ);
@@ -14148,8 +14082,7 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::TupleIndexExpr>
Parser<ManagedTokenSource>::parse_tuple_index_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> tuple_expr,
- std::vector<AST::Attribute> outer_attrs,
- ParseRestrictions restrictions ATTRIBUTE_UNUSED)
+ AST::AttrVec outer_attrs, ParseRestrictions restrictions ATTRIBUTE_UNUSED)
{
// parse int literal (as token already skipped)
const_TokenPtr index_tok = expect_token (INT_LITERAL);
@@ -14174,11 +14107,11 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::ArrayIndexExpr>
Parser<ManagedTokenSource>::parse_index_expr (
const_TokenPtr, std::unique_ptr<AST::Expr> array_expr,
- std::vector<AST::Attribute> outer_attrs, ParseRestrictions)
+ AST::AttrVec outer_attrs, ParseRestrictions)
{
// parse RHS (as tok has already been consumed in parse_expression)
/*std::unique_ptr<AST::Expr> index_expr
- = parse_expr (LBP_ARRAY_REF, std::vector<AST::Attribute> (),
+ = parse_expr (LBP_ARRAY_REF, AST::AttrVec (),
restrictions);*/
// TODO: conceptually, should treat [] as brackets, so just parse all expr
std::unique_ptr<AST::Expr> index_expr = parse_expr ();
@@ -14205,8 +14138,7 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::FieldAccessExpr>
Parser<ManagedTokenSource>::parse_field_access_expr (
const_TokenPtr tok ATTRIBUTE_UNUSED, std::unique_ptr<AST::Expr> struct_expr,
- std::vector<AST::Attribute> outer_attrs,
- ParseRestrictions restrictions ATTRIBUTE_UNUSED)
+ AST::AttrVec outer_attrs, ParseRestrictions restrictions ATTRIBUTE_UNUSED)
{
/* get field name identifier (assume that this is a field access expr and not
* await, for instance) */
@@ -14226,7 +14158,7 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::MethodCallExpr>
Parser<ManagedTokenSource>::parse_method_call_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> receiver_expr,
- std::vector<AST::Attribute> outer_attrs, ParseRestrictions)
+ AST::AttrVec outer_attrs, ParseRestrictions)
{
// parse path expr segment
AST::PathExprSegment segment = parse_path_expr_segment ();
@@ -14289,7 +14221,7 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::CallExpr>
Parser<ManagedTokenSource>::parse_function_call_expr (
const_TokenPtr, std::unique_ptr<AST::Expr> function_expr,
- std::vector<AST::Attribute> outer_attrs, ParseRestrictions)
+ AST::AttrVec outer_attrs, ParseRestrictions)
{
// parse function params (if they exist)
std::vector<std::unique_ptr<AST::Expr>> params;
@@ -14335,7 +14267,7 @@ Parser<ManagedTokenSource>::parse_function_call_expr (
template <typename ManagedTokenSource>
std::unique_ptr<AST::MacroInvocation>
Parser<ManagedTokenSource>::parse_macro_invocation_partial (
- AST::PathInExpression path, std::vector<AST::Attribute> outer_attrs)
+ AST::PathInExpression path, AST::AttrVec outer_attrs)
{
// macro invocation
if (!skip_token (EXCLAM))
@@ -14371,7 +14303,7 @@ Parser<ManagedTokenSource>::parse_macro_invocation_partial (
template <typename ManagedTokenSource>
std::unique_ptr<AST::StructExprStruct>
Parser<ManagedTokenSource>::parse_struct_expr_struct_partial (
- AST::PathInExpression path, std::vector<AST::Attribute> outer_attrs)
+ AST::PathInExpression path, AST::AttrVec outer_attrs)
{
// assume struct expr struct (as struct-enum disambiguation requires name
// lookup) again, make statement if final ';'
@@ -14381,7 +14313,7 @@ Parser<ManagedTokenSource>::parse_struct_expr_struct_partial (
}
// parse inner attributes
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
// branch based on next token
const_TokenPtr t = lexer.peek_token ();
@@ -14508,14 +14440,14 @@ Parser<ManagedTokenSource>::parse_struct_expr_struct_partial (
template <typename ManagedTokenSource>
std::unique_ptr<AST::CallExpr>
Parser<ManagedTokenSource>::parse_struct_expr_tuple_partial (
- AST::PathInExpression path, std::vector<AST::Attribute> outer_attrs)
+ AST::PathInExpression path, AST::AttrVec outer_attrs)
{
if (!skip_token (LEFT_PAREN))
{
return nullptr;
}
- std::vector<AST::Attribute> inner_attrs = parse_inner_attributes ();
+ AST::AttrVec inner_attrs = parse_inner_attributes ();
std::vector<std::unique_ptr<AST::Expr>> exprs;
@@ -14673,8 +14605,8 @@ Parser<ManagedTokenSource>::parse_path_in_expression_pratt (const_TokenPtr tok)
// Parses a closure expression with pratt parsing (from null denotation).
template <typename ManagedTokenSource>
std::unique_ptr<AST::ClosureExpr>
-Parser<ManagedTokenSource>::parse_closure_expr_pratt (
- const_TokenPtr tok, std::vector<AST::Attribute> outer_attrs)
+Parser<ManagedTokenSource>::parse_closure_expr_pratt (const_TokenPtr tok,
+ AST::AttrVec outer_attrs)
{
// TODO: does this need pratt parsing (for precedence)? probably not, but idk
Location locus = tok->get_locus ();
@@ -14806,8 +14738,7 @@ template <typename ManagedTokenSource>
std::unique_ptr<AST::TupleIndexExpr>
Parser<ManagedTokenSource>::parse_tuple_index_expr_float (
const_TokenPtr tok, std::unique_ptr<AST::Expr> tuple_expr,
- std::vector<AST::Attribute> outer_attrs,
- ParseRestrictions restrictions ATTRIBUTE_UNUSED)
+ AST::AttrVec outer_attrs, ParseRestrictions restrictions ATTRIBUTE_UNUSED)
{
// only works on float literals
if (tok->get_id () != FLOAT_LITERAL)
diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h
index 47f55ea..bde2613 100644
--- a/gcc/rust/parse/rust-parse.h
+++ b/gcc/rust/parse/rust-parse.h
@@ -101,9 +101,9 @@ private:
void parse_statement_seq (bool (Parser::*done) ());
// AST-related stuff - maybe move or something?
- std::vector<AST::Attribute> parse_inner_attributes ();
+ AST::AttrVec parse_inner_attributes ();
AST::Attribute parse_inner_attribute ();
- std::vector<AST::Attribute> parse_outer_attributes ();
+ AST::AttrVec parse_outer_attributes ();
AST::Attribute parse_outer_attribute ();
AST::Attribute parse_attribute_body ();
std::unique_ptr<AST::AttrInput> parse_attr_input ();
@@ -128,11 +128,11 @@ private:
AST::DelimTokenTree parse_delim_token_tree ();
std::unique_ptr<AST::TokenTree> parse_token_tree ();
std::unique_ptr<AST::MacroRulesDefinition>
- parse_macro_rules_def (std::vector<AST::Attribute> outer_attrs);
+ parse_macro_rules_def (AST::AttrVec outer_attrs);
std::unique_ptr<AST::MacroInvocationSemi>
- parse_macro_invocation_semi (std::vector<AST::Attribute> outer_attrs);
+ parse_macro_invocation_semi (AST::AttrVec outer_attrs);
std::unique_ptr<AST::MacroInvocation>
- parse_macro_invocation (std::vector<AST::Attribute> outer_attrs);
+ parse_macro_invocation (AST::AttrVec outer_attrs);
AST::MacroRule parse_macro_rule ();
AST::MacroMatcher parse_macro_matcher ();
std::unique_ptr<AST::MacroMatch> parse_macro_match ();
@@ -142,23 +142,20 @@ private:
// Top-level item-related
std::vector<std::unique_ptr<AST::Item> > parse_items ();
std::unique_ptr<AST::Item> parse_item (bool called_from_statement);
- std::unique_ptr<AST::VisItem>
- parse_vis_item (std::vector<AST::Attribute> outer_attrs);
- std::unique_ptr<AST::MacroItem>
- parse_macro_item (std::vector<AST::Attribute> outer_attrs);
+ std::unique_ptr<AST::VisItem> parse_vis_item (AST::AttrVec outer_attrs);
+ std::unique_ptr<AST::MacroItem> parse_macro_item (AST::AttrVec outer_attrs);
AST::Visibility parse_visibility ();
// VisItem subclass-related
- std::unique_ptr<AST::Module>
- parse_module (AST::Visibility vis, std::vector<AST::Attribute> outer_attrs);
+ std::unique_ptr<AST::Module> parse_module (AST::Visibility vis,
+ AST::AttrVec outer_attrs);
std::unique_ptr<AST::ExternCrate>
- parse_extern_crate (AST::Visibility vis,
- std::vector<AST::Attribute> outer_attrs);
+ parse_extern_crate (AST::Visibility vis, AST::AttrVec outer_attrs);
std::unique_ptr<AST::UseDeclaration>
- parse_use_decl (AST::Visibility vis, std::vector<AST::Attribute> outer_attrs);
+ parse_use_decl (AST::Visibility vis, AST::AttrVec outer_attrs);
std::unique_ptr<AST::UseTree> parse_use_tree ();
- std::unique_ptr<AST::Function>
- parse_function (AST::Visibility vis, std::vector<AST::Attribute> outer_attrs);
+ std::unique_ptr<AST::Function> parse_function (AST::Visibility vis,
+ AST::AttrVec outer_attrs);
AST::FunctionQualifiers parse_function_qualifiers ();
std::vector<std::unique_ptr<AST::GenericParam> >
parse_generic_params_in_angles ();
@@ -207,359 +204,328 @@ private:
template <typename EndTokenPred>
std::vector<AST::Lifetime> parse_lifetime_bounds (EndTokenPred is_end_token);
AST::Lifetime parse_lifetime ();
- std::unique_ptr<AST::TypeAlias>
- parse_type_alias (AST::Visibility vis,
- std::vector<AST::Attribute> outer_attrs);
- std::unique_ptr<AST::Struct>
- parse_struct (AST::Visibility vis, std::vector<AST::Attribute> outer_attrs);
+ std::unique_ptr<AST::TypeAlias> parse_type_alias (AST::Visibility vis,
+ AST::AttrVec outer_attrs);
+ std::unique_ptr<AST::Struct> parse_struct (AST::Visibility vis,
+ AST::AttrVec outer_attrs);
std::vector<AST::StructField> parse_struct_fields ();
template <typename EndTokenPred>
std::vector<AST::StructField> parse_struct_fields (EndTokenPred is_end_token);
AST::StructField parse_struct_field ();
std::vector<AST::TupleField> parse_tuple_fields ();
AST::TupleField parse_tuple_field ();
- std::unique_ptr<AST::Enum>
- parse_enum (AST::Visibility vis, std::vector<AST::Attribute> outer_attrs);
+ std::unique_ptr<AST::Enum> parse_enum (AST::Visibility vis,
+ AST::AttrVec outer_attrs);
std::vector<std::unique_ptr<AST::EnumItem> > parse_enum_items ();
template <typename EndTokenPred>
std::vector<std::unique_ptr<AST::EnumItem> >
parse_enum_items (EndTokenPred is_end_token);
std::unique_ptr<AST::EnumItem> parse_enum_item ();
- std::unique_ptr<AST::Union>
- parse_union (AST::Visibility vis, std::vector<AST::Attribute> outer_attrs);
+ std::unique_ptr<AST::Union> parse_union (AST::Visibility vis,
+ AST::AttrVec outer_attrs);
std::unique_ptr<AST::ConstantItem>
- parse_const_item (AST::Visibility vis,
- std::vector<AST::Attribute> outer_attrs);
- std::unique_ptr<AST::StaticItem>
- parse_static_item (AST::Visibility vis,
- std::vector<AST::Attribute> outer_attrs);
- std::unique_ptr<AST::Trait>
- parse_trait (AST::Visibility vis, std::vector<AST::Attribute> outer_attrs);
+ parse_const_item (AST::Visibility vis, AST::AttrVec outer_attrs);
+ std::unique_ptr<AST::StaticItem> parse_static_item (AST::Visibility vis,
+ AST::AttrVec outer_attrs);
+ std::unique_ptr<AST::Trait> parse_trait (AST::Visibility vis,
+ AST::AttrVec outer_attrs);
std::unique_ptr<AST::TraitItem> parse_trait_item ();
std::unique_ptr<AST::TraitItemType>
- parse_trait_type (std::vector<AST::Attribute> outer_attrs);
+ parse_trait_type (AST::AttrVec outer_attrs);
std::unique_ptr<AST::TraitItemConst>
- parse_trait_const (std::vector<AST::Attribute> outer_attrs);
+ parse_trait_const (AST::AttrVec outer_attrs);
AST::SelfParam parse_self_param ();
- std::unique_ptr<AST::Impl>
- parse_impl (AST::Visibility vis, std::vector<AST::Attribute> outer_attrs);
+ std::unique_ptr<AST::Impl> parse_impl (AST::Visibility vis,
+ AST::AttrVec outer_attrs);
std::unique_ptr<AST::InherentImplItem> parse_inherent_impl_item ();
std::unique_ptr<AST::InherentImplItem>
- parse_inherent_impl_function_or_method (
- AST::Visibility vis, std::vector<AST::Attribute> outer_attrs);
+ parse_inherent_impl_function_or_method (AST::Visibility vis,
+ AST::AttrVec outer_attrs);
std::unique_ptr<AST::TraitImplItem> parse_trait_impl_item ();
std::unique_ptr<AST::TraitImplItem>
parse_trait_impl_function_or_method (AST::Visibility vis,
- std::vector<AST::Attribute> outer_attrs);
+ AST::AttrVec outer_attrs);
std::unique_ptr<AST::ExternBlock>
- parse_extern_block (AST::Visibility vis,
- std::vector<AST::Attribute> outer_attrs);
+ parse_extern_block (AST::Visibility vis, AST::AttrVec outer_attrs);
std::unique_ptr<AST::ExternalItem> parse_external_item ();
- AST::NamedFunctionParam
- parse_named_function_param (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> ());
+ AST::NamedFunctionParam parse_named_function_param (AST::AttrVec outer_attrs
+ = AST::AttrVec ());
AST::Method parse_method ();
// Expression-related (Pratt parsed)
- std::unique_ptr<AST::Expr> parse_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
- ParseRestrictions restrictions
- = ParseRestrictions ());
- std::unique_ptr<AST::Expr> parse_expr (int right_binding_power,
- std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
- ParseRestrictions restrictions
- = ParseRestrictions ());
std::unique_ptr<AST::Expr>
- null_denotation (const_TokenPtr t,
- std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
+ parse_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
+ ParseRestrictions restrictions = ParseRestrictions ());
+ std::unique_ptr<AST::Expr>
+ parse_expr (int right_binding_power,
+ AST::AttrVec outer_attrs = AST::AttrVec (),
+ ParseRestrictions restrictions = ParseRestrictions ());
+ std::unique_ptr<AST::Expr>
+ null_denotation (const_TokenPtr t, AST::AttrVec outer_attrs = AST::AttrVec (),
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::Expr>
left_denotation (const_TokenPtr t, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
+ AST::AttrVec outer_attrs = AST::AttrVec (),
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_arithmetic_or_logical_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
- AST::ArithmeticOrLogicalExpr::ExprType expr_type,
+ AST::AttrVec outer_attrs, AST::ArithmeticOrLogicalExpr::ExprType expr_type,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_binary_plus_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_binary_minus_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_binary_mult_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_binary_div_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_binary_mod_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_bitwise_and_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_bitwise_or_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_bitwise_xor_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_left_shift_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ArithmeticOrLogicalExpr>
parse_right_shift_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
std::unique_ptr<AST::ComparisonExpr>
parse_comparison_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
AST::ComparisonExpr::ExprType expr_type,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ComparisonExpr>
parse_binary_equal_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
std::unique_ptr<AST::ComparisonExpr> parse_binary_not_equal_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ComparisonExpr> parse_binary_greater_than_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ComparisonExpr> parse_binary_less_than_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ComparisonExpr> parse_binary_greater_equal_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ComparisonExpr> parse_binary_less_equal_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::LazyBooleanExpr>
parse_lazy_or_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::LazyBooleanExpr>
parse_lazy_and_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::TypeCastExpr>
parse_type_cast_expr (const_TokenPtr tok,
std::unique_ptr<AST::Expr> expr_to_cast,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::AssignmentExpr>
parse_assig_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr> parse_compound_assignment_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
- AST::CompoundAssignmentExpr::ExprType expr_type,
+ AST::AttrVec outer_attrs, AST::CompoundAssignmentExpr::ExprType expr_type,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr>
parse_plus_assig_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr>
parse_minus_assig_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions
= ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr>
parse_mult_assig_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr>
parse_div_assig_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr>
parse_mod_assig_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr>
parse_and_assig_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr>
parse_or_assig_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr>
parse_xor_assig_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr> parse_left_shift_assig_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CompoundAssignmentExpr> parse_right_shift_assig_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::AwaitExpr>
parse_await_expr (const_TokenPtr tok,
std::unique_ptr<AST::Expr> expr_to_await,
- std::vector<AST::Attribute> outer_attrs);
+ AST::AttrVec outer_attrs);
std::unique_ptr<AST::MethodCallExpr> parse_method_call_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> receiver_expr,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::CallExpr> parse_function_call_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> function_expr,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::RangeExpr> parse_led_range_exclusive_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::RangeExpr>
- parse_nud_range_exclusive_expr (const_TokenPtr tok,
- std::vector<AST::Attribute> outer_attrs);
+ parse_nud_range_exclusive_expr (const_TokenPtr tok, AST::AttrVec outer_attrs);
std::unique_ptr<AST::RangeFromToInclExpr> parse_range_inclusive_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> left,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::RangeToInclExpr>
- parse_range_to_inclusive_expr (const_TokenPtr tok,
- std::vector<AST::Attribute> outer_attrs);
+ parse_range_to_inclusive_expr (const_TokenPtr tok, AST::AttrVec outer_attrs);
std::unique_ptr<AST::TupleIndexExpr> parse_tuple_index_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> tuple_expr,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::FieldAccessExpr> parse_field_access_expr (
const_TokenPtr tok, std::unique_ptr<AST::Expr> struct_expr,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::ArrayIndexExpr>
parse_index_expr (const_TokenPtr tok, std::unique_ptr<AST::Expr> array_expr,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
std::unique_ptr<AST::MacroInvocation>
parse_macro_invocation_partial (AST::PathInExpression path,
- std::vector<AST::Attribute> outer_attrs);
+ AST::AttrVec outer_attrs);
std::unique_ptr<AST::StructExprStruct>
parse_struct_expr_struct_partial (AST::PathInExpression path,
- std::vector<AST::Attribute> outer_attrs);
+ AST::AttrVec outer_attrs);
std::unique_ptr<AST::CallExpr>
parse_struct_expr_tuple_partial (AST::PathInExpression path,
- std::vector<AST::Attribute> outer_attrs);
+ AST::AttrVec outer_attrs);
AST::PathInExpression parse_path_in_expression_pratt (const_TokenPtr tok);
std::unique_ptr<AST::ClosureExpr>
parse_closure_expr_pratt (const_TokenPtr tok,
- std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> ());
+ AST::AttrVec outer_attrs = AST::AttrVec ());
std::unique_ptr<AST::TupleIndexExpr> parse_tuple_index_expr_float (
const_TokenPtr tok, std::unique_ptr<AST::Expr> tuple_expr,
- std::vector<AST::Attribute> outer_attrs,
+ AST::AttrVec outer_attrs,
ParseRestrictions restrictions = ParseRestrictions ());
// Expression-related (non-Pratt parsed)
std::unique_ptr<AST::ExprWithBlock>
- parse_expr_with_block (std::vector<AST::Attribute> outer_attrs);
+ parse_expr_with_block (AST::AttrVec outer_attrs);
std::unique_ptr<AST::ExprWithoutBlock>
- parse_expr_without_block (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> ());
- std::unique_ptr<AST::BlockExpr>
- parse_block_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
- bool pratt_parse = false);
- std::unique_ptr<AST::IfExpr>
- parse_if_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
- bool pratt_parse = false);
- std::unique_ptr<AST::IfLetExpr>
- parse_if_let_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
- bool pratt_parse = false);
- std::unique_ptr<AST::LoopExpr> parse_loop_expr (
- std::vector<AST::Attribute> outer_attrs = std::vector<AST::Attribute> (),
- AST::LoopLabel label = AST::LoopLabel::error (), bool pratt_parse = false);
- std::unique_ptr<AST::WhileLoopExpr> parse_while_loop_expr (
- std::vector<AST::Attribute> outer_attrs = std::vector<AST::Attribute> (),
- AST::LoopLabel label = AST::LoopLabel::error (), bool pratt_parse = false);
+ parse_expr_without_block (AST::AttrVec outer_attrs = AST::AttrVec ());
+ std::unique_ptr<AST::BlockExpr> parse_block_expr (AST::AttrVec outer_attrs
+ = AST::AttrVec (),
+ bool pratt_parse = false);
+ std::unique_ptr<AST::IfExpr> parse_if_expr (AST::AttrVec outer_attrs
+ = AST::AttrVec (),
+ bool pratt_parse = false);
+ std::unique_ptr<AST::IfLetExpr> parse_if_let_expr (AST::AttrVec outer_attrs
+ = AST::AttrVec (),
+ bool pratt_parse = false);
+ std::unique_ptr<AST::LoopExpr>
+ parse_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
+ AST::LoopLabel label = AST::LoopLabel::error (),
+ bool pratt_parse = false);
+ std::unique_ptr<AST::WhileLoopExpr>
+ parse_while_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
+ AST::LoopLabel label = AST::LoopLabel::error (),
+ bool pratt_parse = false);
std::unique_ptr<AST::WhileLetLoopExpr>
- parse_while_let_loop_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
+ parse_while_let_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
AST::LoopLabel label = AST::LoopLabel::error ());
std::unique_ptr<AST::ForLoopExpr>
- parse_for_loop_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
+ parse_for_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
AST::LoopLabel label = AST::LoopLabel::error ());
- std::unique_ptr<AST::MatchExpr>
- parse_match_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
- bool pratt_parse = false);
+ std::unique_ptr<AST::MatchExpr> parse_match_expr (AST::AttrVec outer_attrs
+ = AST::AttrVec (),
+ bool pratt_parse = false);
AST::MatchArm parse_match_arm ();
std::vector<std::unique_ptr<AST::Pattern> >
parse_match_arm_patterns (TokenId end_token_id);
std::unique_ptr<AST::BaseLoopExpr>
- parse_labelled_loop_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> ());
+ parse_labelled_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec ());
AST::LoopLabel parse_loop_label ();
std::unique_ptr<AST::AsyncBlockExpr>
- parse_async_block_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> ());
+ parse_async_block_expr (AST::AttrVec outer_attrs = AST::AttrVec ());
std::unique_ptr<AST::UnsafeBlockExpr>
- parse_unsafe_block_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> ());
- std::unique_ptr<AST::GroupedExpr>
- parse_grouped_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> ());
- std::unique_ptr<AST::ClosureExpr>
- parse_closure_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> ());
+ parse_unsafe_block_expr (AST::AttrVec outer_attrs = AST::AttrVec ());
+ std::unique_ptr<AST::GroupedExpr> parse_grouped_expr (AST::AttrVec outer_attrs
+ = AST::AttrVec ());
+ std::unique_ptr<AST::ClosureExpr> parse_closure_expr (AST::AttrVec outer_attrs
+ = AST::AttrVec ());
AST::ClosureParam parse_closure_param ();
- std::unique_ptr<AST::LiteralExpr>
- parse_literal_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> ());
- std::unique_ptr<AST::ReturnExpr>
- parse_return_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
- bool pratt_parse = false);
- std::unique_ptr<AST::BreakExpr>
- parse_break_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
- bool pratt_parse = false);
+ std::unique_ptr<AST::LiteralExpr> parse_literal_expr (AST::AttrVec outer_attrs
+ = AST::AttrVec ());
+ std::unique_ptr<AST::ReturnExpr> parse_return_expr (AST::AttrVec outer_attrs
+ = AST::AttrVec (),
+ bool pratt_parse = false);
+ std::unique_ptr<AST::BreakExpr> parse_break_expr (AST::AttrVec outer_attrs
+ = AST::AttrVec (),
+ bool pratt_parse = false);
std::unique_ptr<AST::ContinueExpr>
- parse_continue_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
+ parse_continue_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
bool pratt_parse = false);
- std::unique_ptr<AST::ArrayExpr>
- parse_array_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
- bool pratt_parse = false);
+ std::unique_ptr<AST::ArrayExpr> parse_array_expr (AST::AttrVec outer_attrs
+ = AST::AttrVec (),
+ bool pratt_parse = false);
std::unique_ptr<AST::ExprWithoutBlock>
- parse_grouped_or_tuple_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
+ parse_grouped_or_tuple_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
bool pratt_parse = false);
std::unique_ptr<AST::StructExprField> parse_struct_expr_field ();
bool will_be_expr_with_block ();
@@ -575,26 +541,20 @@ private:
std::unique_ptr<AST::Type> parse_paren_prefixed_type ();
std::unique_ptr<AST::TypeNoBounds> parse_paren_prefixed_type_no_bounds ();
std::unique_ptr<AST::Type> parse_for_prefixed_type ();
- AST::MaybeNamedParam
- parse_maybe_named_param (std::vector<AST::Attribute> outer_attrs);
+ AST::MaybeNamedParam parse_maybe_named_param (AST::AttrVec outer_attrs);
// Statement-related
std::unique_ptr<AST::Stmt> parse_stmt ();
- std::unique_ptr<AST::LetStmt>
- parse_let_stmt (std::vector<AST::Attribute> outer_attrs);
- std::unique_ptr<AST::ExprStmt>
- parse_expr_stmt (std::vector<AST::Attribute> outer_attrs);
+ std::unique_ptr<AST::LetStmt> parse_let_stmt (AST::AttrVec outer_attrs);
+ std::unique_ptr<AST::ExprStmt> parse_expr_stmt (AST::AttrVec outer_attrs);
std::unique_ptr<AST::ExprStmtWithBlock>
- parse_expr_stmt_with_block (std::vector<AST::Attribute> outer_attrs);
+ parse_expr_stmt_with_block (AST::AttrVec outer_attrs);
std::unique_ptr<AST::ExprStmtWithoutBlock>
- parse_expr_stmt_without_block (std::vector<AST::Attribute> outer_attrs);
+ parse_expr_stmt_without_block (AST::AttrVec outer_attrs);
ExprOrStmt parse_stmt_or_expr_without_block ();
- ExprOrStmt
- parse_stmt_or_expr_with_block (std::vector<AST::Attribute> outer_attrs);
- ExprOrStmt
- parse_macro_invocation_maybe_semi (std::vector<AST::Attribute> outer_attrs);
- ExprOrStmt
- parse_path_based_stmt_or_expr (std::vector<AST::Attribute> outer_attrs);
+ ExprOrStmt parse_stmt_or_expr_with_block (AST::AttrVec outer_attrs);
+ ExprOrStmt parse_macro_invocation_maybe_semi (AST::AttrVec outer_attrs);
+ ExprOrStmt parse_path_based_stmt_or_expr (AST::AttrVec outer_attrs);
// Pattern-related
std::unique_ptr<AST::Pattern> parse_pattern ();
@@ -609,7 +569,7 @@ private:
AST::StructPatternElements parse_struct_pattern_elems ();
std::unique_ptr<AST::StructPatternField> parse_struct_pattern_field ();
std::unique_ptr<AST::StructPatternField>
- parse_struct_pattern_field_partial (std::vector<AST::Attribute> outer_attrs);
+ parse_struct_pattern_field_partial (AST::AttrVec outer_attrs);
int left_binding_power (const_TokenPtr token);
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index eb52a50..6ed556a 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -657,7 +657,7 @@ Session::register_plugins (AST::Crate &crate ATTRIBUTE_UNUSED)
// TODO: move somewhere else
bool
-contains_name (const std::vector<AST::Attribute> &attrs, std::string name)
+contains_name (const AST::AttrVec &attrs, std::string name)
{
for (const auto &attr : attrs)
{
diff --git a/gcc/rust/typecheck/rust-hir-const-fold-base.h b/gcc/rust/typecheck/rust-hir-const-fold-base.h
index bcb59ef..108d372 100644
--- a/gcc/rust/typecheck/rust-hir-const-fold-base.h
+++ b/gcc/rust/typecheck/rust-hir-const-fold-base.h
@@ -36,8 +36,6 @@ public:
virtual ~ConstFoldBase () {}
virtual void visit (HIR::Token &) override {}
- virtual void visit (HIR::DelimTokenTree &) override {}
- virtual void visit (HIR::AttrInputMetaItemContainer &) override {}
virtual void visit (HIR::IdentifierExpr &) override {}
virtual void visit (HIR::Lifetime &) override {}
virtual void visit (HIR::LifetimeParam &) override {}
@@ -50,9 +48,6 @@ public:
virtual void visit (HIR::QualifiedPathInType &) override {}
virtual void visit (HIR::LiteralExpr &) override {}
- virtual void visit (HIR::AttrInputLiteral &) override {}
- virtual void visit (HIR::MetaItemLitExpr &) override {}
- virtual void visit (HIR::MetaItemPathLit &) override {}
virtual void visit (HIR::BorrowExpr &) override {}
virtual void visit (HIR::DereferenceExpr &) override {}
virtual void visit (HIR::ErrorPropagationExpr &) override {}
@@ -164,12 +159,6 @@ public:
virtual void visit (HIR::MacroMatcher &) override {}
virtual void visit (HIR::MacroRulesDefinition &) override {}
virtual void visit (HIR::MacroInvocation &) override {}
- virtual void visit (HIR::MetaItemPath &) override {}
- virtual void visit (HIR::MetaItemSeq &) override {}
- virtual void visit (HIR::MetaWord &) override {}
- virtual void visit (HIR::MetaNameValueStr &) override {}
- virtual void visit (HIR::MetaListPaths &) override {}
- virtual void visit (HIR::MetaListNameValueStr &) override {}
virtual void visit (HIR::LiteralPattern &) override {}
virtual void visit (HIR::IdentifierPattern &) override {}
diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.h b/gcc/rust/typecheck/rust-hir-type-check-base.h
index 6906878..a0ec0a0 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-base.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-base.h
@@ -35,8 +35,6 @@ public:
virtual ~TypeCheckBase () {}
virtual void visit (HIR::Token &) override {}
- virtual void visit (HIR::DelimTokenTree &) override {}
- virtual void visit (HIR::AttrInputMetaItemContainer &) override {}
virtual void visit (HIR::IdentifierExpr &) override {}
virtual void visit (HIR::Lifetime &) override {}
virtual void visit (HIR::LifetimeParam &) override {}
@@ -49,9 +47,6 @@ public:
virtual void visit (HIR::QualifiedPathInType &) override {}
virtual void visit (HIR::LiteralExpr &) override {}
- virtual void visit (HIR::AttrInputLiteral &) override {}
- virtual void visit (HIR::MetaItemLitExpr &) override {}
- virtual void visit (HIR::MetaItemPathLit &) override {}
virtual void visit (HIR::BorrowExpr &) override {}
virtual void visit (HIR::DereferenceExpr &) override {}
virtual void visit (HIR::ErrorPropagationExpr &) override {}
@@ -163,12 +158,6 @@ public:
virtual void visit (HIR::MacroMatcher &) override {}
virtual void visit (HIR::MacroRulesDefinition &) override {}
virtual void visit (HIR::MacroInvocation &) override {}
- virtual void visit (HIR::MetaItemPath &) override {}
- virtual void visit (HIR::MetaItemSeq &) override {}
- virtual void visit (HIR::MetaWord &) override {}
- virtual void visit (HIR::MetaNameValueStr &) override {}
- virtual void visit (HIR::MetaListPaths &) override {}
- virtual void visit (HIR::MetaListNameValueStr &) override {}
virtual void visit (HIR::LiteralPattern &) override {}
virtual void visit (HIR::IdentifierPattern &) override {}
diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc
index c950040..d21fb3d 100644
--- a/gcc/rust/typecheck/rust-hir-type-check.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check.cc
@@ -208,7 +208,7 @@ TypeCheckStructExpr::visit (HIR::StructExprStructFields &struct_expr)
HIR::StructExprField *implicit_field = nullptr;
- std::vector<HIR::Attribute> outer_attribs;
+ AST::AttrVec outer_attribs;
auto crate_num = mappings->get_current_crate ();
Analysis::NodeMapping mapping (
crate_num,