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 <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
11 | 11 |
12 #include <cstdarg> | 12 #include <cstdarg> |
13 | 13 |
14 #include "bin/builtin.h" | 14 #include "bin/builtin.h" |
15 #include "bin/dartutils.h" | 15 #include "bin/dartutils.h" |
| 16 #include "bin/dfe.h" |
16 #include "bin/eventhandler.h" | 17 #include "bin/eventhandler.h" |
17 #include "bin/file.h" | 18 #include "bin/file.h" |
18 #include "bin/loader.h" | 19 #include "bin/loader.h" |
19 #include "bin/log.h" | 20 #include "bin/log.h" |
20 #include "bin/thread.h" | 21 #include "bin/thread.h" |
21 #include "bin/utils.h" | 22 #include "bin/utils.h" |
22 #include "bin/vmservice_impl.h" | 23 #include "bin/vmservice_impl.h" |
23 | 24 |
24 #include "include/dart_api.h" | 25 #include "include/dart_api.h" |
25 #include "include/dart_tools_api.h" | 26 #include "include/dart_tools_api.h" |
26 | 27 |
27 #include "platform/hashmap.h" | 28 #include "platform/hashmap.h" |
28 #include "platform/globals.h" | 29 #include "platform/globals.h" |
29 #include "platform/growable_array.h" | 30 #include "platform/growable_array.h" |
30 | 31 |
31 namespace dart { | 32 namespace dart { |
32 namespace bin { | 33 namespace bin { |
33 | 34 |
| 35 DFE dfe; |
| 36 |
34 // Exit code indicating an API error. | 37 // Exit code indicating an API error. |
35 static const int kApiErrorExitCode = 253; | 38 static const int kApiErrorExitCode = 253; |
36 // Exit code indicating a compilation error. | 39 // Exit code indicating a compilation error. |
37 static const int kCompilationErrorExitCode = 254; | 40 static const int kCompilationErrorExitCode = 254; |
38 // Exit code indicating an unhandled error that is not a compilation error. | 41 // Exit code indicating an unhandled error that is not a compilation error. |
39 static const int kErrorExitCode = 255; | 42 static const int kErrorExitCode = 255; |
40 | 43 |
41 #define CHECK_RESULT(result) \ | 44 #define CHECK_RESULT(result) \ |
42 if (Dart_IsError(result)) { \ | 45 if (Dart_IsError(result)) { \ |
43 intptr_t exit_code = 0; \ | 46 intptr_t exit_code = 0; \ |
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 Dart_ExitScope(); | 1566 Dart_ExitScope(); |
1564 Dart_ExitIsolate(); | 1567 Dart_ExitIsolate(); |
1565 | 1568 |
1566 // Now we create an isolate into which we load all the code that needs to | 1569 // Now we create an isolate into which we load all the code that needs to |
1567 // be in the snapshot. | 1570 // be in the snapshot. |
1568 isolate_data = new IsolateData(app_script_name, commandline_package_root, | 1571 isolate_data = new IsolateData(app_script_name, commandline_package_root, |
1569 commandline_packages_file, NULL); | 1572 commandline_packages_file, NULL); |
1570 const uint8_t* kernel = NULL; | 1573 const uint8_t* kernel = NULL; |
1571 intptr_t kernel_length = 0; | 1574 intptr_t kernel_length = 0; |
1572 const bool is_kernel_file = | 1575 const bool is_kernel_file = |
1573 TryReadKernel(app_script_name, &kernel, &kernel_length); | 1576 dfe.TryReadKernelFile(app_script_name, &kernel, &kernel_length); |
1574 | 1577 |
1575 if ((dependencies_filename != NULL) || print_dependencies) { | 1578 if ((dependencies_filename != NULL) || print_dependencies) { |
1576 isolate_data->set_dependencies(new MallocGrowableArray<char*>()); | 1579 isolate_data->set_dependencies(new MallocGrowableArray<char*>()); |
1577 } | 1580 } |
1578 | 1581 |
1579 void* kernel_program = NULL; | 1582 void* kernel_program = NULL; |
1580 if (is_kernel_file) { | 1583 if (is_kernel_file) { |
1581 kernel_program = Dart_ReadKernelBinary(kernel, kernel_length); | 1584 kernel_program = Dart_ReadKernelBinary(kernel, kernel_length); |
1582 free(const_cast<uint8_t*>(kernel)); | 1585 free(const_cast<uint8_t*>(kernel)); |
1583 } | 1586 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 delete mapped_isolate_snapshot_data; | 1681 delete mapped_isolate_snapshot_data; |
1679 return 0; | 1682 return 0; |
1680 } | 1683 } |
1681 | 1684 |
1682 } // namespace bin | 1685 } // namespace bin |
1683 } // namespace dart | 1686 } // namespace dart |
1684 | 1687 |
1685 int main(int argc, char** argv) { | 1688 int main(int argc, char** argv) { |
1686 return dart::bin::main(argc, argv); | 1689 return dart::bin::main(argc, argv); |
1687 } | 1690 } |
OLD | NEW |