Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 | 24 |
| 25 Dart_Handle Builtin::Source(BuiltinLibraryId id) { | 25 Dart_Handle Builtin::Source(BuiltinLibraryId id) { |
| 26 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == | 26 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == |
| 27 kInvalidLibrary); | 27 kInvalidLibrary); |
| 28 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); | 28 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); |
| 29 return DartUtils::NewString(builtin_libraries_[id].source_); | 29 return DartUtils::NewString(builtin_libraries_[id].source_); |
| 30 } | 30 } |
| 31 | 31 |
| 32 | 32 |
| 33 Dart_NativeFunction Builtin::NativeLookup(Dart_Handle name, | |
| 34 int argument_count) { | |
| 35 UNREACHABLE(); | |
| 36 return NULL; | |
| 37 } | |
| 38 | |
| 39 | |
| 33 void Builtin::SetNativeResolver(BuiltinLibraryId id) { | 40 void Builtin::SetNativeResolver(BuiltinLibraryId id) { |
| 34 UNREACHABLE(); | 41 UNREACHABLE(); |
| 35 } | 42 } |
| 36 | 43 |
| 37 | 44 |
| 38 Dart_Handle Builtin::LoadAndCheckLibrary(BuiltinLibraryId id) { | 45 Dart_Handle Builtin::LoadAndCheckLibrary(BuiltinLibraryId id) { |
| 39 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == | 46 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == |
| 40 kInvalidLibrary); | 47 kInvalidLibrary); |
| 41 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); | 48 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); |
| 42 Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_); | 49 Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_); |
| 43 Dart_Handle library = Dart_LookupLibrary(url); | 50 Dart_Handle library = Dart_LookupLibrary(url); |
| 44 if (Dart_IsError(library)) { | 51 if (Dart_IsError(library)) { |
| 45 library = Dart_LoadLibrary(url, Source(id)); | 52 library = Dart_LoadLibrary(url, Source(id)); |
| 46 if (!Dart_IsError(library) && (builtin_libraries_[id].has_natives_)) { | 53 if (!Dart_IsError(library) && (builtin_libraries_[id].has_natives_)) { |
| 47 // Setup the native resolver for built in library functions. | 54 // Setup the native resolver for built in library functions. |
| 48 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup)); | 55 // Looks up native functions only in libdart_builtin, not libdart_io. |
| 56 // This is for use in the snapshot generator, which must not link with | |
|
Mads Ager (google)
2012/11/08 09:32:26
Instead of focusing this comment on the problem ca
| |
| 57 // the native implementations for libdart_io, to break the dependence | |
| 58 // of Dartium on our copies of NSS and NSPR (secure networking libraries). | |
| 59 DART_CHECK_VALID(Dart_SetNativeResolver(library, BuiltinNativeLookup)); | |
| 49 } | 60 } |
| 50 if (builtin_libraries_[id].patch_url_ != NULL) { | 61 if (builtin_libraries_[id].patch_url_ != NULL) { |
| 51 ASSERT(builtin_libraries_[id].patch_source_ != NULL); | 62 ASSERT(builtin_libraries_[id].patch_source_ != NULL); |
| 52 Dart_Handle patch_url = | 63 Dart_Handle patch_url = |
| 53 DartUtils::NewString(builtin_libraries_[id].patch_url_); | 64 DartUtils::NewString(builtin_libraries_[id].patch_url_); |
| 54 Dart_Handle patch_source = | 65 Dart_Handle patch_source = |
| 55 DartUtils::NewString(builtin_libraries_[id].patch_source_); | 66 DartUtils::NewString(builtin_libraries_[id].patch_source_); |
| 56 DART_CHECK_VALID(Dart_LoadPatch(library, patch_url, patch_source)); | 67 DART_CHECK_VALID(Dart_LoadPatch(library, patch_url, patch_source)); |
| 57 } | 68 } |
| 58 } | 69 } |
| 59 DART_CHECK_VALID(library); | 70 DART_CHECK_VALID(library); |
| 60 return library; | 71 return library; |
| 61 } | 72 } |
| OLD | NEW |