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

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
« bin/main.cc ('K') | « 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 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 // --- Methods and Fields --- 2004 // --- Methods and Fields ---
2005 2005
2006 2006
2007 DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library_in, 2007 DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library_in,
2008 Dart_Handle class_name_in, 2008 Dart_Handle class_name_in,
2009 Dart_Handle function_name_in, 2009 Dart_Handle function_name_in,
2010 int number_of_arguments, 2010 int number_of_arguments,
2011 Dart_Handle* arguments) { 2011 Dart_Handle* arguments) {
2012 Isolate* isolate = Isolate::Current(); 2012 Isolate* isolate = Isolate::Current();
2013 DARTSCOPE(isolate); 2013 DARTSCOPE(isolate);
2014 // Finalize all classes. 2014 // Check whether class finalization is needed.
2015 const char* msg = CheckIsolateState(isolate); 2015 bool finalize_classes = true;
2016 if (msg != NULL) {
2017 return Api::NewError(msg);
2018 }
2019
2020 // Now try to resolve and invoke the static function.
2021 const Library& library = 2016 const Library& library =
2022 Library::CheckedHandle(Api::UnwrapHandle(library_in)); 2017 Library::CheckedHandle(Api::UnwrapHandle(library_in));
2023 if (library.IsNull()) { 2018 if (library.IsNull()) {
2024 return Api::NewError("No library specified"); 2019 return Api::NewError("No library specified");
2025 } 2020 }
2021
2022 // When calling functions in the dart:builtin library do not finalize as it
2023 // should have been prefinalized.
2024 Library& builtin =
2025 Library::Handle(isolate->object_store()->builtin_library());
siva 2012/03/07 18:32:17 if (builtin.IsNull()) { return Api::NewError("..
Ivan Posva 2012/03/08 00:49:33 Discussed offline.
2026 if (builtin.raw() == library.raw()) {
2027 finalize_classes = false;
2028 }
2029
2030 // Finalize all classes if needed.
2031 if (finalize_classes) {
2032 const char* msg = CheckIsolateState(isolate);
2033 if (msg != NULL) {
2034 return Api::NewError(msg);
2035 }
2036 }
2037
2038 // Now try to resolve and invoke the static function.
2026 const String& class_name = 2039 const String& class_name =
2027 String::CheckedHandle(Api::UnwrapHandle(class_name_in)); 2040 String::CheckedHandle(Api::UnwrapHandle(class_name_in));
2028 const String& function_name = 2041 const String& function_name =
2029 String::CheckedHandle(Api::UnwrapHandle(function_name_in)); 2042 String::CheckedHandle(Api::UnwrapHandle(function_name_in));
2030 const Function& function = Function::Handle( 2043 const Function& function = Function::Handle(
2031 Resolver::ResolveStatic(library, 2044 Resolver::ResolveStatic(library,
2032 class_name, 2045 class_name,
2033 function_name, 2046 function_name,
2034 number_of_arguments, 2047 number_of_arguments,
2035 Array::Handle(), // Named arguments are not yet 2048 Array::Handle(), // Named arguments are not yet
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
2642 const Array& mapping_array = Api::UnwrapArrayHandle(import_map); 2655 const Array& mapping_array = Api::UnwrapArrayHandle(import_map);
2643 Library& library = Library::Handle(Library::LookupLibrary(url_str)); 2656 Library& library = Library::Handle(Library::LookupLibrary(url_str));
2644 if (library.IsNull()) { 2657 if (library.IsNull()) {
2645 library = Library::New(url_str); 2658 library = Library::New(url_str);
2646 if (mapping_array.IsNull()) { 2659 if (mapping_array.IsNull()) {
2647 library.set_import_map(Array::Handle(Array::Empty())); 2660 library.set_import_map(Array::Handle(Array::Empty()));
2648 } else { 2661 } else {
2649 library.set_import_map(mapping_array); 2662 library.set_import_map(mapping_array);
2650 } 2663 }
2651 library.Register(); 2664 library.Register();
2665 // If this is the dart:builtin library register it with the VM.
2666 if (url_str.Equals("dart:builtin")) {
2667 isolate->object_store()->set_builtin_library(library);
2668 const char* msg = CheckIsolateState(isolate);
2669 if (msg != NULL) {
2670 return Api::NewError(msg);
2671 }
2672 }
2652 } else if (!library.LoadNotStarted()) { 2673 } else if (!library.LoadNotStarted()) {
2653 // The source for this library has either been loaded or is in the 2674 // The source for this library has either been loaded or is in the
2654 // process of loading. Return an error. 2675 // process of loading. Return an error.
2655 return Api::NewError("%s: library '%s' has already been loaded.", 2676 return Api::NewError("%s: library '%s' has already been loaded.",
2656 CURRENT_FUNC, url_str.ToCString()); 2677 CURRENT_FUNC, url_str.ToCString());
2657 } 2678 }
2658 Dart_Handle result; 2679 Dart_Handle result;
2659 CompileSource(isolate, 2680 CompileSource(isolate,
2660 library, 2681 library,
2661 url_str, 2682 url_str,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2743 *buffer = NULL; 2764 *buffer = NULL;
2744 } 2765 }
2745 delete debug_region; 2766 delete debug_region;
2746 } else { 2767 } else {
2747 *buffer = NULL; 2768 *buffer = NULL;
2748 *buffer_size = 0; 2769 *buffer_size = 0;
2749 } 2770 }
2750 } 2771 }
2751 2772
2752 } // namespace dart 2773 } // namespace dart
OLDNEW
« bin/main.cc ('K') | « bin/main.cc ('k') | vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698