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 5086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5141 | 5142 |
5142 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( | 5143 DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( |
5143 Dart_LibraryTagHandler handler) { | 5144 Dart_LibraryTagHandler handler) { |
5144 Isolate* isolate = Isolate::Current(); | 5145 Isolate* isolate = Isolate::Current(); |
5145 CHECK_ISOLATE(isolate); | 5146 CHECK_ISOLATE(isolate); |
5146 isolate->set_library_tag_handler(handler); | 5147 isolate->set_library_tag_handler(handler); |
5147 return Api::Success(); | 5148 return Api::Success(); |
5148 } | 5149 } |
5149 | 5150 |
5150 | 5151 |
5152 DART_EXPORT Dart_Handle Dart_DefaultCanonicalizeUrl(Dart_Handle library, | |
5153 Dart_Handle url) { | |
5154 API_TIMELINE_DURATION; | |
5155 DARTSCOPE(Thread::Current()); | |
5156 CHECK_CALLBACK_STATE(T); | |
5157 | |
5158 const Library& lib = Api::UnwrapLibraryHandle(Z, library); | |
5159 if (lib.IsNull()) { | |
5160 RETURN_TYPE_ERROR(Z, library, Library); | |
5161 } | |
5162 const String& uri = Api::UnwrapStringHandle(Z, url); | |
5163 if (uri.IsNull()) { | |
5164 RETURN_TYPE_ERROR(Z, url, String); | |
5165 } | |
5166 | |
5167 const String& lib_uri = String::Handle(Z, lib.url()); | |
5168 const char* resolved_uri; | |
ahe
2016/05/25 12:44:52
I don't understand how memory is managed for this.
Florian Schneider
2016/05/26 14:09:45
The string is in zone-allocated memory.
| |
5169 if (!ResolveUri(uri.ToCString(), lib_uri.ToCString(), &resolved_uri)) { | |
5170 return Api::NewError("%s: Unable to canonicalize uri '%s'.", | |
5171 CURRENT_FUNC, uri.ToCString()); | |
5172 } | |
5173 return Api::NewHandle(T, String::New(resolved_uri)); | |
5174 } | |
5175 | |
5176 | |
5151 // NOTE: Need to pass 'result' as a parameter here in order to avoid | 5177 // NOTE: Need to pass 'result' as a parameter here in order to avoid |
5152 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' | 5178 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' |
5153 // which shows up because of the use of setjmp. | 5179 // which shows up because of the use of setjmp. |
5154 static void CompileSource(Thread* thread, | 5180 static void CompileSource(Thread* thread, |
5155 const Library& lib, | 5181 const Library& lib, |
5156 const Script& script, | 5182 const Script& script, |
5157 Dart_Handle* result) { | 5183 Dart_Handle* result) { |
5158 bool update_lib_status = (script.kind() == RawScript::kScriptTag || | 5184 bool update_lib_status = (script.kind() == RawScript::kScriptTag || |
5159 script.kind() == RawScript::kLibraryTag); | 5185 script.kind() == RawScript::kLibraryTag); |
5160 if (update_lib_status) { | 5186 if (update_lib_status) { |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6376 | 6402 |
6377 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6403 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
6378 #if defined(DART_PRECOMPILED_RUNTIME) | 6404 #if defined(DART_PRECOMPILED_RUNTIME) |
6379 return true; | 6405 return true; |
6380 #else | 6406 #else |
6381 return false; | 6407 return false; |
6382 #endif | 6408 #endif |
6383 } | 6409 } |
6384 | 6410 |
6385 } // namespace dart | 6411 } // namespace dart |
OLD | NEW |