| 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 2976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2987 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 2987 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
| 2988 Isolate* isolate = arguments->isolate(); | 2988 Isolate* isolate = arguments->isolate(); |
| 2989 DARTSCOPE(isolate); | 2989 DARTSCOPE(isolate); |
| 2990 arguments->SetReturn(Object::Handle(isolate, Api::UnwrapHandle(retval))); | 2990 arguments->SetReturn(Object::Handle(isolate, Api::UnwrapHandle(retval))); |
| 2991 } | 2991 } |
| 2992 | 2992 |
| 2993 | 2993 |
| 2994 // --- Scripts and Libraries --- | 2994 // --- Scripts and Libraries --- |
| 2995 | 2995 |
| 2996 | 2996 |
| 2997 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( |
| 2998 Dart_LibraryTagHandler handler) { |
| 2999 Isolate* isolate = Isolate::Current(); |
| 3000 CHECK_ISOLATE(isolate); |
| 3001 isolate->set_library_tag_handler(handler); |
| 3002 return Api::Success(isolate); |
| 3003 } |
| 3004 |
| 3005 |
| 2997 // NOTE: Need to pass 'result' as a parameter here in order to avoid | 3006 // NOTE: Need to pass 'result' as a parameter here in order to avoid |
| 2998 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' | 3007 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' |
| 2999 // which shows up because of the use of setjmp. | 3008 // which shows up because of the use of setjmp. |
| 3000 static void CompileSource(Isolate* isolate, | 3009 static void CompileSource(Isolate* isolate, |
| 3001 const Library& lib, | 3010 const Library& lib, |
| 3002 const String& url, | 3011 const String& url, |
| 3003 const String& source, | 3012 const String& source, |
| 3004 RawScript::Kind kind, | 3013 RawScript::Kind kind, |
| 3005 Dart_Handle* result) { | 3014 Dart_Handle* result) { |
| 3006 bool update_lib_status = (kind == RawScript::kScript || | 3015 bool update_lib_status = (kind == RawScript::kScript || |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3021 *result = Api::NewHandle(isolate, error.raw()); | 3030 *result = Api::NewHandle(isolate, error.raw()); |
| 3022 if (update_lib_status) { | 3031 if (update_lib_status) { |
| 3023 lib.SetLoadError(); | 3032 lib.SetLoadError(); |
| 3024 } | 3033 } |
| 3025 } | 3034 } |
| 3026 } | 3035 } |
| 3027 | 3036 |
| 3028 | 3037 |
| 3029 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, | 3038 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, |
| 3030 Dart_Handle source, | 3039 Dart_Handle source, |
| 3031 Dart_LibraryTagHandler handler, | |
| 3032 Dart_Handle import_map) { | 3040 Dart_Handle import_map) { |
| 3033 TIMERSCOPE(time_script_loading); | 3041 TIMERSCOPE(time_script_loading); |
| 3034 Isolate* isolate = Isolate::Current(); | 3042 Isolate* isolate = Isolate::Current(); |
| 3035 DARTSCOPE(isolate); | 3043 DARTSCOPE(isolate); |
| 3036 const String& url_str = Api::UnwrapStringHandle(isolate, url); | 3044 const String& url_str = Api::UnwrapStringHandle(isolate, url); |
| 3037 if (url_str.IsNull()) { | 3045 if (url_str.IsNull()) { |
| 3038 RETURN_TYPE_ERROR(isolate, url, String); | 3046 RETURN_TYPE_ERROR(isolate, url, String); |
| 3039 } | 3047 } |
| 3040 const String& source_str = Api::UnwrapStringHandle(isolate, source); | 3048 const String& source_str = Api::UnwrapStringHandle(isolate, source); |
| 3041 if (source_str.IsNull()) { | 3049 if (source_str.IsNull()) { |
| 3042 RETURN_TYPE_ERROR(isolate, source, String); | 3050 RETURN_TYPE_ERROR(isolate, source, String); |
| 3043 } | 3051 } |
| 3044 const Array& mapping_array = Api::UnwrapArrayHandle(isolate, import_map); | 3052 const Array& mapping_array = Api::UnwrapArrayHandle(isolate, import_map); |
| 3045 Library& library = | 3053 Library& library = |
| 3046 Library::Handle(isolate, isolate->object_store()->root_library()); | 3054 Library::Handle(isolate, isolate->object_store()->root_library()); |
| 3047 if (!library.IsNull()) { | 3055 if (!library.IsNull()) { |
| 3048 const String& library_url = String::Handle(isolate, library.url()); | 3056 const String& library_url = String::Handle(isolate, library.url()); |
| 3049 return Api::NewError("%s: A script has already been loaded from '%s'.", | 3057 return Api::NewError("%s: A script has already been loaded from '%s'.", |
| 3050 CURRENT_FUNC, library_url.ToCString()); | 3058 CURRENT_FUNC, library_url.ToCString()); |
| 3051 } | 3059 } |
| 3052 isolate->set_library_tag_handler(handler); | |
| 3053 library = Library::New(url_str); | 3060 library = Library::New(url_str); |
| 3054 if (mapping_array.IsNull()) { | 3061 if (mapping_array.IsNull()) { |
| 3055 library.set_import_map(Array::Handle(isolate, Array::Empty())); | 3062 library.set_import_map(Array::Handle(isolate, Array::Empty())); |
| 3056 } else { | 3063 } else { |
| 3057 library.set_import_map(mapping_array); | 3064 library.set_import_map(mapping_array); |
| 3058 } | 3065 } |
| 3059 library.Register(); | 3066 library.Register(); |
| 3060 isolate->object_store()->set_root_library(library); | 3067 isolate->object_store()->set_root_library(library); |
| 3061 Dart_Handle result; | 3068 Dart_Handle result; |
| 3062 CompileSource(isolate, | 3069 CompileSource(isolate, |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3322 *buffer = NULL; | 3329 *buffer = NULL; |
| 3323 } | 3330 } |
| 3324 delete debug_region; | 3331 delete debug_region; |
| 3325 } else { | 3332 } else { |
| 3326 *buffer = NULL; | 3333 *buffer = NULL; |
| 3327 *buffer_size = 0; | 3334 *buffer_size = 0; |
| 3328 } | 3335 } |
| 3329 } | 3336 } |
| 3330 | 3337 |
| 3331 } // namespace dart | 3338 } // namespace dart |
| OLD | NEW |