-enum {
- DO_EXEC,
- DO_REGRESSION
-};
-
-int
-mono_main (int argc, char *argv [])
-{
- MonoDomain *domain;
- int retval = 0, i;
- char *file, *config_file = NULL;
- int enable_debugging = FALSE;
- MainThreadArgs main_args;
- const char *error;
- int action = DO_EXEC;
-
- setlocale (LC_ALL, "");
- if (argc < 2)
- usage ();
-
- for (i = 1; i < argc && argv [i][0] == '-'; i++){
- if (strcmp (argv [i], "--trace") == 0)
- global_tracing = 1;
- if (strcmp (argv [i], "--noptr") == 0)
- global_no_pointers = 1;
- if (strcmp (argv [i], "--regression") == 0)
- action = DO_REGRESSION;
- if (strcmp (argv [i], "--traceops") == 0)
- global_tracing = 2;
- if (strcmp (argv [i], "--traceopt") == 0)
- ++mono_interp_traceopt;
- if (strcmp (argv [i], "--dieonex") == 0) {
- die_on_exception = 1;
- enable_debugging = 1;
- }
- if (strcmp (argv [i], "--print-vtable") == 0)
- mono_print_vtable = TRUE;
- if (strcmp (argv [i], "--profile") == 0)
- mono_profiler_load (NULL);
- if (strcmp (argv [i], "--config") == 0)
- config_file = argv [++i];
- if (strcmp (argv [i], "--help") == 0)
- usage ();
-#if DEBUG_INTERP
- if (strcmp (argv [i], "--debug") == 0) {
- MonoMethodDesc *desc = mono_method_desc_new (argv [++i], FALSE);
- if (!desc)
- g_error ("Invalid method name '%s'", argv [i]);
- db_methods = g_list_append (db_methods, desc);
- }
- if (strcmp (argv [i], "--nested") == 0)
- nested_trace = 1;
-#endif
- }
-
- file = argv [i];
-
- if (!file)
- usage ();
-
- mono_set_rootdir ();
- domain = mono_interp_init (file);
- mono_config_parse (config_file);
-
- error = mono_check_corlib_version ();
- if (error) {
- fprintf (stderr, "Corlib not in sync with this runtime: %s\n", error);
- fprintf (stderr, "Download a newer corlib at http://www.go-mono.com/daily.\n");
- exit (1);
- }
-
- main_args.domain=domain;
- main_args.file=file;
- main_args.argc=argc-i;
- main_args.argv=argv+i;
- main_args.enable_debugging=enable_debugging;
-
- switch (action) {
- case DO_REGRESSION:
- if (interp_regression_list (2, argc -i, argv + i)) {
- g_print ("Regression ERRORS!\n");
- // mini_cleanup (domain);
- return 1;
- }
- // mini_cleanup (domain);
- return 0;
- }
-
- mono_runtime_exec_managed_code (domain, main_thread_handler, &main_args);
-
- quit_function (domain, NULL);
-
- /* Get the return value from System.Environment.ExitCode */
- retval=mono_environment_exitcode_get ();
-
-#if COUNT_OPS
- for (i = 0; i < 512; i++)
- if (opcode_counts[i] != 0)
- printf("%s %d\n", mono_interp_opname[i], opcode_counts[i]);
-#endif
- return retval;
-}