aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-macro.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/ast/rust-macro.h')
-rw-r--r--gcc/rust/ast/rust-macro.h129
1 files changed, 0 insertions, 129 deletions
diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h
index 1e95ebe..b5370d8 100644
--- a/gcc/rust/ast/rust-macro.h
+++ b/gcc/rust/ast/rust-macro.h
@@ -84,135 +84,6 @@ get_frag_spec_from_str (std::string str)
}
}
-class SingleASTNode
-{
-public:
- enum NodeType
- {
- EXPRESSION,
- ITEM,
- };
-
- SingleASTNode (std::unique_ptr<Expr> expr)
- : type (EXPRESSION), expr (std::move (expr)), item (nullptr)
- {}
-
- SingleASTNode (std::unique_ptr<Item> item)
- : type (ITEM), expr (nullptr), item (std::move (item))
- {}
-
- SingleASTNode (SingleASTNode const &other)
- {
- type = other.type;
- switch (type)
- {
- case EXPRESSION:
- expr = other.expr->clone_expr ();
- break;
-
- case ITEM:
- item = other.item->clone_item ();
- break;
- }
- }
-
- SingleASTNode operator= (SingleASTNode const &other)
- {
- type = other.type;
- switch (type)
- {
- case EXPRESSION:
- expr = other.expr->clone_expr ();
- break;
-
- case ITEM:
- item = other.item->clone_item ();
- break;
- }
- return *this;
- }
-
- SingleASTNode (SingleASTNode &&other) = default;
- SingleASTNode &operator= (SingleASTNode &&other) = default;
-
- std::unique_ptr<Expr> &get_expr ()
- {
- rust_assert (type == EXPRESSION);
- return expr;
- }
-
- std::unique_ptr<Item> &get_item ()
- {
- rust_assert (type == ITEM);
- return item;
- }
-
- void accept_vis (ASTVisitor &vis)
- {
- switch (type)
- {
- case EXPRESSION:
- expr->accept_vis (vis);
- break;
-
- case ITEM:
- item->accept_vis (vis);
- break;
- }
- }
-
-private:
- NodeType type;
- std::unique_ptr<Expr> expr;
- std::unique_ptr<Item> item;
- // TODO add meta attribute
-};
-
-/* Basically, a "fragment" that can be incorporated into the AST, created as
- * a result of macro expansion. Really annoying to work with due to the fact
- * that macros can really expand to anything. As such, horrible representation
- * at the moment. */
-class ASTFragment
-{
-private:
- /* basic idea: essentially, a vector of tagged unions of different AST node
- * types. Now, this could actually be stored without a tagged union if the
- * different AST node types had a unified parent, but that would create
- * issues with the diamond problem or significant performance penalties. So
- * a tagged union had to be used instead. A vector is used to represent the
- * ability for a macro to expand to two statements, for instance. */
-
- std::vector<SingleASTNode> nodes;
-
-public:
- ASTFragment (std::vector<SingleASTNode> nodes) : nodes (std::move (nodes)) {}
-
- ASTFragment (ASTFragment const &other)
- {
- nodes.clear ();
- nodes.reserve (other.nodes.size ());
- for (auto &n : other.nodes)
- {
- nodes.push_back (n);
- }
- }
-
- ASTFragment &operator= (ASTFragment const &other)
- {
- nodes.clear ();
- nodes.reserve (other.nodes.size ());
- for (auto &n : other.nodes)
- {
- nodes.push_back (n);
- }
- return *this;
- }
-
- static ASTFragment create_empty () { return ASTFragment ({}); }
-
- std::vector<SingleASTNode> &get_nodes () { return nodes; }
-};
-
// A macro match that has an identifier and fragment spec
class MacroMatchFragment : public MacroMatch
{