| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "allocation.h" | 31 #include "allocation.h" |
| 32 #include "ast.h" | 32 #include "ast.h" |
| 33 | 33 |
| 34 namespace v8 { | 34 namespace v8 { |
| 35 namespace internal { | 35 namespace internal { |
| 36 | 36 |
| 37 #ifdef DEBUG | 37 #ifdef DEBUG |
| 38 | 38 |
| 39 class PrettyPrinter: public AstVisitor { | 39 class PrettyPrinter: public AstVisitor { |
| 40 public: | 40 public: |
| 41 PrettyPrinter(); | 41 explicit PrettyPrinter(Isolate* isolate); |
| 42 virtual ~PrettyPrinter(); | 42 virtual ~PrettyPrinter(); |
| 43 | 43 |
| 44 // The following routines print a node into a string. | 44 // The following routines print a node into a string. |
| 45 // The result string is alive as long as the PrettyPrinter is alive. | 45 // The result string is alive as long as the PrettyPrinter is alive. |
| 46 const char* Print(AstNode* node); | 46 const char* Print(AstNode* node); |
| 47 const char* PrintExpression(FunctionLiteral* program); | 47 const char* PrintExpression(FunctionLiteral* program); |
| 48 const char* PrintProgram(FunctionLiteral* program); | 48 const char* PrintProgram(FunctionLiteral* program); |
| 49 | 49 |
| 50 void Print(const char* format, ...); | 50 void Print(const char* format, ...); |
| 51 | 51 |
| 52 // Print a node to stdout. | 52 // Print a node to stdout. |
| 53 static void PrintOut(AstNode* node); | 53 static void PrintOut(Isolate* isolate, AstNode* node); |
| 54 | 54 |
| 55 // Individual nodes | 55 // Individual nodes |
| 56 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 56 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 57 AST_NODE_LIST(DECLARE_VISIT) | 57 AST_NODE_LIST(DECLARE_VISIT) |
| 58 #undef DECLARE_VISIT | 58 #undef DECLARE_VISIT |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 char* output_; // output string buffer | 61 char* output_; // output string buffer |
| 62 int size_; // output_ size | 62 int size_; // output_ size |
| 63 int pos_; // current printing position | 63 int pos_; // current printing position |
| (...skipping 11 matching lines...) Expand all Loading... |
| 75 void PrintFunctionLiteral(FunctionLiteral* function); | 75 void PrintFunctionLiteral(FunctionLiteral* function); |
| 76 void PrintCaseClause(CaseClause* clause); | 76 void PrintCaseClause(CaseClause* clause); |
| 77 | 77 |
| 78 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 78 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 | 81 |
| 82 // Prints the AST structure | 82 // Prints the AST structure |
| 83 class AstPrinter: public PrettyPrinter { | 83 class AstPrinter: public PrettyPrinter { |
| 84 public: | 84 public: |
| 85 AstPrinter(); | 85 explicit AstPrinter(Isolate* isolate); |
| 86 virtual ~AstPrinter(); | 86 virtual ~AstPrinter(); |
| 87 | 87 |
| 88 const char* PrintProgram(FunctionLiteral* program); | 88 const char* PrintProgram(FunctionLiteral* program); |
| 89 | 89 |
| 90 // Individual nodes | 90 // Individual nodes |
| 91 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 91 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 92 AST_NODE_LIST(DECLARE_VISIT) | 92 AST_NODE_LIST(DECLARE_VISIT) |
| 93 #undef DECLARE_VISIT | 93 #undef DECLARE_VISIT |
| 94 | 94 |
| 95 private: | 95 private: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 112 void dec_indent() { indent_--; } | 112 void dec_indent() { indent_--; } |
| 113 | 113 |
| 114 int indent_; | 114 int indent_; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 #endif // DEBUG | 117 #endif // DEBUG |
| 118 | 118 |
| 119 } } // namespace v8::internal | 119 } } // namespace v8::internal |
| 120 | 120 |
| 121 #endif // V8_PRETTYPRINTER_H_ | 121 #endif // V8_PRETTYPRINTER_H_ |
| OLD | NEW |