Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index 0236cf1ad81de4925f30ac7712b3a716ccfaa955..604e9e5f69794cc740dd67716754ea333c51a63c 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -8307,6 +8307,54 @@ void Script::PrintJSONImpl(JSONStream* stream, bool ref) const { |
} |
+RawLibrary* Script::FindLibrary() const { |
+ Isolate* isolate = Isolate::Current(); |
+ const GrowableObjectArray& libs = GrowableObjectArray::Handle( |
+ isolate, isolate->object_store()->libraries()); |
+ Library& lib = Library::Handle(); |
+ Script& script = Script::Handle(); |
+ for (intptr_t i = 0; i < libs.Length(); i++) { |
+ lib ^= libs.At(i); |
+ ASSERT(!lib.IsNull()); |
+ const Array& loaded_scripts = Array::Handle(lib.LoadedScripts()); |
+ ASSERT(!loaded_scripts.IsNull()); |
+ for (intptr_t j = 0; j < loaded_scripts.Length(); j++) { |
+ script ^= loaded_scripts.At(j); |
+ ASSERT(!script.IsNull()); |
+ if (script.raw() == raw()) { |
+ return lib.raw(); |
Ivan Posva
2014/06/26 10:14:33
How does this work for scripts that have been incl
|
+ } |
+ } |
+ } |
+ return Library::null(); |
+} |
+ |
+ |
+RawScript* Script::FindByUrl(const String& url) { |
+ Isolate* isolate = Isolate::Current(); |
+ const GrowableObjectArray& libs = GrowableObjectArray::Handle( |
+ isolate, isolate->object_store()->libraries()); |
+ Library& lib = Library::Handle(); |
+ Script& script = Script::Handle(); |
+ String& script_url = String::Handle(); |
+ for (intptr_t i = 0; i < libs.Length(); i++) { |
+ lib ^= libs.At(i); |
+ ASSERT(!lib.IsNull()); |
+ const Array& loaded_scripts = Array::Handle(lib.LoadedScripts()); |
+ ASSERT(!loaded_scripts.IsNull()); |
+ for (intptr_t j = 0; j < loaded_scripts.Length(); j++) { |
+ script ^= loaded_scripts.At(j); |
+ ASSERT(!script.IsNull()); |
+ script_url ^= script.url(); |
+ if (script_url.Equals(url)) { |
+ return script.raw(); |
+ } |
+ } |
+ } |
+ return Script::null(); |
+} |
+ |
+ |
DictionaryIterator::DictionaryIterator(const Library& library) |
: array_(Array::Handle(library.dictionary())), |
// Last element in array is a Smi indicating the number of entries used. |