| OLD | NEW | 
|    1 // Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file |    1 // Copyright (c) 2013, 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  297   } |  297   } | 
|  298  |  298  | 
|  299   if (!Dart_IsString(url)) { |  299   if (!Dart_IsString(url)) { | 
|  300     return Dart_Error("url is not a string"); |  300     return Dart_Error("url is not a string"); | 
|  301   } |  301   } | 
|  302   const char* url_string = DartUtils::GetStringValue(url); |  302   const char* url_string = DartUtils::GetStringValue(url); | 
|  303   const char* mapped_url_string = DartUtils::MapLibraryUrl(url_mapping, |  303   const char* mapped_url_string = DartUtils::MapLibraryUrl(url_mapping, | 
|  304                                                            url_string); |  304                                                            url_string); | 
|  305  |  305  | 
|  306   Builtin::BuiltinLibraryId libraryBuiltinId = BuiltinId(library_url_string); |  306   Builtin::BuiltinLibraryId libraryBuiltinId = BuiltinId(library_url_string); | 
|  307   if (tag == kCanonicalizeUrl) { |  307   if (tag == Dart_kCanonicalizeUrl) { | 
|  308     if (mapped_url_string) { |  308     if (mapped_url_string) { | 
|  309       return url; |  309       return url; | 
|  310     } |  310     } | 
|  311     // Parts of internal libraries are handled internally. |  311     // Parts of internal libraries are handled internally. | 
|  312     if (libraryBuiltinId != Builtin::kInvalidLibrary) { |  312     if (libraryBuiltinId != Builtin::kInvalidLibrary) { | 
|  313       return url; |  313       return url; | 
|  314     } |  314     } | 
|  315     return ResolveUri(library_url_string, url_string); |  315     return ResolveUri(library_url_string, url_string); | 
|  316   } |  316   } | 
|  317  |  317  | 
|  318   Builtin::BuiltinLibraryId builtinId = BuiltinId(url_string); |  318   Builtin::BuiltinLibraryId builtinId = BuiltinId(url_string); | 
|  319   if (builtinId != Builtin::kInvalidLibrary) { |  319   if (builtinId != Builtin::kInvalidLibrary) { | 
|  320     // Special case for importing a builtin library. |  320     // Special case for importing a builtin library. | 
|  321     if (tag == kImportTag) { |  321     if (tag == Dart_kImportTag) { | 
|  322       return Builtin::LoadAndCheckLibrary(builtinId); |  322       return Builtin::LoadAndCheckLibrary(builtinId); | 
|  323     } |  323     } | 
|  324     ASSERT(tag == kSourceTag); |  324     ASSERT(tag == Dart_kSourceTag); | 
|  325     return Dart_Error("Unable to part '%s' ", url_string); |  325     return Dart_Error("Unable to part '%s' ", url_string); | 
|  326   } |  326   } | 
|  327  |  327  | 
|  328   if (libraryBuiltinId != Builtin::kInvalidLibrary) { |  328   if (libraryBuiltinId != Builtin::kInvalidLibrary) { | 
|  329     // Special case for parting sources of a builtin library. |  329     // Special case for parting sources of a builtin library. | 
|  330     if (tag == kSourceTag) { |  330     if (tag == Dart_kSourceTag) { | 
|  331       return Dart_LoadSource( |  331       return Dart_LoadSource( | 
|  332           library, url, Builtin::PartSource(libraryBuiltinId, url_string)); |  332           library, url, Builtin::PartSource(libraryBuiltinId, url_string)); | 
|  333     } |  333     } | 
|  334     ASSERT(tag == kImportTag); |  334     ASSERT(tag == Dart_kImportTag); | 
|  335     return Dart_Error("Unable to import '%s' ", url_string); |  335     return Dart_Error("Unable to import '%s' ", url_string); | 
|  336   } |  336   } | 
|  337  |  337  | 
|  338   Dart_Handle resolved_url = url; |  338   Dart_Handle resolved_url = url; | 
|  339   if (mapped_url_string != NULL) { |  339   if (mapped_url_string != NULL) { | 
|  340     // Mapped urls are relative to working directory. |  340     // Mapped urls are relative to working directory. | 
|  341     resolved_url = ResolveScriptUri(mapped_url_string); |  341     resolved_url = ResolveScriptUri(mapped_url_string); | 
|  342     if (Dart_IsError(resolved_url)) { |  342     if (Dart_IsError(resolved_url)) { | 
|  343       return resolved_url; |  343       return resolved_url; | 
|  344     } |  344     } | 
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  565   } |  565   } | 
|  566   return 0; |  566   return 0; | 
|  567 } |  567 } | 
|  568  |  568  | 
|  569 }  // namespace bin |  569 }  // namespace bin | 
|  570 }  // namespace dart |  570 }  // namespace dart | 
|  571  |  571  | 
|  572 int main(int argc, char** argv) { |  572 int main(int argc, char** argv) { | 
|  573   return dart::bin::main(argc, argv); |  573   return dart::bin::main(argc, argv); | 
|  574 } |  574 } | 
| OLD | NEW |