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

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

Issue 10332257: Revert my last change. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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/dartutils.cc ('k') | runtime/bin/main.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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ASSERT(file != NULL); 109 ASSERT(file != NULL);
110 for (intptr_t i = 0; i < size; i++) { 110 for (intptr_t i = 0; i < size; i++) {
111 file->WriteByte(buffer[i]); 111 file->WriteByte(buffer[i]);
112 } 112 }
113 delete file; 113 delete file;
114 } 114 }
115 115
116 116
117 static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag, 117 static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
118 Dart_Handle library, 118 Dart_Handle library,
119 Dart_Handle url) { 119 Dart_Handle url,
120 Dart_Handle import_map) {
120 if (!Dart_IsLibrary(library)) { 121 if (!Dart_IsLibrary(library)) {
121 return Dart_Error("not a library"); 122 return Dart_Error("not a library");
122 } 123 }
123 if (!Dart_IsString8(url)) { 124 if (!Dart_IsString8(url)) {
124 return Dart_Error("url is not a string"); 125 return Dart_Error("url is not a string");
125 } 126 }
126 const char* url_string = NULL; 127 const char* url_string = NULL;
127 Dart_Handle result = Dart_StringToCString(url, &url_string); 128 Dart_Handle result = Dart_StringToCString(url, &url_string);
128 if (Dart_IsError(result)) { 129 if (Dart_IsError(result)) {
129 return result; 130 return result;
130 } 131 }
131 132
132 // If the URL starts with "dart:" then it is handled specially. 133 // If the URL starts with "dart:" then it is handled specially.
133 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); 134 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string);
134 if (tag == kCanonicalizeUrl) { 135 if (tag == kCanonicalizeUrl) {
135 if (is_dart_scheme_url) { 136 if (is_dart_scheme_url) {
136 return url; 137 return url;
137 } 138 }
138 return DartUtils::CanonicalizeURL(url_mapping, library, url_string); 139 return DartUtils::CanonicalizeURL(url_mapping, library, url_string);
139 } 140 }
140 return DartUtils::LoadSource(url_mapping, 141 return DartUtils::LoadSource(url_mapping,
141 library, 142 library,
142 url, 143 url,
143 tag, 144 tag,
144 url_string); 145 url_string,
146 import_map);
145 } 147 }
146 148
147 149
148 static Dart_Handle LoadSnapshotCreationScript(const char* script_name) { 150 static Dart_Handle LoadSnapshotCreationScript(const char* script_name) {
149 Dart_Handle source = DartUtils::ReadStringFromFile(script_name); 151 Dart_Handle source = DartUtils::ReadStringFromFile(script_name);
150 if (Dart_IsError(source)) { 152 if (Dart_IsError(source)) {
151 return source; // source contains the error string. 153 return source; // source contains the error string.
152 } 154 }
153 Dart_Handle url = Dart_NewString(script_name); 155 Dart_Handle url = Dart_NewString(script_name);
156 Dart_Handle import_map = Dart_NewList(0);
154 157
155 return Dart_LoadScript(url, source); 158 return Dart_LoadScript(url,
159 source,
160 import_map);
156 } 161 }
157 162
158 163
159 static Dart_Handle BuiltinLibraryTagHandler(Dart_LibraryTag tag, 164 static Dart_Handle BuiltinLibraryTagHandler(Dart_LibraryTag tag,
160 Dart_Handle library, 165 Dart_Handle library,
161 Dart_Handle url) { 166 Dart_Handle url,
167 Dart_Handle import_map) {
162 if (!Dart_IsLibrary(library)) { 168 if (!Dart_IsLibrary(library)) {
163 return Dart_Error("not a library"); 169 return Dart_Error("not a library");
164 } 170 }
165 if (!Dart_IsString8(url)) { 171 if (!Dart_IsString8(url)) {
166 return Dart_Error("url is not a string"); 172 return Dart_Error("url is not a string");
167 } 173 }
168 const char* url_string = NULL; 174 const char* url_string = NULL;
169 Dart_Handle result = Dart_StringToCString(url, &url_string); 175 Dart_Handle result = Dart_StringToCString(url, &url_string);
170 if (Dart_IsError(result)) { 176 if (Dart_IsError(result)) {
171 return result; 177 return result;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 257 }
252 258
253 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); 259 Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
254 260
255 // Initialize the Dart VM. 261 // Initialize the Dart VM.
256 // Note: We don't expect isolates to be created from dart code during 262 // Note: We don't expect isolates to be created from dart code during
257 // snapshot generation. 263 // snapshot generation.
258 Dart_Initialize(NULL, NULL); 264 Dart_Initialize(NULL, NULL);
259 265
260 char* error; 266 char* error;
261 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &error); 267 Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, NULL, &error);
262 if (isolate == NULL) { 268 if (isolate == NULL) {
263 fprintf(stderr, "%s", error); 269 fprintf(stderr, "%s", error);
264 free(error); 270 free(error);
265 exit(255); 271 exit(255);
266 } 272 }
267 273
268 Dart_Handle result; 274 Dart_Handle result;
269 Dart_Handle library; 275 Dart_Handle library;
270 Dart_EnterScope(); 276 Dart_EnterScope();
271 277
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 exit(255); 326 exit(255);
321 } 327 }
322 // Now write the snapshot out to specified file and exit. 328 // Now write the snapshot out to specified file and exit.
323 WriteSnapshotFile(buffer, size); 329 WriteSnapshotFile(buffer, size);
324 Dart_ExitScope(); 330 Dart_ExitScope();
325 331
326 // Shutdown the isolate. 332 // Shutdown the isolate.
327 Dart_ShutdownIsolate(); 333 Dart_ShutdownIsolate();
328 return 0; 334 return 0;
329 } 335 }
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698