Attached is an example. On Wed, Nov 26, 2008 at 3:08 PM, <[EMAIL PROTECTED]> wrote: > Reviewers: Erik Corry, > > Description: > Graph node attribute printing. > > Please review this at http://codereview.chromium.org/12471 > > Affected files: > M src/jsregexp.cc > M test/cctest/test-regexp.cc > > > Index: src/jsregexp.cc > diff --git a/src/jsregexp.cc b/src/jsregexp.cc > index > e569365d03146a03ad86e2451a7dd867e482bdfc..827b51addf1669a4a604fb54b308608dc8549678 > 100644 > --- a/src/jsregexp.cc > +++ b/src/jsregexp.cc > @@ -1496,6 +1496,7 @@ class DotPrinter: public NodeVisitor { > void PrintNode(const char* label, RegExpNode* node); > void Visit(RegExpNode* node); > void PrintOnFailure(RegExpNode* from, RegExpNode* on_failure); > + void PrintAttributes(RegExpNode* from); > StringStream* stream() { return &stream_; } > #define DECLARE_VISIT(Type) \ > virtual void Visit##Type(Type##Node* that); > @@ -1598,11 +1599,34 @@ class TableEntryHeaderPrinter { > }; > > > +void DotPrinter::PrintAttributes(RegExpNode* that) { > + stream()->Add(" a%p [shape=Mrecord, style=dashed, color=lightgrey, " > + "fontcolor=lightgrey, margin=0.1, fontsize=10, label=\"{", > + that); > + NodeInfo* info = that->info(); > + stream()->Add("{NI|%i}|{SI|%i}|{WI|%i}", > + info->follows_newline_interest, > + info->follows_start_interest, > + info->follows_word_interest); > + stream()->Add("|{DN|%i}|{DS|%i}|{DW|%i}", > + info->determine_newline, > + info->determine_start, > + info->determine_word); > + Label* label = that->label(); > + if (label->is_bound()) > + stream()->Add("|{@|%i}", label->pos()); > + stream()->Add("}\"];\n"); > + stream()->Add(" a%p -> n%p [style=dashed, color=lightgrey, " > + "arrowhead=none];\n", that, that); > +} > + > + > void DotPrinter::VisitChoice(ChoiceNode* that) { > stream()->Add(" n%p [shape=Mrecord, label=\"", that); > TableEntryHeaderPrinter header_printer(stream()); > that->table()->ForEach(&header_printer); > stream()->Add("\"]\n", that); > + PrintAttributes(that); > TableEntryBodyPrinter body_printer(stream(), that); > that->table()->ForEach(&body_printer); > PrintOnFailure(that, that->on_failure()); > @@ -1640,6 +1664,7 @@ void DotPrinter::VisitText(TextNode* that) { > } > } > stream()->Add("\", shape=box, peripheries=2];\n"); > + PrintAttributes(that); > stream()->Add(" n%p -> n%p;\n", that, that->on_success()); > Visit(that->on_success()); > PrintOnFailure(that, that->on_failure()); > @@ -1651,6 +1676,7 @@ void DotPrinter::VisitBackReference(BackReferenceNode* > that) { > that, > that->start_register(), > that->end_register()); > + PrintAttributes(that); > stream()->Add(" n%p -> n%p;\n", that, that->on_success()); > Visit(that->on_success()); > PrintOnFailure(that, that->on_failure()); > @@ -1659,6 +1685,7 @@ void DotPrinter::VisitBackReference(BackReferenceNode* > that) { > > void DotPrinter::VisitEnd(EndNode* that) { > stream()->Add(" n%p [style=bold, shape=point];\n", that); > + PrintAttributes(that); > } > > > @@ -1694,6 +1721,7 @@ void DotPrinter::VisitAction(ActionNode* that) { > break; > } > stream()->Add("];\n"); > + PrintAttributes(that); > stream()->Add(" n%p -> n%p;\n", that, that->on_success()); > Visit(that->on_success()); > } > Index: test/cctest/test-regexp.cc > diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc > index > 6869b5d44b7cae1466cf773085aa54e5cbb3ca7a..afc68f851e1e8a568a5fdb2156c3d0c33f7d2142 > 100644 > --- a/test/cctest/test-regexp.cc > +++ b/test/cctest/test-regexp.cc > @@ -1170,5 +1170,5 @@ TEST(CharacterRangeCaseIndependence) { > > TEST(Graph) { > V8::Initialize(NULL); > - Execute("(x)?\\1y", "", true); > + Execute("\\w+", "", true); > } > > >
--~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
<<inline: graph.svg>>
