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" |
11 | 11 |
12 | 12 |
13 Builtin::builtin_lib_props Builtin::builtin_libraries_[] = { | 13 Builtin::builtin_lib_props Builtin::builtin_libraries_[] = { |
14 /* url_ source_ has_natives_ */ | 14 /* url_ source_ has_natives_ */ |
15 { DartUtils::kBuiltinLibURL, NULL, true }, | 15 { DartUtils::kBuiltinLibURL, NULL, true }, |
16 { DartUtils::kJsonLibURL, NULL, false }, | 16 { DartUtils::kJsonLibURL, NULL, false }, |
17 { DartUtils::kUriLibURL, NULL, false }, | 17 { DartUtils::kUriLibURL, NULL, false }, |
18 { DartUtils::kCryptoLibURL, NULL, false }, | 18 { DartUtils::kCryptoLibURL, NULL, false }, |
19 { DartUtils::kIOLibURL, NULL, true }, | 19 { DartUtils::kIOLibURL, NULL, true }, |
20 { DartUtils::kUtfLibURL, NULL, false } | 20 { DartUtils::kUtfLibURL, NULL, false }, |
21 { DartUtils::kWebLibURL, NULL, false } | |
siva
2012/06/21 00:30:49
{ DartUtils::kWebLibURL, web_source_, fals
Emily Fortuna
2012/06/21 16:56:47
Done.
| |
21 }; | 22 }; |
22 | 23 |
23 | 24 |
24 Dart_Handle Builtin::Source(BuiltinLibraryId id) { | 25 Dart_Handle Builtin::Source(BuiltinLibraryId id) { |
25 UNREACHABLE(); | 26 UNREACHABLE(); |
siva
2012/06/21 00:30:49
ASSERT((sizeof(builtin_libraries_) / sizeof(builti
Emily Fortuna
2012/06/21 16:56:47
Done.
| |
26 return Dart_Null(); | 27 return Dart_Null(); |
27 } | 28 } |
28 | 29 |
29 | 30 |
30 void Builtin::SetupLibrary(Dart_Handle library, BuiltinLibraryId id) { | 31 void Builtin::SetupLibrary(Dart_Handle library, BuiltinLibraryId id) { |
31 UNREACHABLE(); | 32 UNREACHABLE(); |
siva
2012/06/21 00:30:49
ASSERT((sizeof(builtin_libraries_) / sizeof(builti
| |
32 } | 33 } |
33 | 34 |
34 | 35 |
35 Dart_Handle Builtin::LoadLibrary(BuiltinLibraryId id) { | 36 Dart_Handle Builtin::LoadLibrary(BuiltinLibraryId id) { |
36 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == | 37 ASSERT((sizeof(builtin_libraries_) / sizeof(builtin_lib_props)) == |
37 kInvalidLibrary); | 38 kInvalidLibrary); |
38 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); | 39 ASSERT(id >= kBuiltinLibrary && id < kInvalidLibrary); |
39 Dart_Handle url = Dart_NewString(builtin_libraries_[id].url_); | 40 Dart_Handle url = Dart_NewString(builtin_libraries_[id].url_); |
40 Dart_Handle library = Dart_LookupLibrary(url); | 41 Dart_Handle library = Dart_LookupLibrary(url); |
41 if (Dart_IsError(library)) { | 42 if (Dart_IsError(library)) { |
42 ASSERT(id >= kCryptoLibrary && id < kInvalidLibrary); | 43 ASSERT(id >= kCryptoLibrary && id < kInvalidLibrary); |
43 library = Dart_LoadLibrary(url, Source(id)); | 44 library = Dart_LoadLibrary(url, Source(id)); |
44 if (!Dart_IsError(library)) { | 45 if (!Dart_IsError(library)) { |
45 SetupLibrary(library, id); | 46 SetupLibrary(library, id); |
46 } | 47 } |
47 } | 48 } |
48 DART_CHECK_VALID(library); | 49 DART_CHECK_VALID(library); |
49 return library; | 50 return library; |
50 } | 51 } |
51 | 52 |
52 | 53 |
53 void Builtin::ImportLibrary(Dart_Handle library, BuiltinLibraryId id) { | 54 void Builtin::ImportLibrary(Dart_Handle library, BuiltinLibraryId id) { |
54 Dart_Handle imported_library = LoadLibrary(id); | 55 Dart_Handle imported_library = LoadLibrary(id); |
55 // Import the library into current library. | 56 // Import the library into current library. |
56 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, imported_library)); | 57 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, imported_library)); |
57 } | 58 } |
OLD | NEW |