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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 10867032: Beginning support for library prefixes in the dart API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use Dart_Null in builtin.cc Created 8 years, 3 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 | « runtime/include/dart_api.h ('k') | runtime/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 2616 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 2627
2628 // Case 2. Lookup the function without the external setter suffix 2628 // Case 2. Lookup the function without the external setter suffix
2629 // '='. Make sure to do this check after the regular lookup, so 2629 // '='. Make sure to do this check after the regular lookup, so
2630 // that we don't interfere with operator lookups (like ==). 2630 // that we don't interfere with operator lookups (like ==).
2631 if (func.IsNull() && HasExternalSetterSuffix(func_name)) { 2631 if (func.IsNull() && HasExternalSetterSuffix(func_name)) {
2632 tmp_name = RemoveExternalSetterSuffix(func_name); 2632 tmp_name = RemoveExternalSetterSuffix(func_name);
2633 tmp_name = Field::SetterName(tmp_name); 2633 tmp_name = Field::SetterName(tmp_name);
2634 func = lib.LookupFunctionAllowPrivate(tmp_name); 2634 func = lib.LookupFunctionAllowPrivate(tmp_name);
2635 } 2635 }
2636 2636
2637 // Case 3. Lookup the funciton with the getter prefix prepended. 2637 // Case 3. Lookup the function with the getter prefix prepended.
2638 if (func.IsNull()) { 2638 if (func.IsNull()) {
2639 tmp_name = Field::GetterName(func_name); 2639 tmp_name = Field::GetterName(func_name);
2640 func = lib.LookupFunctionAllowPrivate(tmp_name); 2640 func = lib.LookupFunctionAllowPrivate(tmp_name);
2641 } 2641 }
2642 } else { 2642 } else {
2643 return Api::NewError( 2643 return Api::NewError(
2644 "%s expects argument 'target' to be a class or library.", 2644 "%s expects argument 'target' to be a class or library.",
2645 CURRENT_FUNC); 2645 CURRENT_FUNC);
2646 } 2646 }
2647 2647
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
4030 const char* msg = CheckIsolateState(isolate); 4030 const char* msg = CheckIsolateState(isolate);
4031 if (msg != NULL) { 4031 if (msg != NULL) {
4032 return Api::NewError(msg); 4032 return Api::NewError(msg);
4033 } 4033 }
4034 } 4034 }
4035 return result; 4035 return result;
4036 } 4036 }
4037 4037
4038 4038
4039 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, 4039 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library,
4040 Dart_Handle import) { 4040 Dart_Handle import,
4041 Dart_Handle prefix) {
4041 Isolate* isolate = Isolate::Current(); 4042 Isolate* isolate = Isolate::Current();
4042 DARTSCOPE(isolate); 4043 DARTSCOPE(isolate);
4043 const Library& library_vm = Api::UnwrapLibraryHandle(isolate, library); 4044 const Library& library_vm = Api::UnwrapLibraryHandle(isolate, library);
4044 if (library_vm.IsNull()) { 4045 if (library_vm.IsNull()) {
4045 RETURN_TYPE_ERROR(isolate, library, Library); 4046 RETURN_TYPE_ERROR(isolate, library, Library);
4046 } 4047 }
4047 const Library& import_vm = Api::UnwrapLibraryHandle(isolate, import); 4048 const Library& import_vm = Api::UnwrapLibraryHandle(isolate, import);
4048 if (import_vm.IsNull()) { 4049 if (import_vm.IsNull()) {
4049 RETURN_TYPE_ERROR(isolate, import, Library); 4050 RETURN_TYPE_ERROR(isolate, import, Library);
4050 } 4051 }
4051 library_vm.AddImport(import_vm); 4052 const String& prefix_vm = Dart_IsNull(prefix)
4053 ? String::Handle(isolate, Symbols::New(""))
4054 : Api::UnwrapStringHandle(isolate, prefix);
4055 if (prefix_vm.IsNull()) {
4056 RETURN_TYPE_ERROR(isolate, prefix, String);
4057 }
4058 const String& prefix_symbol =
4059 String::Handle(isolate, Symbols::New(prefix_vm));
4060 if (prefix_vm.Length() == 0) {
4061 library_vm.AddImport(import_vm);
4062 } else {
4063 LibraryPrefix& library_prefix = LibraryPrefix::Handle();
4064 library_prefix = library_vm.LookupLocalLibraryPrefix(prefix_symbol);
4065 if (!library_prefix.IsNull()) {
4066 library_prefix.AddLibrary(import_vm);
4067 } else {
4068 library_prefix = LibraryPrefix::New(prefix_symbol, import_vm);
4069 library_vm.AddObject(library_prefix, prefix_symbol);
4070 }
4071 }
4052 return Api::Success(isolate); 4072 return Api::Success(isolate);
4053 } 4073 }
4054 4074
4055 4075
4056 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library, 4076 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library,
4057 Dart_Handle url, 4077 Dart_Handle url,
4058 Dart_Handle source) { 4078 Dart_Handle source) {
4059 TIMERSCOPE(time_script_loading); 4079 TIMERSCOPE(time_script_loading);
4060 Isolate* isolate = Isolate::Current(); 4080 Isolate* isolate = Isolate::Current();
4061 DARTSCOPE(isolate); 4081 DARTSCOPE(isolate);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4131 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { 4151 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) {
4132 Dart::set_perf_events_writer(function); 4152 Dart::set_perf_events_writer(function);
4133 } 4153 }
4134 4154
4135 4155
4136 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { 4156 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) {
4137 Dart::set_flow_graph_writer(function); 4157 Dart::set_flow_graph_writer(function);
4138 } 4158 }
4139 4159
4140 } // namespace dart 4160 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698