Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: src/ast/prettyprinter.h

Issue 2265073002: Handle unicode correctly in CallPrinter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ast/prettyprinter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12
12 namespace v8 { 13 namespace v8 {
13 namespace internal { 14 namespace internal {
14 15
15 class CallPrinter final : public AstVisitor<CallPrinter> { 16 class CallPrinter final : public AstVisitor<CallPrinter> {
16 public: 17 public:
17 explicit CallPrinter(Isolate* isolate, bool is_builtin); 18 explicit CallPrinter(Isolate* isolate, bool is_builtin);
18 ~CallPrinter();
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. The result string is alive as long as the CallPrinter is alive. 21 // string.
22 const char* Print(FunctionLiteral* program, int position); 22 Handle<String> Print(FunctionLiteral* program, int position);
23
24 void PRINTF_FORMAT(2, 3) Print(const char* format, ...);
25
26 void Find(AstNode* node, bool print = false);
27 23
28 // Individual nodes 24 // Individual nodes
29 #define DECLARE_VISIT(type) void Visit##type(type* node); 25 #define DECLARE_VISIT(type) void Visit##type(type* node);
30 AST_NODE_LIST(DECLARE_VISIT) 26 AST_NODE_LIST(DECLARE_VISIT)
31 #undef DECLARE_VISIT 27 #undef DECLARE_VISIT
32 28
33 private: 29 private:
34 void Init(); 30 void Print(const char* str);
31 void Print(Handle<String> str);
32
33 void Find(AstNode* node, bool print = false);
34
35 Isolate* isolate_; 35 Isolate* isolate_;
36 char* output_; // output string buffer 36 int num_prints_;
37 int size_; // output_ size 37 IncrementalStringBuilder builder_;
38 int pos_; // current printing position
39 int position_; // position of ast node to print 38 int position_; // position of ast node to print
40 bool found_; 39 bool found_;
41 bool done_; 40 bool done_;
42 bool is_builtin_; 41 bool is_builtin_;
43 42
44 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); 43 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
45 44
46 protected: 45 protected:
47 void PrintLiteral(Object* value, bool quote); 46 void PrintLiteral(Handle<Object> value, bool quote);
48 void PrintLiteral(const AstRawString* value, bool quote); 47 void PrintLiteral(const AstRawString* value, bool quote);
49 void FindStatements(ZoneList<Statement*>* statements); 48 void FindStatements(ZoneList<Statement*>* statements);
50 void FindArguments(ZoneList<Expression*>* arguments); 49 void FindArguments(ZoneList<Expression*>* arguments);
51 }; 50 };
52 51
53 52
54 #ifdef DEBUG 53 #ifdef DEBUG
55 54
56 class AstPrinter final : public AstVisitor<AstPrinter> { 55 class AstPrinter final : public AstVisitor<AstPrinter> {
57 public: 56 public:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 int pos_; // current printing position 107 int pos_; // current printing position
109 int indent_; 108 int indent_;
110 }; 109 };
111 110
112 #endif // DEBUG 111 #endif // DEBUG
113 112
114 } // namespace internal 113 } // namespace internal
115 } // namespace v8 114 } // namespace v8
116 115
117 #endif // V8_AST_PRETTYPRINTER_H_ 116 #endif // V8_AST_PRETTYPRINTER_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698