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

Unified Diff: src/jsregexp.cc

Issue 12471: Graph node attribute printing. (Closed)
Patch Set: Created 12 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-regexp.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « no previous file | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698