Loading...
Searching...
No Matches
stelaVisitor.hpp
Go to the documentation of this file.
1
2#pragma once
3
5#include <map>
6
7namespace by {
8
9#define X(T) class T;
10#include "visitee.inl"
11#undef X
12 class valStela;
13
30 class _nout stelaVisitor: public typeProvidable, public clonable {
32
33 public:
35 ~stelaVisitor() override;
36
37 public:
38 void work(stela& root);
39
40#define X(T) \
41 virtual void visit(const stelaVisitInfo& i, T& it); \
42 virtual nbool onVisit(const stelaVisitInfo& i, T& it); \
43 virtual void onLeave(const stelaVisitInfo& i, T& it);
44#include "visitee.inl"
45#undef X
46
47 // valStela is abstract, so it is not a visitee: no node dispatches to it
48 // directly. It still needs an overload because it is the `super` a concrete
49 // value type chains up to -- without it verStela would skip straight to the
50 // stela& base and a writer would lose its output.
51 virtual nbool onVisit(const stelaVisitInfo& i, valStela& it);
52 virtual void onLeave(const stelaVisitInfo& i, valStela& it);
53
54 virtual void visit(const stelaVisitInfo& i, stela& it);
55 virtual nbool onVisit(const stelaVisitInfo& i, stela& it);
56 virtual void onLeave(const stelaVisitInfo& i, stela& it);
57
58 // traverse:
59 // generalized-way:
60 virtual void onTraverse(const stelaVisitInfo& i, stela& it);
61
62 private:
63 nbool _markVisited(stela& it);
64
65 private:
66 std::map<stela*, nbool> _visited;
67 };
68} // namespace by
Interface for objects that can be cloned.
Definition clonable.hpp:13
Definition stela.hpp:63
Traversal context handed to every stelaVisitor callback.
Definition stelaVisitInfo.hpp:17
Preorder visitor for the stela AST.
Definition stelaVisitor.hpp:30
Interface for objects that can provide their type information.
Definition typeProvidable.hpp:13
Scalar value — the abstract base of every leaf form.
Definition valStela.hpp:21
Rich logging support with polymorphic type conversion.
Definition richLog.hpp:34