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 15 matching lines...) Expand all Loading... |
26 kInvalidLibrary); | 26 kInvalidLibrary); |
27 return Dart_NewApiError("Unreachable code in Builtin::Source (%d).", id); | 27 return Dart_NewApiError("Unreachable code in Builtin::Source (%d).", id); |
28 } | 28 } |
29 | 29 |
30 | 30 |
31 void Builtin::SetNativeResolver(BuiltinLibraryId id) { | 31 void Builtin::SetNativeResolver(BuiltinLibraryId id) { |
32 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == | 32 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == |
33 kInvalidLibrary); | 33 kInvalidLibrary); |
34 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); | 34 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); |
35 if (builtin_libraries_[id].has_natives_) { | 35 if (builtin_libraries_[id].has_natives_) { |
36 Dart_Handle url = Dart_NewString(builtin_libraries_[id].url_); | 36 Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_); |
37 Dart_Handle library = Dart_LookupLibrary(url); | 37 Dart_Handle library = Dart_LookupLibrary(url); |
38 ASSERT(!Dart_IsError(library)); | 38 ASSERT(!Dart_IsError(library)); |
39 // Setup the native resolver for built in library functions. | 39 // Setup the native resolver for built in library functions. |
40 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup)); | 40 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup)); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 Dart_Handle Builtin::LoadAndCheckLibrary(BuiltinLibraryId id) { | 45 Dart_Handle Builtin::LoadAndCheckLibrary(BuiltinLibraryId id) { |
46 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == | 46 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == |
47 kInvalidLibrary); | 47 kInvalidLibrary); |
48 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); | 48 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); |
49 Dart_Handle url = Dart_NewString(builtin_libraries_[id].url_); | 49 Dart_Handle url = DartUtils::NewString(builtin_libraries_[id].url_); |
50 Dart_Handle library = Dart_LookupLibrary(url); | 50 Dart_Handle library = Dart_LookupLibrary(url); |
51 if (Dart_IsError(library)) { | 51 if (Dart_IsError(library)) { |
52 ASSERT(id > kUtfLibrary); | 52 ASSERT(id > kUtfLibrary); |
53 library = Dart_LoadLibrary(url, Source(id)); | 53 library = Dart_LoadLibrary(url, Source(id)); |
54 if (!Dart_IsError(library) && (builtin_libraries_[id].has_natives_)) { | 54 if (!Dart_IsError(library) && (builtin_libraries_[id].has_natives_)) { |
55 // Setup the native resolver for built in library functions. | 55 // Setup the native resolver for built in library functions. |
56 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup)); | 56 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup)); |
57 } | 57 } |
58 } | 58 } |
59 DART_CHECK_VALID(library); | 59 DART_CHECK_VALID(library); |
60 return library; | 60 return library; |
61 } | 61 } |
OLD | NEW |