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

Side by Side Diff: vm/dart_api_impl.cc

Issue 10302020: Fix issue 2888. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 7 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 | « include/dart_api.h ('k') | vm/dart_api_impl_test.cc » ('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) 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 2946 matching lines...) Expand 10 before | Expand all | Expand 10 after
2957 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 2957 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
2958 Isolate* isolate = arguments->isolate(); 2958 Isolate* isolate = arguments->isolate();
2959 DARTSCOPE(isolate); 2959 DARTSCOPE(isolate);
2960 arguments->SetReturn(Object::Handle(isolate, Api::UnwrapHandle(retval))); 2960 arguments->SetReturn(Object::Handle(isolate, Api::UnwrapHandle(retval)));
2961 } 2961 }
2962 2962
2963 2963
2964 // --- Scripts and Libraries --- 2964 // --- Scripts and Libraries ---
2965 2965
2966 2966
2967 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler(
2968 Dart_LibraryTagHandler handler) {
2969 Isolate* isolate = Isolate::Current();
2970 CHECK_ISOLATE(isolate);
2971 isolate->set_library_tag_handler(handler);
2972 return Api::Success(isolate);
2973 }
2974
2975
2967 // NOTE: Need to pass 'result' as a parameter here in order to avoid 2976 // NOTE: Need to pass 'result' as a parameter here in order to avoid
2968 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' 2977 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork'
2969 // which shows up because of the use of setjmp. 2978 // which shows up because of the use of setjmp.
2970 static void CompileSource(Isolate* isolate, 2979 static void CompileSource(Isolate* isolate,
2971 const Library& lib, 2980 const Library& lib,
2972 const String& url, 2981 const String& url,
2973 const String& source, 2982 const String& source,
2974 RawScript::Kind kind, 2983 RawScript::Kind kind,
2975 Dart_Handle* result) { 2984 Dart_Handle* result) {
2976 bool update_lib_status = (kind == RawScript::kScript || 2985 bool update_lib_status = (kind == RawScript::kScript ||
(...skipping 14 matching lines...) Expand all
2991 *result = Api::NewHandle(isolate, error.raw()); 3000 *result = Api::NewHandle(isolate, error.raw());
2992 if (update_lib_status) { 3001 if (update_lib_status) {
2993 lib.SetLoadError(); 3002 lib.SetLoadError();
2994 } 3003 }
2995 } 3004 }
2996 } 3005 }
2997 3006
2998 3007
2999 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, 3008 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
3000 Dart_Handle source, 3009 Dart_Handle source,
3001 Dart_LibraryTagHandler handler,
3002 Dart_Handle import_map) { 3010 Dart_Handle import_map) {
3003 TIMERSCOPE(time_script_loading); 3011 TIMERSCOPE(time_script_loading);
3004 Isolate* isolate = Isolate::Current(); 3012 Isolate* isolate = Isolate::Current();
3005 DARTSCOPE(isolate); 3013 DARTSCOPE(isolate);
3006 const String& url_str = Api::UnwrapStringHandle(isolate, url); 3014 const String& url_str = Api::UnwrapStringHandle(isolate, url);
3007 if (url_str.IsNull()) { 3015 if (url_str.IsNull()) {
3008 RETURN_TYPE_ERROR(isolate, url, String); 3016 RETURN_TYPE_ERROR(isolate, url, String);
3009 } 3017 }
3010 const String& source_str = Api::UnwrapStringHandle(isolate, source); 3018 const String& source_str = Api::UnwrapStringHandle(isolate, source);
3011 if (source_str.IsNull()) { 3019 if (source_str.IsNull()) {
3012 RETURN_TYPE_ERROR(isolate, source, String); 3020 RETURN_TYPE_ERROR(isolate, source, String);
3013 } 3021 }
3014 const Array& mapping_array = Api::UnwrapArrayHandle(isolate, import_map); 3022 const Array& mapping_array = Api::UnwrapArrayHandle(isolate, import_map);
3015 Library& library = 3023 Library& library =
3016 Library::Handle(isolate, isolate->object_store()->root_library()); 3024 Library::Handle(isolate, isolate->object_store()->root_library());
3017 if (!library.IsNull()) { 3025 if (!library.IsNull()) {
3018 const String& library_url = String::Handle(isolate, library.url()); 3026 const String& library_url = String::Handle(isolate, library.url());
3019 return Api::NewError("%s: A script has already been loaded from '%s'.", 3027 return Api::NewError("%s: A script has already been loaded from '%s'.",
3020 CURRENT_FUNC, library_url.ToCString()); 3028 CURRENT_FUNC, library_url.ToCString());
3021 } 3029 }
3022 isolate->set_library_tag_handler(handler);
3023 library = Library::New(url_str); 3030 library = Library::New(url_str);
3024 if (mapping_array.IsNull()) { 3031 if (mapping_array.IsNull()) {
3025 library.set_import_map(Array::Handle(isolate, Array::Empty())); 3032 library.set_import_map(Array::Handle(isolate, Array::Empty()));
3026 } else { 3033 } else {
3027 library.set_import_map(mapping_array); 3034 library.set_import_map(mapping_array);
3028 } 3035 }
3029 library.Register(); 3036 library.Register();
3030 isolate->object_store()->set_root_library(library); 3037 isolate->object_store()->set_root_library(library);
3031 Dart_Handle result; 3038 Dart_Handle result;
3032 CompileSource(isolate, 3039 CompileSource(isolate,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
3292 *buffer = NULL; 3299 *buffer = NULL;
3293 } 3300 }
3294 delete debug_region; 3301 delete debug_region;
3295 } else { 3302 } else {
3296 *buffer = NULL; 3303 *buffer = NULL;
3297 *buffer_size = 0; 3304 *buffer_size = 0;
3298 } 3305 }
3299 } 3306 }
3300 3307
3301 } // namespace dart 3308 } // namespace dart
OLDNEW
« no previous file with comments | « include/dart_api.h ('k') | vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698