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

Unified Diff: runtime/vm/isolate.cc

Issue 864233003: Fix http://dartbug.com/22115 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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 | tests/isolate/spawn_uri_exported_main.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
===================================================================
--- runtime/vm/isolate.cc (revision 42999)
+++ runtime/vm/isolate.cc (working copy)
@@ -1569,31 +1569,46 @@
RawObject* IsolateSpawnState::ResolveFunction() {
- // Resolve the library.
- Library& lib = Library::Handle();
- if (library_url()) {
- const String& lib_url = String::Handle(String::New(library_url()));
- lib = Library::LookupLibrary(lib_url);
- if (lib.IsNull() || lib.IsError()) {
+ const String& func_name = String::Handle(String::New(function_name()));
+
+ if (library_url() == NULL) {
+ // Handle spawnUri lookup rules.
+ // Check whether the root library defines a main function.
+ const Library& lib = Library::Handle(I->object_store()->root_library());
+ Function& func = Function::Handle(lib.LookupLocalFunction(func_name));
+ if (func.IsNull()) {
+ // Check whether main is reexported from the root library.
+ const Object& obj = Object::Handle(lib.LookupReExport(func_name));
+ if (obj.IsFunction()) {
+ func ^= obj.raw();
+ }
+ }
+ if (func.IsNull()) {
const String& msg = String::Handle(String::NewFormatted(
- "Unable to find library '%s'.", library_url()));
+ "Unable to resolve function '%s' in script '%s'.",
+ function_name(), script_url()));
return LanguageError::New(msg);
}
- } else {
- lib = I->object_store()->root_library();
+ return func.raw();
}
- ASSERT(!lib.IsNull());
+ ASSERT(script_url() == NULL);
+ // Resolve the library.
+ const String& lib_url = String::Handle(String::New(library_url()));
+ const Library& lib = Library::Handle(Library::LookupLibrary(lib_url));
+ if (lib.IsNull() || lib.IsError()) {
+ const String& msg = String::Handle(String::NewFormatted(
+ "Unable to find library '%s'.", library_url()));
+ return LanguageError::New(msg);
+ }
+
// Resolve the function.
- const String& func_name = String::Handle(String::New(function_name()));
-
if (class_name() == NULL) {
const Function& func = Function::Handle(lib.LookupLocalFunction(func_name));
if (func.IsNull()) {
const String& msg = String::Handle(String::NewFormatted(
"Unable to resolve function '%s' in library '%s'.",
- function_name(),
- (library_url() != NULL ? library_url() : script_url())));
+ function_name(), library_url()));
return LanguageError::New(msg);
}
return func.raw();
« no previous file with comments | « no previous file | tests/isolate/spawn_uri_exported_main.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698