| Index: bin/main.cc
|
| ===================================================================
|
| --- bin/main.cc (revision 1162)
|
| +++ bin/main.cc (working copy)
|
| @@ -90,6 +90,50 @@
|
| }
|
|
|
|
|
| +static Dart_Handle SetupRuntimeOptions(CommandLineOptions* options) {
|
| + int options_count = options->count();
|
| + Dart_Handle dart_arguments = Dart_NewArray(options_count);
|
| + if (!Dart_IsValid(dart_arguments)) {
|
| + return dart_arguments;
|
| + }
|
| + for (int i = 0; i < options_count; i++) {
|
| + Dart_Handle argument_value = Dart_NewString(options->GetArgument(i));
|
| + if (!Dart_IsValid(argument_value)) {
|
| + return argument_value;
|
| + }
|
| + Dart_Handle result = Dart_ArraySetAt(dart_arguments, i, argument_value);
|
| + if (!Dart_IsValid(result)) {
|
| + return result;
|
| + }
|
| + }
|
| + Dart_Handle core_lib_url = Dart_NewString("dart:coreimpl");
|
| + if (!Dart_IsValid(core_lib_url)) {
|
| + return core_lib_url;
|
| + }
|
| + Dart_Handle core_lib = Dart_LookupLibrary(core_lib_url);
|
| + if (!Dart_IsValid(core_lib)) {
|
| + return core_lib;
|
| + }
|
| + Dart_Handle runtime_options_class_name = Dart_NewString("RuntimeOptions");
|
| + if (!Dart_IsValid(runtime_options_class_name)) {
|
| + return runtime_options_class_name;
|
| + }
|
| + Dart_Handle runtime_options_class = Dart_GetClass(
|
| + core_lib, runtime_options_class_name);
|
| + if (!Dart_IsValid(runtime_options_class)) {
|
| + return runtime_options_class;
|
| + }
|
| + Dart_Handle native_name = Dart_NewString("_nativeArguments");
|
| + if (!Dart_IsValid(native_name)) {
|
| + return native_name;
|
| + }
|
| +
|
| + return Dart_SetStaticField(runtime_options_class,
|
| + native_name,
|
| + dart_arguments);
|
| +}
|
| +
|
| +
|
| static void DumpPprofSymbolInfo() {
|
| if (generate_pprof_symbols_filename != NULL) {
|
| Dart_EnterScope();
|
| @@ -199,8 +243,6 @@
|
| }
|
|
|
| Dart_EnterScope();
|
| - // TODO(asiva): Create a dart options object that can be accessed from
|
| - // dart code.
|
| if (HasCompileAll(vm_options)) {
|
| Dart_Handle result = Dart_CompileAll();
|
| if (!Dart_IsValid(result)) {
|
| @@ -212,6 +254,16 @@
|
| }
|
| }
|
|
|
| + // Create a dart options object that can be accessed from dart code.
|
| + Dart_Handle options_result = SetupRuntimeOptions(&dart_options);
|
| + if (!Dart_IsValid(options_result)) {
|
| + fprintf(stderr, "%s\n", Dart_GetError(options_result));
|
| + Dart_ExitScope();
|
| + Dart_ShutdownIsolate();
|
| + free(canonical_script_name);
|
| + return 255; // Indicates we encountered an error.
|
| + }
|
| +
|
| // Lookup and invoke the top level main function.
|
| Dart_Handle script_url = Dart_NewString(canonical_script_name);
|
| Dart_Handle library = Dart_LookupLibrary(script_url);
|
|
|