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 #include "src/prettyprinter.h" | 5 #include "src/prettyprinter.h" |
6 | 6 |
7 #include <stdarg.h> | 7 #include <stdarg.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" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 void CallPrinter::VisitLiteral(Literal* node) { | 241 void CallPrinter::VisitLiteral(Literal* node) { |
242 PrintLiteral(node->value(), true); | 242 PrintLiteral(node->value(), true); |
243 } | 243 } |
244 | 244 |
245 | 245 |
246 void CallPrinter::VisitRegExpLiteral(RegExpLiteral* node) { | 246 void CallPrinter::VisitRegExpLiteral(RegExpLiteral* node) { |
247 Print("/"); | 247 Print("/"); |
248 PrintLiteral(node->pattern(), false); | 248 PrintLiteral(node->pattern(), false); |
249 Print("/"); | 249 Print("/"); |
250 PrintLiteral(node->flags(), false); | 250 if (node->flags() & RegExp::kGlobal) Print("g"); |
| 251 if (node->flags() & RegExp::kIgnoreCase) Print("i"); |
| 252 if (node->flags() & RegExp::kMultiline) Print("m"); |
| 253 if (node->flags() & RegExp::kUnicode) Print("u"); |
| 254 if (node->flags() & RegExp::kSticky) Print("y"); |
251 } | 255 } |
252 | 256 |
253 | 257 |
254 void CallPrinter::VisitObjectLiteral(ObjectLiteral* node) { | 258 void CallPrinter::VisitObjectLiteral(ObjectLiteral* node) { |
255 for (int i = 0; i < node->properties()->length(); i++) { | 259 for (int i = 0; i < node->properties()->length(); i++) { |
256 Find(node->properties()->at(i)->value()); | 260 Find(node->properties()->at(i)->value()); |
257 } | 261 } |
258 } | 262 } |
259 | 263 |
260 | 264 |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 | 735 |
732 void PrettyPrinter::VisitLiteral(Literal* node) { | 736 void PrettyPrinter::VisitLiteral(Literal* node) { |
733 PrintLiteral(node->value(), true); | 737 PrintLiteral(node->value(), true); |
734 } | 738 } |
735 | 739 |
736 | 740 |
737 void PrettyPrinter::VisitRegExpLiteral(RegExpLiteral* node) { | 741 void PrettyPrinter::VisitRegExpLiteral(RegExpLiteral* node) { |
738 Print(" RegExp("); | 742 Print(" RegExp("); |
739 PrintLiteral(node->pattern(), false); | 743 PrintLiteral(node->pattern(), false); |
740 Print(","); | 744 Print(","); |
741 PrintLiteral(node->flags(), false); | 745 if (node->flags() & RegExp::kGlobal) Print("g"); |
| 746 if (node->flags() & RegExp::kIgnoreCase) Print("i"); |
| 747 if (node->flags() & RegExp::kMultiline) Print("m"); |
| 748 if (node->flags() & RegExp::kUnicode) Print("u"); |
| 749 if (node->flags() & RegExp::kSticky) Print("y"); |
742 Print(") "); | 750 Print(") "); |
743 } | 751 } |
744 | 752 |
745 | 753 |
746 void PrettyPrinter::VisitObjectLiteral(ObjectLiteral* node) { | 754 void PrettyPrinter::VisitObjectLiteral(ObjectLiteral* node) { |
747 Print("{ "); | 755 Print("{ "); |
748 for (int i = 0; i < node->properties()->length(); i++) { | 756 for (int i = 0; i < node->properties()->length(); i++) { |
749 if (i != 0) Print(","); | 757 if (i != 0) Print(","); |
750 PrintObjectLiteralProperty(node->properties()->at(i)); | 758 PrintObjectLiteralProperty(node->properties()->at(i)); |
751 } | 759 } |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 PrintLiteralIndented("LITERAL", node->value(), true); | 1471 PrintLiteralIndented("LITERAL", node->value(), true); |
1464 } | 1472 } |
1465 | 1473 |
1466 | 1474 |
1467 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) { | 1475 void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) { |
1468 IndentedScope indent(this, "REGEXP LITERAL", node->position()); | 1476 IndentedScope indent(this, "REGEXP LITERAL", node->position()); |
1469 EmbeddedVector<char, 128> buf; | 1477 EmbeddedVector<char, 128> buf; |
1470 SNPrintF(buf, "literal_index = %d\n", node->literal_index()); | 1478 SNPrintF(buf, "literal_index = %d\n", node->literal_index()); |
1471 PrintIndented(buf.start()); | 1479 PrintIndented(buf.start()); |
1472 PrintLiteralIndented("PATTERN", node->pattern(), false); | 1480 PrintLiteralIndented("PATTERN", node->pattern(), false); |
1473 PrintLiteralIndented("FLAGS", node->flags(), false); | 1481 int i = 0; |
| 1482 if (node->flags() & RegExp::kGlobal) buf[i++] = 'g'; |
| 1483 if (node->flags() & RegExp::kIgnoreCase) buf[i++] = 'i'; |
| 1484 if (node->flags() & RegExp::kMultiline) buf[i++] = 'm'; |
| 1485 if (node->flags() & RegExp::kUnicode) buf[i++] = 'u'; |
| 1486 if (node->flags() & RegExp::kSticky) buf[i++] = 'y'; |
| 1487 buf[i] = '\0'; |
| 1488 PrintIndented("FLAGS "); |
| 1489 Print(buf.start()); |
| 1490 Print("\n"); |
1474 } | 1491 } |
1475 | 1492 |
1476 | 1493 |
1477 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) { | 1494 void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) { |
1478 IndentedScope indent(this, "OBJ LITERAL", node->position()); | 1495 IndentedScope indent(this, "OBJ LITERAL", node->position()); |
1479 EmbeddedVector<char, 128> buf; | 1496 EmbeddedVector<char, 128> buf; |
1480 SNPrintF(buf, "literal_index = %d\n", node->literal_index()); | 1497 SNPrintF(buf, "literal_index = %d\n", node->literal_index()); |
1481 PrintIndented(buf.start()); | 1498 PrintIndented(buf.start()); |
1482 PrintProperties(node->properties()); | 1499 PrintProperties(node->properties()); |
1483 } | 1500 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 | 1655 |
1639 void AstPrinter::VisitSuperCallReference(SuperCallReference* node) { | 1656 void AstPrinter::VisitSuperCallReference(SuperCallReference* node) { |
1640 IndentedScope indent(this, "SUPER-CALL-REFERENCE", node->position()); | 1657 IndentedScope indent(this, "SUPER-CALL-REFERENCE", node->position()); |
1641 } | 1658 } |
1642 | 1659 |
1643 | 1660 |
1644 #endif // DEBUG | 1661 #endif // DEBUG |
1645 | 1662 |
1646 } // namespace internal | 1663 } // namespace internal |
1647 } // namespace v8 | 1664 } // namespace v8 |
OLD | NEW |