| 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 6070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6081 script ^= scripts.At(i); | 6081 script ^= scripts.At(i); |
| 6082 script_url = script.url(); | 6082 script_url = script.url(); |
| 6083 if (script_url.Equals(url)) { | 6083 if (script_url.Equals(url)) { |
| 6084 return script.raw(); | 6084 return script.raw(); |
| 6085 } | 6085 } |
| 6086 } | 6086 } |
| 6087 return Script::null(); | 6087 return Script::null(); |
| 6088 } | 6088 } |
| 6089 | 6089 |
| 6090 | 6090 |
| 6091 RawFunction* Library::LookupFunctionInSource(const String& script_url, | |
| 6092 intptr_t line_number) const { | |
| 6093 Script& script = Script::Handle(LookupScript(script_url)); | |
| 6094 if (script.IsNull()) { | |
| 6095 // The given script url is not loaded into this library. | |
| 6096 return Function::null(); | |
| 6097 } | |
| 6098 | |
| 6099 // Determine token position at given line number. | |
| 6100 intptr_t first_token_pos, last_token_pos; | |
| 6101 script.TokenRangeAtLine(line_number, &first_token_pos, &last_token_pos); | |
| 6102 if (first_token_pos < 0) { | |
| 6103 // Script does not contain the given line number. | |
| 6104 return Function::null(); | |
| 6105 } | |
| 6106 Function& func = Function::Handle(); | |
| 6107 for (intptr_t pos = first_token_pos; pos <= last_token_pos; pos++) { | |
| 6108 func = LookupFunctionInScript(script, pos); | |
| 6109 if (!func.IsNull()) { | |
| 6110 return func.raw(); | |
| 6111 } | |
| 6112 } | |
| 6113 return Function::null(); | |
| 6114 } | |
| 6115 | |
| 6116 | |
| 6117 RawFunction* Library::LookupFunctionInScript(const Script& script, | 6091 RawFunction* Library::LookupFunctionInScript(const Script& script, |
| 6118 intptr_t token_pos) const { | 6092 intptr_t token_pos) const { |
| 6119 Class& cls = Class::Handle(); | 6093 Class& cls = Class::Handle(); |
| 6120 Function& func = Function::Handle(); | 6094 Function& func = Function::Handle(); |
| 6121 ClassDictionaryIterator it(*this); | 6095 ClassDictionaryIterator it(*this); |
| 6122 while (it.HasNext()) { | 6096 while (it.HasNext()) { |
| 6123 cls = it.GetNextClass(); | 6097 cls = it.GetNextClass(); |
| 6124 if (script.raw() == cls.script()) { | 6098 if (script.raw() == cls.script()) { |
| 6125 func = cls.LookupFunctionAtToken(token_pos); | 6099 func = cls.LookupFunctionAtToken(token_pos); |
| 6126 if (!func.IsNull()) { | 6100 if (!func.IsNull()) { |
| (...skipping 7140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13267 } | 13241 } |
| 13268 return result.raw(); | 13242 return result.raw(); |
| 13269 } | 13243 } |
| 13270 | 13244 |
| 13271 | 13245 |
| 13272 const char* WeakProperty::ToCString() const { | 13246 const char* WeakProperty::ToCString() const { |
| 13273 return "_WeakProperty"; | 13247 return "_WeakProperty"; |
| 13274 } | 13248 } |
| 13275 | 13249 |
| 13276 } // namespace dart | 13250 } // namespace dart |
| OLD | NEW |