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

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

Issue 9462001: Unify most of our utf8 implementations. This takes the implementation (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 | « runtime/bin/builtin.h ('k') | runtime/bin/builtin_nolib.cc » ('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"
(...skipping 15 matching lines...) Expand all
26 break; 26 break;
27 case kIOLibrary: 27 case kIOLibrary:
28 source = Dart_NewString(Builtin::io_source_); 28 source = Dart_NewString(Builtin::io_source_);
29 break; 29 break;
30 case kJsonLibrary: 30 case kJsonLibrary:
31 source = Dart_NewString(Builtin::json_source_); 31 source = Dart_NewString(Builtin::json_source_);
32 break; 32 break;
33 case kUriLibrary: 33 case kUriLibrary:
34 source = Dart_NewString(Builtin::uri_source_); 34 source = Dart_NewString(Builtin::uri_source_);
35 break; 35 break;
36 case kUtf8Library: 36 case kUtfLibrary:
37 source = Dart_NewString(Builtin::utf8_source_); 37 source = Dart_NewString(Builtin::utf_source_);
38 break; 38 break;
39 default: 39 default:
40 return Dart_Error("Unknown builtin source requested."); 40 return Dart_Error("Unknown builtin source requested.");
41 } 41 }
42 return source; 42 return source;
43 } 43 }
44 44
45 45
46 void Builtin::SetupLibrary(Dart_Handle library, BuiltinLibraryId id) { 46 void Builtin::SetupLibrary(Dart_Handle library, BuiltinLibraryId id) {
47 if ((id == kJsonLibrary) || (id == kUriLibrary) || (id == kUtf8Library)) { 47 if ((id == kJsonLibrary) || (id == kUriLibrary) || (id == kUtfLibrary)) {
48 // No native resolver for these pure Dart libraries. 48 // No native resolver for these pure Dart libraries.
49 return; 49 return;
50 } else if (id == kBuiltinLibrary) { 50 } else if (id == kBuiltinLibrary) {
51 // Import the builtin library into the core and isolate libraries. 51 // Import the builtin library into the core and isolate libraries.
52 ImportBuiltinLibIntoLib(DartUtils::kCoreLibURL, library); 52 ImportBuiltinLibIntoLib(DartUtils::kCoreLibURL, library);
53 ImportBuiltinLibIntoLib(DartUtils::kCoreImplLibURL, library); 53 ImportBuiltinLibIntoLib(DartUtils::kCoreImplLibURL, library);
54 ImportBuiltinLibIntoLib(DartUtils::kIsolateLibURL, library); 54 ImportBuiltinLibIntoLib(DartUtils::kIsolateLibURL, library);
55 } 55 }
56 // Setup the native resolver for built in library functions. 56 // Setup the native resolver for built in library functions.
57 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup)); 57 DART_CHECK_VALID(Dart_SetNativeResolver(library, NativeLookup));
58 } 58 }
59 59
60 60
61 Dart_Handle Builtin::LoadLibrary(BuiltinLibraryId id) { 61 Dart_Handle Builtin::LoadLibrary(BuiltinLibraryId id) {
62 Dart_Handle url; 62 Dart_Handle url;
63 switch (id) { 63 switch (id) {
64 case kBuiltinLibrary: 64 case kBuiltinLibrary:
65 url = Dart_NewString(DartUtils::kBuiltinLibURL); 65 url = Dart_NewString(DartUtils::kBuiltinLibURL);
66 break; 66 break;
67 case kIOLibrary: 67 case kIOLibrary:
68 url = Dart_NewString(DartUtils::kIOLibURL); 68 url = Dart_NewString(DartUtils::kIOLibURL);
69 break; 69 break;
70 case kJsonLibrary: 70 case kJsonLibrary:
71 url = Dart_NewString(DartUtils::kJsonLibURL); 71 url = Dart_NewString(DartUtils::kJsonLibURL);
72 break; 72 break;
73 case kUriLibrary: 73 case kUriLibrary:
74 url = Dart_NewString(DartUtils::kUriLibURL); 74 url = Dart_NewString(DartUtils::kUriLibURL);
75 break; 75 break;
76 case kUtf8Library: 76 case kUtfLibrary:
77 url = Dart_NewString(DartUtils::kUtf8LibURL); 77 url = Dart_NewString(DartUtils::kUtfLibURL);
78 break; 78 break;
79 default: 79 default:
80 return Dart_Error("Unknown builtin library requested."); 80 return Dart_Error("Unknown builtin library requested.");
81 } 81 }
82 Dart_Handle library = Dart_LookupLibrary(url); 82 Dart_Handle library = Dart_LookupLibrary(url);
83 if (Dart_IsError(library)) { 83 if (Dart_IsError(library)) {
84 Dart_Handle import_map = Dart_NewList(0); 84 Dart_Handle import_map = Dart_NewList(0);
85 library = Dart_LoadLibrary(url, Source(id), import_map); 85 library = Dart_LoadLibrary(url, Source(id), import_map);
86 if (!Dart_IsError(library)) { 86 if (!Dart_IsError(library)) {
87 SetupLibrary(library, id); 87 SetupLibrary(library, id);
88 } 88 }
89 } 89 }
90 DART_CHECK_VALID(library); 90 DART_CHECK_VALID(library);
91 return library; 91 return library;
92 } 92 }
93 93
94 94
95 void Builtin::ImportLibrary(Dart_Handle library, BuiltinLibraryId id) { 95 void Builtin::ImportLibrary(Dart_Handle library, BuiltinLibraryId id) {
96 Dart_Handle imported_library = LoadLibrary(id); 96 Dart_Handle imported_library = LoadLibrary(id);
97 // Import the library into current library. 97 // Import the library into current library.
98 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, imported_library)); 98 DART_CHECK_VALID(Dart_LibraryImportLibrary(library, imported_library));
99 } 99 }
OLDNEW
« no previous file with comments | « runtime/bin/builtin.h ('k') | runtime/bin/builtin_nolib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698