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

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
« no previous file with comments | « lib/isolate/isolate_frog.dart ('k') | runtime/bin/dartutils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
25 20
26 Dart_Handle Builtin::Source(BuiltinLibraryId id) { 21 Dart_Handle Builtin::Source(BuiltinLibraryId id) {
27 Dart_Handle source; 22 Dart_Handle source;
28 switch (id) { 23 switch (id) {
29 case kBuiltinLibrary: 24 case kBuiltinLibrary:
30 source = Dart_NewString(Builtin::builtin_source_); 25 source = Dart_NewString(Builtin::builtin_source_);
31 break; 26 break;
32 case kIOLibrary: 27 case kIOLibrary:
(...skipping 13 matching lines...) Expand all
46 } 41 }
47 return source; 42 return source;
48 } 43 }
49 44
50 45
51 void Builtin::SetupLibrary(Dart_Handle library, BuiltinLibraryId id) { 46 void Builtin::SetupLibrary(Dart_Handle library, BuiltinLibraryId id) {
52 if ((id == kJsonLibrary) || (id == kUriLibrary) || (id == kUtf8Library)) { 47 if ((id == kJsonLibrary) || (id == kUriLibrary) || (id == kUtf8Library)) {
53 // No native resolver for these pure Dart libraries. 48 // No native resolver for these pure Dart libraries.
54 return; 49 return;
55 } else if (id == kBuiltinLibrary) { 50 } else if (id == kBuiltinLibrary) {
56 // Setup core lib, builtin import structure. 51 // Import the builtin library into the core and isolate libraries.
57 SetupCorelibImports(library); 52 ImportBuiltinLibIntoLib(DartUtils::kCoreLibURL, library);
53 ImportBuiltinLibIntoLib(DartUtils::kCoreImplLibURL, library);
54 ImportBuiltinLibIntoLib(DartUtils::kIsolateLibURL, library);
58 } 55 }
59 // Setup the native resolver for built in library functions. 56 // Setup the native resolver for built in library functions.
60 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup)); 57 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup));
61 } 58 }
62 59
63 60
64 Dart_Handle Builtin::LoadLibrary(BuiltinLibraryId id) { 61 Dart_Handle Builtin::LoadLibrary(BuiltinLibraryId id) {
65 Dart_Handle url; 62 Dart_Handle url;
66 switch (id) { 63 switch (id) {
67 case kBuiltinLibrary: 64 case kBuiltinLibrary:
(...skipping 25 matching lines...) Expand all
93 DART_CHECK_VALID(library); 90 DART_CHECK_VALID(library);
94 return library; 91 return library;
95 } 92 }
96 93
97 94
98 void Builtin::ImportLibrary(Dart_Handle library, BuiltinLibraryId id) { 95 void Builtin::ImportLibrary(Dart_Handle library, BuiltinLibraryId id) {
99 Dart_Handle imported_library = LoadLibrary(id); 96 Dart_Handle imported_library = LoadLibrary(id);
100 // Import the library into current library. 97 // Import the library into current library.
101 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, imported_library)); 98 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, imported_library));
102 } 99 }
OLDNEW
« no previous file with comments | « lib/isolate/isolate_frog.dart ('k') | runtime/bin/dartutils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698