| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 2966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2977 const Array& mapping_array = Api::UnwrapArrayHandle(import_map); | 2977 const Array& mapping_array = Api::UnwrapArrayHandle(import_map); |
| 2978 Library& library = Library::Handle(Library::LookupLibrary(url_str)); | 2978 Library& library = Library::Handle(Library::LookupLibrary(url_str)); |
| 2979 if (library.IsNull()) { | 2979 if (library.IsNull()) { |
| 2980 library = Library::New(url_str); | 2980 library = Library::New(url_str); |
| 2981 if (mapping_array.IsNull()) { | 2981 if (mapping_array.IsNull()) { |
| 2982 library.set_import_map(Array::Handle(Array::Empty())); | 2982 library.set_import_map(Array::Handle(Array::Empty())); |
| 2983 } else { | 2983 } else { |
| 2984 library.set_import_map(mapping_array); | 2984 library.set_import_map(mapping_array); |
| 2985 } | 2985 } |
| 2986 library.Register(); | 2986 library.Register(); |
| 2987 // If this is the dart:builtin library register it with the VM. | |
| 2988 if (url_str.Equals("dart:builtin")) { | |
| 2989 isolate->object_store()->set_builtin_library(library); | |
| 2990 const char* msg = CheckIsolateState(isolate); | |
| 2991 if (msg != NULL) { | |
| 2992 return Api::NewError(msg); | |
| 2993 } | |
| 2994 } | |
| 2995 } else if (!library.LoadNotStarted()) { | 2987 } else if (!library.LoadNotStarted()) { |
| 2996 // The source for this library has either been loaded or is in the | 2988 // The source for this library has either been loaded or is in the |
| 2997 // process of loading. Return an error. | 2989 // process of loading. Return an error. |
| 2998 return Api::NewError("%s: library '%s' has already been loaded.", | 2990 return Api::NewError("%s: library '%s' has already been loaded.", |
| 2999 CURRENT_FUNC, url_str.ToCString()); | 2991 CURRENT_FUNC, url_str.ToCString()); |
| 3000 } | 2992 } |
| 3001 Dart_Handle result; | 2993 Dart_Handle result; |
| 3002 CompileSource(isolate, | 2994 CompileSource(isolate, |
| 3003 library, | 2995 library, |
| 3004 url_str, | 2996 url_str, |
| 3005 source_str, | 2997 source_str, |
| 3006 RawScript::kLibrary, | 2998 RawScript::kLibrary, |
| 3007 &result); | 2999 &result); |
| 3000 // Propagate the error out right now. |
| 3001 if (Dart_IsError(result)) { |
| 3002 return result; |
| 3003 } |
| 3004 |
| 3005 // If this is the dart:builtin library register it with the VM. |
| 3006 if (url_str.Equals("dart:builtin")) { |
| 3007 isolate->object_store()->set_builtin_library(library); |
| 3008 const char* msg = CheckIsolateState(isolate); |
| 3009 if (msg != NULL) { |
| 3010 return Api::NewError(msg); |
| 3011 } |
| 3012 } |
| 3008 return result; | 3013 return result; |
| 3009 } | 3014 } |
| 3010 | 3015 |
| 3011 | 3016 |
| 3012 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, | 3017 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, |
| 3013 Dart_Handle import) { | 3018 Dart_Handle import) { |
| 3014 DARTSCOPE(Isolate::Current()); | 3019 DARTSCOPE(Isolate::Current()); |
| 3015 const Library& library_vm = Api::UnwrapLibraryHandle(library); | 3020 const Library& library_vm = Api::UnwrapLibraryHandle(library); |
| 3016 if (library_vm.IsNull()) { | 3021 if (library_vm.IsNull()) { |
| 3017 RETURN_TYPE_ERROR(library, Library); | 3022 RETURN_TYPE_ERROR(library, Library); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3086 *buffer = NULL; | 3091 *buffer = NULL; |
| 3087 } | 3092 } |
| 3088 delete debug_region; | 3093 delete debug_region; |
| 3089 } else { | 3094 } else { |
| 3090 *buffer = NULL; | 3095 *buffer = NULL; |
| 3091 *buffer_size = 0; | 3096 *buffer_size = 0; |
| 3092 } | 3097 } |
| 3093 } | 3098 } |
| 3094 | 3099 |
| 3095 } // namespace dart | 3100 } // namespace dart |
| OLD | NEW |