Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: runtime/bin/main.cc

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/io_service_patch.dart ('k') | runtime/bin/socket_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_debugger_api.h" 10 #include "include/dart_debugger_api.h"
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 Dart_GetError(result)); 874 Dart_GetError(result));
875 } 875 }
876 } 876 }
877 if (has_print_script) { 877 if (has_print_script) {
878 result = GenerateScriptSource(); 878 result = GenerateScriptSource();
879 if (Dart_IsError(result)) { 879 if (Dart_IsError(result)) {
880 return DartErrorExit(result); 880 return DartErrorExit(result);
881 } 881 }
882 } else { 882 } else {
883 // Lookup and invoke the top level main function. 883 // Lookup and invoke the top level main function.
884 Dart_Handle main_args[1]; 884 // The top-level function may accept up to two arguments:
885 // main(List<String> args, var message).
886 // However most commonly it either accepts one (the args list) or
887 // none.
888 // If the message is optional, main(args, [message]), it is invoked with
889 // one argument only.
890 Dart_Handle main_args[2];
885 main_args[0] = CreateRuntimeOptions(&dart_options); 891 main_args[0] = CreateRuntimeOptions(&dart_options);
892 main_args[1] = Dart_Null();
893 // First try with 1 argument.
886 result = Dart_Invoke(library, DartUtils::NewString("main"), 1, main_args); 894 result = Dart_Invoke(library, DartUtils::NewString("main"), 1, main_args);
887 // TODO(iposva): Return a special error type for mismatched argument 895 // TODO(iposva): Return a special error type for mismatched argument
888 // counts from Dart_Invoke to avoid the string comparison. 896 // counts from Dart_Invoke to avoid the string comparison.
889 const char* expected_error = "Dart_Invoke: wrong argument count for " 897 const char* expected_error = "Dart_Invoke: wrong argument count for "
890 "function 'main': 1 passed, 0 expected."; 898 "function 'main': ";
899 intptr_t length = strlen(expected_error);
891 if (Dart_IsError(result) && 900 if (Dart_IsError(result) &&
892 strcmp(expected_error, Dart_GetError(result)) == 0) { 901 strncmp(expected_error, Dart_GetError(result), length) == 0) {
893 result = Dart_Invoke(library, DartUtils::NewString("main"), 0, NULL); 902 // Try with two arguments.
903 result =
904 Dart_Invoke(library, DartUtils::NewString("main"), 2, main_args);
905 if (Dart_IsError(result) &&
906 strncmp(expected_error, Dart_GetError(result), length) == 0) {
907 // Finally try with 0 arguments.
908 result = Dart_Invoke(library, DartUtils::NewString("main"), 0, NULL);
909 }
894 } 910 }
895 if (Dart_IsError(result)) { 911 if (Dart_IsError(result)) {
896 return DartErrorExit(result); 912 return DartErrorExit(result);
897 } 913 }
898 914
899 // Keep handling messages until the last active receive port is closed. 915 // Keep handling messages until the last active receive port is closed.
900 result = Dart_RunLoop(); 916 result = Dart_RunLoop();
901 if (Dart_IsError(result)) { 917 if (Dart_IsError(result)) {
902 return DartErrorExit(result); 918 return DartErrorExit(result);
903 } 919 }
(...skipping 15 matching lines...) Expand all
919 935
920 return Process::GlobalExitCode(); 936 return Process::GlobalExitCode();
921 } 937 }
922 938
923 } // namespace bin 939 } // namespace bin
924 } // namespace dart 940 } // namespace dart
925 941
926 int main(int argc, char** argv) { 942 int main(int argc, char** argv) {
927 return dart::bin::main(argc, argv); 943 return dart::bin::main(argc, argv);
928 } 944 }
OLDNEW
« no previous file with comments | « runtime/bin/io_service_patch.dart ('k') | runtime/bin/socket_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698