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

Side by Side Diff: src/prettyprinter.h

Issue 861623002: Add a pretty printer to improve the error message non-function calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comment Created 5 years, 11 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 | « src/messages.h ('k') | src/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_PRETTYPRINTER_H_ 5 #ifndef V8_PRETTYPRINTER_H_
6 #define V8_PRETTYPRINTER_H_ 6 #define V8_PRETTYPRINTER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 class CallPrinter : public AstVisitor {
15 public:
16 explicit CallPrinter(Zone* zone);
17 virtual ~CallPrinter();
18
19 // The following routine prints the node with position |position| into a
20 // string. The result string is alive as long as the CallPrinter is alive.
21 const char* Print(FunctionLiteral* program, int position);
22
23 void Print(const char* format, ...);
24
25 void Find(AstNode* node, bool print = false);
26
27 // Individual nodes
28 #define DECLARE_VISIT(type) void Visit##type(type* node) OVERRIDE;
29 AST_NODE_LIST(DECLARE_VISIT)
30 #undef DECLARE_VISIT
31
32 private:
33 void Init();
34 char* output_; // output string buffer
35 int size_; // output_ size
36 int pos_; // current printing position
37 int position_; // position of ast node to print
38 bool found_;
39 bool done_;
40
41 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
42
43 protected:
44 void PrintLiteral(Handle<Object> value, bool quote);
45 void PrintLiteral(const AstRawString* value, bool quote);
46 void FindStatements(ZoneList<Statement*>* statements);
47 void FindArguments(ZoneList<Expression*>* arguments);
48 };
49
50
14 #ifdef DEBUG 51 #ifdef DEBUG
15 52
16 class PrettyPrinter: public AstVisitor { 53 class PrettyPrinter: public AstVisitor {
17 public: 54 public:
18 explicit PrettyPrinter(Zone* zone); 55 explicit PrettyPrinter(Zone* zone);
19 virtual ~PrettyPrinter(); 56 virtual ~PrettyPrinter();
20 57
21 // The following routines print a node into a string. 58 // The following routines print a node into a string.
22 // The result string is alive as long as the PrettyPrinter is alive. 59 // The result string is alive as long as the PrettyPrinter is alive.
23 const char* Print(AstNode* node); 60 const char* Print(AstNode* node);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void dec_indent() { indent_--; } 128 void dec_indent() { indent_--; }
92 129
93 int indent_; 130 int indent_;
94 }; 131 };
95 132
96 #endif // DEBUG 133 #endif // DEBUG
97 134
98 } } // namespace v8::internal 135 } } // namespace v8::internal
99 136
100 #endif // V8_PRETTYPRINTER_H_ 137 #endif // V8_PRETTYPRINTER_H_
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698