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

Side by Side Diff: src/prettyprinter.cc

Issue 868883002: Remove the dependency of Zone on Isolate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation issues 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/prettyprinter.h ('k') | src/regexp-macro-assembler.h » ('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 #include <stdarg.h> 5 #include <stdarg.h>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/ast-value-factory.h" 9 #include "src/ast-value-factory.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
11 #include "src/prettyprinter.h" 11 #include "src/prettyprinter.h"
12 #include "src/scopes.h" 12 #include "src/scopes.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 16
17 CallPrinter::CallPrinter(Zone* zone) { 17 CallPrinter::CallPrinter(Isolate* isolate, Zone* zone) {
18 output_ = NULL; 18 output_ = NULL;
19 size_ = 0; 19 size_ = 0;
20 pos_ = 0; 20 pos_ = 0;
21 position_ = 0; 21 position_ = 0;
22 found_ = false; 22 found_ = false;
23 done_ = false; 23 done_ = false;
24 InitializeAstVisitor(zone); 24 InitializeAstVisitor(isolate, zone);
25 } 25 }
26 26
27 27
28 CallPrinter::~CallPrinter() { DeleteArray(output_); } 28 CallPrinter::~CallPrinter() { DeleteArray(output_); }
29 29
30 30
31 const char* CallPrinter::Print(FunctionLiteral* program, int position) { 31 const char* CallPrinter::Print(FunctionLiteral* program, int position) {
32 Init(); 32 Init();
33 position_ = position; 33 position_ = position;
34 Find(program); 34 Find(program);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 void CallPrinter::PrintLiteral(const AstRawString* value, bool quote) { 429 void CallPrinter::PrintLiteral(const AstRawString* value, bool quote) {
430 PrintLiteral(value->string(), quote); 430 PrintLiteral(value->string(), quote);
431 } 431 }
432 432
433 433
434 //----------------------------------------------------------------------------- 434 //-----------------------------------------------------------------------------
435 435
436 436
437 #ifdef DEBUG 437 #ifdef DEBUG
438 438
439 PrettyPrinter::PrettyPrinter(Zone* zone) { 439 PrettyPrinter::PrettyPrinter(Isolate* isolate, Zone* zone) {
440 output_ = NULL; 440 output_ = NULL;
441 size_ = 0; 441 size_ = 0;
442 pos_ = 0; 442 pos_ = 0;
443 InitializeAstVisitor(zone); 443 InitializeAstVisitor(isolate, zone);
444 } 444 }
445 445
446 446
447 PrettyPrinter::~PrettyPrinter() { 447 PrettyPrinter::~PrettyPrinter() {
448 DeleteArray(output_); 448 DeleteArray(output_);
449 } 449 }
450 450
451 451
452 void PrettyPrinter::VisitBlock(Block* node) { 452 void PrettyPrinter::VisitBlock(Block* node) {
453 if (!node->is_initializer_block()) Print("{ "); 453 if (!node->is_initializer_block()) Print("{ ");
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 910
911 911
912 const char* PrettyPrinter::PrintProgram(FunctionLiteral* program) { 912 const char* PrettyPrinter::PrintProgram(FunctionLiteral* program) {
913 Init(); 913 Init();
914 PrintStatements(program->body()); 914 PrintStatements(program->body());
915 Print("\n"); 915 Print("\n");
916 return output_; 916 return output_;
917 } 917 }
918 918
919 919
920 void PrettyPrinter::PrintOut(Zone* zone, AstNode* node) { 920 void PrettyPrinter::PrintOut(Isolate* isolate, Zone* zone, AstNode* node) {
921 PrettyPrinter printer(zone); 921 PrettyPrinter printer(isolate, zone);
922 PrintF("%s", printer.Print(node)); 922 PrintF("%s", printer.Print(node));
923 } 923 }
924 924
925 925
926 void PrettyPrinter::Init() { 926 void PrettyPrinter::Init() {
927 if (size_ == 0) { 927 if (size_ == 0) {
928 DCHECK(output_ == NULL); 928 DCHECK(output_ == NULL);
929 const int initial_size = 256; 929 const int initial_size = 256;
930 output_ = NewArray<char>(initial_size); 930 output_ = NewArray<char>(initial_size);
931 size_ = initial_size; 931 size_ = initial_size;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 } 1079 }
1080 1080
1081 private: 1081 private:
1082 AstPrinter* ast_printer_; 1082 AstPrinter* ast_printer_;
1083 }; 1083 };
1084 1084
1085 1085
1086 //----------------------------------------------------------------------------- 1086 //-----------------------------------------------------------------------------
1087 1087
1088 1088
1089 AstPrinter::AstPrinter(Zone* zone) : PrettyPrinter(zone), indent_(0) { 1089 AstPrinter::AstPrinter(Isolate* isolate, Zone* zone)
1090 } 1090 : PrettyPrinter(isolate, zone), indent_(0) {}
1091 1091
1092 1092
1093 AstPrinter::~AstPrinter() { 1093 AstPrinter::~AstPrinter() {
1094 DCHECK(indent_ == 0); 1094 DCHECK(indent_ == 0);
1095 } 1095 }
1096 1096
1097 1097
1098 void AstPrinter::PrintIndented(const char* txt) { 1098 void AstPrinter::PrintIndented(const char* txt) {
1099 for (int i = 0; i < indent_; i++) { 1099 for (int i = 0; i < indent_; i++) {
1100 Print(". "); 1100 Print(". ");
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 } 1598 }
1599 1599
1600 1600
1601 void AstPrinter::VisitSuperReference(SuperReference* node) { 1601 void AstPrinter::VisitSuperReference(SuperReference* node) {
1602 IndentedScope indent(this, "SUPER-REFERENCE"); 1602 IndentedScope indent(this, "SUPER-REFERENCE");
1603 } 1603 }
1604 1604
1605 #endif // DEBUG 1605 #endif // DEBUG
1606 1606
1607 } } // namespace v8::internal 1607 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/prettyprinter.h ('k') | src/regexp-macro-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698