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

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: ptal 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 29725c72b3d739c3aeb5639516455f1558347c89..0fc7cd49cf81a6a5eb25de2f6d5348d0c4735521 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -6789,6 +6789,24 @@ void Library::AddClass(const Class& cls) const {
cls.set_library(*this);
}
+static void AddScriptIfUnique(const GrowableObjectArray& scripts,
+ Script& candidate) {
+ Script& script_obj = Script::Handle();
siva 2013/09/06 15:33:51 Move the handle creation below the null check so w
+ if (candidate.IsNull())
+ return;
+ if (candidate.raw() == Object::null())
+ return;
siva 2013/09/06 15:33:51 Seems like duplicate checks: candidate.IsNull() i
+
+ 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
@@ -6799,13 +6817,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()) {
@@ -6814,22 +6838,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