| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 return resolved_url; | 344 return resolved_url; |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 // Get the file path out of the url. | 348 // Get the file path out of the url. |
| 349 Dart_Handle file_path = FilePathFromUri( | 349 Dart_Handle file_path = FilePathFromUri( |
| 350 DartUtils::GetStringValue(resolved_url)); | 350 DartUtils::GetStringValue(resolved_url)); |
| 351 if (Dart_IsError(file_path)) { | 351 if (Dart_IsError(file_path)) { |
| 352 return file_path; | 352 return file_path; |
| 353 } | 353 } |
| 354 | 354 const char* raw_path = DartUtils::GetStringValue(file_path); |
| 355 Dart_Handle builtin_lib = | 355 Dart_Handle source = DartUtils::ReadStringFromFile(raw_path); |
| 356 Builtin::LoadAndCheckLibrary(Builtin::kBuiltinLibrary); | 356 if (Dart_IsError(source)) { |
| 357 Dart_Handle result = DartUtils::LoadSourceAsync(library, | 357 return source; |
| 358 url, | |
| 359 tag, | |
| 360 builtin_lib); | |
| 361 if (Dart_IsError(result)) { | |
| 362 return result; | |
| 363 } | 358 } |
| 364 return Dart_RunLoop(); | 359 if (tag == Dart_kImportTag) { |
| 360 return Dart_LoadLibrary(url, source, 0, 0); |
| 361 } else { |
| 362 ASSERT(tag == Dart_kSourceTag); |
| 363 return Dart_LoadSource(library, url, source, 0, 0); |
| 364 } |
| 365 } | 365 } |
| 366 | 366 |
| 367 | 367 |
| 368 static Dart_Handle LoadSnapshotCreationScript(const char* script_name) { | 368 static Dart_Handle LoadSnapshotCreationScript(const char* script_name) { |
| 369 Dart_Handle resolved_script_uri = ResolveScriptUri(script_name); | 369 Dart_Handle resolved_script_uri = ResolveScriptUri(script_name); |
| 370 if (Dart_IsError(resolved_script_uri)) { | 370 if (Dart_IsError(resolved_script_uri)) { |
| 371 return resolved_script_uri; | 371 return resolved_script_uri; |
| 372 } | 372 } |
| 373 Dart_Handle script_path = FilePathFromUri( | 373 Dart_Handle script_path = FilePathFromUri( |
| 374 DartUtils::GetStringValue(resolved_script_uri)); | 374 DartUtils::GetStringValue(resolved_script_uri)); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 } | 589 } |
| 590 return 0; | 590 return 0; |
| 591 } | 591 } |
| 592 | 592 |
| 593 } // namespace bin | 593 } // namespace bin |
| 594 } // namespace dart | 594 } // namespace dart |
| 595 | 595 |
| 596 int main(int argc, char** argv) { | 596 int main(int argc, char** argv) { |
| 597 return dart::bin::main(argc, argv); | 597 return dart::bin::main(argc, argv); |
| 598 } | 598 } |
| OLD | NEW |