From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tiger-compiler/src/ast/chunk.hxx | 118 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 tiger-compiler/src/ast/chunk.hxx (limited to 'tiger-compiler/src/ast/chunk.hxx') diff --git a/tiger-compiler/src/ast/chunk.hxx b/tiger-compiler/src/ast/chunk.hxx new file mode 100644 index 0000000..a3c3ada --- /dev/null +++ b/tiger-compiler/src/ast/chunk.hxx @@ -0,0 +1,118 @@ +/** + ** \file ast/chunk.hxx + ** \brief Implementation of ast::Chunk. + */ + +#pragma once + +#include +#include +#include + +namespace ast +{ + template + Chunk::Chunk(const Location& location, Ds* decs) + : ChunkInterface(location) + , decs_(decs) + {} + + template + Chunk::Chunk(const Location& location) + : ChunkInterface(location) + {} + + template Chunk::~Chunk() + { + misc::deep_clear(*decs_); + delete decs_; + } + + template inline void Chunk::accept(Visitor& v) { v(*this); } + + template inline void Chunk::accept(ConstVisitor& v) const + { + v(*this); + } + + template + inline constexpr typename Chunk::reference + Chunk::operator[](size_type pos) + { + return decs_->operator[](pos); + } + + template + inline constexpr typename Chunk::const_reference + Chunk::operator[](size_type pos) const + { + return decs_->operator[](pos); + } + + template inline typename Chunk::Ds& Chunk::decs_get() + { + return *decs_; + } + + template + inline const typename Chunk::Ds& Chunk::decs_get() const + { + return *decs_; + } + + template inline typename Chunk::iterator Chunk::begin() + { + return decs_->begin(); + } + + template + inline typename Chunk::const_iterator Chunk::begin() const + { + return decs_->begin(); + } + + template inline typename Chunk::iterator Chunk::end() + { + return decs_->end(); + } + + template + inline typename Chunk::const_iterator Chunk::end() const + { + return decs_->end(); + } + + template inline constexpr bool Chunk::empty() const noexcept + { + return decs_->empty(); + } + + template + inline constexpr typename Chunk::iterator + Chunk::erase(const_iterator pos) + { + return decs_->erase(pos); + } + + template + inline constexpr typename Chunk::iterator + Chunk::erase(const_iterator first, const_iterator last) + { + return decs_->erase(first, last); + } + + template Chunk& Chunk::push_front(D& d) + { + location_set(location_get() + d.location_get()); + decs_->insert(decs_->begin(), &d); + return *this; + } + + template Chunk& Chunk::emplace_back(D& d) + { + location_set(location_get() + d.location_get()); + decs_->emplace_back(&d); + return *this; + } + +} // namespace ast -- cgit v1.2.3