Chromium Code Reviews| Index: runtime/vm/object.cc |
| =================================================================== |
| --- runtime/vm/object.cc (revision 17094) |
| +++ runtime/vm/object.cc (working copy) |
| @@ -2204,6 +2204,16 @@ |
| } |
| +RawFunction* Class::LookupDynamicFunctionAllowPrivate( |
| + const String& name) const { |
| + Function& function = Function::Handle(LookupFunctionAllowPrivate(name)); |
| + if (function.IsNull() || !function.IsDynamicFunction()) { |
| + return Function::null(); |
| + } |
| + return function.raw(); |
| +} |
| + |
| + |
| RawFunction* Class::LookupStaticFunction(const String& name) const { |
| Function& function = Function::Handle(LookupFunction(name)); |
| if (function.IsNull() || !function.IsStaticFunction()) { |
| @@ -2213,6 +2223,15 @@ |
| } |
| +RawFunction* Class::LookupStaticFunctionAllowPrivate(const String& name) const { |
| + Function& function = Function::Handle(LookupFunctionAllowPrivate(name)); |
| + if (function.IsNull() || !function.IsStaticFunction()) { |
| + return Function::null(); |
| + } |
| + return function.raw(); |
| +} |
| + |
| + |
| RawFunction* Class::LookupConstructor(const String& name) const { |
| Function& function = Function::Handle(LookupFunction(name)); |
| if (function.IsNull() || !function.IsConstructor()) { |
| @@ -2266,6 +2285,40 @@ |
| return Function::null(); |
| } |
| Function& function = Function::Handle(isolate, Function::null()); |
| + if (name.IsSymbol()) { |
| + // Quick Symbol compare. |
| + intptr_t len = funcs.Length(); |
| + for (intptr_t i = 0; i < len; i++) { |
| + function ^= funcs.At(i); |
| + if (function.name() == name.raw()) { |
| + return function.raw(); |
| + } |
| + } |
| + } else { |
| + String& function_name = String::Handle(isolate, String::null()); |
| + intptr_t len = funcs.Length(); |
| + for (intptr_t i = 0; i < len; i++) { |
| + function ^= funcs.At(i); |
| + function_name ^= function.name(); |
| + if (function_name.Equals(name)) { |
| + return function.raw(); |
| + } |
| + } |
| + } |
| + // No function found. |
| + return Function::null(); |
| +} |
| + |
| + |
| +RawFunction* Class::LookupFunctionAllowPrivate(const String& name) const { |
| + Isolate* isolate = Isolate::Current(); |
| + ASSERT(name.IsOneByteString()); |
| + Array& funcs = Array::Handle(isolate, functions()); |
| + if (funcs.IsNull()) { |
| + // This can occur, e.g., for Null classes. |
| + return Function::null(); |
| + } |
| + Function& function = Function::Handle(isolate, Function::null()); |
| String& function_name = String::Handle(isolate, String::null()); |
| intptr_t len = funcs.Length(); |
| for (intptr_t i = 0; i < len; i++) { |
| @@ -2275,7 +2328,6 @@ |
| return function.raw(); |
| } |
| } |
| - |
| // No function found. |
| return Function::null(); |
| } |
| @@ -5701,15 +5753,22 @@ |
| static bool ShouldBePrivate(const String& name) { |
| - return |
| - (name.Length() >= 1 && |
| - name.CharAt(0) == '_') || |
| - (name.Length() >= 5 && |
| - (name.CharAt(4) == '_' && |
| - (name.CharAt(0) == 'g' || name.CharAt(0) == 's') && |
| - name.CharAt(1) == 'e' && |
| - name.CharAt(2) == 't' && |
| - name.CharAt(3) == ':')); |
| + if (name.Length() <= 1) return false; |
| + if (name.CharAt(0) == '_') return true; |
| + if (name.StartsWith(Symbols::PrivateGetterPrefix()) || |
| + name.StartsWith(Symbols::PrivateSetterPrefix())) { |
| + return true; |
| + } |
| + // Factory names: List._fromLiteral. |
| + // 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.
|
| + for (intptr_t i = 1; i < name.Length() - 1; i++) { |
| + if (name.CharAt(i) == '.') { |
| + if (name.CharAt(i + 1) == '_') { |
| + return true; |
| + } |
| + } |
| + } |
| + return false; |
| } |