-private:
- struct Visitor: TraversingVisitor
- {
- typedef void ResultType;
-
- Stage *stage;
-
- Visitor();
-
- virtual void apply(Stage &);
- void get_result() const { }
- };
-
- struct BlockModifier: Visitor
- {
- bool remove_node;
- std::vector<RefPtr<Statement> > insert_nodes;
-
- BlockModifier();
-
- void flatten_block(Block &);
- void apply_and_increment(Block &, NodeList<Statement>::iterator &);
- using Visitor::visit;
- virtual void visit(Block &);
- };
-
- struct Formatter: Visitor
- {
- typedef std::string ResultType;
-
- std::string formatted;
- unsigned source_index;
- unsigned source_line;
- unsigned indent;
- bool parameter_list;
- std::string block_interface;
-
- Formatter();
-
- virtual void apply(Stage &);
- const std::string &get_result() const { return formatted; }
- using Visitor::visit;
- void append(const std::string &);
- void append(char);
- void set_source(unsigned, unsigned);
- virtual void visit(Block &);
- virtual void visit(Literal &);
- virtual void visit(ParenthesizedExpression &);
- virtual void visit(VariableReference &);
- virtual void visit(MemberAccess &);
- virtual void visit(UnaryExpression &);
- virtual void visit(BinaryExpression &);
- virtual void visit(Assignment &);
- virtual void visit(FunctionCall &);
- virtual void visit(ExpressionStatement &);
- virtual void visit(Import &);
- virtual void visit(Precision &);
- virtual void visit(Layout &);
- virtual void visit(InterfaceLayout &);
- virtual void visit(StructDeclaration &);
- virtual void visit(VariableDeclaration &);
- virtual void visit(InterfaceBlock &);
- virtual void visit(FunctionDeclaration &);
- virtual void visit(Conditional &);
- virtual void visit(Iteration &);
- virtual void visit(Return &);
- virtual void visit(Jump &);
- };
-
- template<typename T>
- struct NodeGatherer: Visitor
- {
- typedef std::vector<T *> ResultType;
-
- std::vector<T *> nodes;
-
- const ResultType &get_result() const { return nodes; }
- using Visitor::visit;
- virtual void visit(T &n) { nodes.push_back(&n); }
- };
-
- struct DeclarationCombiner: BlockModifier
- {
- bool toplevel;
- std::map<std::string, std::vector<FunctionDeclaration *> > functions;
- std::map<std::string, VariableDeclaration *> variables;
-
- DeclarationCombiner();
-
- using Visitor::visit;
- virtual void visit(Block &);
- virtual void visit(FunctionDeclaration &);
- virtual void visit(VariableDeclaration &);
- };
-
- struct VariableResolver: Visitor
- {
- std::vector<Block *> blocks;
- StructDeclaration *type;
- bool anonymous;
- std::string block_interface;
- bool record_target;
- VariableDeclaration *assignment_target;
- bool self_referencing;
-
- VariableResolver();
-
- virtual void apply(Stage &);
- using Visitor::visit;
- virtual void visit(Block &);
- virtual void visit(VariableReference &);
- virtual void visit(MemberAccess &);
- virtual void visit(BinaryExpression &);
- virtual void visit(Assignment &);
- virtual void visit(StructDeclaration &);
- virtual void visit(VariableDeclaration &);
- virtual void visit(InterfaceBlock &);
- };
-
- struct FunctionResolver: Visitor
- {
- std::map<std::string, std::vector<FunctionDeclaration *> > functions;
-
- using Visitor::visit;
- virtual void visit(FunctionCall &);
- virtual void visit(FunctionDeclaration &);
- };
-
- struct InterfaceGenerator: BlockModifier