diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/src/ast/default-visitor.hxx | |
Diffstat (limited to 'tiger-compiler/src/ast/default-visitor.hxx')
| -rw-r--r-- | tiger-compiler/src/ast/default-visitor.hxx | 247 |
1 files changed, 247 insertions, 0 deletions
diff --git a/tiger-compiler/src/ast/default-visitor.hxx b/tiger-compiler/src/ast/default-visitor.hxx new file mode 100644 index 0000000..3d49e83 --- /dev/null +++ b/tiger-compiler/src/ast/default-visitor.hxx @@ -0,0 +1,247 @@ +/** + ** \file ast/default-visitor.hxx + ** \brief Implementation for ast/default-visitor.hh. + */ + +#pragma once + +#include <ast/all.hh> +#include <ast/default-visitor.hh> +#include <misc/algorithm.hh> + +namespace ast +{ + template <template <typename> class Const> + GenDefaultVisitor<Const>::GenDefaultVisitor() + : GenVisitor<Const>() + {} + + template <template <typename> class Const> + GenDefaultVisitor<Const>::~GenDefaultVisitor() + {} + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<Ast>& e) + { + super_type::operator()(e); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<SimpleVar>&) + {} + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<FieldVar>& e) + { + // FIXME DONE: Some code was deleted here. + e.var_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<SubscriptVar>& e) + { + e.var_get().accept(*this); + e.index_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<NilExp>&) + {} + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<IntExp>&) + {} + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<StringExp>&) + {} + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<CallExp>& e) + { + // FIXME DONE: Some code was deleted here. + for (auto arg : e.args_get()) + arg->accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<OpExp>& e) + { + e.left_get().accept(*this); + e.right_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<RecordExp>& e) + { + // FIXME DONE: Some code was deleted here. + e.type_name_get().accept(*this); + for (auto field : e.fields_get()) + field->accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<SeqExp>& e) + { + // FIXME DONE: Some code was deleted here. + for (auto exp : e.exps_get()) + exp->accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<AssignExp>& e) + { + // FIXME DONE: Some code was deleted here. + e.var_get().accept(*this); + e.exp_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<IfExp>& e) + { + // FIXME DONE: Some code was deleted here. + e.test_get().accept(*this); + e.thenclause_get().accept(*this); + e.elseclause_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<WhileExp>& e) + { + e.test_get().accept(*this); + e.body_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<ForExp>& e) + { + e.vardec_get().accept(*this); + e.hi_get().accept(*this); + e.body_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<BreakExp>&) + {} + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<LetExp>& e) + { + // FIXME DONE: Some code was deleted here. + e.chunks_get().accept(*this); + e.body_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<ArrayExp>& e) + { + // FIXME: Some code was deleted here. + e.type_name_get().accept(*this); + e.size_get().accept(*this); + e.init_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<CastExp>& e) + { + e.exp_get().accept(*this); + e.ty_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<FieldInit>& e) + { + e.init_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<ChunkList>& e) + { + // FIXME DONE: Some code was deleted here. + for (auto chunk : e.chunks_get()) + chunk->accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<ChunkInterface>& e) + { + e.accept(*this); + } + + template <template <typename> class Const> + template <typename ChunkType> + inline void GenDefaultVisitor<Const>::chunk_visit(const_t<ChunkType>& e) + { + for (const auto dec : e) + dec->accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<VarChunk>& e) + { + chunk_visit<VarChunk>(e); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<VarDec>& e) + { + // `type_name' might be omitted. + this->accept(e.type_name_get()); + // `init' can be null in case of formal parameter. + this->accept(e.init_get()); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<FunctionChunk>& e) + { + chunk_visit<FunctionChunk>(e); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<FunctionDec>& e) + { + // FIXME DONE: Some code was deleted here. + e.formals_get().accept(*this); + if (e.result_get() != nullptr) + e.result_get()->accept(*this); + if (e.body_get() != nullptr) + e.body_get()->accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<TypeChunk>& e) + { + chunk_visit<TypeChunk>(e); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<TypeDec>& e) + { + e.ty_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<NameTy>&) + {} + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<RecordTy>& e) + { + // FIXME DONE: Some code was deleted here. + for (auto field : e.fields_get()) + field->accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<ArrayTy>& e) + { + e.base_type_get().accept(*this); + } + + template <template <typename> class Const> + void GenDefaultVisitor<Const>::operator()(const_t<Field>& e) + { + e.type_name_get().accept(*this); + } + +} // namespace ast |
