Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: runtime/vm/object.cc

Issue 1120223003: Minor cleanup for getter/setter lookup (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 45537)
+++ runtime/vm/object.cc (working copy)
@@ -6973,8 +6973,6 @@
RawString* Field::GetterName(const String& field_name) {
CompilerStats::make_accessor_name++;
- // TODO(koda): Avoid most of these allocations by adding prefix-based lookup
- // to Class::Lookup*.
return String::Concat(Symbols::GetterPrefix(), field_name);
}
@@ -6986,8 +6984,6 @@
RawString* Field::SetterName(const String& field_name) {
CompilerStats::make_accessor_name++;
- // TODO(koda): Avoid most of these allocations by adding prefix-based lookup
- // to Class::Lookup*.
return String::Concat(Symbols::SetterPrefix(), field_name);
}
@@ -8914,6 +8910,19 @@
}
+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) == ':'));
+}
+
+
RawObject* Library::ResolveName(const String& name) const {
Object& obj = Object::Handle();
if (FLAG_use_lib_cache && LookupResolvedNamesCache(name, &obj)) {
@@ -8930,7 +8939,7 @@
if (obj.IsNull()) {
accessor_name = Field::SetterName(name);
obj = LookupLocalObject(accessor_name);
- if (obj.IsNull()) {
+ if (obj.IsNull() && !ShouldBePrivate(name)) {
obj = LookupImportedObject(name);
}
}
@@ -9266,19 +9275,6 @@
}
-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) == ':'));
-}
-
-
RawField* Library::LookupFieldAllowPrivate(const String& name) const {
Object& obj = Object::Handle(LookupObjectAllowPrivate(name));
if (obj.IsField()) {
@@ -9352,6 +9348,10 @@
String& first_import_lib_url = String::Handle();
Object& found_obj = Object::Handle();
String& found_obj_name = String::Handle();
+ // We don't look up getter names explicitly. Setter names are
+ // looked up explicitly when converting top-level getters to setters.
+ ASSERT(!Field::IsGetterName(name));
+ ASSERT(!ShouldBePrivate(name));
for (intptr_t i = 0; i < num_imports(); i++) {
import ^= ImportAt(i);
obj = import.Lookup(name);
@@ -10361,18 +10361,13 @@
intptr_t ignore = 0;
// Lookup the name in the library's symbols.
- const String* filter_name = &name;
Object& obj = Object::Handle(isolate, lib.LookupEntry(name, &ignore));
- if (Field::IsGetterName(name)) {
- filter_name = &String::Handle(Field::NameFromGetter(name));
- } else if (Field::IsSetterName(name)) {
- filter_name = &String::Handle(Field::NameFromSetter(name));
- } else {
- if (obj.IsNull() || obj.IsLibraryPrefix()) {
- obj = lib.LookupEntry(String::Handle(Field::GetterName(name)), &ignore);
- if (obj.IsNull()) {
- obj = lib.LookupEntry(String::Handle(Field::SetterName(name)), &ignore);
- }
+ if (!Field::IsGetterName(name) &&
+ !Field::IsSetterName(name) &&
+ (obj.IsNull() || obj.IsLibraryPrefix())) {
+ obj = lib.LookupEntry(String::Handle(Field::GetterName(name)), &ignore);
+ if (obj.IsNull()) {
+ obj = lib.LookupEntry(String::Handle(Field::SetterName(name)), &ignore);
}
}
@@ -10381,7 +10376,7 @@
// Lookup in the re-exported symbols.
obj = lib.LookupReExport(name);
}
- if (obj.IsNull() || HidesName(*filter_name) || obj.IsLibraryPrefix()) {
+ if (obj.IsNull() || HidesName(name) || obj.IsLibraryPrefix()) {
return Object::null();
}
return obj.raw();
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698