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

Side by Side Diff: vm/dart_api_impl.cc

Issue 9614006: - Proper URI resolution when loading scripts from the standalone binary. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 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 | « bin/main.cc ('k') | vm/object_store.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) 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 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 // --- Methods and Fields --- 2011 // --- Methods and Fields ---
2012 2012
2013 2013
2014 DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library_in, 2014 DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library_in,
2015 Dart_Handle class_name_in, 2015 Dart_Handle class_name_in,
2016 Dart_Handle function_name_in, 2016 Dart_Handle function_name_in,
2017 int number_of_arguments, 2017 int number_of_arguments,
2018 Dart_Handle* arguments) { 2018 Dart_Handle* arguments) {
2019 Isolate* isolate = Isolate::Current(); 2019 Isolate* isolate = Isolate::Current();
2020 DARTSCOPE(isolate); 2020 DARTSCOPE(isolate);
2021 // Finalize all classes. 2021 // Check whether class finalization is needed.
2022 const char* msg = CheckIsolateState(isolate); 2022 bool finalize_classes = true;
2023 if (msg != NULL) {
2024 return Api::NewError(msg);
2025 }
2026
2027 // Now try to resolve and invoke the static function.
2028 const Library& library = 2023 const Library& library =
2029 Library::CheckedHandle(Api::UnwrapHandle(library_in)); 2024 Library::CheckedHandle(Api::UnwrapHandle(library_in));
2030 if (library.IsNull()) { 2025 if (library.IsNull()) {
2031 return Api::NewError("No library specified"); 2026 return Api::NewError("No library specified");
2032 } 2027 }
2028
2029 // When calling functions in the dart:builtin library do not finalize as it
2030 // should have been prefinalized.
2031 Library& builtin =
2032 Library::Handle(isolate->object_store()->builtin_library());
2033 if (builtin.raw() == library.raw()) {
2034 finalize_classes = false;
2035 }
2036
2037 // Finalize all classes if needed.
2038 if (finalize_classes) {
2039 const char* msg = CheckIsolateState(isolate);
2040 if (msg != NULL) {
2041 return Api::NewError(msg);
2042 }
2043 }
2044
2045 // Now try to resolve and invoke the static function.
2033 const String& class_name = 2046 const String& class_name =
2034 String::CheckedHandle(Api::UnwrapHandle(class_name_in)); 2047 String::CheckedHandle(Api::UnwrapHandle(class_name_in));
2035 const String& function_name = 2048 const String& function_name =
2036 String::CheckedHandle(Api::UnwrapHandle(function_name_in)); 2049 String::CheckedHandle(Api::UnwrapHandle(function_name_in));
2037 const Function& function = Function::Handle( 2050 const Function& function = Function::Handle(
2038 Resolver::ResolveStatic(library, 2051 Resolver::ResolveStatic(library,
2039 class_name, 2052 class_name,
2040 function_name, 2053 function_name,
2041 number_of_arguments, 2054 number_of_arguments,
2042 Array::Handle(), // Named arguments are not yet 2055 Array::Handle(), // Named arguments are not yet
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 const Array& mapping_array = Api::UnwrapArrayHandle(import_map); 2662 const Array& mapping_array = Api::UnwrapArrayHandle(import_map);
2650 Library& library = Library::Handle(Library::LookupLibrary(url_str)); 2663 Library& library = Library::Handle(Library::LookupLibrary(url_str));
2651 if (library.IsNull()) { 2664 if (library.IsNull()) {
2652 library = Library::New(url_str); 2665 library = Library::New(url_str);
2653 if (mapping_array.IsNull()) { 2666 if (mapping_array.IsNull()) {
2654 library.set_import_map(Array::Handle(Array::Empty())); 2667 library.set_import_map(Array::Handle(Array::Empty()));
2655 } else { 2668 } else {
2656 library.set_import_map(mapping_array); 2669 library.set_import_map(mapping_array);
2657 } 2670 }
2658 library.Register(); 2671 library.Register();
2672 // If this is the dart:builtin library register it with the VM.
2673 if (url_str.Equals("dart:builtin")) {
2674 isolate->object_store()->set_builtin_library(library);
2675 const char* msg = CheckIsolateState(isolate);
2676 if (msg != NULL) {
2677 return Api::NewError(msg);
2678 }
2679 }
2659 } else if (!library.LoadNotStarted()) { 2680 } else if (!library.LoadNotStarted()) {
2660 // The source for this library has either been loaded or is in the 2681 // The source for this library has either been loaded or is in the
2661 // process of loading. Return an error. 2682 // process of loading. Return an error.
2662 return Api::NewError("%s: library '%s' has already been loaded.", 2683 return Api::NewError("%s: library '%s' has already been loaded.",
2663 CURRENT_FUNC, url_str.ToCString()); 2684 CURRENT_FUNC, url_str.ToCString());
2664 } 2685 }
2665 Dart_Handle result; 2686 Dart_Handle result;
2666 CompileSource(isolate, 2687 CompileSource(isolate,
2667 library, 2688 library,
2668 url_str, 2689 url_str,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2750 *buffer = NULL; 2771 *buffer = NULL;
2751 } 2772 }
2752 delete debug_region; 2773 delete debug_region;
2753 } else { 2774 } else {
2754 *buffer = NULL; 2775 *buffer = NULL;
2755 *buffer_size = 0; 2776 *buffer_size = 0;
2756 } 2777 }
2757 } 2778 }
2758 2779
2759 } // namespace dart 2780 } // namespace dart
OLDNEW
« no previous file with comments | « bin/main.cc ('k') | vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698