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

Side by Side Diff: src/jsregexp.cc

Issue 618643002: Replace OStream with std::ostream. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/ic/ic-state.cc ('k') | src/lithium-codegen.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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/compilation-cache.h" 9 #include "src/compilation-cache.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 4368 matching lines...) Expand 10 before | Expand all | Expand 10 after
4379 4379
4380 // ------------------------------------------------------------------- 4380 // -------------------------------------------------------------------
4381 // Dot/dotty output 4381 // Dot/dotty output
4382 4382
4383 4383
4384 #ifdef DEBUG 4384 #ifdef DEBUG
4385 4385
4386 4386
4387 class DotPrinter: public NodeVisitor { 4387 class DotPrinter: public NodeVisitor {
4388 public: 4388 public:
4389 DotPrinter(OStream& os, bool ignore_case) // NOLINT 4389 DotPrinter(std::ostream& os, bool ignore_case) // NOLINT
4390 : os_(os), 4390 : os_(os),
4391 ignore_case_(ignore_case) {} 4391 ignore_case_(ignore_case) {}
4392 void PrintNode(const char* label, RegExpNode* node); 4392 void PrintNode(const char* label, RegExpNode* node);
4393 void Visit(RegExpNode* node); 4393 void Visit(RegExpNode* node);
4394 void PrintAttributes(RegExpNode* from); 4394 void PrintAttributes(RegExpNode* from);
4395 void PrintOnFailure(RegExpNode* from, RegExpNode* to); 4395 void PrintOnFailure(RegExpNode* from, RegExpNode* to);
4396 #define DECLARE_VISIT(Type) \ 4396 #define DECLARE_VISIT(Type) \
4397 virtual void Visit##Type(Type##Node* that); 4397 virtual void Visit##Type(Type##Node* that);
4398 FOR_EACH_NODE_TYPE(DECLARE_VISIT) 4398 FOR_EACH_NODE_TYPE(DECLARE_VISIT)
4399 #undef DECLARE_VISIT 4399 #undef DECLARE_VISIT
4400 private: 4400 private:
4401 OStream& os_; 4401 std::ostream& os_;
4402 bool ignore_case_; 4402 bool ignore_case_;
4403 }; 4403 };
4404 4404
4405 4405
4406 void DotPrinter::PrintNode(const char* label, RegExpNode* node) { 4406 void DotPrinter::PrintNode(const char* label, RegExpNode* node) {
4407 os_ << "digraph G {\n graph [label=\""; 4407 os_ << "digraph G {\n graph [label=\"";
4408 for (int i = 0; label[i]; i++) { 4408 for (int i = 0; label[i]; i++) {
4409 switch (label[i]) { 4409 switch (label[i]) {
4410 case '\\': 4410 case '\\':
4411 os_ << "\\\\"; 4411 os_ << "\\\\";
4412 break; 4412 break;
4413 case '"': 4413 case '"':
4414 os_ << "\""; 4414 os_ << "\"";
4415 break; 4415 break;
4416 default: 4416 default:
4417 os_ << label[i]; 4417 os_ << label[i];
4418 break; 4418 break;
4419 } 4419 }
4420 } 4420 }
4421 os_ << "\"];\n"; 4421 os_ << "\"];\n";
4422 Visit(node); 4422 Visit(node);
4423 os_ << "}" << endl; 4423 os_ << "}" << std::endl;
4424 } 4424 }
4425 4425
4426 4426
4427 void DotPrinter::Visit(RegExpNode* node) { 4427 void DotPrinter::Visit(RegExpNode* node) {
4428 if (node->info()->visited) return; 4428 if (node->info()->visited) return;
4429 node->info()->visited = true; 4429 node->info()->visited = true;
4430 node->Accept(this); 4430 node->Accept(this);
4431 } 4431 }
4432 4432
4433 4433
4434 void DotPrinter::PrintOnFailure(RegExpNode* from, RegExpNode* on_failure) { 4434 void DotPrinter::PrintOnFailure(RegExpNode* from, RegExpNode* on_failure) {
4435 os_ << " n" << from << " -> n" << on_failure << " [style=dotted];\n"; 4435 os_ << " n" << from << " -> n" << on_failure << " [style=dotted];\n";
4436 Visit(on_failure); 4436 Visit(on_failure);
4437 } 4437 }
4438 4438
4439 4439
4440 class TableEntryBodyPrinter { 4440 class TableEntryBodyPrinter {
4441 public: 4441 public:
4442 TableEntryBodyPrinter(OStream& os, ChoiceNode* choice) // NOLINT 4442 TableEntryBodyPrinter(std::ostream& os, ChoiceNode* choice) // NOLINT
4443 : os_(os), 4443 : os_(os),
4444 choice_(choice) {} 4444 choice_(choice) {}
4445 void Call(uc16 from, DispatchTable::Entry entry) { 4445 void Call(uc16 from, DispatchTable::Entry entry) {
4446 OutSet* out_set = entry.out_set(); 4446 OutSet* out_set = entry.out_set();
4447 for (unsigned i = 0; i < OutSet::kFirstLimit; i++) { 4447 for (unsigned i = 0; i < OutSet::kFirstLimit; i++) {
4448 if (out_set->Get(i)) { 4448 if (out_set->Get(i)) {
4449 os_ << " n" << choice() << ":s" << from << "o" << i << " -> n" 4449 os_ << " n" << choice() << ":s" << from << "o" << i << " -> n"
4450 << choice()->alternatives()->at(i).node() << ";\n"; 4450 << choice()->alternatives()->at(i).node() << ";\n";
4451 } 4451 }
4452 } 4452 }
4453 } 4453 }
4454 private: 4454 private:
4455 ChoiceNode* choice() { return choice_; } 4455 ChoiceNode* choice() { return choice_; }
4456 OStream& os_; 4456 std::ostream& os_;
4457 ChoiceNode* choice_; 4457 ChoiceNode* choice_;
4458 }; 4458 };
4459 4459
4460 4460
4461 class TableEntryHeaderPrinter { 4461 class TableEntryHeaderPrinter {
4462 public: 4462 public:
4463 explicit TableEntryHeaderPrinter(OStream& os) // NOLINT 4463 explicit TableEntryHeaderPrinter(std::ostream& os) // NOLINT
4464 : first_(true), 4464 : first_(true),
4465 os_(os) {} 4465 os_(os) {}
4466 void Call(uc16 from, DispatchTable::Entry entry) { 4466 void Call(uc16 from, DispatchTable::Entry entry) {
4467 if (first_) { 4467 if (first_) {
4468 first_ = false; 4468 first_ = false;
4469 } else { 4469 } else {
4470 os_ << "|"; 4470 os_ << "|";
4471 } 4471 }
4472 os_ << "{\\" << AsUC16(from) << "-\\" << AsUC16(entry.to()) << "|{"; 4472 os_ << "{\\" << AsUC16(from) << "-\\" << AsUC16(entry.to()) << "|{";
4473 OutSet* out_set = entry.out_set(); 4473 OutSet* out_set = entry.out_set();
4474 int priority = 0; 4474 int priority = 0;
4475 for (unsigned i = 0; i < OutSet::kFirstLimit; i++) { 4475 for (unsigned i = 0; i < OutSet::kFirstLimit; i++) {
4476 if (out_set->Get(i)) { 4476 if (out_set->Get(i)) {
4477 if (priority > 0) os_ << "|"; 4477 if (priority > 0) os_ << "|";
4478 os_ << "<s" << from << "o" << i << "> " << priority; 4478 os_ << "<s" << from << "o" << i << "> " << priority;
4479 priority++; 4479 priority++;
4480 } 4480 }
4481 } 4481 }
4482 os_ << "}}"; 4482 os_ << "}}";
4483 } 4483 }
4484 4484
4485 private: 4485 private:
4486 bool first_; 4486 bool first_;
4487 OStream& os_; 4487 std::ostream& os_;
4488 }; 4488 };
4489 4489
4490 4490
4491 class AttributePrinter { 4491 class AttributePrinter {
4492 public: 4492 public:
4493 explicit AttributePrinter(OStream& os) // NOLINT 4493 explicit AttributePrinter(std::ostream& os) // NOLINT
4494 : os_(os), 4494 : os_(os),
4495 first_(true) {} 4495 first_(true) {}
4496 void PrintSeparator() { 4496 void PrintSeparator() {
4497 if (first_) { 4497 if (first_) {
4498 first_ = false; 4498 first_ = false;
4499 } else { 4499 } else {
4500 os_ << "|"; 4500 os_ << "|";
4501 } 4501 }
4502 } 4502 }
4503 void PrintBit(const char* name, bool value) { 4503 void PrintBit(const char* name, bool value) {
4504 if (!value) return; 4504 if (!value) return;
4505 PrintSeparator(); 4505 PrintSeparator();
4506 os_ << "{" << name << "}"; 4506 os_ << "{" << name << "}";
4507 } 4507 }
4508 void PrintPositive(const char* name, int value) { 4508 void PrintPositive(const char* name, int value) {
4509 if (value < 0) return; 4509 if (value < 0) return;
4510 PrintSeparator(); 4510 PrintSeparator();
4511 os_ << "{" << name << "|" << value << "}"; 4511 os_ << "{" << name << "|" << value << "}";
4512 } 4512 }
4513 4513
4514 private: 4514 private:
4515 OStream& os_; 4515 std::ostream& os_;
4516 bool first_; 4516 bool first_;
4517 }; 4517 };
4518 4518
4519 4519
4520 void DotPrinter::PrintAttributes(RegExpNode* that) { 4520 void DotPrinter::PrintAttributes(RegExpNode* that) {
4521 os_ << " a" << that << " [shape=Mrecord, color=grey, fontcolor=grey, " 4521 os_ << " a" << that << " [shape=Mrecord, color=grey, fontcolor=grey, "
4522 << "margin=0.1, fontsize=10, label=\"{"; 4522 << "margin=0.1, fontsize=10, label=\"{";
4523 AttributePrinter printer(os_); 4523 AttributePrinter printer(os_);
4524 NodeInfo* info = that->info(); 4524 NodeInfo* info = that->info();
4525 printer.PrintBit("NI", info->follows_newline_interest); 4525 printer.PrintBit("NI", info->follows_newline_interest);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
4674 os_ << "];\n"; 4674 os_ << "];\n";
4675 PrintAttributes(that); 4675 PrintAttributes(that);
4676 RegExpNode* successor = that->on_success(); 4676 RegExpNode* successor = that->on_success();
4677 os_ << " n" << that << " -> n" << successor << ";\n"; 4677 os_ << " n" << that << " -> n" << successor << ";\n";
4678 Visit(successor); 4678 Visit(successor);
4679 } 4679 }
4680 4680
4681 4681
4682 class DispatchTableDumper { 4682 class DispatchTableDumper {
4683 public: 4683 public:
4684 explicit DispatchTableDumper(OStream& os) : os_(os) {} 4684 explicit DispatchTableDumper(std::ostream& os) : os_(os) {}
4685 void Call(uc16 key, DispatchTable::Entry entry); 4685 void Call(uc16 key, DispatchTable::Entry entry);
4686 private: 4686 private:
4687 OStream& os_; 4687 std::ostream& os_;
4688 }; 4688 };
4689 4689
4690 4690
4691 void DispatchTableDumper::Call(uc16 key, DispatchTable::Entry entry) { 4691 void DispatchTableDumper::Call(uc16 key, DispatchTable::Entry entry) {
4692 os_ << "[" << AsUC16(key) << "-" << AsUC16(entry.to()) << "]: {"; 4692 os_ << "[" << AsUC16(key) << "-" << AsUC16(entry.to()) << "]: {";
4693 OutSet* set = entry.out_set(); 4693 OutSet* set = entry.out_set();
4694 bool first = true; 4694 bool first = true;
4695 for (unsigned i = 0; i < OutSet::kFirstLimit; i++) { 4695 for (unsigned i = 0; i < OutSet::kFirstLimit; i++) {
4696 if (set->Get(i)) { 4696 if (set->Get(i)) {
4697 if (first) { 4697 if (first) {
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
6159 } 6159 }
6160 6160
6161 return compiler.Assemble(&macro_assembler, 6161 return compiler.Assemble(&macro_assembler,
6162 node, 6162 node,
6163 data->capture_count, 6163 data->capture_count,
6164 pattern); 6164 pattern);
6165 } 6165 }
6166 6166
6167 6167
6168 }} // namespace v8::internal 6168 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic/ic-state.cc ('k') | src/lithium-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698