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

Side by Side Diff: src/jsregexp.cc

Issue 12861: Regexp logging and stl (Closed)
Patch Set: Created 12 years 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/jsregexp.h ('k') | src/log.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 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #define _HAS_EXCEPTIONS 0
29 #include <set>
30
31 #include "v8.h" 28 #include "v8.h"
32 29
33 #include "ast.h" 30 #include "ast.h"
34 #include "execution.h" 31 #include "execution.h"
35 #include "factory.h" 32 #include "factory.h"
36 #include "jsregexp-inl.h" 33 #include "jsregexp-inl.h"
37 #include "platform.h" 34 #include "platform.h"
38 #include "runtime.h" 35 #include "runtime.h"
39 #include "top.h" 36 #include "top.h"
40 #include "compilation-cache.h" 37 #include "compilation-cache.h"
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 void PrintAttributes(RegExpNode* from); 1577 void PrintAttributes(RegExpNode* from);
1581 StringStream* stream() { return &stream_; } 1578 StringStream* stream() { return &stream_; }
1582 #define DECLARE_VISIT(Type) \ 1579 #define DECLARE_VISIT(Type) \
1583 virtual void Visit##Type(Type##Node* that); 1580 virtual void Visit##Type(Type##Node* that);
1584 FOR_EACH_NODE_TYPE(DECLARE_VISIT) 1581 FOR_EACH_NODE_TYPE(DECLARE_VISIT)
1585 #undef DECLARE_VISIT 1582 #undef DECLARE_VISIT
1586 private: 1583 private:
1587 bool ignore_case_; 1584 bool ignore_case_;
1588 HeapStringAllocator alloc_; 1585 HeapStringAllocator alloc_;
1589 StringStream stream_; 1586 StringStream stream_;
1590 std::set<RegExpNode*> seen_;
1591 }; 1587 };
1592 1588
1593 1589
1594 void DotPrinter::PrintNode(const char* label, RegExpNode* node) { 1590 void DotPrinter::PrintNode(const char* label, RegExpNode* node) {
1595 stream()->Add("digraph G {\n graph [label=\""); 1591 stream()->Add("digraph G {\n graph [label=\"");
1596 for (int i = 0; label[i]; i++) { 1592 for (int i = 0; label[i]; i++) {
1597 switch (label[i]) { 1593 switch (label[i]) {
1598 case '\\': 1594 case '\\':
1599 stream()->Add("\\\\"); 1595 stream()->Add("\\\\");
1600 break; 1596 break;
1601 case '"': 1597 case '"':
1602 stream()->Add("\""); 1598 stream()->Add("\"");
1603 break; 1599 break;
1604 default: 1600 default:
1605 stream()->Put(label[i]); 1601 stream()->Put(label[i]);
1606 break; 1602 break;
1607 } 1603 }
1608 } 1604 }
1609 stream()->Add("\"];\n"); 1605 stream()->Add("\"];\n");
1610 Visit(node); 1606 Visit(node);
1611 stream()->Add("}\n"); 1607 stream()->Add("}\n");
1612 printf("%s", *(stream()->ToCString())); 1608 printf("%s", *(stream()->ToCString()));
1613 } 1609 }
1614 1610
1615 1611
1616 void DotPrinter::Visit(RegExpNode* node) { 1612 void DotPrinter::Visit(RegExpNode* node) {
1617 if (seen_.find(node) != seen_.end()) 1613 if (node->info()->visited) return;
1618 return; 1614 node->info()->visited = true;
1619 seen_.insert(node);
1620 node->Accept(this); 1615 node->Accept(this);
1621 } 1616 }
1622 1617
1623 1618
1624 void DotPrinter::PrintOnFailure(RegExpNode* from, RegExpNode* on_failure) { 1619 void DotPrinter::PrintOnFailure(RegExpNode* from, RegExpNode* on_failure) {
1625 if (on_failure->IsBacktrack()) return; 1620 if (on_failure->IsBacktrack()) return;
1626 stream()->Add(" n%p -> n%p [style=dotted];\n", from, on_failure); 1621 stream()->Add(" n%p -> n%p [style=dotted];\n", from, on_failure);
1627 Visit(on_failure); 1622 Visit(on_failure);
1628 } 1623 }
1629 1624
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after
3036 } 3031 }
3037 EmbeddedVector<byte, 1024> codes; 3032 EmbeddedVector<byte, 1024> codes;
3038 RegExpMacroAssemblerIrregexp macro_assembler(codes); 3033 RegExpMacroAssemblerIrregexp macro_assembler(codes);
3039 return compiler.Assemble(&macro_assembler, 3034 return compiler.Assemble(&macro_assembler,
3040 node, 3035 node,
3041 input->capture_count); 3036 input->capture_count);
3042 } 3037 }
3043 3038
3044 3039
3045 }} // namespace v8::internal 3040 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jsregexp.h ('k') | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698