| 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 9183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9194 return loaded_scripts(); | 9194 return loaded_scripts(); |
| 9195 } | 9195 } |
| 9196 | 9196 |
| 9197 | 9197 |
| 9198 // TODO(hausner): we might want to add a script dictionary to the | 9198 // TODO(hausner): we might want to add a script dictionary to the |
| 9199 // library class to make this lookup faster. | 9199 // library class to make this lookup faster. |
| 9200 RawScript* Library::LookupScript(const String& url) const { | 9200 RawScript* Library::LookupScript(const String& url) const { |
| 9201 const Array& scripts = Array::Handle(LoadedScripts()); | 9201 const Array& scripts = Array::Handle(LoadedScripts()); |
| 9202 Script& script = Script::Handle(); | 9202 Script& script = Script::Handle(); |
| 9203 String& script_url = String::Handle(); | 9203 String& script_url = String::Handle(); |
| 9204 intptr_t num_scripts = scripts.Length(); | 9204 const intptr_t url_length = url.Length(); |
| 9205 const intptr_t num_scripts = scripts.Length(); |
| 9205 for (int i = 0; i < num_scripts; i++) { | 9206 for (int i = 0; i < num_scripts; i++) { |
| 9206 script ^= scripts.At(i); | 9207 script ^= scripts.At(i); |
| 9207 script_url = script.url(); | 9208 script_url = script.url(); |
| 9208 if (script_url.Equals(url)) { | 9209 const intptr_t start_idx = script_url.Length() - url_length; |
| 9210 if ((start_idx == 0) && url.Equals(script_url)) { |
| 9209 return script.raw(); | 9211 return script.raw(); |
| 9212 } else if (start_idx > 0) { |
| 9213 // If we do a suffix match, only match if the partial path |
| 9214 // starts at or immediately after the path separator. |
| 9215 if (((url.CharAt(0) == '/') || |
| 9216 (script_url.CharAt(start_idx - 1) == '/')) && |
| 9217 url.Equals(script_url, start_idx, url_length)) { |
| 9218 return script.raw(); |
| 9219 } |
| 9210 } | 9220 } |
| 9211 } | 9221 } |
| 9212 return Script::null(); | 9222 return Script::null(); |
| 9213 } | 9223 } |
| 9214 | 9224 |
| 9215 | 9225 |
| 9216 RawFunction* Library::LookupFunctionInScript(const Script& script, | 9226 RawFunction* Library::LookupFunctionInScript(const Script& script, |
| 9217 intptr_t token_pos) const { | 9227 intptr_t token_pos) const { |
| 9218 Class& cls = Class::Handle(); | 9228 Class& cls = Class::Handle(); |
| 9219 Function& func = Function::Handle(); | 9229 Function& func = Function::Handle(); |
| (...skipping 11141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20361 return tag_label.ToCString(); | 20371 return tag_label.ToCString(); |
| 20362 } | 20372 } |
| 20363 | 20373 |
| 20364 | 20374 |
| 20365 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20375 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20366 Instance::PrintJSONImpl(stream, ref); | 20376 Instance::PrintJSONImpl(stream, ref); |
| 20367 } | 20377 } |
| 20368 | 20378 |
| 20369 | 20379 |
| 20370 } // namespace dart | 20380 } // namespace dart |
| OLD | NEW |