File tree 2 files changed +27
-7
lines changed
2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -542,6 +542,13 @@ struct Attribute
542
542
class AttrInput
543
543
{
544
544
public:
545
+ enum AttrInputType
546
+ {
547
+ LITERAL,
548
+ META_ITEM,
549
+ TOKEN_TREE,
550
+ };
551
+
545
552
virtual ~AttrInput () {}
546
553
547
554
// Unique pointer custom clone function
@@ -564,6 +571,8 @@ class AttrInput
564
571
// Returns whether attr input has been parsed to meta item syntax.
565
572
virtual bool is_meta_item () const = 0;
566
573
574
+ virtual AttrInputType get_attr_input_type () const = 0;
575
+
567
576
protected:
568
577
// pure virtual clone implementation
569
578
virtual AttrInput *clone_attr_input_impl () const = 0;
@@ -650,6 +659,11 @@ class AttrInputMetaItemContainer : public AttrInput
650
659
651
660
bool check_cfg_predicate (const Session &session) const override ;
652
661
662
+ AttrInputType get_attr_input_type () const final override
663
+ {
664
+ return AttrInput::AttrInputType::META_ITEM;
665
+ }
666
+
653
667
// Clones this object.
654
668
std::unique_ptr<AttrInputMetaItemContainer>
655
669
clone_attr_input_meta_item_container () const
@@ -767,6 +781,11 @@ class DelimTokenTree : public TokenTree, public AttrInput
767
781
}
768
782
769
783
bool is_meta_item () const override { return false ; }
784
+
785
+ AttrInputType get_attr_input_type () const final override
786
+ {
787
+ return AttrInput::AttrInputType::TOKEN_TREE;
788
+ }
770
789
};
771
790
772
791
/* Forward decl - definition moved to rust-expr.h as it requires LiteralExpr to
Original file line number Diff line number Diff line change @@ -102,13 +102,7 @@ class LiteralExpr : public ExprWithoutBlock
102
102
// Literal expression attribute body (non-macro attribute)
103
103
class AttrInputLiteral : public AttrInput
104
104
{
105
- // Literal expression WITHOUT SUFFIX
106
- // std::unique_ptr<LiteralExpr> literal_expr;
107
- LiteralExpr
108
- literal_expr; // as not using polymorphic behaviour, doesn't require pointer
109
- // TODO: will require pointer if LiteralExpr is changed to have subclassing
110
-
111
- // TODO: should this store location data?
105
+ LiteralExpr literal_expr;
112
106
113
107
public:
114
108
AttrInputLiteral (LiteralExpr lit_expr) : literal_expr (std::move (lit_expr))
@@ -127,6 +121,13 @@ class AttrInputLiteral : public AttrInput
127
121
128
122
bool is_meta_item () const override { return false ; }
129
123
124
+ LiteralExpr &get_literal () { return literal_expr; }
125
+
126
+ AttrInputType get_attr_input_type () const final override
127
+ {
128
+ return AttrInput::AttrInputType::LITERAL;
129
+ }
130
+
130
131
protected:
131
132
/* Use covariance to implement clone function as returning this object rather
132
133
* than base */
You can’t perform that action at this time.
0 commit comments