aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-03-28 10:33:25 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2022-03-31 09:42:08 +0200
commitcf94fd8d51fcbf5f857a26dc7ae09e29384abc95 (patch)
treef7ede3521208471ddfc6bde35844e2348226ea2f
parente8b9587d3a0615f497cfe9c66995c1f21e42a536 (diff)
downloadgcc-cf94fd8d51fcbf5f857a26dc7ae09e29384abc95.zip
gcc-cf94fd8d51fcbf5f857a26dc7ae09e29384abc95.tar.gz
gcc-cf94fd8d51fcbf5f857a26dc7ae09e29384abc95.tar.bz2
single_ast_node: Add TYPE kind
-rw-r--r--gcc/rust/ast/rust-ast.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index a22c2d1..5368c42 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -1515,6 +1515,7 @@ public:
TRAIT,
IMPL,
TRAIT_IMPL,
+ TYPE,
};
private:
@@ -1528,6 +1529,7 @@ private:
std::unique_ptr<TraitItem> trait_item;
std::unique_ptr<InherentImplItem> impl_item;
std::unique_ptr<TraitImplItem> trait_impl_item;
+ std::unique_ptr<Type> type;
public:
SingleASTNode (std::unique_ptr<Expr> expr)
@@ -1558,6 +1560,10 @@ public:
: kind (TRAIT_IMPL), trait_impl_item (std::move (trait_impl_item))
{}
+ SingleASTNode (std::unique_ptr<Type> type)
+ : kind (TYPE), type (std::move (type))
+ {}
+
SingleASTNode (SingleASTNode const &other)
{
kind = other.kind;
@@ -1590,6 +1596,10 @@ public:
case TRAIT_IMPL:
trait_impl_item = other.trait_impl_item->clone_trait_impl_item ();
break;
+
+ case TYPE:
+ type = other.type->clone_type ();
+ break;
}
}
@@ -1625,6 +1635,10 @@ public:
case TRAIT_IMPL:
trait_impl_item = other.trait_impl_item->clone_trait_impl_item ();
break;
+
+ case TYPE:
+ type = other.type->clone_type ();
+ break;
}
return *this;
}
@@ -1699,6 +1713,12 @@ public:
return std::move (trait_impl_item);
}
+ std::unique_ptr<Type> take_type ()
+ {
+ rust_assert (!is_error ());
+ return std::move (type);
+ }
+
void accept_vis (ASTVisitor &vis)
{
switch (kind)
@@ -1730,6 +1750,10 @@ public:
case TRAIT_IMPL:
trait_impl_item->accept_vis (vis);
break;
+
+ case TYPE:
+ type->accept_vis (vis);
+ break;
}
}
@@ -1751,6 +1775,8 @@ public:
return impl_item == nullptr;
case TRAIT_IMPL:
return trait_impl_item == nullptr;
+ case TYPE:
+ return type == nullptr;
}
gcc_unreachable ();
@@ -1775,6 +1801,8 @@ public:
return "Impl Item: " + impl_item->as_string ();
case TRAIT_IMPL:
return "Trait Impl Item: " + impl_item->as_string ();
+ case TYPE:
+ return "Type: " + type->as_string ();
}
gcc_unreachable ();