| OLD | NEW |
| 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
| 10 #include "include/dart_debugger_api.h" | 10 #include "include/dart_debugger_api.h" |
| 11 | 11 |
| 12 #include "bin/builtin.h" | 12 #include "bin/builtin.h" |
| 13 #include "bin/dartutils.h" | 13 #include "bin/dartutils.h" |
| 14 #include "bin/eventhandler.h" | 14 #include "bin/eventhandler.h" |
| 15 #include "bin/extensions.h" |
| 15 #include "bin/file.h" | 16 #include "bin/file.h" |
| 16 #include "bin/platform.h" | 17 #include "bin/platform.h" |
| 17 #include "bin/process.h" | 18 #include "bin/process.h" |
| 18 #include "platform/globals.h" | 19 #include "platform/globals.h" |
| 19 | 20 |
| 20 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise | 21 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise |
| 21 // it is initialized to NULL. | 22 // it is initialized to NULL. |
| 22 extern const uint8_t* snapshot_buffer; | 23 extern const uint8_t* snapshot_buffer; |
| 23 | 24 |
| 24 | 25 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 251 } |
| 251 if (!Dart_IsString8(url)) { | 252 if (!Dart_IsString8(url)) { |
| 252 return Dart_Error("url is not a string"); | 253 return Dart_Error("url is not a string"); |
| 253 } | 254 } |
| 254 const char* url_string = NULL; | 255 const char* url_string = NULL; |
| 255 Dart_Handle result = Dart_StringToCString(url, &url_string); | 256 Dart_Handle result = Dart_StringToCString(url, &url_string); |
| 256 if (Dart_IsError(result)) { | 257 if (Dart_IsError(result)) { |
| 257 return Dart_Error("accessing url characters failed"); | 258 return Dart_Error("accessing url characters failed"); |
| 258 } | 259 } |
| 259 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); | 260 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); |
| 261 bool is_dart_extension_url = DartUtils::IsDartExtensionSchemeURL(url_string); |
| 260 if (tag == kCanonicalizeUrl) { | 262 if (tag == kCanonicalizeUrl) { |
| 261 // If this is a Dart Scheme URL then it is not modified as it will be | 263 // If this is a Dart Scheme URL then it is not modified as it will be |
| 262 // handled by the VM internally. | 264 // handled by the VM internally. |
| 263 if (is_dart_scheme_url) { | 265 if (is_dart_scheme_url || is_dart_extension_url) { |
| 264 return url; | 266 return url; |
| 265 } | 267 } |
| 266 // Create a canonical path based on the including library and current url. | 268 // Create a canonical path based on the including library and current url. |
| 267 return DartUtils::CanonicalizeURL(NULL, library, url_string); | 269 return DartUtils::CanonicalizeURL(NULL, library, url_string); |
| 268 } | 270 } |
| 269 if (is_dart_scheme_url) { | 271 if (is_dart_scheme_url) { |
| 270 ASSERT(tag == kImportTag); | 272 ASSERT(tag == kImportTag); |
| 271 // Handle imports of other built-in libraries present in the SDK. | 273 // Handle imports of other built-in libraries present in the SDK. |
| 272 if (DartUtils::IsDartIOLibURL(url_string)) { | 274 if (DartUtils::IsDartIOLibURL(url_string)) { |
| 273 return Builtin::LoadLibrary(Builtin::kIOLibrary); | 275 return Builtin::LoadLibrary(Builtin::kIOLibrary); |
| 274 } else if (DartUtils::IsDartJsonLibURL(url_string)) { | 276 } else if (DartUtils::IsDartJsonLibURL(url_string)) { |
| 275 return Builtin::LoadLibrary(Builtin::kJsonLibrary); | 277 return Builtin::LoadLibrary(Builtin::kJsonLibrary); |
| 276 } else if (DartUtils::IsDartUriLibURL(url_string)) { | 278 } else if (DartUtils::IsDartUriLibURL(url_string)) { |
| 277 return Builtin::LoadLibrary(Builtin::kUriLibrary); | 279 return Builtin::LoadLibrary(Builtin::kUriLibrary); |
| 278 } else if (DartUtils::IsDartUtf8LibURL(url_string)) { | 280 } else if (DartUtils::IsDartUtf8LibURL(url_string)) { |
| 279 return Builtin::LoadLibrary(Builtin::kUtf8Library); | 281 return Builtin::LoadLibrary(Builtin::kUtf8Library); |
| 280 } else { | 282 } else { |
| 281 return Dart_Error("Do not know how to load '%s'", url_string); | 283 return Dart_Error("Do not know how to load '%s'", url_string); |
| 282 } | 284 } |
| 285 } else if (is_dart_extension_url) { |
| 286 if (tag != kImportTag) { |
| 287 return Dart_Error("Dart extensions must use import: '%s'", url_string); |
| 288 } |
| 289 return Extensions::LoadExtension(url_string, library); |
| 283 } | 290 } |
| 284 result = DartUtils::LoadSource(NULL, | 291 result = DartUtils::LoadSource(NULL, |
| 285 library, | 292 library, |
| 286 url, | 293 url, |
| 287 tag, | 294 tag, |
| 288 url_string, | 295 url_string, |
| 289 import_map); | 296 import_map); |
| 290 if (!Dart_IsError(result) && (tag == kImportTag)) { | 297 if (!Dart_IsError(result) && (tag == kImportTag)) { |
| 291 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary); | 298 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary); |
| 292 } | 299 } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 DumpPprofSymbolInfo(); | 624 DumpPprofSymbolInfo(); |
| 618 // Shutdown the isolate. | 625 // Shutdown the isolate. |
| 619 Dart_ShutdownIsolate(); | 626 Dart_ShutdownIsolate(); |
| 620 // Terminate event handler. | 627 // Terminate event handler. |
| 621 EventHandler::Terminate(); | 628 EventHandler::Terminate(); |
| 622 // Terminate process exit-code handler. | 629 // Terminate process exit-code handler. |
| 623 Process::TerminateExitCodeHandler(); | 630 Process::TerminateExitCodeHandler(); |
| 624 | 631 |
| 625 return 0; | 632 return 0; |
| 626 } | 633 } |
| OLD | NEW |