| 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/crypto.h" | 7 #include "bin/crypto.h" |
| 8 #include "bin/directory.h" | 8 #include "bin/directory.h" |
| 9 #include "bin/extensions.h" | 9 #include "bin/extensions.h" |
| 10 #include "bin/file.h" | 10 #include "bin/file.h" |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 snapshot_magic_number.length); | 372 snapshot_magic_number.length); |
| 373 ASSERT(bytes_written); | 373 ASSERT(bytes_written); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void DartUtils::SkipSnapshotMagicNumber(const uint8_t** buffer, | 376 void DartUtils::SkipSnapshotMagicNumber(const uint8_t** buffer, |
| 377 intptr_t* buffer_length) { | 377 intptr_t* buffer_length) { |
| 378 *buffer += snapshot_magic_number.length; | 378 *buffer += snapshot_magic_number.length; |
| 379 *buffer_length -= snapshot_magic_number.length; | 379 *buffer_length -= snapshot_magic_number.length; |
| 380 } | 380 } |
| 381 | 381 |
| 382 void FUNCTION_NAME(Builtin_GetCurrentDirectory)(Dart_NativeArguments args) { | |
| 383 const char* current = Directory::Current(); | |
| 384 if (current != NULL) { | |
| 385 Dart_SetReturnValue(args, DartUtils::NewString(current)); | |
| 386 } else { | |
| 387 Dart_Handle err = DartUtils::NewError("Failed to get current directory."); | |
| 388 Dart_PropagateError(err); | |
| 389 } | |
| 390 } | |
| 391 | |
| 392 Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib, | 382 Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib, |
| 393 Dart_Handle internal_lib, | 383 Dart_Handle internal_lib, |
| 394 bool is_service_isolate, | 384 bool is_service_isolate, |
| 395 bool trace_loading) { | 385 bool trace_loading) { |
| 396 // Setup the internal library's 'internalPrint' function. | 386 // Setup the internal library's 'internalPrint' function. |
| 397 Dart_Handle print = | 387 Dart_Handle print = |
| 398 Dart_Invoke(builtin_lib, NewString("_getPrintClosure"), 0, NULL); | 388 Dart_Invoke(builtin_lib, NewString("_getPrintClosure"), 0, NULL); |
| 399 RETURN_IF_ERROR(print); | 389 RETURN_IF_ERROR(print); |
| 400 Dart_Handle result = | 390 Dart_Handle result = |
| 401 Dart_SetField(internal_lib, NewString("_printClosure"), print); | 391 Dart_SetField(internal_lib, NewString("_printClosure"), print); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 412 RETURN_IF_ERROR(result); | 402 RETURN_IF_ERROR(result); |
| 413 } | 403 } |
| 414 // Set current working directory. | 404 // Set current working directory. |
| 415 result = SetWorkingDirectory(); | 405 result = SetWorkingDirectory(); |
| 416 RETURN_IF_ERROR(result); | 406 RETURN_IF_ERROR(result); |
| 417 } | 407 } |
| 418 return Dart_True(); | 408 return Dart_True(); |
| 419 } | 409 } |
| 420 | 410 |
| 421 Dart_Handle DartUtils::PrepareCoreLibrary(Dart_Handle core_lib, | 411 Dart_Handle DartUtils::PrepareCoreLibrary(Dart_Handle core_lib, |
| 422 Dart_Handle builtin_lib, | 412 Dart_Handle io_lib, |
| 423 bool is_service_isolate) { | 413 bool is_service_isolate) { |
| 424 if (!is_service_isolate) { | 414 if (!is_service_isolate) { |
| 425 // Setup the 'Uri.base' getter in dart:core. | 415 // Setup the 'Uri.base' getter in dart:core. |
| 426 Dart_Handle uri_base = | 416 Dart_Handle uri_base = |
| 427 Dart_Invoke(builtin_lib, NewString("_getUriBaseClosure"), 0, NULL); | 417 Dart_Invoke(io_lib, NewString("_getUriBaseClosure"), 0, NULL); |
| 428 RETURN_IF_ERROR(uri_base); | 418 RETURN_IF_ERROR(uri_base); |
| 429 Dart_Handle result = | 419 Dart_Handle result = |
| 430 Dart_SetField(core_lib, NewString("_uriBaseClosure"), uri_base); | 420 Dart_SetField(core_lib, NewString("_uriBaseClosure"), uri_base); |
| 431 RETURN_IF_ERROR(result); | 421 RETURN_IF_ERROR(result); |
| 432 } | 422 } |
| 433 return Dart_True(); | 423 return Dart_True(); |
| 434 } | 424 } |
| 435 | 425 |
| 436 Dart_Handle DartUtils::PrepareAsyncLibrary(Dart_Handle async_lib, | 426 Dart_Handle DartUtils::PrepareAsyncLibrary(Dart_Handle async_lib, |
| 437 Dart_Handle isolate_lib) { | 427 Dart_Handle isolate_lib) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 // We need to ensure that all the scripts loaded so far are finalized | 515 // We need to ensure that all the scripts loaded so far are finalized |
| 526 // as we are about to invoke some Dart code below to setup closures. | 516 // as we are about to invoke some Dart code below to setup closures. |
| 527 Dart_Handle result = Dart_FinalizeLoading(false); | 517 Dart_Handle result = Dart_FinalizeLoading(false); |
| 528 RETURN_IF_ERROR(result); | 518 RETURN_IF_ERROR(result); |
| 529 | 519 |
| 530 result = PrepareBuiltinLibrary(builtin_lib, internal_lib, is_service_isolate, | 520 result = PrepareBuiltinLibrary(builtin_lib, internal_lib, is_service_isolate, |
| 531 trace_loading); | 521 trace_loading); |
| 532 RETURN_IF_ERROR(result); | 522 RETURN_IF_ERROR(result); |
| 533 | 523 |
| 534 RETURN_IF_ERROR(PrepareAsyncLibrary(async_lib, isolate_lib)); | 524 RETURN_IF_ERROR(PrepareAsyncLibrary(async_lib, isolate_lib)); |
| 535 RETURN_IF_ERROR( | 525 RETURN_IF_ERROR(PrepareCoreLibrary(core_lib, io_lib, is_service_isolate)); |
| 536 PrepareCoreLibrary(core_lib, builtin_lib, is_service_isolate)); | |
| 537 RETURN_IF_ERROR(PrepareIsolateLibrary(isolate_lib)); | 526 RETURN_IF_ERROR(PrepareIsolateLibrary(isolate_lib)); |
| 538 RETURN_IF_ERROR(PrepareIOLibrary(io_lib)); | 527 RETURN_IF_ERROR(PrepareIOLibrary(io_lib)); |
| 539 return result; | 528 return result; |
| 540 } | 529 } |
| 541 | 530 |
| 542 Dart_Handle DartUtils::SetupIOLibrary(const char* script_uri) { | 531 Dart_Handle DartUtils::SetupIOLibrary(const char* script_uri) { |
| 543 Dart_Handle io_lib_url = NewString(kIOLibURL); | 532 Dart_Handle io_lib_url = NewString(kIOLibURL); |
| 544 RETURN_IF_ERROR(io_lib_url); | 533 RETURN_IF_ERROR(io_lib_url); |
| 545 Dart_Handle io_lib = Dart_LookupLibrary(io_lib_url); | 534 Dart_Handle io_lib = Dart_LookupLibrary(io_lib_url); |
| 546 RETURN_IF_ERROR(io_lib); | 535 RETURN_IF_ERROR(io_lib); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 new CObjectString(CObject::NewString(os_error->message())); | 949 new CObjectString(CObject::NewString(os_error->message())); |
| 961 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 950 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 962 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 951 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 963 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 952 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 964 result->SetAt(2, error_message); | 953 result->SetAt(2, error_message); |
| 965 return result; | 954 return result; |
| 966 } | 955 } |
| 967 | 956 |
| 968 } // namespace bin | 957 } // namespace bin |
| 969 } // namespace dart | 958 } // namespace dart |
| OLD | NEW |