diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-10-19 14:53:43 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-10-19 15:01:53 +0200 |
commit | 89490980726d298311107a452bdebeb43a2ff7e6 (patch) | |
tree | 29a06a0125db7dd6a057f5ff367d00e99cade8d4 /gcc/rust/ast/rust-ast-fragment.h | |
parent | 540d896c3fa745efdc96ad34e7e5c585f9b7b93f (diff) | |
download | gcc-89490980726d298311107a452bdebeb43a2ff7e6.zip gcc-89490980726d298311107a452bdebeb43a2ff7e6.tar.gz gcc-89490980726d298311107a452bdebeb43a2ff7e6.tar.bz2 |
ast: Improve Fragment API
Diffstat (limited to 'gcc/rust/ast/rust-ast-fragment.h')
-rw-r--r-- | gcc/rust/ast/rust-ast-fragment.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/gcc/rust/ast/rust-ast-fragment.h b/gcc/rust/ast/rust-ast-fragment.h index ee6ab0d..3ef4ba1 100644 --- a/gcc/rust/ast/rust-ast-fragment.h +++ b/gcc/rust/ast/rust-ast-fragment.h @@ -57,11 +57,23 @@ enum class FragmentKind class Fragment { public: - Fragment (std::vector<SingleASTNode> nodes, bool fragment_is_error = false); Fragment (Fragment const &other); + Fragment &operator= (Fragment const &other); + + /** + * Create an error fragment + */ static Fragment create_error (); - Fragment &operator= (Fragment const &other); + /** + * Create a complete AST fragment + */ + static Fragment complete (std::vector<AST::SingleASTNode> nodes); + + /** + * Create a fragment which contains unexpanded nodes + */ + static Fragment unexpanded (); FragmentKind get_kind () const; std::vector<SingleASTNode> &get_nodes (); @@ -78,6 +90,8 @@ public: void accept_vis (ASTVisitor &vis); private: + Fragment (FragmentKind kind, std::vector<SingleASTNode> nodes); + FragmentKind kind; /** |