| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 | 1489 |
| 1490 #ifdef DEBUG | 1490 #ifdef DEBUG |
| 1491 | 1491 |
| 1492 | 1492 |
| 1493 class DotPrinter: public NodeVisitor { | 1493 class DotPrinter: public NodeVisitor { |
| 1494 public: | 1494 public: |
| 1495 DotPrinter() : stream_(&alloc_) { } | 1495 DotPrinter() : stream_(&alloc_) { } |
| 1496 void PrintNode(const char* label, RegExpNode* node); | 1496 void PrintNode(const char* label, RegExpNode* node); |
| 1497 void Visit(RegExpNode* node); | 1497 void Visit(RegExpNode* node); |
| 1498 void PrintOnFailure(RegExpNode* from, RegExpNode* on_failure); | 1498 void PrintOnFailure(RegExpNode* from, RegExpNode* on_failure); |
| 1499 void PrintAttributes(RegExpNode* from); |
| 1499 StringStream* stream() { return &stream_; } | 1500 StringStream* stream() { return &stream_; } |
| 1500 #define DECLARE_VISIT(Type) \ | 1501 #define DECLARE_VISIT(Type) \ |
| 1501 virtual void Visit##Type(Type##Node* that); | 1502 virtual void Visit##Type(Type##Node* that); |
| 1502 FOR_EACH_NODE_TYPE(DECLARE_VISIT) | 1503 FOR_EACH_NODE_TYPE(DECLARE_VISIT) |
| 1503 #undef DECLARE_VISIT | 1504 #undef DECLARE_VISIT |
| 1504 private: | 1505 private: |
| 1505 HeapStringAllocator alloc_; | 1506 HeapStringAllocator alloc_; |
| 1506 StringStream stream_; | 1507 StringStream stream_; |
| 1507 std::set<RegExpNode*> seen_; | 1508 std::set<RegExpNode*> seen_; |
| 1508 }; | 1509 }; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 } | 1592 } |
| 1592 stream()->Add("}}"); | 1593 stream()->Add("}}"); |
| 1593 } | 1594 } |
| 1594 private: | 1595 private: |
| 1595 bool first_; | 1596 bool first_; |
| 1596 StringStream* stream() { return stream_; } | 1597 StringStream* stream() { return stream_; } |
| 1597 StringStream* stream_; | 1598 StringStream* stream_; |
| 1598 }; | 1599 }; |
| 1599 | 1600 |
| 1600 | 1601 |
| 1602 void DotPrinter::PrintAttributes(RegExpNode* that) { |
| 1603 stream()->Add(" a%p [shape=Mrecord, style=dashed, color=lightgrey, " |
| 1604 "fontcolor=lightgrey, margin=0.1, fontsize=10, label=\"{", |
| 1605 that); |
| 1606 NodeInfo* info = that->info(); |
| 1607 stream()->Add("{NI|%i}|{SI|%i}|{WI|%i}", |
| 1608 info->follows_newline_interest, |
| 1609 info->follows_start_interest, |
| 1610 info->follows_word_interest); |
| 1611 stream()->Add("|{DN|%i}|{DS|%i}|{DW|%i}", |
| 1612 info->determine_newline, |
| 1613 info->determine_start, |
| 1614 info->determine_word); |
| 1615 Label* label = that->label(); |
| 1616 if (label->is_bound()) |
| 1617 stream()->Add("|{@|%i}", label->pos()); |
| 1618 stream()->Add("}\"];\n"); |
| 1619 stream()->Add(" a%p -> n%p [style=dashed, color=lightgrey, " |
| 1620 "arrowhead=none];\n", that, that); |
| 1621 } |
| 1622 |
| 1623 |
| 1601 void DotPrinter::VisitChoice(ChoiceNode* that) { | 1624 void DotPrinter::VisitChoice(ChoiceNode* that) { |
| 1602 stream()->Add(" n%p [shape=Mrecord, label=\"", that); | 1625 stream()->Add(" n%p [shape=Mrecord, label=\"", that); |
| 1603 TableEntryHeaderPrinter header_printer(stream()); | 1626 TableEntryHeaderPrinter header_printer(stream()); |
| 1604 that->table()->ForEach(&header_printer); | 1627 that->table()->ForEach(&header_printer); |
| 1605 stream()->Add("\"]\n", that); | 1628 stream()->Add("\"]\n", that); |
| 1629 PrintAttributes(that); |
| 1606 TableEntryBodyPrinter body_printer(stream(), that); | 1630 TableEntryBodyPrinter body_printer(stream(), that); |
| 1607 that->table()->ForEach(&body_printer); | 1631 that->table()->ForEach(&body_printer); |
| 1608 PrintOnFailure(that, that->on_failure()); | 1632 PrintOnFailure(that, that->on_failure()); |
| 1609 for (int i = 0; i < that->alternatives()->length(); i++) { | 1633 for (int i = 0; i < that->alternatives()->length(); i++) { |
| 1610 GuardedAlternative alt = that->alternatives()->at(i); | 1634 GuardedAlternative alt = that->alternatives()->at(i); |
| 1611 alt.node()->Accept(this); | 1635 alt.node()->Accept(this); |
| 1612 } | 1636 } |
| 1613 } | 1637 } |
| 1614 | 1638 |
| 1615 | 1639 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1633 stream()->Add("%k-%k", range.from(), range.to()); | 1657 stream()->Add("%k-%k", range.from(), range.to()); |
| 1634 } | 1658 } |
| 1635 stream()->Add("]"); | 1659 stream()->Add("]"); |
| 1636 break; | 1660 break; |
| 1637 } | 1661 } |
| 1638 default: | 1662 default: |
| 1639 UNREACHABLE(); | 1663 UNREACHABLE(); |
| 1640 } | 1664 } |
| 1641 } | 1665 } |
| 1642 stream()->Add("\", shape=box, peripheries=2];\n"); | 1666 stream()->Add("\", shape=box, peripheries=2];\n"); |
| 1667 PrintAttributes(that); |
| 1643 stream()->Add(" n%p -> n%p;\n", that, that->on_success()); | 1668 stream()->Add(" n%p -> n%p;\n", that, that->on_success()); |
| 1644 Visit(that->on_success()); | 1669 Visit(that->on_success()); |
| 1645 PrintOnFailure(that, that->on_failure()); | 1670 PrintOnFailure(that, that->on_failure()); |
| 1646 } | 1671 } |
| 1647 | 1672 |
| 1648 | 1673 |
| 1649 void DotPrinter::VisitBackReference(BackReferenceNode* that) { | 1674 void DotPrinter::VisitBackReference(BackReferenceNode* that) { |
| 1650 stream()->Add(" n%p [label=\"$%i..$%i\", shape=doubleoctagon];\n", | 1675 stream()->Add(" n%p [label=\"$%i..$%i\", shape=doubleoctagon];\n", |
| 1651 that, | 1676 that, |
| 1652 that->start_register(), | 1677 that->start_register(), |
| 1653 that->end_register()); | 1678 that->end_register()); |
| 1679 PrintAttributes(that); |
| 1654 stream()->Add(" n%p -> n%p;\n", that, that->on_success()); | 1680 stream()->Add(" n%p -> n%p;\n", that, that->on_success()); |
| 1655 Visit(that->on_success()); | 1681 Visit(that->on_success()); |
| 1656 PrintOnFailure(that, that->on_failure()); | 1682 PrintOnFailure(that, that->on_failure()); |
| 1657 } | 1683 } |
| 1658 | 1684 |
| 1659 | 1685 |
| 1660 void DotPrinter::VisitEnd(EndNode* that) { | 1686 void DotPrinter::VisitEnd(EndNode* that) { |
| 1661 stream()->Add(" n%p [style=bold, shape=point];\n", that); | 1687 stream()->Add(" n%p [style=bold, shape=point];\n", that); |
| 1688 PrintAttributes(that); |
| 1662 } | 1689 } |
| 1663 | 1690 |
| 1664 | 1691 |
| 1665 void DotPrinter::VisitAction(ActionNode* that) { | 1692 void DotPrinter::VisitAction(ActionNode* that) { |
| 1666 stream()->Add(" n%p [", that); | 1693 stream()->Add(" n%p [", that); |
| 1667 switch (that->type_) { | 1694 switch (that->type_) { |
| 1668 case ActionNode::STORE_REGISTER: | 1695 case ActionNode::STORE_REGISTER: |
| 1669 stream()->Add("label=\"$%i:=%i\", shape=octagon", | 1696 stream()->Add("label=\"$%i:=%i\", shape=octagon", |
| 1670 that->data_.u_store_register.reg, | 1697 that->data_.u_store_register.reg, |
| 1671 that->data_.u_store_register.value); | 1698 that->data_.u_store_register.value); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1687 that->data_.u_position_register.reg); | 1714 that->data_.u_position_register.reg); |
| 1688 break; | 1715 break; |
| 1689 case ActionNode::BEGIN_SUBMATCH: | 1716 case ActionNode::BEGIN_SUBMATCH: |
| 1690 stream()->Add("label=\"begin\", shape=septagon"); | 1717 stream()->Add("label=\"begin\", shape=septagon"); |
| 1691 break; | 1718 break; |
| 1692 case ActionNode::ESCAPE_SUBMATCH: | 1719 case ActionNode::ESCAPE_SUBMATCH: |
| 1693 stream()->Add("label=\"escape\", shape=septagon"); | 1720 stream()->Add("label=\"escape\", shape=septagon"); |
| 1694 break; | 1721 break; |
| 1695 } | 1722 } |
| 1696 stream()->Add("];\n"); | 1723 stream()->Add("];\n"); |
| 1724 PrintAttributes(that); |
| 1697 stream()->Add(" n%p -> n%p;\n", that, that->on_success()); | 1725 stream()->Add(" n%p -> n%p;\n", that, that->on_success()); |
| 1698 Visit(that->on_success()); | 1726 Visit(that->on_success()); |
| 1699 } | 1727 } |
| 1700 | 1728 |
| 1701 | 1729 |
| 1702 class DispatchTableDumper { | 1730 class DispatchTableDumper { |
| 1703 public: | 1731 public: |
| 1704 explicit DispatchTableDumper(StringStream* stream) : stream_(stream) { } | 1732 explicit DispatchTableDumper(StringStream* stream) : stream_(stream) { } |
| 1705 void Call(uc16 key, DispatchTable::Entry entry); | 1733 void Call(uc16 key, DispatchTable::Entry entry); |
| 1706 StringStream* stream() { return stream_; } | 1734 StringStream* stream() { return stream_; } |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2594 byte codes[1024]; | 2622 byte codes[1024]; |
| 2595 IrregexpAssembler assembler(Vector<byte>(codes, 1024)); | 2623 IrregexpAssembler assembler(Vector<byte>(codes, 1024)); |
| 2596 RegExpMacroAssemblerIrregexp macro_assembler(&assembler); | 2624 RegExpMacroAssemblerIrregexp macro_assembler(&assembler); |
| 2597 return compiler.Assemble(¯o_assembler, | 2625 return compiler.Assemble(¯o_assembler, |
| 2598 node, | 2626 node, |
| 2599 input->capture_count); | 2627 input->capture_count); |
| 2600 } | 2628 } |
| 2601 | 2629 |
| 2602 | 2630 |
| 2603 }} // namespace v8::internal | 2631 }} // namespace v8::internal |
| OLD | NEW |