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

Unified Diff: runtime/vm/resolver.cc

Issue 19662003: Refactor resolution code in the vm to properly handle ambiguity errors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 | « runtime/vm/resolver.h ('k') | runtime/vm/resolver_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/resolver.cc
===================================================================
--- runtime/vm/resolver.cc (revision 25321)
+++ runtime/vm/resolver.cc (working copy)
@@ -150,12 +150,14 @@
const String& function_name,
intptr_t num_arguments,
const Array& argument_names,
- StaticResolveType resolve_type) {
+ StaticResolveType resolve_type,
+ String* ambiguity_error_msg) {
ASSERT(!library.IsNull());
Function& function = Function::Handle();
if (class_name.IsNull() || (class_name.Length() == 0)) {
// Check if we are referring to a top level function.
- const Object& object = Object::Handle(library.LookupObject(function_name));
+ const Object& object = Object::Handle(
+ library.LookupObject(function_name, ambiguity_error_msg));
if (!object.IsNull() && object.IsFunction()) {
function ^= object.raw();
if (!function.AreValidArguments(num_arguments, argument_names, NULL)) {
@@ -174,19 +176,31 @@
} else {
if (FLAG_trace_resolving) {
OS::Print("ResolveStatic error '%s': %s.\n",
- function_name.ToCString(), "top level function not found");
+ function_name.ToCString(),
+ ambiguity_error_msg->IsNull() ? "top level function not found"
+ : ambiguity_error_msg->ToCString());
}
}
} else {
// Lookup class_name in the library's class dictionary to get at
// the dart class object. If class_name is not found in the dictionary
// ResolveStatic will return a NULL function object.
- const Class& cls = Class::Handle(library.LookupClass(class_name));
- function = ResolveStatic(cls,
- function_name,
- num_arguments,
- argument_names,
- resolve_type);
+ const Class& cls = Class::Handle(
+ library.LookupClass(class_name, ambiguity_error_msg));
+ if (!cls.IsNull()) {
+ function = ResolveStatic(cls,
+ function_name,
+ num_arguments,
+ argument_names,
+ resolve_type);
+ }
+ if (FLAG_trace_resolving && function.IsNull()) {
+ OS::Print("ResolveStatic error '%s.%s': %s.\n",
+ class_name.ToCString(),
+ function_name.ToCString(),
+ ambiguity_error_msg->IsNull() ? "static function not found"
+ : ambiguity_error_msg->ToCString());
+ }
}
return function.raw();
}
@@ -195,10 +209,7 @@
RawFunction* Resolver::ResolveStaticByName(const Class& cls,
const String& function_name,
StaticResolveType resolve_type) {
- if (cls.IsNull()) {
- // Can't resolve function if cls is null.
- return Function::null();
- }
+ ASSERT(!cls.IsNull());
if (FLAG_trace_resolving) {
OS::Print("ResolveStatic '%s'\n", function_name.ToCString());
@@ -227,6 +238,7 @@
intptr_t num_arguments,
const Array& argument_names,
StaticResolveType resolve_type) {
+ ASSERT(!cls.IsNull());
const Function& function = Function::Handle(
ResolveStaticByName(cls, function_name, resolve_type));
if (function.IsNull() ||
« no previous file with comments | « runtime/vm/resolver.h ('k') | runtime/vm/resolver_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698