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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 2186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2197 | 2197 |
2198 RawFunction* Class::LookupDynamicFunction(const String& name) const { | 2198 RawFunction* Class::LookupDynamicFunction(const String& name) const { |
2199 Function& function = Function::Handle(LookupFunction(name)); | 2199 Function& function = Function::Handle(LookupFunction(name)); |
2200 if (function.IsNull() || !function.IsDynamicFunction()) { | 2200 if (function.IsNull() || !function.IsDynamicFunction()) { |
2201 return Function::null(); | 2201 return Function::null(); |
2202 } | 2202 } |
2203 return function.raw(); | 2203 return function.raw(); |
2204 } | 2204 } |
2205 | 2205 |
2206 | 2206 |
2207 RawFunction* Class::LookupDynamicFunctionAllowPrivate( | |
2208 const String& name) const { | |
2209 Function& function = Function::Handle(LookupFunctionAllowPrivate(name)); | |
2210 if (function.IsNull() || !function.IsDynamicFunction()) { | |
2211 return Function::null(); | |
2212 } | |
2213 return function.raw(); | |
2214 } | |
2215 | |
2216 | |
2207 RawFunction* Class::LookupStaticFunction(const String& name) const { | 2217 RawFunction* Class::LookupStaticFunction(const String& name) const { |
2208 Function& function = Function::Handle(LookupFunction(name)); | 2218 Function& function = Function::Handle(LookupFunction(name)); |
2209 if (function.IsNull() || !function.IsStaticFunction()) { | 2219 if (function.IsNull() || !function.IsStaticFunction()) { |
2210 return Function::null(); | 2220 return Function::null(); |
2211 } | 2221 } |
2212 return function.raw(); | 2222 return function.raw(); |
2213 } | 2223 } |
2214 | 2224 |
2215 | 2225 |
2226 RawFunction* Class::LookupStaticFunctionAllowPrivate(const String& name) const { | |
2227 Function& function = Function::Handle(LookupFunctionAllowPrivate(name)); | |
2228 if (function.IsNull() || !function.IsStaticFunction()) { | |
2229 return Function::null(); | |
2230 } | |
2231 return function.raw(); | |
2232 } | |
2233 | |
2234 | |
2216 RawFunction* Class::LookupConstructor(const String& name) const { | 2235 RawFunction* Class::LookupConstructor(const String& name) const { |
2217 Function& function = Function::Handle(LookupFunction(name)); | 2236 Function& function = Function::Handle(LookupFunction(name)); |
2218 if (function.IsNull() || !function.IsConstructor()) { | 2237 if (function.IsNull() || !function.IsConstructor()) { |
2219 return Function::null(); | 2238 return Function::null(); |
2220 } | 2239 } |
2221 ASSERT(!function.is_static()); | 2240 ASSERT(!function.is_static()); |
2222 return function.raw(); | 2241 return function.raw(); |
2223 } | 2242 } |
2224 | 2243 |
2225 | 2244 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2259 | 2278 |
2260 RawFunction* Class::LookupFunction(const String& name) const { | 2279 RawFunction* Class::LookupFunction(const String& name) const { |
2261 Isolate* isolate = Isolate::Current(); | 2280 Isolate* isolate = Isolate::Current(); |
2262 ASSERT(name.IsOneByteString()); | 2281 ASSERT(name.IsOneByteString()); |
2263 Array& funcs = Array::Handle(isolate, functions()); | 2282 Array& funcs = Array::Handle(isolate, functions()); |
2264 if (funcs.IsNull()) { | 2283 if (funcs.IsNull()) { |
2265 // This can occur, e.g., for Null classes. | 2284 // This can occur, e.g., for Null classes. |
2266 return Function::null(); | 2285 return Function::null(); |
2267 } | 2286 } |
2268 Function& function = Function::Handle(isolate, Function::null()); | 2287 Function& function = Function::Handle(isolate, Function::null()); |
2288 if (name.IsSymbol()) { | |
2289 // Quick Symbol compare. | |
2290 intptr_t len = funcs.Length(); | |
2291 for (intptr_t i = 0; i < len; i++) { | |
2292 function ^= funcs.At(i); | |
2293 if (function.name() == name.raw()) { | |
2294 return function.raw(); | |
2295 } | |
2296 } | |
2297 } else { | |
2298 String& function_name = String::Handle(isolate, String::null()); | |
2299 intptr_t len = funcs.Length(); | |
2300 for (intptr_t i = 0; i < len; i++) { | |
2301 function ^= funcs.At(i); | |
2302 function_name ^= function.name(); | |
2303 if (function_name.Equals(name)) { | |
2304 return function.raw(); | |
2305 } | |
2306 } | |
2307 } | |
2308 // No function found. | |
2309 return Function::null(); | |
2310 } | |
2311 | |
2312 | |
2313 RawFunction* Class::LookupFunctionAllowPrivate(const String& name) const { | |
2314 Isolate* isolate = Isolate::Current(); | |
2315 ASSERT(name.IsOneByteString()); | |
2316 Array& funcs = Array::Handle(isolate, functions()); | |
2317 if (funcs.IsNull()) { | |
2318 // This can occur, e.g., for Null classes. | |
2319 return Function::null(); | |
2320 } | |
2321 Function& function = Function::Handle(isolate, Function::null()); | |
2269 String& function_name = String::Handle(isolate, String::null()); | 2322 String& function_name = String::Handle(isolate, String::null()); |
2270 intptr_t len = funcs.Length(); | 2323 intptr_t len = funcs.Length(); |
2271 for (intptr_t i = 0; i < len; i++) { | 2324 for (intptr_t i = 0; i < len; i++) { |
2272 function ^= funcs.At(i); | 2325 function ^= funcs.At(i); |
2273 function_name ^= function.name(); | 2326 function_name ^= function.name(); |
2274 if (OneByteString::EqualsIgnoringPrivateKey(function_name, name)) { | 2327 if (OneByteString::EqualsIgnoringPrivateKey(function_name, name)) { |
2275 return function.raw(); | 2328 return function.raw(); |
2276 } | 2329 } |
2277 } | 2330 } |
2278 | |
2279 // No function found. | 2331 // No function found. |
2280 return Function::null(); | 2332 return Function::null(); |
2281 } | 2333 } |
2282 | 2334 |
2283 | 2335 |
2284 RawFunction* Class::LookupGetterFunction(const String& name) const { | 2336 RawFunction* Class::LookupGetterFunction(const String& name) const { |
2285 return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name); | 2337 return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name); |
2286 } | 2338 } |
2287 | 2339 |
2288 | 2340 |
(...skipping 3405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5694 } | 5746 } |
5695 | 5747 |
5696 | 5748 |
5697 RawObject* Library::LookupLocalObject(const String& name) const { | 5749 RawObject* Library::LookupLocalObject(const String& name) const { |
5698 intptr_t index; | 5750 intptr_t index; |
5699 return LookupEntry(name, &index); | 5751 return LookupEntry(name, &index); |
5700 } | 5752 } |
5701 | 5753 |
5702 | 5754 |
5703 static bool ShouldBePrivate(const String& name) { | 5755 static bool ShouldBePrivate(const String& name) { |
5704 return | 5756 if (name.Length() <= 1) return false; |
5705 (name.Length() >= 1 && | 5757 if (name.CharAt(0) == '_') return true; |
5706 name.CharAt(0) == '_') || | 5758 if (name.StartsWith(Symbols::PrivateGetterPrefix()) || |
5707 (name.Length() >= 5 && | 5759 name.StartsWith(Symbols::PrivateSetterPrefix())) { |
5708 (name.CharAt(4) == '_' && | 5760 return true; |
5709 (name.CharAt(0) == 'g' || name.CharAt(0) == 's') && | 5761 } |
5710 name.CharAt(1) == 'e' && | 5762 // Factory names: List._fromLiteral. |
5711 name.CharAt(2) == 't' && | 5763 // TODO(srdjan): Improve speed by assuming OnebyteStrings. |
siva
2013/01/16 23:57:24
could also be ExternalOneByteString?
srdjan
2013/01/17 00:31:11
Removed comment.
| |
5712 name.CharAt(3) == ':')); | 5764 for (intptr_t i = 1; i < name.Length() - 1; i++) { |
5765 if (name.CharAt(i) == '.') { | |
5766 if (name.CharAt(i + 1) == '_') { | |
5767 return true; | |
5768 } | |
5769 } | |
5770 } | |
5771 return false; | |
5713 } | 5772 } |
5714 | 5773 |
5715 | 5774 |
5716 RawField* Library::LookupFieldAllowPrivate(const String& name) const { | 5775 RawField* Library::LookupFieldAllowPrivate(const String& name) const { |
5717 // First check if name is found in the local scope of the library. | 5776 // First check if name is found in the local scope of the library. |
5718 Field& field = Field::Handle(LookupLocalField(name)); | 5777 Field& field = Field::Handle(LookupLocalField(name)); |
5719 if (!field.IsNull()) { | 5778 if (!field.IsNull()) { |
5720 return field.raw(); | 5779 return field.raw(); |
5721 } | 5780 } |
5722 | 5781 |
(...skipping 6762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12485 } | 12544 } |
12486 return result.raw(); | 12545 return result.raw(); |
12487 } | 12546 } |
12488 | 12547 |
12489 | 12548 |
12490 const char* WeakProperty::ToCString() const { | 12549 const char* WeakProperty::ToCString() const { |
12491 return "_WeakProperty"; | 12550 return "_WeakProperty"; |
12492 } | 12551 } |
12493 | 12552 |
12494 } // namespace dart | 12553 } // namespace dart |
OLD | NEW |