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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 328923002: Lazy loading of deferred libraries (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/object.h » ('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 "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
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.LoadNotStarted() || library.LoadRequested())) {
Ivan Posva 2014/06/13 18:26:39 Double negative makes it hard to understand what i
hausner 2014/06/13 22:41:57 The comment was supposed to make it clearer. Chang
4981 // The source for this library has either been loaded or is in the 4981 // The source for this library has either been loaded or is in the
4982 // process of loading. Return an error. 4982 // process of loading. Return an error.
4983 return Api::NewError("%s: library '%s' has already been loaded.", 4983 return Api::NewError("%s: library '%s' has already been loaded.",
4984 CURRENT_FUNC, url_str.ToCString()); 4984 CURRENT_FUNC, url_str.ToCString());
4985 } 4985 }
4986 const Script& script = Script::Handle( 4986 const Script& script = Script::Handle(
4987 isolate, Script::New(url_str, source_str, RawScript::kLibraryTag)); 4987 isolate, Script::New(url_str, source_str, RawScript::kLibraryTag));
4988 Dart_Handle result; 4988 Dart_Handle result;
4989 CompileSource(isolate, library, script, &result); 4989 CompileSource(isolate, library, script, &result);
4990 // Propagate the error out right now. 4990 // Propagate the error out right now.
4991 if (::Dart_IsError(result)) { 4991 if (::Dart_IsError(result)) {
4992 return result; 4992 return result;
4993 } 4993 }
4994 4994
4995 // If this is the dart:builtin library, register it with the VM. 4995 // If this is the dart:_builtin library, register it with the VM.
4996 if (url_str.Equals("dart:builtin")) { 4996 if (url_str.Equals("dart:_builtin")) {
4997 isolate->object_store()->set_builtin_library(library); 4997 isolate->object_store()->set_builtin_library(library);
4998 Dart_Handle state = Api::CheckIsolateState(isolate); 4998 Dart_Handle state = Api::CheckIsolateState(isolate);
4999 if (::Dart_IsError(state)) { 4999 if (::Dart_IsError(state)) {
5000 return state; 5000 return state;
5001 } 5001 }
5002 } 5002 }
5003 return result; 5003 return result;
5004 } 5004 }
5005 5005
5006 5006
(...skipping 25 matching lines...) Expand all
5032 const Namespace& import_ns = Namespace::Handle( 5032 const Namespace& import_ns = Namespace::Handle(
5033 Namespace::New(import_vm, Object::null_array(), Object::null_array())); 5033 Namespace::New(import_vm, Object::null_array(), Object::null_array()));
5034 if (prefix_vm.Length() == 0) { 5034 if (prefix_vm.Length() == 0) {
5035 library_vm.AddImport(import_ns); 5035 library_vm.AddImport(import_ns);
5036 } else { 5036 } else {
5037 LibraryPrefix& library_prefix = LibraryPrefix::Handle(); 5037 LibraryPrefix& library_prefix = LibraryPrefix::Handle();
5038 library_prefix = library_vm.LookupLocalLibraryPrefix(prefix_symbol); 5038 library_prefix = library_vm.LookupLocalLibraryPrefix(prefix_symbol);
5039 if (!library_prefix.IsNull()) { 5039 if (!library_prefix.IsNull()) {
5040 library_prefix.AddImport(import_ns); 5040 library_prefix.AddImport(import_ns);
5041 } else { 5041 } else {
5042 library_prefix = LibraryPrefix::New(prefix_symbol, import_ns, false); 5042 library_prefix =
5043 LibraryPrefix::New(prefix_symbol, import_ns, false, library_vm);
5043 library_vm.AddObject(library_prefix, prefix_symbol); 5044 library_vm.AddObject(library_prefix, prefix_symbol);
5044 } 5045 }
5045 } 5046 }
5046 return Api::Success(); 5047 return Api::Success();
5047 } 5048 }
5048 5049
5049 5050
5050 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library, 5051 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library,
5051 Dart_Handle url, 5052 Dart_Handle url,
5052 Dart_Handle source) { 5053 Dart_Handle source) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
5189 5190
5190 5191
5191 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( 5192 DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
5192 const char* name, 5193 const char* name,
5193 Dart_ServiceRequestCallback callback, 5194 Dart_ServiceRequestCallback callback,
5194 void* user_data) { 5195 void* user_data) {
5195 Service::RegisterRootEmbedderCallback(name, callback, user_data); 5196 Service::RegisterRootEmbedderCallback(name, callback, user_data);
5196 } 5197 }
5197 5198
5198 } // namespace dart 5199 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698