summaryrefslogtreecommitdiff
path: root/tiger-compiler/src/ast/chunk-list.hh
diff options
context:
space:
mode:
Diffstat (limited to 'tiger-compiler/src/ast/chunk-list.hh')
-rw-r--r--tiger-compiler/src/ast/chunk-list.hh80
1 files changed, 80 insertions, 0 deletions
diff --git a/tiger-compiler/src/ast/chunk-list.hh b/tiger-compiler/src/ast/chunk-list.hh
new file mode 100644
index 0000000..3674e27
--- /dev/null
+++ b/tiger-compiler/src/ast/chunk-list.hh
@@ -0,0 +1,80 @@
+/**
+ ** \file ast/chunk-list.hh
+ ** \brief Declaration of ast::ChunkList.
+ */
+
+#pragma once
+
+#include <ast/ast.hh>
+
+namespace ast
+{
+ /// ChunkList.
+ class ChunkList : public Ast
+ {
+ public:
+ using list_type = std::list<ChunkInterface*>;
+ /// Define value type
+ using value_type = list_type::value_type;
+ /// Define size type
+ using size_type = list_type::size_type;
+ /// Define reference to value type
+ using reference = list_type::reference;
+ /// Define const reference to value type
+ using const_reference = list_type::const_reference;
+ /// Define shorthand type for D-declations iterator.
+ using iterator = list_type::iterator;
+ /// Define shorthand type for D-declations const iterator.
+ using const_iterator = list_type::const_iterator;
+
+ iterator begin();
+ iterator end();
+ const_iterator begin() const;
+ const_iterator end() const;
+
+ /// Prepend \a d.
+ void push_front(ChunkInterface* d);
+ /// Append \a d.
+ void emplace_back(ChunkInterface* d);
+
+ /// Splice the content of \a ds in front of this list.
+ void splice_front(ChunkList& ds);
+ /// Splice the content of \a ds at the back this list.
+ void splice_back(ChunkList& ds);
+
+ /// Construct a ChunkList node.
+ ChunkList(const Location& location);
+
+ public:
+ /** \name Ctor & dtor.
+ ** \{ */
+ /// Construct a ChunkList node.
+ ChunkList(const Location& location, const ChunkList::list_type& chunks);
+ ChunkList(const ChunkList&) = delete;
+ ChunkList& operator=(const ChunkList&) = delete;
+ /// Destroy a ChunkList node.
+ ~ChunkList() override;
+ /** \} */
+
+ /// \name Visitors entry point.
+ /// \{ */
+ /// Accept a const visitor \a v.
+ void accept(ConstVisitor& v) const override;
+ /// Accept a non-const visitor \a v.
+ void accept(Visitor& v) override;
+ /// \}
+
+ /** \name Accessors.
+ ** \{ */
+ /// Return declarations.
+ const ChunkList::list_type& chunks_get() const;
+ /// Return declarations.
+ ChunkList::list_type& chunks_get();
+ /** \} */
+
+ protected:
+ /// Declarations.
+ ChunkList::list_type chunks_;
+ };
+} // namespace ast
+#include <ast/chunk-list.hxx>