Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: runtime/bin/builtin.cc

Issue 9422019: isolates refactor: this change introduces 'dart:isolate' as a library. This is a (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 static void SetupCorelibImports(Dart_Handle builtin_lib) { 12 static void ImportBuiltinLibIntoLib(
13 // Lookup the core libraries and import the builtin library into them. 13 const char* liburl, Dart_Handle builtin_lib) {
14 Dart_Handle url = Dart_NewString(DartUtils::kCoreLibURL); 14 Dart_Handle url = Dart_NewString(liburl);
15 Dart_Handle core_lib = Dart_LookupLibrary(url); 15 Dart_Handle lib = Dart_LookupLibrary(url);
16 DART_CHECK_VALID(core_lib); 16 DART_CHECK_VALID(lib);
17 DART_CHECK_VALID(Dart_LibraryImportLibrary(core_lib, builtin_lib)); 17 DART_CHECK_VALID(Dart_LibraryImportLibrary(lib, builtin_lib));
18
19 url = Dart_NewString(DartUtils::kCoreImplLibURL);
20 Dart_Handle coreimpl_lib = Dart_LookupLibrary(url);
21 DART_CHECK_VALID(coreimpl_lib);
22 DART_CHECK_VALID(Dart_LibraryImportLibrary(coreimpl_lib, builtin_lib));
23 } 18 }
24 19
Ivan Posva 2012/02/25 00:14:38 Two lines between C++ methods.
Siggi Cherem (dart-lang) 2012/02/25 02:10:38 Done.
25
26 Dart_Handle Builtin::Source(BuiltinLibraryId id) { 20 Dart_Handle Builtin::Source(BuiltinLibraryId id) {
27 Dart_Handle source; 21 Dart_Handle source;
28 switch (id) { 22 switch (id) {
29 case kBuiltinLibrary: 23 case kBuiltinLibrary:
30 source = Dart_NewString(Builtin::builtin_source_); 24 source = Dart_NewString(Builtin::builtin_source_);
31 break; 25 break;
32 case kIOLibrary: 26 case kIOLibrary:
33 source = Dart_NewString(Builtin::io_source_); 27 source = Dart_NewString(Builtin::io_source_);
34 break; 28 break;
35 case kJsonLibrary: 29 case kJsonLibrary:
(...skipping 10 matching lines...) Expand all
46 } 40 }
47 return source; 41 return source;
48 } 42 }
49 43
50 44
51 void Builtin::SetupLibrary(Dart_Handle library, BuiltinLibraryId id) { 45 void Builtin::SetupLibrary(Dart_Handle library, BuiltinLibraryId id) {
52 if ((id == kJsonLibrary) || (id == kUriLibrary) || (id == kUtf8Library)) { 46 if ((id == kJsonLibrary) || (id == kUriLibrary) || (id == kUtf8Library)) {
53 // No native resolver for these pure Dart libraries. 47 // No native resolver for these pure Dart libraries.
54 return; 48 return;
55 } else if (id == kBuiltinLibrary) { 49 } else if (id == kBuiltinLibrary) {
56 // Setup core lib, builtin import structure. 50 // Import the builtin library into the core and isolate libraries.
57 SetupCorelibImports(library); 51 ImportBuiltinLibIntoLib(DartUtils::kCoreLibURL, library);
52 ImportBuiltinLibIntoLib(DartUtils::kCoreImplLibURL, library);
53 ImportBuiltinLibIntoLib(DartUtils::kIsolateLibURL, library);
58 } 54 }
59 // Setup the native resolver for built in library functions. 55 // Setup the native resolver for built in library functions.
60 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup)); 56 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup));
61 } 57 }
62 58
63 59
64 Dart_Handle Builtin::LoadLibrary(BuiltinLibraryId id) { 60 Dart_Handle Builtin::LoadLibrary(BuiltinLibraryId id) {
65 Dart_Handle url; 61 Dart_Handle url;
66 switch (id) { 62 switch (id) {
67 case kBuiltinLibrary: 63 case kBuiltinLibrary:
(...skipping 25 matching lines...) Expand all
93 DART_CHECK_VALID(library); 89 DART_CHECK_VALID(library);
94 return library; 90 return library;
95 } 91 }
96 92
97 93
98 void Builtin::ImportLibrary(Dart_Handle library, BuiltinLibraryId id) { 94 void Builtin::ImportLibrary(Dart_Handle library, BuiltinLibraryId id) {
99 Dart_Handle imported_library = LoadLibrary(id); 95 Dart_Handle imported_library = LoadLibrary(id);
100 // Import the library into current library. 96 // Import the library into current library.
101 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, imported_library)); 97 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, imported_library));
102 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698