| 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" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 256 } |
| 257 // Resolve the url within the context of the library's URL. | 257 // Resolve the url within the context of the library's URL. |
| 258 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); | 258 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); |
| 259 Dart_Handle library_url = Dart_LibraryUrl(library); | 259 Dart_Handle library_url = Dart_LibraryUrl(library); |
| 260 if (Dart_IsError(library_url)) { | 260 if (Dart_IsError(library_url)) { |
| 261 return library_url; | 261 return library_url; |
| 262 } | 262 } |
| 263 Dart_Handle dart_args[2]; | 263 Dart_Handle dart_args[2]; |
| 264 dart_args[0] = library_url; | 264 dart_args[0] = library_url; |
| 265 dart_args[1] = url; | 265 dart_args[1] = url; |
| 266 if (is_dart_extension_url) { | 266 return Dart_Invoke( |
| 267 return Dart_Invoke( | 267 builtin_lib, Dart_NewString("_resolveUri"), 2, dart_args); |
| 268 builtin_lib, Dart_NewString("_resolveExtensionUri"), 2, dart_args); | |
| 269 } else { | |
| 270 return Dart_Invoke( | |
| 271 builtin_lib, Dart_NewString("_resolveUri"), 2, dart_args); | |
| 272 } | |
| 273 } | 268 } |
| 274 if (is_dart_scheme_url) { | 269 if (is_dart_scheme_url) { |
| 275 ASSERT(tag == kImportTag); | 270 ASSERT(tag == kImportTag); |
| 276 // Handle imports of other built-in libraries present in the SDK. | 271 // Handle imports of other built-in libraries present in the SDK. |
| 277 if (DartUtils::IsDartIOLibURL(url_string)) { | 272 if (DartUtils::IsDartIOLibURL(url_string)) { |
| 278 return Builtin::LoadLibrary(Builtin::kIOLibrary); | 273 return Builtin::LoadLibrary(Builtin::kIOLibrary); |
| 279 } else if (DartUtils::IsDartJsonLibURL(url_string)) { | 274 } else if (DartUtils::IsDartJsonLibURL(url_string)) { |
| 280 return Builtin::LoadLibrary(Builtin::kJsonLibrary); | 275 return Builtin::LoadLibrary(Builtin::kJsonLibrary); |
| 281 } else if (DartUtils::IsDartUriLibURL(url_string)) { | 276 } else if (DartUtils::IsDartUriLibURL(url_string)) { |
| 282 return Builtin::LoadLibrary(Builtin::kUriLibrary); | 277 return Builtin::LoadLibrary(Builtin::kUriLibrary); |
| 283 } else if (DartUtils::IsDartUtfLibURL(url_string)) { | 278 } else if (DartUtils::IsDartUtfLibURL(url_string)) { |
| 284 return Builtin::LoadLibrary(Builtin::kUtfLibrary); | 279 return Builtin::LoadLibrary(Builtin::kUtfLibrary); |
| 285 } else { | 280 } else { |
| 286 return Dart_Error("Do not know how to load '%s'", url_string); | 281 return Dart_Error("Do not know how to load '%s'", url_string); |
| 287 } | 282 } |
| 288 } else if (is_dart_extension_url) { | |
| 289 if (tag != kImportTag) { | |
| 290 return Dart_Error("Dart extensions must use import: '%s'", url_string); | |
| 291 } | |
| 292 return Extensions::LoadExtension(url_string, library); | |
| 293 } else { | 283 } else { |
| 294 // Get the file path out of the url. | 284 // Get the file path out of the url. |
| 295 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); | 285 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); |
| 296 Dart_Handle dart_args[1]; | 286 Dart_Handle dart_args[1]; |
| 297 dart_args[0] = url; | 287 dart_args[0] = url; |
| 298 Dart_Handle file_path = Dart_Invoke( | 288 Dart_Handle file_path = Dart_Invoke( |
| 299 builtin_lib, Dart_NewString("_filePathFromUri"), 1, dart_args); | 289 builtin_lib, Dart_NewString("_filePathFromUri"), 1, dart_args); |
| 300 if (Dart_IsError(file_path)) { | 290 if (Dart_IsError(file_path)) { |
| 301 return file_path; | 291 return file_path; |
| 302 } | 292 } |
| 303 Dart_StringToCString(file_path, &url_string); | 293 Dart_StringToCString(file_path, &url_string); |
| 304 } | 294 } |
| 295 if (is_dart_extension_url) { |
| 296 if (tag != kImportTag) { |
| 297 return Dart_Error("Dart extensions must use import: '%s'", url_string); |
| 298 } |
| 299 return Extensions::LoadExtension(url_string, library); |
| 300 } |
| 305 result = DartUtils::LoadSource(NULL, | 301 result = DartUtils::LoadSource(NULL, |
| 306 library, | 302 library, |
| 307 url, | 303 url, |
| 308 tag, | 304 tag, |
| 309 url_string, | 305 url_string, |
| 310 import_map); | 306 import_map); |
| 311 if (!Dart_IsError(result) && (tag == kImportTag)) { | 307 if (!Dart_IsError(result) && (tag == kImportTag)) { |
| 312 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary); | 308 Builtin::ImportLibrary(result, Builtin::kBuiltinLibrary); |
| 313 } | 309 } |
| 314 return result; | 310 return result; |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 Dart_ShutdownIsolate(); | 602 Dart_ShutdownIsolate(); |
| 607 // Terminate process exit-code handler. | 603 // Terminate process exit-code handler. |
| 608 Process::TerminateExitCodeHandler(); | 604 Process::TerminateExitCodeHandler(); |
| 609 | 605 |
| 610 free(const_cast<char*>(original_script_name)); | 606 free(const_cast<char*>(original_script_name)); |
| 611 free(const_cast<char*>(original_working_directory)); | 607 free(const_cast<char*>(original_working_directory)); |
| 612 free(const_cast<char*>(original_script_url)); | 608 free(const_cast<char*>(original_script_url)); |
| 613 | 609 |
| 614 return 0; | 610 return 0; |
| 615 } | 611 } |
| OLD | NEW |