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 "bin/io_buffer.h" | 10 #include "bin/io_buffer.h" |
11 #include "include/dart_api.h" | 11 #include "include/dart_api.h" |
12 #include "platform/assert.h" | 12 #include "platform/assert.h" |
13 #include "platform/globals.h" | 13 #include "platform/globals.h" |
14 | 14 |
15 const char* DartUtils::original_working_directory = NULL; | 15 const char* DartUtils::original_working_directory = NULL; |
16 const char* DartUtils::kDartScheme = "dart:"; | 16 const char* DartUtils::kDartScheme = "dart:"; |
17 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; | 17 const char* DartUtils::kDartExtensionScheme = "dart-ext:"; |
| 18 const char* DartUtils::kASyncLibURL = "dart:async"; |
18 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; | 19 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; |
19 const char* DartUtils::kCoreLibURL = "dart:core"; | 20 const char* DartUtils::kCoreLibURL = "dart:core"; |
20 const char* DartUtils::kCryptoLibURL = "dart:crypto"; | 21 const char* DartUtils::kCryptoLibURL = "dart:crypto"; |
21 const char* DartUtils::kIOLibURL = "dart:io"; | 22 const char* DartUtils::kIOLibURL = "dart:io"; |
22 const char* DartUtils::kIOLibPatchURL = "dart:io-patch"; | 23 const char* DartUtils::kIOLibPatchURL = "dart:io-patch"; |
23 const char* DartUtils::kJsonLibURL = "dart:json"; | 24 const char* DartUtils::kJsonLibURL = "dart:json"; |
24 const char* DartUtils::kUriLibURL = "dart:uri"; | 25 const char* DartUtils::kUriLibURL = "dart:uri"; |
25 const char* DartUtils::kUtfLibURL = "dart:utf"; | 26 const char* DartUtils::kUtfLibURL = "dart:utf"; |
26 const char* DartUtils::kIsolateLibURL = "dart:isolate"; | 27 const char* DartUtils::kIsolateLibURL = "dart:isolate"; |
27 | 28 |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 Dart_Handle builtin_lib) { | 410 Dart_Handle builtin_lib) { |
410 // Setup the corelib 'print' function. | 411 // Setup the corelib 'print' function. |
411 Dart_Handle print = Dart_Invoke( | 412 Dart_Handle print = Dart_Invoke( |
412 builtin_lib, NewString("_getPrintClosure"), 0, 0); | 413 builtin_lib, NewString("_getPrintClosure"), 0, 0); |
413 Dart_Handle corelib = Dart_LookupLibrary(NewString("dart:core")); | 414 Dart_Handle corelib = Dart_LookupLibrary(NewString("dart:core")); |
414 Dart_Handle result = Dart_SetField(corelib, | 415 Dart_Handle result = Dart_SetField(corelib, |
415 NewString("_printClosure"), | 416 NewString("_printClosure"), |
416 print); | 417 print); |
417 | 418 |
418 // Setup the 'timer' factory. | 419 // Setup the 'timer' factory. |
419 Dart_Handle url = NewString(kIsolateLibURL); | 420 Dart_Handle url = NewString(kASyncLibURL); |
420 DART_CHECK_VALID(url); | 421 DART_CHECK_VALID(url); |
421 Dart_Handle isolate_lib = Dart_LookupLibrary(url); | 422 Dart_Handle async_lib = Dart_LookupLibrary(url); |
422 DART_CHECK_VALID(isolate_lib); | 423 DART_CHECK_VALID(async_lib); |
423 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); | 424 Dart_Handle io_lib = Builtin::LoadAndCheckLibrary(Builtin::kIOLibrary); |
424 Dart_Handle timer_closure = | 425 Dart_Handle timer_closure = |
425 Dart_Invoke(io_lib, NewString("_getTimerFactoryClosure"), 0, NULL); | 426 Dart_Invoke(io_lib, NewString("_getTimerFactoryClosure"), 0, NULL); |
426 Dart_Handle args[1]; | 427 Dart_Handle args[1]; |
427 args[0] = timer_closure; | 428 args[0] = timer_closure; |
428 DART_CHECK_VALID(Dart_Invoke( | 429 DART_CHECK_VALID(Dart_Invoke( |
429 isolate_lib, NewString("_setTimerFactoryClosure"), 1, args)); | 430 async_lib, NewString("_setTimerFactoryClosure"), 1, args)); |
430 | 431 |
431 // Set up package root if specified. | 432 // Set up package root if specified. |
432 if (package_root != NULL) { | 433 if (package_root != NULL) { |
433 result = NewString(package_root); | 434 result = NewString(package_root); |
434 if (!Dart_IsError(result)) { | 435 if (!Dart_IsError(result)) { |
435 const int kNumArgs = 1; | 436 const int kNumArgs = 1; |
436 Dart_Handle dart_args[kNumArgs]; | 437 Dart_Handle dart_args[kNumArgs]; |
437 dart_args[0] = result; | 438 dart_args[0] = result; |
438 return Dart_Invoke(builtin_lib, | 439 return Dart_Invoke(builtin_lib, |
439 NewString("_setPackageRoot"), | 440 NewString("_setPackageRoot"), |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 | 713 |
713 CObject* CObject::NewOSError(OSError* os_error) { | 714 CObject* CObject::NewOSError(OSError* os_error) { |
714 CObject* error_message = | 715 CObject* error_message = |
715 new CObjectString(CObject::NewString(os_error->message())); | 716 new CObjectString(CObject::NewString(os_error->message())); |
716 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 717 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
717 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 718 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
718 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 719 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
719 result->SetAt(2, error_message); | 720 result->SetAt(2, error_message); |
720 return result; | 721 return result; |
721 } | 722 } |
OLD | NEW |