| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_AST_PRINTER_H_ | 5 #ifndef VM_AST_PRINTER_H_ |
| 6 #define VM_AST_PRINTER_H_ | 6 #define VM_AST_PRINTER_H_ |
| 7 | 7 |
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
| 9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // Forward declaration. | 13 // Forward declaration. |
| 14 class ParsedFunction; | 14 class ParsedFunction; |
| 15 | 15 |
| 16 class AstPrinter : public AstNodeVisitor { | 16 class AstPrinter : public AstNodeVisitor { |
| 17 public: | 17 public: |
| 18 static void PrintNode(AstNode* node); | 18 static void PrintNode(AstNode* node); |
| 19 static void PrintFunctionScope(const ParsedFunction& parsed_function); | 19 static void PrintFunctionScope(const ParsedFunction& parsed_function); |
| 20 static void PrintFunctionNodes(const ParsedFunction& parsed_function); | 20 static void PrintFunctionNodes(const ParsedFunction& parsed_function); |
| 21 static void PrintLocalScope(const LocalScope* scope, int variable_index); | 21 static void PrintLocalScope(const LocalScope* scope, int variable_index); |
| 22 | 22 |
| 23 | 23 |
| 24 #define DEFINE_VISITOR_FUNCTION(type, name) \ | 24 #define DECLARE_VISITOR_FUNCTION(BaseName) \ |
| 25 virtual void Visit##type(type* node); | 25 virtual void Visit##BaseName##Node(BaseName##Node* node); |
| 26 NODE_LIST(DEFINE_VISITOR_FUNCTION) | 26 |
| 27 #undef DEFINE_VISITOR_FUNCTION | 27 FOR_EACH_NODE(DECLARE_VISITOR_FUNCTION) |
| 28 #undef DECLARE_VISITOR_FUNCTION |
| 28 | 29 |
| 29 private: | 30 private: |
| 30 AstPrinter(); | 31 AstPrinter(); |
| 31 ~AstPrinter(); | 32 ~AstPrinter(); |
| 32 | 33 |
| 33 void VisitGenericAstNode(AstNode* node); | 34 void VisitGenericAstNode(AstNode* node); |
| 34 void VisitGenericLocalNode(AstNode* node, const LocalVariable& local); | 35 void VisitGenericLocalNode(AstNode* node, const LocalVariable& local); |
| 35 void VisitGenericFieldNode(AstNode* node, const Field& field); | 36 void VisitGenericFieldNode(AstNode* node, const Field& field); |
| 36 | 37 |
| 37 DISALLOW_COPY_AND_ASSIGN(AstPrinter); | 38 DISALLOW_COPY_AND_ASSIGN(AstPrinter); |
| 38 }; | 39 }; |
| 39 | 40 |
| 40 } // namespace dart | 41 } // namespace dart |
| 41 | 42 |
| 42 #endif // VM_AST_PRINTER_H_ | 43 #endif // VM_AST_PRINTER_H_ |
| OLD | NEW |