mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 14:32:24 +00:00
- Make sure to lookup main in re-exported namespaces too. R=asiva@google.com Review URL: https://codereview.chromium.org//864233003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43078 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
03aa9c33e5
commit
fc044a7294
4 changed files with 64 additions and 18 deletions
|
@ -1569,31 +1569,46 @@ IsolateSpawnState::~IsolateSpawnState() {
|
|||
|
||||
|
||||
RawObject* IsolateSpawnState::ResolveFunction() {
|
||||
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 resolve function '%s' in script '%s'.",
|
||||
function_name(), script_url()));
|
||||
return LanguageError::New(msg);
|
||||
}
|
||||
return func.raw();
|
||||
}
|
||||
|
||||
ASSERT(script_url() == NULL);
|
||||
// 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);
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
lib = I->object_store()->root_library();
|
||||
}
|
||||
ASSERT(!lib.IsNull());
|
||||
|
||||
// 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();
|
||||
|
|
5
tests/isolate/spawn_uri_exported_main.dart
Normal file
5
tests/isolate/spawn_uri_exported_main.dart
Normal file
|
@ -0,0 +1,5 @@
|
|||
export "spawn_uri_exported_main_lib.dart";
|
||||
|
||||
maine() {
|
||||
print("This is not the maine you are looking for.");
|
||||
}
|
6
tests/isolate/spawn_uri_exported_main_lib.dart
Normal file
6
tests/isolate/spawn_uri_exported_main_lib.dart
Normal file
|
@ -0,0 +1,6 @@
|
|||
library spawn_uri_exported_main_lib;
|
||||
|
||||
main(args, msg) {
|
||||
print("From main!");
|
||||
msg.send(50);
|
||||
}
|
20
tests/isolate/spawn_uri_exported_main_test.dart
Normal file
20
tests/isolate/spawn_uri_exported_main_test.dart
Normal file
|
@ -0,0 +1,20 @@
|
|||
import "dart:async";
|
||||
import "dart:isolate";
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
print("Spawning isolate.");
|
||||
var t = new Timer(new Duration(seconds:5), () {
|
||||
Expect.fail("Isolate was not spawned successfully.");
|
||||
});
|
||||
var rp = new RawReceivePort();
|
||||
rp.handler = (msg) {
|
||||
print("Spawned main called.");
|
||||
Expect.equals(msg, 50);
|
||||
rp.close();
|
||||
};
|
||||
Isolate.spawnUri(Uri.parse("spawn_uri_exported_main.dart"), null, rp.sendPort).then((_) {
|
||||
print("Loaded");
|
||||
t.cancel();
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue