| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 i += 1; | 98 i += 1; |
| 99 } else { | 99 } else { |
| 100 *script_name = NULL; | 100 *script_name = NULL; |
| 101 } | 101 } |
| 102 | 102 |
| 103 return 0; | 103 return 0; |
| 104 } | 104 } |
| 105 | 105 |
| 106 | 106 |
| 107 static void WriteSnapshotFile(const uint8_t* buffer, const intptr_t size) { | 107 static void WriteSnapshotFile(const uint8_t* buffer, const intptr_t size) { |
| 108 const bool kWritable = true; | 108 File* file = File::Open(snapshot_filename, File::kWriteTruncate); |
| 109 File* file = File::Open(snapshot_filename, kWritable); | |
| 110 ASSERT(file != NULL); | 109 ASSERT(file != NULL); |
| 111 for (intptr_t i = 0; i < size; i++) { | 110 for (intptr_t i = 0; i < size; i++) { |
| 112 file->WriteByte(buffer[i]); | 111 file->WriteByte(buffer[i]); |
| 113 } | 112 } |
| 114 delete file; | 113 delete file; |
| 115 } | 114 } |
| 116 | 115 |
| 117 | 116 |
| 118 static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag, | 117 static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag, |
| 119 Dart_Handle library, | 118 Dart_Handle library, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 exit(255); | 267 exit(255); |
| 269 } | 268 } |
| 270 // Now write the snapshot out to specified file and exit. | 269 // Now write the snapshot out to specified file and exit. |
| 271 WriteSnapshotFile(buffer, size); | 270 WriteSnapshotFile(buffer, size); |
| 272 Dart_ExitScope(); | 271 Dart_ExitScope(); |
| 273 | 272 |
| 274 // Shutdown the isolate. | 273 // Shutdown the isolate. |
| 275 Dart_ShutdownIsolate(); | 274 Dart_ShutdownIsolate(); |
| 276 return 0; | 275 return 0; |
| 277 } | 276 } |
| OLD | NEW |