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 #include <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "include/dart_tools_api.h" | 10 #include "include/dart_tools_api.h" |
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 result = Dart_ParseAll(); | 1480 result = Dart_ParseAll(); |
1481 CHECK_RESULT(result); | 1481 CHECK_RESULT(result); |
1482 Dart_ExitScope(); | 1482 Dart_ExitScope(); |
1483 // Shutdown the isolate. | 1483 // Shutdown the isolate. |
1484 Dart_ShutdownIsolate(); | 1484 Dart_ShutdownIsolate(); |
1485 return false; | 1485 return false; |
1486 } | 1486 } |
1487 | 1487 |
1488 if (gen_snapshot_kind == kAppAOT) { | 1488 if (gen_snapshot_kind == kAppAOT) { |
1489 Dart_QualifiedFunctionName standalone_entry_points[] = { | 1489 Dart_QualifiedFunctionName standalone_entry_points[] = { |
1490 {"dart:_builtin", "::", "_getMainClosure"}, | |
1491 {"dart:_builtin", "::", "_getPrintClosure"}, | 1490 {"dart:_builtin", "::", "_getPrintClosure"}, |
1492 {"dart:_builtin", "::", "_getUriBaseClosure"}, | 1491 {"dart:_builtin", "::", "_getUriBaseClosure"}, |
1493 {"dart:_builtin", "::", "_libraryFilePath"}, | 1492 {"dart:_builtin", "::", "_libraryFilePath"}, |
1494 {"dart:_builtin", "::", "_resolveInWorkingDirectory"}, | 1493 {"dart:_builtin", "::", "_resolveInWorkingDirectory"}, |
1495 {"dart:_builtin", "::", "_setPackageRoot"}, | 1494 {"dart:_builtin", "::", "_setPackageRoot"}, |
1496 {"dart:_builtin", "::", "_setPackagesMap"}, | 1495 {"dart:_builtin", "::", "_setPackagesMap"}, |
1497 {"dart:_builtin", "::", "_setWorkingDirectory"}, | 1496 {"dart:_builtin", "::", "_setWorkingDirectory"}, |
1498 {"dart:async", "::", "_setScheduleImmediateClosure"}, | 1497 {"dart:async", "::", "_setScheduleImmediateClosure"}, |
1499 {"dart:io", "::", "_getWatchSignalInternal"}, | 1498 {"dart:io", "::", "_getWatchSignalInternal"}, |
1500 {"dart:io", "::", "_makeDatagram"}, | 1499 {"dart:io", "::", "_makeDatagram"}, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 } | 1563 } |
1565 | 1564 |
1566 if (load_compilation_trace_filename != NULL) { | 1565 if (load_compilation_trace_filename != NULL) { |
1567 uint8_t* buffer = NULL; | 1566 uint8_t* buffer = NULL; |
1568 intptr_t size = 0; | 1567 intptr_t size = 0; |
1569 ReadFile(load_compilation_trace_filename, &buffer, &size); | 1568 ReadFile(load_compilation_trace_filename, &buffer, &size); |
1570 result = Dart_LoadCompilationTrace(buffer, size); | 1569 result = Dart_LoadCompilationTrace(buffer, size); |
1571 CHECK_RESULT(result); | 1570 CHECK_RESULT(result); |
1572 } | 1571 } |
1573 | 1572 |
1574 // The helper function _getMainClosure creates a closure for the main | 1573 // Create a closure for the main entry point which is in the exported |
1575 // entry point which is either explicitly or implictly exported from the | 1574 // namespace of the root library or invoke a getter of the same name |
1576 // root library. | 1575 // in the exported namespace and return the resulting closure. |
1577 Dart_Handle main_closure = | 1576 Dart_Handle main_closure = |
1578 Dart_Invoke(isolate_data->builtin_lib(), | 1577 Dart_GetClosure(root_lib, Dart_NewStringFromCString("main")); |
1579 Dart_NewStringFromCString("_getMainClosure"), 0, NULL); | |
1580 CHECK_RESULT(main_closure); | 1578 CHECK_RESULT(main_closure); |
| 1579 if (!Dart_IsClosure(main_closure)) { |
| 1580 ErrorExit(kErrorExitCode, |
| 1581 "Unable to find 'main' in root library '%s'\n", script_name); |
| 1582 } |
1581 | 1583 |
1582 // Call _startIsolate in the isolate library to enable dispatching the | 1584 // Call _startIsolate in the isolate library to enable dispatching the |
1583 // initial startup message. | 1585 // initial startup message. |
1584 const intptr_t kNumIsolateArgs = 2; | 1586 const intptr_t kNumIsolateArgs = 2; |
1585 Dart_Handle isolate_args[kNumIsolateArgs]; | 1587 Dart_Handle isolate_args[kNumIsolateArgs]; |
1586 isolate_args[0] = main_closure; // entryPoint | 1588 isolate_args[0] = main_closure; // entryPoint |
1587 isolate_args[1] = CreateRuntimeOptions(dart_options); // args | 1589 isolate_args[1] = CreateRuntimeOptions(dart_options); // args |
1588 | 1590 |
1589 Dart_Handle isolate_lib = | 1591 Dart_Handle isolate_lib = |
1590 Dart_LookupLibrary(Dart_NewStringFromCString("dart:isolate")); | 1592 Dart_LookupLibrary(Dart_NewStringFromCString("dart:isolate")); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 Platform::Exit(Process::GlobalExitCode()); | 1917 Platform::Exit(Process::GlobalExitCode()); |
1916 } | 1918 } |
1917 | 1919 |
1918 } // namespace bin | 1920 } // namespace bin |
1919 } // namespace dart | 1921 } // namespace dart |
1920 | 1922 |
1921 int main(int argc, char** argv) { | 1923 int main(int argc, char** argv) { |
1922 dart::bin::main(argc, argv); | 1924 dart::bin::main(argc, argv); |
1923 UNREACHABLE(); | 1925 UNREACHABLE(); |
1924 } | 1926 } |
OLD | NEW |