| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 9097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9108 return loaded_scripts(); | 9108 return loaded_scripts(); |
| 9109 } | 9109 } |
| 9110 | 9110 |
| 9111 | 9111 |
| 9112 // TODO(hausner): we might want to add a script dictionary to the | 9112 // TODO(hausner): we might want to add a script dictionary to the |
| 9113 // library class to make this lookup faster. | 9113 // library class to make this lookup faster. |
| 9114 RawScript* Library::LookupScript(const String& url) const { | 9114 RawScript* Library::LookupScript(const String& url) const { |
| 9115 const Array& scripts = Array::Handle(LoadedScripts()); | 9115 const Array& scripts = Array::Handle(LoadedScripts()); |
| 9116 Script& script = Script::Handle(); | 9116 Script& script = Script::Handle(); |
| 9117 String& script_url = String::Handle(); | 9117 String& script_url = String::Handle(); |
| 9118 intptr_t num_scripts = scripts.Length(); | 9118 const intptr_t url_length = url.Length(); |
| 9119 const intptr_t num_scripts = scripts.Length(); |
| 9119 for (int i = 0; i < num_scripts; i++) { | 9120 for (int i = 0; i < num_scripts; i++) { |
| 9120 script ^= scripts.At(i); | 9121 script ^= scripts.At(i); |
| 9121 script_url = script.url(); | 9122 script_url = script.url(); |
| 9122 if (script_url.Equals(url)) { | 9123 const intptr_t start_idx = script_url.Length() - url_length; |
| 9124 if ((start_idx == 0) && url.Equals(script_url)) { |
| 9123 return script.raw(); | 9125 return script.raw(); |
| 9126 } else if (start_idx > 0) { |
| 9127 // If we do a suffix match, only match if the partial path |
| 9128 // starts at or immediately after the path separator. |
| 9129 if (((url.CharAt(0) == '/') || |
| 9130 (script_url.CharAt(start_idx - 1) == '/')) && |
| 9131 url.Equals(script_url, start_idx, url_length)) { |
| 9132 return script.raw(); |
| 9133 } |
| 9124 } | 9134 } |
| 9125 } | 9135 } |
| 9126 return Script::null(); | 9136 return Script::null(); |
| 9127 } | 9137 } |
| 9128 | 9138 |
| 9129 | 9139 |
| 9130 RawFunction* Library::LookupFunctionInScript(const Script& script, | 9140 RawFunction* Library::LookupFunctionInScript(const Script& script, |
| 9131 intptr_t token_pos) const { | 9141 intptr_t token_pos) const { |
| 9132 Class& cls = Class::Handle(); | 9142 Class& cls = Class::Handle(); |
| 9133 Function& func = Function::Handle(); | 9143 Function& func = Function::Handle(); |
| (...skipping 11141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20275 return tag_label.ToCString(); | 20285 return tag_label.ToCString(); |
| 20276 } | 20286 } |
| 20277 | 20287 |
| 20278 | 20288 |
| 20279 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20289 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20280 Instance::PrintJSONImpl(stream, ref); | 20290 Instance::PrintJSONImpl(stream, ref); |
| 20281 } | 20291 } |
| 20282 | 20292 |
| 20283 | 20293 |
| 20284 } // namespace dart | 20294 } // namespace dart |
| OLD | NEW |