OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_AST_PRETTYPRINTER_H_ | 5 #ifndef V8_AST_PRETTYPRINTER_H_ |
6 #define V8_AST_PRETTYPRINTER_H_ | 6 #define V8_AST_PRETTYPRINTER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/base/compiler-specific.h" | 10 #include "src/base/compiler-specific.h" |
11 #include "src/string-builder.h" | 11 #include "src/string-builder.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 class CallPrinter final : public AstVisitor<CallPrinter> { | 16 class CallPrinter final : public AstVisitor<CallPrinter> { |
17 public: | 17 public: |
18 explicit CallPrinter(Isolate* isolate, bool is_builtin); | 18 explicit CallPrinter(Isolate* isolate, bool is_user_js); |
19 | 19 |
20 // The following routine prints the node with position |position| into a | 20 // The following routine prints the node with position |position| into a |
21 // string. | 21 // string. |
22 Handle<String> Print(FunctionLiteral* program, int position); | 22 Handle<String> Print(FunctionLiteral* program, int position); |
23 | 23 |
24 // Individual nodes | 24 // Individual nodes |
25 #define DECLARE_VISIT(type) void Visit##type(type* node); | 25 #define DECLARE_VISIT(type) void Visit##type(type* node); |
26 AST_NODE_LIST(DECLARE_VISIT) | 26 AST_NODE_LIST(DECLARE_VISIT) |
27 #undef DECLARE_VISIT | 27 #undef DECLARE_VISIT |
28 | 28 |
29 private: | 29 private: |
30 void Print(const char* str); | 30 void Print(const char* str); |
31 void Print(Handle<String> str); | 31 void Print(Handle<String> str); |
32 | 32 |
33 void Find(AstNode* node, bool print = false); | 33 void Find(AstNode* node, bool print = false); |
34 | 34 |
35 Isolate* isolate_; | 35 Isolate* isolate_; |
36 int num_prints_; | 36 int num_prints_; |
37 IncrementalStringBuilder builder_; | 37 IncrementalStringBuilder builder_; |
38 int position_; // position of ast node to print | 38 int position_; // position of ast node to print |
39 bool found_; | 39 bool found_; |
40 bool done_; | 40 bool done_; |
41 bool is_builtin_; | 41 bool is_user_js_; |
42 | 42 |
43 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 43 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
44 | 44 |
45 protected: | 45 protected: |
46 void PrintLiteral(Handle<Object> value, bool quote); | 46 void PrintLiteral(Handle<Object> value, bool quote); |
47 void PrintLiteral(const AstRawString* value, bool quote); | 47 void PrintLiteral(const AstRawString* value, bool quote); |
48 void FindStatements(ZoneList<Statement*>* statements); | 48 void FindStatements(ZoneList<Statement*>* statements); |
49 void FindArguments(ZoneList<Expression*>* arguments); | 49 void FindArguments(ZoneList<Expression*>* arguments); |
50 }; | 50 }; |
51 | 51 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 int pos_; // current printing position | 108 int pos_; // current printing position |
109 int indent_; | 109 int indent_; |
110 }; | 110 }; |
111 | 111 |
112 #endif // DEBUG | 112 #endif // DEBUG |
113 | 113 |
114 } // namespace internal | 114 } // namespace internal |
115 } // namespace v8 | 115 } // namespace v8 |
116 | 116 |
117 #endif // V8_AST_PRETTYPRINTER_H_ | 117 #endif // V8_AST_PRETTYPRINTER_H_ |
OLD | NEW |