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

Side by Side Diff: vm/dart_api_impl.cc

Issue 9447041: Allow Dart_Null to be passed in for the import map in Dart_LoadLibrary and Dart_LoadScript. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 10 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 | « no previous file | 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 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 DARTSCOPE(isolate); 2444 DARTSCOPE(isolate);
2445 const String& url_str = Api::UnwrapStringHandle(url); 2445 const String& url_str = Api::UnwrapStringHandle(url);
2446 if (url_str.IsNull()) { 2446 if (url_str.IsNull()) {
2447 RETURN_TYPE_ERROR(url, String); 2447 RETURN_TYPE_ERROR(url, String);
2448 } 2448 }
2449 const String& source_str = Api::UnwrapStringHandle(source); 2449 const String& source_str = Api::UnwrapStringHandle(source);
2450 if (source_str.IsNull()) { 2450 if (source_str.IsNull()) {
2451 RETURN_TYPE_ERROR(source, String); 2451 RETURN_TYPE_ERROR(source, String);
2452 } 2452 }
2453 const Array& mapping_array = Api::UnwrapArrayHandle(import_map); 2453 const Array& mapping_array = Api::UnwrapArrayHandle(import_map);
2454 if (mapping_array.IsNull()) {
2455 RETURN_TYPE_ERROR(import_map, Array);
2456 }
2457 Library& library = Library::Handle(isolate->object_store()->root_library()); 2454 Library& library = Library::Handle(isolate->object_store()->root_library());
2458 if (!library.IsNull()) { 2455 if (!library.IsNull()) {
2459 const String& library_url = String::Handle(library.url()); 2456 const String& library_url = String::Handle(library.url());
2460 return Api::NewError("%s: A script has already been loaded from '%s'.", 2457 return Api::NewError("%s: A script has already been loaded from '%s'.",
2461 CURRENT_FUNC, library_url.ToCString()); 2458 CURRENT_FUNC, library_url.ToCString());
2462 } 2459 }
2463 isolate->set_library_tag_handler(handler); 2460 isolate->set_library_tag_handler(handler);
2464 library = Library::New(url_str); 2461 library = Library::New(url_str);
2465 library.set_import_map(mapping_array); 2462 if (mapping_array.IsNull()) {
2463 library.set_import_map(Array::Handle(Array::Empty()));
2464 } else {
2465 library.set_import_map(mapping_array);
2466 }
2466 library.Register(); 2467 library.Register();
2467 isolate->object_store()->set_root_library(library); 2468 isolate->object_store()->set_root_library(library);
2468 Dart_Handle result; 2469 Dart_Handle result;
2469 CompileSource(isolate, 2470 CompileSource(isolate,
2470 library, 2471 library,
2471 url_str, 2472 url_str,
2472 source_str, 2473 source_str,
2473 RawScript::kScript, 2474 RawScript::kScript,
2474 &result); 2475 &result);
2475 return result; 2476 return result;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 DARTSCOPE(isolate); 2597 DARTSCOPE(isolate);
2597 const String& url_str = Api::UnwrapStringHandle(url); 2598 const String& url_str = Api::UnwrapStringHandle(url);
2598 if (url_str.IsNull()) { 2599 if (url_str.IsNull()) {
2599 RETURN_TYPE_ERROR(url, String); 2600 RETURN_TYPE_ERROR(url, String);
2600 } 2601 }
2601 const String& source_str = Api::UnwrapStringHandle(source); 2602 const String& source_str = Api::UnwrapStringHandle(source);
2602 if (source_str.IsNull()) { 2603 if (source_str.IsNull()) {
2603 RETURN_TYPE_ERROR(source, String); 2604 RETURN_TYPE_ERROR(source, String);
2604 } 2605 }
2605 const Array& mapping_array = Api::UnwrapArrayHandle(import_map); 2606 const Array& mapping_array = Api::UnwrapArrayHandle(import_map);
2606 if (mapping_array.IsNull()) {
2607 RETURN_TYPE_ERROR(import_map, Array);
2608 }
2609 Library& library = Library::Handle(Library::LookupLibrary(url_str)); 2607 Library& library = Library::Handle(Library::LookupLibrary(url_str));
2610 if (library.IsNull()) { 2608 if (library.IsNull()) {
2611 library = Library::New(url_str); 2609 library = Library::New(url_str);
2612 library.set_import_map(mapping_array); 2610 if (mapping_array.IsNull()) {
2611 library.set_import_map(Array::Handle(Array::Empty()));
2612 } else {
2613 library.set_import_map(mapping_array);
2614 }
2613 library.Register(); 2615 library.Register();
2614 } else if (!library.LoadNotStarted()) { 2616 } else if (!library.LoadNotStarted()) {
2615 // The source for this library has either been loaded or is in the 2617 // The source for this library has either been loaded or is in the
2616 // process of loading. Return an error. 2618 // process of loading. Return an error.
2617 return Api::NewError("%s: library '%s' has already been loaded.", 2619 return Api::NewError("%s: library '%s' has already been loaded.",
2618 CURRENT_FUNC, url_str.ToCString()); 2620 CURRENT_FUNC, url_str.ToCString());
2619 } 2621 }
2620 Dart_Handle result; 2622 Dart_Handle result;
2621 CompileSource(isolate, 2623 CompileSource(isolate,
2622 library, 2624 library,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 *buffer = NULL; 2707 *buffer = NULL;
2706 } 2708 }
2707 delete debug_region; 2709 delete debug_region;
2708 } else { 2710 } else {
2709 *buffer = NULL; 2711 *buffer = NULL;
2710 *buffer_size = 0; 2712 *buffer_size = 0;
2711 } 2713 }
2712 } 2714 }
2713 2715
2714 } // namespace dart 2716 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698