| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 | 8 |
| 9 #include "bin/builtin.h" | 9 #include "bin/builtin.h" |
| 10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 | 23 |
| 24 Dart_Handle Builtin::Source(BuiltinLibraryId id) { | 24 Dart_Handle Builtin::Source(BuiltinLibraryId id) { |
| 25 UNREACHABLE(); | 25 UNREACHABLE(); |
| 26 return Dart_Null(); | 26 return Dart_Null(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 | 29 |
| 30 void Builtin::SetupLibrary(Dart_Handle library, BuiltinLibraryId id) { | 30 void Builtin::SetupLibrary(Dart_Handle library, BuiltinLibraryId id) { |
| 31 UNREACHABLE(); | 31 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == |
| 32 kInvalidLibrary); |
| 33 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); |
| 34 if (builtin_libraries_[id].has_natives_) { |
| 35 // Setup the native resolver for built in library functions. |
| 36 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup)); |
| 37 } |
| 32 } | 38 } |
| 33 | 39 |
| 34 | 40 |
| 35 Dart_Handle Builtin::LoadLibrary(BuiltinLibraryId id) { | 41 Dart_Handle Builtin::LoadLibrary(BuiltinLibraryId id) { |
| 36 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == | 42 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == |
| 37 kInvalidLibrary); | 43 kInvalidLibrary); |
| 38 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); | 44 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); |
| 39 Dart_Handle url = Dart_NewString(builtin_libraries_[id].url_); | 45 Dart_Handle url = Dart_NewString(builtin_libraries_[id].url_); |
| 40 Dart_Handle library = Dart_LookupLibrary(url); | 46 Dart_Handle library = Dart_LookupLibrary(url); |
| 41 if (Dart_IsError(library)) { | 47 if (Dart_IsError(library)) { |
| 42 ASSERT(id >= kCryptoLibrary && id < kInvalidLibrary); | 48 ASSERT(id >= kCryptoLibrary && id < kInvalidLibrary); |
| 43 library = Dart_LoadLibrary(url, Source(id)); | 49 library = Dart_LoadLibrary(url, Source(id)); |
| 44 if (!Dart_IsError(library)) { | 50 if (!Dart_IsError(library)) { |
| 45 SetupLibrary(library, id); | 51 SetupLibrary(library, id); |
| 46 } | 52 } |
| 47 } | 53 } |
| 48 DART_CHECK_VALID(library); | 54 DART_CHECK_VALID(library); |
| 49 return library; | 55 return library; |
| 50 } | 56 } |
| 51 | 57 |
| 52 | 58 |
| 53 void Builtin::ImportLibrary(Dart_Handle library, BuiltinLibraryId id) { | 59 void Builtin::ImportLibrary(Dart_Handle library, BuiltinLibraryId id) { |
| 54 Dart_Handle imported_library = LoadLibrary(id); | 60 Dart_Handle imported_library = LoadLibrary(id); |
| 55 // Import the library into current library. | 61 // Import the library into current library. |
| 56 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, imported_library)); | 62 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, imported_library)); |
| 57 } | 63 } |
| OLD | NEW |