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

Side by Side Diff: bin/gen_snapshot.cc

Issue 9417012: - Add dart:json, dart:uri and dart:utf8 to the known and builtin libraries. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
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 | « bin/dartutils.cc ('k') | bin/io_in.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 // Generate a snapshot file after loading all the scripts specified on the 5 // Generate a snapshot file after loading all the scripts specified on the
6 // command line. 6 // command line.
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 Dart_Handle lib; 197 Dart_Handle lib;
198 if (id == Builtin::kBuiltinLibrary) { 198 if (id == Builtin::kBuiltinLibrary) {
199 // Load the dart:builtin library as the script. 199 // Load the dart:builtin library as the script.
200 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL); 200 Dart_Handle url = Dart_NewString(DartUtils::kBuiltinLibURL);
201 Dart_Handle import_map = Dart_NewList(0); 201 Dart_Handle import_map = Dart_NewList(0);
202 lib = Dart_LoadScript(url, 202 lib = Dart_LoadScript(url,
203 source, 203 source,
204 BuiltinLibraryTagHandler, 204 BuiltinLibraryTagHandler,
205 import_map); 205 import_map);
206 } else { 206 } else {
207 ASSERT(id == Builtin::kIOLibrary); 207 // Load the builtin library to make it available in the snapshot
208 // Load the dart:io library to make it available in the snapshot
209 // for importing. 208 // for importing.
210 lib = Builtin::LoadLibrary(Builtin::kIOLibrary); 209 lib = Builtin::LoadLibrary(id);
211 } 210 }
212 if (!Dart_IsError(lib)) { 211 if (!Dart_IsError(lib)) {
213 Builtin::SetupLibrary(lib, id); 212 Builtin::SetupLibrary(lib, id);
214 } 213 }
215 return lib; 214 return lib;
216 } 215 }
217 216
218 217
219 static void PrintUsage() { 218 static void PrintUsage() {
220 fprintf(stderr, 219 fprintf(stderr,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 if (app_script_name != NULL) { 279 if (app_script_name != NULL) {
281 // Load the specified script. 280 // Load the specified script.
282 library = LoadSnapshotCreationScript(app_script_name); 281 library = LoadSnapshotCreationScript(app_script_name);
283 VerifyLoaded(library); 282 VerifyLoaded(library);
284 } else { 283 } else {
285 // This is a generic dart snapshot which needs builtin library setup. 284 // This is a generic dart snapshot which needs builtin library setup.
286 library = LoadGenericSnapshotCreationScript(Builtin::kBuiltinLibrary); 285 library = LoadGenericSnapshotCreationScript(Builtin::kBuiltinLibrary);
287 VerifyLoaded(library); 286 VerifyLoaded(library);
288 library = LoadGenericSnapshotCreationScript(Builtin::kIOLibrary); 287 library = LoadGenericSnapshotCreationScript(Builtin::kIOLibrary);
289 VerifyLoaded(library); 288 VerifyLoaded(library);
289 library = LoadGenericSnapshotCreationScript(Builtin::kJsonLibrary);
290 VerifyLoaded(library);
291 library = LoadGenericSnapshotCreationScript(Builtin::kUriLibrary);
292 VerifyLoaded(library);
293 library = LoadGenericSnapshotCreationScript(Builtin::kUtf8Library);
294 VerifyLoaded(library);
290 } 295 }
291 296
292 uint8_t* buffer = NULL; 297 uint8_t* buffer = NULL;
293 intptr_t size = 0; 298 intptr_t size = 0;
294 // First create the snapshot. 299 // First create the snapshot.
295 result = Dart_CreateSnapshot(&buffer, &size); 300 result = Dart_CreateSnapshot(&buffer, &size);
296 if (Dart_IsError(result)) { 301 if (Dart_IsError(result)) {
297 const char* err_msg = Dart_GetError(result); 302 const char* err_msg = Dart_GetError(result);
298 fprintf(stderr, "Error while creating snapshot: %s\n", err_msg); 303 fprintf(stderr, "Error while creating snapshot: %s\n", err_msg);
299 Dart_ExitScope(); 304 Dart_ExitScope();
300 Dart_ShutdownIsolate(); 305 Dart_ShutdownIsolate();
301 exit(255); 306 exit(255);
302 } 307 }
303 // Now write the snapshot out to specified file and exit. 308 // Now write the snapshot out to specified file and exit.
304 WriteSnapshotFile(buffer, size); 309 WriteSnapshotFile(buffer, size);
305 Dart_ExitScope(); 310 Dart_ExitScope();
306 311
307 // Shutdown the isolate. 312 // Shutdown the isolate.
308 Dart_ShutdownIsolate(); 313 Dart_ShutdownIsolate();
309 return 0; 314 return 0;
310 } 315 }
OLDNEW
« no previous file with comments | « bin/dartutils.cc ('k') | bin/io_in.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698