| 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 "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
| 6 | 6 |
| 7 #include "bin/extensions.h" | 7 #include "bin/extensions.h" |
| 8 #include "bin/directory.h" | 8 #include "bin/directory.h" |
| 9 #include "bin/file.h" | 9 #include "bin/file.h" |
| 10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 272 } |
| 273 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); | 273 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); |
| 274 bool is_dart_extension_url = DartUtils::IsDartExtensionSchemeURL(url_string); | 274 bool is_dart_extension_url = DartUtils::IsDartExtensionSchemeURL(url_string); |
| 275 if (tag == kCanonicalizeUrl) { | 275 if (tag == kCanonicalizeUrl) { |
| 276 // If this is a Dart Scheme URL then it is not modified as it will be | 276 // If this is a Dart Scheme URL then it is not modified as it will be |
| 277 // handled by the VM internally. | 277 // handled by the VM internally. |
| 278 if (is_dart_scheme_url) { | 278 if (is_dart_scheme_url) { |
| 279 return url; | 279 return url; |
| 280 } | 280 } |
| 281 // Resolve the url within the context of the library's URL. | 281 // Resolve the url within the context of the library's URL. |
| 282 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); | 282 Dart_Handle builtin_lib = |
| 283 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
| 283 Dart_Handle library_url = Dart_LibraryUrl(library); | 284 Dart_Handle library_url = Dart_LibraryUrl(library); |
| 284 if (Dart_IsError(library_url)) { | 285 if (Dart_IsError(library_url)) { |
| 285 return library_url; | 286 return library_url; |
| 286 } | 287 } |
| 287 const int kNumArgs = 2; | 288 const int kNumArgs = 2; |
| 288 Dart_Handle dart_args[kNumArgs]; | 289 Dart_Handle dart_args[kNumArgs]; |
| 289 dart_args[0] = library_url; | 290 dart_args[0] = library_url; |
| 290 dart_args[1] = url; | 291 dart_args[1] = url; |
| 291 return Dart_Invoke( | 292 return Dart_Invoke( |
| 292 builtin_lib, Dart_NewString("_resolveUri"), kNumArgs, dart_args); | 293 builtin_lib, Dart_NewString("_resolveUri"), kNumArgs, dart_args); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 303 id = Builtin::kJsonLibrary; | 304 id = Builtin::kJsonLibrary; |
| 304 } else if (DartUtils::IsDartUriLibURL(url_string)) { | 305 } else if (DartUtils::IsDartUriLibURL(url_string)) { |
| 305 id = Builtin::kUriLibrary; | 306 id = Builtin::kUriLibrary; |
| 306 } else if (DartUtils::IsDartUtfLibURL(url_string)) { | 307 } else if (DartUtils::IsDartUtfLibURL(url_string)) { |
| 307 id = Builtin::kUtfLibrary; | 308 id = Builtin::kUtfLibrary; |
| 308 } else if (DartUtils::IsDartWebLibURL(url_string)) { | 309 } else if (DartUtils::IsDartWebLibURL(url_string)) { |
| 309 id = Builtin::kWebLibrary; | 310 id = Builtin::kWebLibrary; |
| 310 } else { | 311 } else { |
| 311 return Dart_Error("Do not know how to load '%s'", url_string); | 312 return Dart_Error("Do not know how to load '%s'", url_string); |
| 312 } | 313 } |
| 313 return Builtin::LoadLibrary(id); | 314 return Builtin::LoadAndCheckLibrary(id); |
| 314 } else { | 315 } else { |
| 315 // Get the file path out of the url. | 316 // Get the file path out of the url. |
| 316 Dart_Handle builtin_lib = Builtin::LoadLibrary(Builtin::kBuiltinLibrary); | 317 Dart_Handle builtin_lib = |
| 318 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); |
| 317 Dart_Handle file_path = FilePathFromUri(url, builtin_lib); | 319 Dart_Handle file_path = FilePathFromUri(url, builtin_lib); |
| 318 if (Dart_IsError(file_path)) { | 320 if (Dart_IsError(file_path)) { |
| 319 return file_path; | 321 return file_path; |
| 320 } | 322 } |
| 321 Dart_StringToCString(file_path, &url_string); | 323 Dart_StringToCString(file_path, &url_string); |
| 322 } | 324 } |
| 323 if (is_dart_extension_url) { | 325 if (is_dart_extension_url) { |
| 324 if (tag != kImportTag) { | 326 if (tag != kImportTag) { |
| 325 return Dart_Error("Dart extensions must use import: '%s'", url_string); | 327 return Dart_Error("Dart extensions must use import: '%s'", url_string); |
| 326 } | 328 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 // Setup the corelib 'print' function. | 406 // Setup the corelib 'print' function. |
| 405 Dart_Handle print = | 407 Dart_Handle print = |
| 406 Dart_Invoke(builtin_lib, Dart_NewString("_getPrintClosure"), 0, 0); | 408 Dart_Invoke(builtin_lib, Dart_NewString("_getPrintClosure"), 0, 0); |
| 407 Dart_Handle coreimpl = Dart_LookupLibrary(Dart_NewString("dart:coreimpl")); | 409 Dart_Handle coreimpl = Dart_LookupLibrary(Dart_NewString("dart:coreimpl")); |
| 408 Dart_Handle print_impl = | 410 Dart_Handle print_impl = |
| 409 Dart_GetClass(coreimpl, Dart_NewString("PrintImplementation")); | 411 Dart_GetClass(coreimpl, Dart_NewString("PrintImplementation")); |
| 410 Dart_Handle result = Dart_SetField(print_impl, | 412 Dart_Handle result = Dart_SetField(print_impl, |
| 411 Dart_NewString("_printClosure"), print); | 413 Dart_NewString("_printClosure"), print); |
| 412 | 414 |
| 413 // Setup the IO library. | 415 // Setup the IO library. |
| 414 Dart_Handle io_lib = Builtin::LoadLibrary(Builtin::kIOLibrary); | 416 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); |
| 415 Builtin::SetupIOLibrary(io_lib); | 417 Builtin::SetupIOLibrary(io_lib); |
| 416 | 418 |
| 417 // Set up package root if specified. | 419 // Set up package root if specified. |
| 418 if (package_root != NULL) { | 420 if (package_root != NULL) { |
| 419 result = Dart_NewString(package_root); | 421 result = Dart_NewString(package_root); |
| 420 if (!Dart_IsError(result)) { | 422 if (!Dart_IsError(result)) { |
| 421 const int kNumArgs = 1; | 423 const int kNumArgs = 1; |
| 422 Dart_Handle dart_args[kNumArgs]; | 424 Dart_Handle dart_args[kNumArgs]; |
| 423 dart_args[0] = result; | 425 dart_args[0] = result; |
| 424 return Dart_Invoke(builtin_lib, | 426 return Dart_Invoke(builtin_lib, |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 660 |
| 659 CObject* CObject::NewOSError(OSError* os_error) { | 661 CObject* CObject::NewOSError(OSError* os_error) { |
| 660 CObject* error_message = | 662 CObject* error_message = |
| 661 new CObjectString(CObject::NewString(os_error->message())); | 663 new CObjectString(CObject::NewString(os_error->message())); |
| 662 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 664 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 663 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 665 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 664 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 666 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 665 result->SetAt(2, error_message); | 667 result->SetAt(2, error_message); |
| 666 return result; | 668 return result; |
| 667 } | 669 } |
| OLD | NEW |