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

Unified Diff: runtime/vm/object.cc

Issue 23982002: Fix bug where Script files that only contained patches were lost from the list of LoadedScripts() T… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: removed dupe code Created 7 years, 3 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/dart_api_impl_test.cc ('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 e65bce07a477beb03064d5d44f52ffe3fea2dd4e..814031edf9966f616551eaad2ffacd0d56e65795 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -6786,6 +6786,23 @@ void Library::AddClass(const Class& cls) const {
cls.set_library(*this);
}
+static void AddScriptIfUnique(const GrowableObjectArray& scripts,
+ Script& candidate) {
+ if (candidate.IsNull()) {
+ return;
+ }
+ Script& script_obj = Script::Handle();
+
+ for (int i = 0; i < scripts.Length(); i++) {
+ script_obj ^= scripts.At(i);
+ if (script_obj.raw() == candidate.raw()) {
+ // We already have a reference to this script.
+ return;
+ }
+ }
+ // Add script to the list of scripts.
+ scripts.Add(candidate);
+}
RawArray* Library::LoadedScripts() const {
// We compute the list of loaded scripts lazily. The result is
@@ -6796,13 +6813,19 @@ RawArray* Library::LoadedScripts() const {
GrowableObjectArray::Handle(GrowableObjectArray::New(8));
Object& entry = Object::Handle();
Class& cls = Class::Handle();
+ Class& patch_cls = Class::Handle();
Script& owner_script = Script::Handle();
+ Script& patch_script = Script::Handle();
DictionaryIterator it(*this);
- Script& script_obj = Script::Handle();
while (it.HasNext()) {
entry = it.GetNext();
if (entry.IsClass()) {
owner_script = Class::Cast(entry).script();
+ patch_cls = Class::Cast(entry).patch_class();
+ if (!patch_cls.IsNull()) {
+ patch_script = patch_cls.script();
+ AddScriptIfUnique(scripts, patch_script);
+ }
} else if (entry.IsFunction()) {
owner_script = Function::Cast(entry).script();
} else if (entry.IsField()) {
@@ -6811,22 +6834,7 @@ RawArray* Library::LoadedScripts() const {
} else {
continue;
}
- if (owner_script.IsNull()) {
- continue;
- }
- bool is_unique = true;
- for (int i = 0; i < scripts.Length(); i++) {
- script_obj ^= scripts.At(i);
- if (script_obj.raw() == owner_script.raw()) {
- // We already have a reference to this script.
- is_unique = false;
- break;
- }
- }
- if (is_unique) {
- // Add script to the list of scripts.
- scripts.Add(owner_script);
- }
+ AddScriptIfUnique(scripts, owner_script);
}
// Create the array of scripts and cache it in loaded_scripts_.
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698