Chromium Code Reviews| Index: src/ast/scopes.cc |
| diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
| index fc020ccefb81466a40ad04295019d6b9a226ae65..bee9e3f11dc4987f5554fd118eadcd90dec6e578 100644 |
| --- a/src/ast/scopes.cc |
| +++ b/src/ast/scopes.cc |
| @@ -1397,39 +1397,41 @@ static void PrintLocation(Variable* var) { |
| static void PrintVar(int indent, Variable* var) { |
|
Igor Sheludko
2016/12/02 22:06:10
While you are here please put this function into a
adamk
2016/12/03 00:04:23
Wrapped all these helpers in an anonymous namespac
|
| - if (var->is_used() || !var->IsUnallocated()) { |
| - Indent(indent, VariableMode2String(var->mode())); |
| - PrintF(" "); |
| - if (var->raw_name()->IsEmpty()) |
| - PrintF(".%p", reinterpret_cast<void*>(var)); |
| - else |
| - PrintName(var->raw_name()); |
| - PrintF("; // "); |
| - PrintLocation(var); |
| - bool comma = !var->IsUnallocated(); |
| - if (var->has_forced_context_allocation()) { |
| - if (comma) PrintF(", "); |
| - PrintF("forced context allocation"); |
| - comma = true; |
| - } |
| - if (var->maybe_assigned() == kNotAssigned) { |
| - if (comma) PrintF(", "); |
| - PrintF("never assigned"); |
| - } |
| - PrintF("\n"); |
| - } |
| -} |
| - |
| -static void PrintMap(int indent, VariableMap* map, bool locals) { |
| + Indent(indent, VariableMode2String(var->mode())); |
| + PrintF(" "); |
| + if (var->raw_name()->IsEmpty()) |
| + PrintF(".%p", reinterpret_cast<void*>(var)); |
| + else |
| + PrintName(var->raw_name()); |
| + PrintF("; // "); |
| + PrintLocation(var); |
| + bool comma = !var->IsUnallocated(); |
| + if (var->has_forced_context_allocation()) { |
| + if (comma) PrintF(", "); |
| + PrintF("forced context allocation"); |
| + comma = true; |
| + } |
| + if (var->maybe_assigned() == kNotAssigned) { |
| + if (comma) PrintF(", "); |
| + PrintF("never assigned"); |
| + } |
| + PrintF("\n"); |
| +} |
| + |
| +static void PrintMap(int indent, const char* label, VariableMap* map, |
|
Igor Sheludko
2016/12/02 22:06:10
Same here.
adamk
2016/12/03 00:04:23
Done.
|
| + bool locals, Variable* function_var) { |
| + bool printed_label = false; |
| for (VariableMap::Entry* p = map->Start(); p != nullptr; p = map->Next(p)) { |
| Variable* var = reinterpret_cast<Variable*>(p->value); |
| + if (var == function_var) continue; |
| bool local = !IsDynamicVariableMode(var->mode()); |
| - if (locals ? local : !local) { |
| - if (var == nullptr) { |
| - Indent(indent, "<?>\n"); |
| - } else { |
| - PrintVar(indent, var); |
| + if ((locals ? local : !local) && |
| + (var->is_used() || !var->IsUnallocated())) { |
| + if (!printed_label) { |
| + Indent(indent, label); |
| + printed_label = true; |
| } |
| + PrintVar(indent, var); |
| } |
| } |
| } |
| @@ -1508,13 +1510,8 @@ void Scope::Print(int n) { |
| PrintVar(n1, function); |
| } |
| - if (variables_.occupancy() != 0) { |
| - Indent(n1, "// local vars:\n"); |
| - PrintMap(n1, &variables_, true); |
| - |
| - Indent(n1, "// dynamic vars:\n"); |
| - PrintMap(n1, &variables_, false); |
| - } |
| + PrintMap(n1, "// local vars:\n", &variables_, true, function); |
| + PrintMap(n1, "// dynamic vars:\n", &variables_, false, function); |
| // Print inner scopes (disable by providing negative n). |
| if (n >= 0) { |