Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 const char* url_string = NULL; | 175 const char* url_string = NULL; |
| 176 Dart_Handle result = Dart_StringToCString(url, &url_string); | 176 Dart_Handle result = Dart_StringToCString(url, &url_string); |
| 177 if (Dart_IsError(result)) { | 177 if (Dart_IsError(result)) { |
| 178 return result; | 178 return result; |
| 179 } | 179 } |
| 180 // We only support canonicalization of "dart:". | 180 // We only support canonicalization of "dart:". |
| 181 if (DartUtils::IsDartSchemeURL(url_string)) { | 181 if (DartUtils::IsDartSchemeURL(url_string)) { |
| 182 if (tag == kCanonicalizeUrl) { | 182 if (tag == kCanonicalizeUrl) { |
| 183 return url; | 183 return url; |
| 184 } | 184 } |
| 185 // TODO(iposva): Make sure only the known libraries are being added. | 185 ASSERT(tag == kImportTag); |
| 186 return Dart_True(); | 186 // Handle imports of other built-in libraries present in the SDK. |
| 187 if (DartUtils::IsDartIOLibURL(url_string)) { | |
| 188 return Builtin::LoadLibrary(Builtin::kIOLibrary); | |
| 189 } else if (DartUtils::IsDartJsonLibURL(url_string)) { | |
| 190 return Builtin::LoadLibrary(Builtin::kJsonLibrary); | |
| 191 } else if (DartUtils::IsDartUriLibURL(url_string)) { | |
| 192 return Builtin::LoadLibrary(Builtin::kUriLibrary); | |
| 193 } else if (DartUtils::IsDartUtfLibURL(url_string)) { | |
| 194 return Builtin::LoadLibrary(Builtin::kUtfLibrary); | |
| 195 } | |
|
siva
2012/03/09 18:02:39
The fall through case here is going to produce an
| |
| 187 } | 196 } |
| 188 return Dart_Error("unexpected tag encountered %d", tag); | 197 return Dart_Error("unexpected tag encountered %d", tag); |
| 189 } | 198 } |
| 190 | 199 |
| 191 | 200 |
| 192 static Dart_Handle LoadGenericSnapshotCreationScript( | 201 static Dart_Handle LoadGenericSnapshotCreationScript( |
| 193 Builtin::BuiltinLibraryId id) { | 202 Builtin::BuiltinLibraryId id) { |
| 194 Dart_Handle source = Builtin::Source(id); | 203 Dart_Handle source = Builtin::Source(id); |
| 195 if (Dart_IsError(source)) { | 204 if (Dart_IsError(source)) { |
| 196 return source; // source contains the error string. | 205 return source; // source contains the error string. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 exit(255); | 313 exit(255); |
| 305 } | 314 } |
| 306 // Now write the snapshot out to specified file and exit. | 315 // Now write the snapshot out to specified file and exit. |
| 307 WriteSnapshotFile(buffer, size); | 316 WriteSnapshotFile(buffer, size); |
| 308 Dart_ExitScope(); | 317 Dart_ExitScope(); |
| 309 | 318 |
| 310 // Shutdown the isolate. | 319 // Shutdown the isolate. |
| 311 Dart_ShutdownIsolate(); | 320 Dart_ShutdownIsolate(); |
| 312 return 0; | 321 return 0; |
| 313 } | 322 } |
| OLD | NEW |