namespace GL {
namespace SL {
+/** Base class for all node visitors. */
class NodeVisitor
{
protected:
virtual void visit(Jump &) { }
};
+/** An intermediate base visitor class which traverses the syntax tree. */
class TraversingVisitor: public NodeVisitor
{
protected:
virtual void visit(Return &);
};
+/** Gathers nodes of a particular type from the syntax tree. */
template<typename T>
class NodeGatherer: private TraversingVisitor
{
virtual void visit(T &n) { nodes.push_back(&n); }
};
+/** Removes a set of nodes from the syntax tree. */
class NodeRemover: private TraversingVisitor
{
private:
virtual void visit(StructDeclaration &);
virtual void visit(VariableDeclaration &);
virtual void visit(InterfaceBlock &);
+ virtual void visit(FunctionDeclaration &);
virtual void visit(Iteration &);
};
+/** Reorders a set of nodes so they appear before another node. Only nodes
+on the same hierarchly level as the target node are reordered. */
+class NodeReorderer: private TraversingVisitor
+{
+private:
+ Node *reorder_before;
+ const std::set<Node *> *to_reorder;
+
+public:
+ NodeReorderer();
+
+ void apply(Stage &, Node &, const std::set<Node *> &);
+
+private:
+ virtual void visit(Block &);
+};
+
} // namespace SL
} // namespace GL
} // namespace Msp