Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "lib/mirrors.h" | 10 #include "lib/mirrors.h" |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 989 T* handle = reinterpret_cast<T*>(reusable_handles_.AllocateScopedHandle()); | 989 T* handle = reinterpret_cast<T*>(reusable_handles_.AllocateScopedHandle()); |
| 990 T::initializeHandle(handle, T::null()); | 990 T::initializeHandle(handle, T::null()); |
| 991 return handle; | 991 return handle; |
| 992 } | 992 } |
| 993 | 993 |
| 994 | 994 |
| 995 IsolateSpawnState::IsolateSpawnState(const Function& func) | 995 IsolateSpawnState::IsolateSpawnState(const Function& func) |
| 996 : isolate_(NULL), | 996 : isolate_(NULL), |
| 997 script_url_(NULL), | 997 script_url_(NULL), |
| 998 library_url_(NULL), | 998 library_url_(NULL), |
| 999 class_name_(NULL), | |
| 999 function_name_(NULL), | 1000 function_name_(NULL), |
| 1000 exception_callback_name_(NULL) { | 1001 exception_callback_name_(NULL) { |
| 1001 script_url_ = NULL; | 1002 script_url_ = NULL; |
| 1002 const Class& cls = Class::Handle(func.Owner()); | 1003 const Class& cls = Class::Handle(func.Owner()); |
| 1003 ASSERT(cls.IsTopLevel()); | |
| 1004 const Library& lib = Library::Handle(cls.library()); | 1004 const Library& lib = Library::Handle(cls.library()); |
| 1005 const String& lib_url = String::Handle(lib.url()); | 1005 const String& lib_url = String::Handle(lib.url()); |
| 1006 library_url_ = strdup(lib_url.ToCString()); | 1006 library_url_ = strdup(lib_url.ToCString()); |
| 1007 | 1007 |
| 1008 const String& func_name = String::Handle(func.name()); | 1008 const String& func_name = String::Handle(func.name()); |
| 1009 function_name_ = strdup(func_name.ToCString()); | 1009 function_name_ = strdup(func_name.ToCString()); |
| 1010 if (!cls.IsTopLevel()) { | |
| 1011 const String& class_name = String::Handle(cls.Name()); | |
| 1012 class_name_ = strdup(class_name.ToCString()); | |
|
Ivan Posva
2013/11/12 07:19:49
Leak!
Lasse Reichstein Nielsen
2013/11/12 07:28:51
Beacuse I'm not freeing it somewhere else? (which
| |
| 1013 } | |
| 1010 exception_callback_name_ = strdup("_unhandledExceptionCallback"); | 1014 exception_callback_name_ = strdup("_unhandledExceptionCallback"); |
| 1011 } | 1015 } |
| 1012 | 1016 |
| 1013 | 1017 |
| 1014 IsolateSpawnState::IsolateSpawnState(const char* script_url) | 1018 IsolateSpawnState::IsolateSpawnState(const char* script_url) |
| 1015 : isolate_(NULL), | 1019 : isolate_(NULL), |
| 1016 library_url_(NULL), | 1020 library_url_(NULL), |
| 1017 function_name_(NULL), | 1021 function_name_(NULL), |
| 1018 exception_callback_name_(NULL) { | 1022 exception_callback_name_(NULL) { |
| 1019 script_url_ = strdup(script_url); | 1023 script_url_ = strdup(script_url); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1041 const String& msg = String::Handle(String::NewFormatted( | 1045 const String& msg = String::Handle(String::NewFormatted( |
| 1042 "Unable to find library '%s'.", library_url())); | 1046 "Unable to find library '%s'.", library_url())); |
| 1043 return LanguageError::New(msg); | 1047 return LanguageError::New(msg); |
| 1044 } | 1048 } |
| 1045 } else { | 1049 } else { |
| 1046 lib = isolate()->object_store()->root_library(); | 1050 lib = isolate()->object_store()->root_library(); |
| 1047 } | 1051 } |
| 1048 ASSERT(!lib.IsNull()); | 1052 ASSERT(!lib.IsNull()); |
| 1049 | 1053 |
| 1050 // Resolve the function. | 1054 // Resolve the function. |
| 1051 const String& func_name = | 1055 const String& func_name = String::Handle(String::New(function_name())); |
| 1052 String::Handle(String::New(function_name())); | 1056 |
| 1053 const Function& func = Function::Handle(lib.LookupLocalFunction(func_name)); | 1057 if (class_name() == NULL) { |
| 1058 const Function& func = Function::Handle(lib.LookupLocalFunction(func_name)); | |
| 1059 if (func.IsNull()) { | |
| 1060 const String& msg = String::Handle(String::NewFormatted( | |
| 1061 "Unable to resolve function '%s' in library '%s'.", | |
| 1062 function_name(), (library_url() ? library_url() : script_url()))); | |
|
Ivan Posva
2013/11/12 07:19:49
ditto (see below).
Lasse Reichstein Nielsen
2013/11/12 07:28:51
Done.
| |
| 1063 return LanguageError::New(msg); | |
| 1064 } | |
| 1065 return func.raw(); | |
| 1066 } | |
| 1067 | |
| 1068 const String& cls_name = String::Handle(String::New(class_name())); | |
| 1069 const Class& cls = Class::Handle(lib.LookupLocalClass(cls_name)); | |
| 1070 if (cls.IsNull()) { | |
| 1071 const String& msg = String::Handle(String::NewFormatted( | |
| 1072 "Unable to resolve class '%s' in library '%s'.", | |
| 1073 class_name(), (library_url() ? library_url() : script_url()))); | |
|
Ivan Posva
2013/11/12 07:19:49
I know this was already bad in the original code,
Lasse Reichstein Nielsen
2013/11/12 07:28:51
Done.
| |
| 1074 return LanguageError::New(msg); | |
| 1075 } | |
| 1076 const Function& func = | |
| 1077 Function::Handle(cls.LookupStaticFunctionAllowPrivate(func_name)); | |
| 1054 if (func.IsNull()) { | 1078 if (func.IsNull()) { |
| 1055 const String& msg = String::Handle(String::NewFormatted( | 1079 const String& msg = String::Handle(String::NewFormatted( |
| 1056 "Unable to resolve function '%s' in library '%s'.", | 1080 "Unable to resolve static method '%s.%s' in library '%s'.", |
| 1057 function_name(), (library_url() ? library_url() : script_url()))); | 1081 class_name(), function_name(), |
| 1082 (library_url() ? library_url() : script_url()))); | |
|
Ivan Posva
2013/11/12 07:19:49
ditto
Lasse Reichstein Nielsen
2013/11/12 07:28:51
Done.
| |
| 1058 return LanguageError::New(msg); | 1083 return LanguageError::New(msg); |
| 1059 } | 1084 } |
| 1060 return func.raw(); | 1085 return func.raw(); |
| 1061 } | 1086 } |
| 1062 | 1087 |
| 1063 | 1088 |
| 1064 void IsolateSpawnState::Cleanup() { | 1089 void IsolateSpawnState::Cleanup() { |
| 1065 SwitchIsolateScope switch_scope(isolate()); | 1090 SwitchIsolateScope switch_scope(isolate()); |
| 1066 Dart::ShutdownIsolate(); | 1091 Dart::ShutdownIsolate(); |
| 1067 } | 1092 } |
| 1068 | 1093 |
| 1069 } // namespace dart | 1094 } // namespace dart |
| OLD | NEW |