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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/isolate/spawn_uri_exported_main.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/isolate.h" 5 #include "vm/isolate.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/json.h" 9 #include "platform/json.h"
10 #include "vm/code_observers.h" 10 #include "vm/code_observers.h"
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 free(package_root_); 1562 free(package_root_);
1563 free(library_url_); 1563 free(library_url_);
1564 free(function_name_); 1564 free(function_name_);
1565 free(class_name_); 1565 free(class_name_);
1566 free(serialized_args_); 1566 free(serialized_args_);
1567 free(serialized_message_); 1567 free(serialized_message_);
1568 } 1568 }
1569 1569
1570 1570
1571 RawObject* IsolateSpawnState::ResolveFunction() { 1571 RawObject* IsolateSpawnState::ResolveFunction() {
1572 // Resolve the library. 1572 const String& func_name = String::Handle(String::New(function_name()));
1573 Library& lib = Library::Handle(); 1573
1574 if (library_url()) { 1574 if (library_url() == NULL) {
1575 const String& lib_url = String::Handle(String::New(library_url())); 1575 // Handle spawnUri lookup rules.
1576 lib = Library::LookupLibrary(lib_url); 1576 // Check whether the root library defines a main function.
1577 if (lib.IsNull() || lib.IsError()) { 1577 const Library& lib = Library::Handle(I->object_store()->root_library());
1578 Function& func = Function::Handle(lib.LookupLocalFunction(func_name));
1579 if (func.IsNull()) {
1580 // Check whether main is reexported from the root library.
1581 const Object& obj = Object::Handle(lib.LookupReExport(func_name));
1582 if (obj.IsFunction()) {
1583 func ^= obj.raw();
1584 }
1585 }
1586 if (func.IsNull()) {
1578 const String& msg = String::Handle(String::NewFormatted( 1587 const String& msg = String::Handle(String::NewFormatted(
1579 "Unable to find library '%s'.", library_url())); 1588 "Unable to resolve function '%s' in script '%s'.",
1589 function_name(), script_url()));
1580 return LanguageError::New(msg); 1590 return LanguageError::New(msg);
1581 } 1591 }
1582 } else { 1592 return func.raw();
1583 lib = I->object_store()->root_library();
1584 } 1593 }
1585 ASSERT(!lib.IsNull()); 1594
1595 ASSERT(script_url() == NULL);
1596 // Resolve the library.
1597 const String& lib_url = String::Handle(String::New(library_url()));
1598 const Library& lib = Library::Handle(Library::LookupLibrary(lib_url));
1599 if (lib.IsNull() || lib.IsError()) {
1600 const String& msg = String::Handle(String::NewFormatted(
1601 "Unable to find library '%s'.", library_url()));
1602 return LanguageError::New(msg);
1603 }
1586 1604
1587 // Resolve the function. 1605 // Resolve the function.
1588 const String& func_name = String::Handle(String::New(function_name()));
1589
1590 if (class_name() == NULL) { 1606 if (class_name() == NULL) {
1591 const Function& func = Function::Handle(lib.LookupLocalFunction(func_name)); 1607 const Function& func = Function::Handle(lib.LookupLocalFunction(func_name));
1592 if (func.IsNull()) { 1608 if (func.IsNull()) {
1593 const String& msg = String::Handle(String::NewFormatted( 1609 const String& msg = String::Handle(String::NewFormatted(
1594 "Unable to resolve function '%s' in library '%s'.", 1610 "Unable to resolve function '%s' in library '%s'.",
1595 function_name(), 1611 function_name(), library_url()));
1596 (library_url() != NULL ? library_url() : script_url())));
1597 return LanguageError::New(msg); 1612 return LanguageError::New(msg);
1598 } 1613 }
1599 return func.raw(); 1614 return func.raw();
1600 } 1615 }
1601 1616
1602 const String& cls_name = String::Handle(String::New(class_name())); 1617 const String& cls_name = String::Handle(String::New(class_name()));
1603 const Class& cls = Class::Handle(lib.LookupLocalClass(cls_name)); 1618 const Class& cls = Class::Handle(lib.LookupLocalClass(cls_name));
1604 if (cls.IsNull()) { 1619 if (cls.IsNull()) {
1605 const String& msg = String::Handle(String::NewFormatted( 1620 const String& msg = String::Handle(String::NewFormatted(
1606 "Unable to resolve class '%s' in library '%s'.", 1621 "Unable to resolve class '%s' in library '%s'.",
(...skipping 24 matching lines...) Expand all
1631 serialized_message_, serialized_message_len_); 1646 serialized_message_, serialized_message_len_);
1632 } 1647 }
1633 1648
1634 1649
1635 void IsolateSpawnState::Cleanup() { 1650 void IsolateSpawnState::Cleanup() {
1636 SwitchIsolateScope switch_scope(I); 1651 SwitchIsolateScope switch_scope(I);
1637 Dart::ShutdownIsolate(); 1652 Dart::ShutdownIsolate();
1638 } 1653 }
1639 1654
1640 } // namespace dart 1655 } // namespace dart
OLDNEW
« 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