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

Unified Diff: runtime/vm/parser.cc

Issue 135123011: Introduce cache of resolved names in library (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 32342)
+++ runtime/vm/parser.cc (working copy)
@@ -9102,43 +9102,9 @@
}
-static RawObject* LookupNameInLibrary(Isolate* isolate,
- const Library& lib,
- const String& name) {
- Object& obj = Object::Handle(isolate);
- obj = lib.LookupLocalObject(name);
- if (!obj.IsNull()) {
- return obj.raw();
- }
- String& accessor_name = String::Handle(isolate, Field::GetterName(name));
- obj = lib.LookupLocalObject(accessor_name);
- if (!obj.IsNull()) {
- return obj.raw();
- }
- accessor_name = Field::SetterName(name);
- obj = lib.LookupLocalObject(accessor_name);
- return obj.raw();
-}
-
-
-// Resolve a name by checking the global scope of the current
-// library. If not found in the current library, then look in the scopes
-// of all libraries that are imported without a library prefix.
-RawObject* Parser::ResolveNameInCurrentLibraryScope(const String& name) {
- TRACE_PARSER("ResolveNameInCurrentLibraryScope");
+RawClass* Parser::ResolveClassInCurrentLibraryScope(const String& name) {
HANDLESCOPE(isolate());
- Object& obj = Object::Handle(isolate(),
- LookupNameInLibrary(isolate(), library_, name));
- if (!obj.IsNull()) {
- return obj.raw();
- }
- return library_.LookupImportedObject(name);
-}
-
-
-RawClass* Parser::ResolveClassInCurrentLibraryScope(const String& name) {
- const Object& obj =
- Object::Handle(ResolveNameInCurrentLibraryScope(name));
+ const Object& obj = Object::Handle(library_.ResolveName(name));
if (obj.IsClass()) {
return Class::Cast(obj).raw();
}
@@ -9152,8 +9118,8 @@
AstNode* Parser::ResolveIdentInCurrentLibraryScope(intptr_t ident_pos,
const String& ident) {
TRACE_PARSER("ResolveIdentInCurrentLibraryScope");
- const Object& obj =
- Object::Handle(ResolveNameInCurrentLibraryScope(ident));
+ HANDLESCOPE(isolate());
+ const Object& obj = Object::Handle(library_.ResolveName(ident));
if (obj.IsClass()) {
const Class& cls = Class::Cast(obj);
return new PrimaryNode(ident_pos, Class::ZoneHandle(cls.raw()));
@@ -9182,17 +9148,10 @@
}
-RawObject* Parser::ResolveNameInPrefixScope(const LibraryPrefix& prefix,
+RawClass* Parser::ResolveClassInPrefixScope(const LibraryPrefix& prefix,
const String& name) {
HANDLESCOPE(isolate());
- return prefix.LookupObject(name);
-}
-
-
-RawClass* Parser::ResolveClassInPrefixScope(const LibraryPrefix& prefix,
- const String& name) {
- const Object& obj =
- Object::Handle(ResolveNameInPrefixScope(prefix, name));
+ const Object& obj = Object::Handle(prefix.LookupObject(name));
if (obj.IsClass()) {
return Class::Cast(obj).raw();
}
@@ -9207,7 +9166,8 @@
const LibraryPrefix& prefix,
const String& ident) {
TRACE_PARSER("ResolveIdentInPrefixScope");
- Object& obj = Object::Handle(ResolveNameInPrefixScope(prefix, ident));
+ HANDLESCOPE(isolate());
+ Object& obj = Object::Handle(prefix.LookupObject(ident));
if (obj.IsNull()) {
// Unresolved prefixed primary identifier.
String& qualified_name = String::ZoneHandle(prefix.name());
« runtime/vm/object.cc ('K') | « runtime/vm/parser.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698