OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "vm/service_event.h" | 35 #include "vm/service_event.h" |
36 #include "vm/service_isolate.h" | 36 #include "vm/service_isolate.h" |
37 #include "vm/service.h" | 37 #include "vm/service.h" |
38 #include "vm/stack_frame.h" | 38 #include "vm/stack_frame.h" |
39 #include "vm/symbols.h" | 39 #include "vm/symbols.h" |
40 #include "vm/tags.h" | 40 #include "vm/tags.h" |
41 #include "vm/thread_registry.h" | 41 #include "vm/thread_registry.h" |
42 #include "vm/timeline.h" | 42 #include "vm/timeline.h" |
43 #include "vm/timer.h" | 43 #include "vm/timer.h" |
44 #include "vm/unicode.h" | 44 #include "vm/unicode.h" |
| 45 #include "vm/uri.h" |
45 #include "vm/verifier.h" | 46 #include "vm/verifier.h" |
46 #include "vm/version.h" | 47 #include "vm/version.h" |
47 | 48 |
48 namespace dart { | 49 namespace dart { |
49 | 50 |
50 // Facilitate quick access to the current zone once we have the curren thread. | 51 // Facilitate quick access to the current zone once we have the curren thread. |
51 #define Z (T->zone()) | 52 #define Z (T->zone()) |
52 | 53 |
53 | 54 |
54 DECLARE_FLAG(bool, print_class_table); | 55 DECLARE_FLAG(bool, print_class_table); |
(...skipping 5106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5161 | 5162 |
5162 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( | 5163 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( |
5163 Dart_LibraryTagHandler handler) { | 5164 Dart_LibraryTagHandler handler) { |
5164 Isolate* isolate = Isolate::Current(); | 5165 Isolate* isolate = Isolate::Current(); |
5165 CHECK_ISOLATE(isolate); | 5166 CHECK_ISOLATE(isolate); |
5166 isolate->set_library_tag_handler(handler); | 5167 isolate->set_library_tag_handler(handler); |
5167 return Api::Success(); | 5168 return Api::Success(); |
5168 } | 5169 } |
5169 | 5170 |
5170 | 5171 |
| 5172 DART_EXPORT Dart_Handle Dart_DefaultCanonicalizeUrl(Dart_Handle library, |
| 5173 Dart_Handle url) { |
| 5174 API_TIMELINE_DURATION; |
| 5175 DARTSCOPE(Thread::Current()); |
| 5176 CHECK_CALLBACK_STATE(T); |
| 5177 |
| 5178 const Library& lib = Api::UnwrapLibraryHandle(Z, library); |
| 5179 if (lib.IsNull()) { |
| 5180 RETURN_TYPE_ERROR(Z, library, Library); |
| 5181 } |
| 5182 const String& uri = Api::UnwrapStringHandle(Z, url); |
| 5183 if (uri.IsNull()) { |
| 5184 RETURN_TYPE_ERROR(Z, url, String); |
| 5185 } |
| 5186 |
| 5187 const String& lib_uri = String::Handle(Z, lib.url()); |
| 5188 const char* resolved_uri; |
| 5189 if (!ResolveUri(uri.ToCString(), lib_uri.ToCString(), &resolved_uri)) { |
| 5190 return Api::NewError("%s: Unable to canonicalize uri '%s'.", |
| 5191 CURRENT_FUNC, uri.ToCString()); |
| 5192 } |
| 5193 return Api::NewHandle(T, String::New(resolved_uri)); |
| 5194 } |
| 5195 |
| 5196 |
5171 // NOTE: Need to pass 'result' as a parameter here in order to avoid | 5197 // NOTE: Need to pass 'result' as a parameter here in order to avoid |
5172 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' | 5198 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' |
5173 // which shows up because of the use of setjmp. | 5199 // which shows up because of the use of setjmp. |
5174 static void CompileSource(Thread* thread, | 5200 static void CompileSource(Thread* thread, |
5175 const Library& lib, | 5201 const Library& lib, |
5176 const Script& script, | 5202 const Script& script, |
5177 Dart_Handle* result) { | 5203 Dart_Handle* result) { |
5178 bool update_lib_status = (script.kind() == RawScript::kScriptTag || | 5204 bool update_lib_status = (script.kind() == RawScript::kScriptTag || |
5179 script.kind() == RawScript::kLibraryTag); | 5205 script.kind() == RawScript::kLibraryTag); |
5180 if (update_lib_status) { | 5206 if (update_lib_status) { |
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6412 | 6438 |
6413 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6439 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
6414 #if defined(DART_PRECOMPILED_RUNTIME) | 6440 #if defined(DART_PRECOMPILED_RUNTIME) |
6415 return true; | 6441 return true; |
6416 #else | 6442 #else |
6417 return false; | 6443 return false; |
6418 #endif | 6444 #endif |
6419 } | 6445 } |
6420 | 6446 |
6421 } // namespace dart | 6447 } // namespace dart |
OLD | NEW |