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

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

Issue 11318018: - Represent strings internally in UTF-16 format, this makes it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 delete file; 146 delete file;
147 } 147 }
148 148
149 149
150 static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag, 150 static Dart_Handle CreateSnapshotLibraryTagHandler(Dart_LibraryTag tag,
151 Dart_Handle library, 151 Dart_Handle library,
152 Dart_Handle url) { 152 Dart_Handle url) {
153 if (!Dart_IsLibrary(library)) { 153 if (!Dart_IsLibrary(library)) {
154 return Dart_Error("not a library"); 154 return Dart_Error("not a library");
155 } 155 }
156 if (!Dart_IsString8(url)) { 156 if (!Dart_IsString(url)) {
157 return Dart_Error("url is not a string"); 157 return Dart_Error("url is not a string");
158 } 158 }
159 const char* url_string = NULL; 159 const char* url_string = NULL;
160 Dart_Handle result = Dart_StringToCString(url, &url_string); 160 Dart_Handle result = Dart_StringToCString(url, &url_string);
161 if (Dart_IsError(result)) { 161 if (Dart_IsError(result)) {
162 return result; 162 return result;
163 } 163 }
164 164
165 // If the URL starts with "dart:" then it is handled specially. 165 // If the URL starts with "dart:" then it is handled specially.
166 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string); 166 bool is_dart_scheme_url = DartUtils::IsDartSchemeURL(url_string);
167 if (tag == kCanonicalizeUrl) { 167 if (tag == kCanonicalizeUrl) {
168 if (is_dart_scheme_url) { 168 if (is_dart_scheme_url) {
169 return url; 169 return url;
170 } 170 }
171 return DartUtils::CanonicalizeURL(url_mapping, library, url_string); 171 return DartUtils::CanonicalizeURL(url_mapping, library, url_string);
172 } 172 }
173 return DartUtils::LoadSource(url_mapping, 173 return DartUtils::LoadSource(url_mapping,
174 library, 174 library,
175 url, 175 url,
176 tag, 176 tag,
177 url_string); 177 url_string);
178 } 178 }
179 179
180 180
181 static Dart_Handle LoadSnapshotCreationScript(const char* script_name) { 181 static Dart_Handle LoadSnapshotCreationScript(const char* script_name) {
182 Dart_Handle source = DartUtils::ReadStringFromFile(script_name); 182 Dart_Handle source = DartUtils::ReadStringFromFile(script_name);
183 if (Dart_IsError(source)) { 183 if (Dart_IsError(source)) {
184 return source; // source contains the error string. 184 return source; // source contains the error string.
185 } 185 }
186 Dart_Handle url = Dart_NewString(script_name); 186 Dart_Handle url = DartUtils::NewString(script_name);
187 187
188 return Dart_LoadScript(url, source); 188 return Dart_LoadScript(url, source);
189 } 189 }
190 190
191 191
192 static Dart_Handle LoadGenericSnapshotCreationScript( 192 static Dart_Handle LoadGenericSnapshotCreationScript(
193 Builtin::BuiltinLibraryId id) { 193 Builtin::BuiltinLibraryId id) {
194 Dart_Handle source = Builtin::Source(id); 194 Dart_Handle source = Builtin::Source(id);
195 if (Dart_IsError(source)) { 195 if (Dart_IsError(source)) {
196 return source; // source contains the error string. 196 return source; // source contains the error string.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 CreateAndWriteSnapshot(true); 388 CreateAndWriteSnapshot(true);
389 389
390 free(snapshot_buffer); 390 free(snapshot_buffer);
391 } 391 }
392 } else { 392 } else {
393 SetupForGenericSnapshotCreation(); 393 SetupForGenericSnapshotCreation();
394 CreateAndWriteSnapshot(false); 394 CreateAndWriteSnapshot(false);
395 } 395 }
396 return 0; 396 return 0;
397 } 397 }
OLDNEW
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/main.cc » ('j') | runtime/vm/dart_api_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698