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

Unified Diff: runtime/vm/object.cc

Issue 267583002: Add some testing for the variable allocation code in the Parser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: improve tests Created 6 years, 8 months 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 | « runtime/vm/debugger.cc ('k') | runtime/vm/parser_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 1ae49e74ad4ab513e8f13380dbd6851aaf79a71c..f26609f81fb4901233cd5dab93833aef26863130 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -10244,10 +10244,41 @@ void LocalVarDescriptors::GetInfo(intptr_t var_index,
}
+static const char* VarKindString(int kind) {
+ switch (kind) {
+ case RawLocalVarDescriptors::kStackVar:
+ return "StackVar";
+ break;
+ case RawLocalVarDescriptors::kContextVar:
+ return "ContextVar";
+ break;
+ case RawLocalVarDescriptors::kContextLevel:
+ return "ContextLevel";
+ break;
+ case RawLocalVarDescriptors::kSavedEntryContext:
+ return "SavedEntryCtx";
+ break;
+ case RawLocalVarDescriptors::kSavedCurrentContext:
+ return "SavedCurrentCtx";
+ break;
+ default:
+ UNREACHABLE();
+ return "Unknown";
+ }
+}
+
+
const char* LocalVarDescriptors::ToCString() const {
intptr_t len = 1; // Trailing '\0'.
const char* kFormat =
- "%2" Pd " kind=%d scope=0x%04x begin=%" Pd " end=%" Pd " name=%s\n";
+ "%2" Pd " %-13s scope=%-3d index=%-3" Pd ""
+ " begin=%-3" Pd " end=%-3" Pd " name=%s\n";
+ const char* kFormatCtxLevel =
+ "%1$2" Pd " %2$-13s level=%4$-3" Pd " scope=%3$-3d"
+ " begin=%5$-3" Pd " end=%6$" Pd "\n";
+ const char* kFormatCtxVar =
+ "%2" Pd " %-13s level=%-3d index=%-3" Pd ""
+ " begin=%-3" Pd " end=%-3" Pd " name=%s\n";
for (intptr_t i = 0; i < Length(); i++) {
String& var_name = String::Handle(GetName(i));
if (var_name.IsNull()) {
@@ -10255,10 +10286,18 @@ const char* LocalVarDescriptors::ToCString() const {
}
RawLocalVarDescriptors::VarInfo info;
GetInfo(i, &info);
- len += OS::SNPrint(NULL, 0, kFormat,
+ const char* format = kFormat;
+ if (info.kind == RawLocalVarDescriptors::kContextLevel) {
+ format = kFormatCtxLevel;
+ } else if (info.kind == RawLocalVarDescriptors::kContextVar) {
+ format = kFormatCtxVar;
+ }
+ len += OS::SNPrint(NULL, 0,
+ format,
i,
- info.kind,
+ VarKindString(info.kind),
info.scope_id,
+ info.index,
info.begin_pos,
info.end_pos,
var_name.ToCString());
@@ -10272,12 +10311,19 @@ const char* LocalVarDescriptors::ToCString() const {
}
RawLocalVarDescriptors::VarInfo info;
GetInfo(i, &info);
+ const char* format = kFormat;
+ if (info.kind == RawLocalVarDescriptors::kContextLevel) {
+ format = kFormatCtxLevel;
+ } else if (info.kind == RawLocalVarDescriptors::kContextVar) {
+ format = kFormatCtxVar;
+ }
num_chars += OS::SNPrint((buffer + num_chars),
(len - num_chars),
- kFormat,
+ format,
i,
- info.kind,
+ VarKindString(info.kind),
info.scope_id,
+ info.index,
info.begin_pos,
info.end_pos,
var_name.ToCString());
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/parser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698