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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 4959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4970 RETURN_TYPE_ERROR(isolate, source, String); | 4970 RETURN_TYPE_ERROR(isolate, source, String); |
4971 } | 4971 } |
4972 CHECK_CALLBACK_STATE(isolate); | 4972 CHECK_CALLBACK_STATE(isolate); |
4973 | 4973 |
4974 NoHeapGrowthControlScope no_growth_control; | 4974 NoHeapGrowthControlScope no_growth_control; |
4975 | 4975 |
4976 Library& library = Library::Handle(isolate, Library::LookupLibrary(url_str)); | 4976 Library& library = Library::Handle(isolate, Library::LookupLibrary(url_str)); |
4977 if (library.IsNull()) { | 4977 if (library.IsNull()) { |
4978 library = Library::New(url_str); | 4978 library = Library::New(url_str); |
4979 library.Register(); | 4979 library.Register(); |
4980 } else if (!library.LoadNotStarted()) { | 4980 } else if (library.LoadInProgress() || |
| 4981 library.Loaded() || |
| 4982 library.LoadError()) { |
4981 // The source for this library has either been loaded or is in the | 4983 // The source for this library has either been loaded or is in the |
4982 // process of loading. Return an error. | 4984 // process of loading. Return an error. |
4983 return Api::NewError("%s: library '%s' has already been loaded.", | 4985 return Api::NewError("%s: library '%s' has already been loaded.", |
4984 CURRENT_FUNC, url_str.ToCString()); | 4986 CURRENT_FUNC, url_str.ToCString()); |
4985 } | 4987 } |
4986 const Script& script = Script::Handle( | 4988 const Script& script = Script::Handle( |
4987 isolate, Script::New(url_str, source_str, RawScript::kLibraryTag)); | 4989 isolate, Script::New(url_str, source_str, RawScript::kLibraryTag)); |
4988 Dart_Handle result; | 4990 Dart_Handle result; |
4989 CompileSource(isolate, library, script, &result); | 4991 CompileSource(isolate, library, script, &result); |
4990 // Propagate the error out right now. | 4992 // Propagate the error out right now. |
4991 if (::Dart_IsError(result)) { | 4993 if (::Dart_IsError(result)) { |
4992 return result; | 4994 return result; |
4993 } | 4995 } |
4994 | 4996 |
4995 // If this is the dart:builtin library, register it with the VM. | 4997 // If this is the dart:_builtin library, register it with the VM. |
4996 if (url_str.Equals("dart:builtin")) { | 4998 if (url_str.Equals("dart:_builtin")) { |
4997 isolate->object_store()->set_builtin_library(library); | 4999 isolate->object_store()->set_builtin_library(library); |
4998 Dart_Handle state = Api::CheckIsolateState(isolate); | 5000 Dart_Handle state = Api::CheckIsolateState(isolate); |
4999 if (::Dart_IsError(state)) { | 5001 if (::Dart_IsError(state)) { |
5000 return state; | 5002 return state; |
5001 } | 5003 } |
5002 } | 5004 } |
5003 return result; | 5005 return result; |
5004 } | 5006 } |
5005 | 5007 |
5006 | 5008 |
(...skipping 25 matching lines...) Expand all Loading... |
5032 const Namespace& import_ns = Namespace::Handle( | 5034 const Namespace& import_ns = Namespace::Handle( |
5033 Namespace::New(import_vm, Object::null_array(), Object::null_array())); | 5035 Namespace::New(import_vm, Object::null_array(), Object::null_array())); |
5034 if (prefix_vm.Length() == 0) { | 5036 if (prefix_vm.Length() == 0) { |
5035 library_vm.AddImport(import_ns); | 5037 library_vm.AddImport(import_ns); |
5036 } else { | 5038 } else { |
5037 LibraryPrefix& library_prefix = LibraryPrefix::Handle(); | 5039 LibraryPrefix& library_prefix = LibraryPrefix::Handle(); |
5038 library_prefix = library_vm.LookupLocalLibraryPrefix(prefix_symbol); | 5040 library_prefix = library_vm.LookupLocalLibraryPrefix(prefix_symbol); |
5039 if (!library_prefix.IsNull()) { | 5041 if (!library_prefix.IsNull()) { |
5040 library_prefix.AddImport(import_ns); | 5042 library_prefix.AddImport(import_ns); |
5041 } else { | 5043 } else { |
5042 library_prefix = LibraryPrefix::New(prefix_symbol, import_ns, false); | 5044 library_prefix = |
| 5045 LibraryPrefix::New(prefix_symbol, import_ns, false, library_vm); |
5043 library_vm.AddObject(library_prefix, prefix_symbol); | 5046 library_vm.AddObject(library_prefix, prefix_symbol); |
5044 } | 5047 } |
5045 } | 5048 } |
5046 return Api::Success(); | 5049 return Api::Success(); |
5047 } | 5050 } |
5048 | 5051 |
5049 | 5052 |
5050 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library, | 5053 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library, |
5051 Dart_Handle url, | 5054 Dart_Handle url, |
5052 Dart_Handle source) { | 5055 Dart_Handle source) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5189 | 5192 |
5190 | 5193 |
5191 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 5194 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
5192 const char* name, | 5195 const char* name, |
5193 Dart_ServiceRequestCallback callback, | 5196 Dart_ServiceRequestCallback callback, |
5194 void* user_data) { | 5197 void* user_data) { |
5195 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 5198 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
5196 } | 5199 } |
5197 | 5200 |
5198 } // namespace dart | 5201 } // namespace dart |
OLD | NEW |