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

Unified Diff: runtime/vm/object.cc

Issue 59283007: List scripts in library and display script source (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « runtime/vm/object.h ('k') | no next file » | 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 482412567e7c2219a01c29ae59038054e8bd10f7..a9546613df94cc63551a542627d862f3f31d2960 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -6791,6 +6791,24 @@ RawString* Script::GenerateSource() const {
}
+const char* Script::GetKindAsCString() const {
+ switch (kind()) {
+ case RawScript::kScriptTag:
+ return "script";
+ case RawScript::kLibraryTag:
+ return "library";
+ case RawScript::kSourceTag:
+ return "source";
+ case RawScript::kPatchTag:
+ return "patch";
+ default:
+ UNIMPLEMENTED();
+ }
+ UNREACHABLE();
+ return NULL;
+}
+
+
void Script::set_url(const String& value) const {
StorePointer(&raw_ptr()->url_, value.raw());
}
@@ -7042,6 +7060,18 @@ const char* Script::ToCString() const {
void Script::PrintToJSONStream(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
+ ObjectIdRing* ring = Isolate::Current()->object_id_ring();
+ intptr_t id = ring->GetIdForObject(raw());
+ jsobj.AddProperty("type", JSONType(ref));
+ jsobj.AddProperty("id", id);
+ const String& name = String::Handle(url());
+ jsobj.AddProperty("name", name.ToCString());
+ jsobj.AddProperty("kind", GetKindAsCString());
+ if (ref) {
+ return;
+ }
+ const String& source = String::Handle(Source());
+ jsobj.AddProperty("source", source.ToCString());
}
@@ -8159,6 +8189,15 @@ void Library::PrintToJSONStream(JSONStream* stream, bool ref) const {
}
}
}
+ {
+ JSONArray jsarr(&jsobj, "scripts");
+ Array& scripts = Array::Handle(LoadedScripts());
+ Script& script = Script::Handle();
+ for (intptr_t i = 0; i < scripts.Length(); i++) {
+ script ^= scripts.At(i);
+ jsarr.AddValue(script);
+ }
+ }
}
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698