| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 79 } |
| 80 return DartUtils::ReadStringFromFile(source_path); | 80 return DartUtils::ReadStringFromFile(source_path); |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 void Builtin::SetNativeResolver(BuiltinLibraryId id) { | 84 void Builtin::SetNativeResolver(BuiltinLibraryId id) { |
| 85 UNREACHABLE(); | 85 UNREACHABLE(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 | 88 |
| 89 Dart_Handle Builtin::LoadLibrary(Dart_Handle url, BuiltinLibraryId id) { |
| 90 Dart_Handle library = Dart_LoadLibrary(url, Source(id)); |
| 91 if (!Dart_IsError(library) && (builtin_libraries_[id].has_natives_)) { |
| 92 // Setup the native resolver for built in library functions. |
| 93 DART_CHECK_VALID( |
| 94 Dart_SetNativeResolver(library, NativeLookup, NativeSymbol)); |
| 95 } |
| 96 if (builtin_libraries_[id].patch_url_ != NULL) { |
| 97 ASSERT(builtin_libraries_[id].patch_paths_ != NULL); |
| 98 LoadPatchFiles(library, |
| 99 builtin_libraries_[id].patch_url_, |
| 100 builtin_libraries_[id].patch_paths_); |
| 101 } |
| 102 return library; |
| 103 } |
| 104 |
| 105 |
| 89 Dart_Handle Builtin::LoadAndCheckLibrary(BuiltinLibraryId id) { | 106 Dart_Handle Builtin::LoadAndCheckLibrary(BuiltinLibraryId id) { |
| 90 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == | 107 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == |
| 91 kInvalidLibrary); | 108 kInvalidLibrary); |
| 92 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); | 109 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); |
| 93 Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_); | 110 Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_); |
| 94 Dart_Handle library = Dart_LookupLibrary(url); | 111 Dart_Handle library = Dart_LookupLibrary(url); |
| 95 if (Dart_IsError(library)) { | 112 if (Dart_IsError(library)) { |
| 96 library = Dart_LoadLibrary(url, Source(id)); | 113 library = LoadLibrary(url, id); |
| 97 if (!Dart_IsError(library) && (builtin_libraries_[id].has_natives_)) { | |
| 98 // Setup the native resolver for built in library functions. | |
| 99 DART_CHECK_VALID( | |
| 100 Dart_SetNativeResolver(library, NativeLookup, NativeSymbol)); | |
| 101 } | |
| 102 if (builtin_libraries_[id].patch_url_ != NULL) { | |
| 103 ASSERT(builtin_libraries_[id].patch_paths_ != NULL); | |
| 104 LoadPatchFiles(library, | |
| 105 builtin_libraries_[id].patch_url_, | |
| 106 builtin_libraries_[id].patch_paths_); | |
| 107 } | |
| 108 } | 114 } |
| 109 DART_CHECK_VALID(library); | 115 DART_CHECK_VALID(library); |
| 110 return library; | 116 return library; |
| 111 } | 117 } |
| 112 | 118 |
| 113 } // namespace bin | 119 } // namespace bin |
| 114 } // namespace dart | 120 } // namespace dart |
| OLD | NEW |