class TraversingVisitor: public NodeVisitor
{
protected:
- TraversingVisitor() { }
+ Block *current_block;
+
+ TraversingVisitor(): current_block(0) { }
public:
using NodeVisitor::visit;
virtual void visit(Return &);
};
-class BlockModifier: public TraversingVisitor
-{
-protected:
- bool remove_node;
- std::vector<RefPtr<Statement> > insert_nodes;
-
- BlockModifier();
-
- void flatten_block(Block &);
- void apply_and_increment(Block &, NodeList<Statement>::iterator &);
-
-public:
- using TraversingVisitor::visit;
- virtual void visit(Block &);
-};
-
template<typename T>
class NodeGatherer: private TraversingVisitor
{
std::vector<T *> nodes;
public:
- const std::vector<T *> &apply(Stage &s) { visit(s.content); return nodes; }
+ const std::vector<T *> &apply(Stage &s) { nodes.clear(); visit(s.content); return nodes; }
private:
using TraversingVisitor::visit;
{
private:
Stage *stage;
- std::set<Node *> to_remove;
+ const std::set<Node *> *to_remove;
+ std::vector<Block *> blocks;
+ bool anonymous;
+ bool recursive_remove;
public:
- NodeRemover(const std::set<Node *> &);
+ NodeRemover();
- void apply(Stage &);
+ void apply(Stage &, const std::set<Node *> &);
private:
+ void remove_variable(std::map<std::string, VariableDeclaration *> &, VariableDeclaration &);
+
using TraversingVisitor::visit;
virtual void visit(Block &);
+ virtual void visit(StructDeclaration &);
virtual void visit(VariableDeclaration &);
+ virtual void visit(InterfaceBlock &);
virtual void visit(Iteration &);
};