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

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

Issue 11318018: - Represent strings internally in UTF-16 format, this makes it (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 293 }
294 294
295 return 0; 295 return 0;
296 } 296 }
297 297
298 298
299 static Dart_Handle SetupRuntimeOptions(CommandLineOptions* options, 299 static Dart_Handle SetupRuntimeOptions(CommandLineOptions* options,
300 const char* executable_name, 300 const char* executable_name,
301 const char* script_name) { 301 const char* script_name) {
302 int options_count = options->count(); 302 int options_count = options->count();
303 Dart_Handle dart_executable = Dart_NewString(executable_name); 303 Dart_Handle dart_executable = DartUtils::NewString(executable_name);
304 if (Dart_IsError(dart_executable)) { 304 if (Dart_IsError(dart_executable)) {
305 return dart_executable; 305 return dart_executable;
306 } 306 }
307 Dart_Handle dart_script = Dart_NewString(script_name); 307 Dart_Handle dart_script = DartUtils::NewString(script_name);
308 if (Dart_IsError(dart_script)) { 308 if (Dart_IsError(dart_script)) {
309 return dart_script; 309 return dart_script;
310 } 310 }
311 Dart_Handle dart_arguments = Dart_NewList(options_count); 311 Dart_Handle dart_arguments = Dart_NewList(options_count);
312 if (Dart_IsError(dart_arguments)) { 312 if (Dart_IsError(dart_arguments)) {
313 return dart_arguments; 313 return dart_arguments;
314 } 314 }
315 for (int i = 0; i < options_count; i++) { 315 for (int i = 0; i < options_count; i++) {
316 Dart_Handle argument_value = Dart_NewString(options->GetArgument(i)); 316 Dart_Handle argument_value =
317 DartUtils::NewString(options->GetArgument(i));
317 if (Dart_IsError(argument_value)) { 318 if (Dart_IsError(argument_value)) {
318 return argument_value; 319 return argument_value;
319 } 320 }
320 Dart_Handle result = Dart_ListSetAt(dart_arguments, i, argument_value); 321 Dart_Handle result = Dart_ListSetAt(dart_arguments, i, argument_value);
321 if (Dart_IsError(result)) { 322 if (Dart_IsError(result)) {
322 return result; 323 return result;
323 } 324 }
324 } 325 }
325 Dart_Handle core_lib_url = Dart_NewString("dart:core"); 326 Dart_Handle core_lib_url = DartUtils::NewString("dart:core");
326 if (Dart_IsError(core_lib_url)) { 327 if (Dart_IsError(core_lib_url)) {
327 return core_lib_url; 328 return core_lib_url;
328 } 329 }
329 Dart_Handle core_lib = Dart_LookupLibrary(core_lib_url); 330 Dart_Handle core_lib = Dart_LookupLibrary(core_lib_url);
330 if (Dart_IsError(core_lib)) { 331 if (Dart_IsError(core_lib)) {
331 return core_lib; 332 return core_lib;
332 } 333 }
333 Dart_Handle runtime_options_class_name = Dart_NewString("_OptionsImpl"); 334 Dart_Handle runtime_options_class_name =
335 DartUtils::NewString("_OptionsImpl");
334 if (Dart_IsError(runtime_options_class_name)) { 336 if (Dart_IsError(runtime_options_class_name)) {
335 return runtime_options_class_name; 337 return runtime_options_class_name;
336 } 338 }
337 Dart_Handle runtime_options_class = Dart_GetClass( 339 Dart_Handle runtime_options_class = Dart_GetClass(
338 core_lib, runtime_options_class_name); 340 core_lib, runtime_options_class_name);
339 if (Dart_IsError(runtime_options_class)) { 341 if (Dart_IsError(runtime_options_class)) {
340 return runtime_options_class; 342 return runtime_options_class;
341 } 343 }
342 Dart_Handle executable_name_name = Dart_NewString("_nativeExecutable"); 344 Dart_Handle executable_name_name =
345 DartUtils::NewString("_nativeExecutable");
343 if (Dart_IsError(executable_name_name)) { 346 if (Dart_IsError(executable_name_name)) {
344 return executable_name_name; 347 return executable_name_name;
345 } 348 }
346 Dart_Handle set_executable_name = 349 Dart_Handle set_executable_name =
347 Dart_SetField(runtime_options_class, 350 Dart_SetField(runtime_options_class,
348 executable_name_name, 351 executable_name_name,
349 dart_executable); 352 dart_executable);
350 if (Dart_IsError(set_executable_name)) { 353 if (Dart_IsError(set_executable_name)) {
351 return set_executable_name; 354 return set_executable_name;
352 } 355 }
353 Dart_Handle script_name_name = Dart_NewString("_nativeScript"); 356 Dart_Handle script_name_name = DartUtils::NewString("_nativeScript");
354 if (Dart_IsError(script_name_name)) { 357 if (Dart_IsError(script_name_name)) {
355 return script_name_name; 358 return script_name_name;
356 } 359 }
357 Dart_Handle set_script_name = 360 Dart_Handle set_script_name =
358 Dart_SetField(runtime_options_class, script_name_name, dart_script); 361 Dart_SetField(runtime_options_class, script_name_name, dart_script);
359 if (Dart_IsError(set_script_name)) { 362 if (Dart_IsError(set_script_name)) {
360 return set_script_name; 363 return set_script_name;
361 } 364 }
362 Dart_Handle native_name = Dart_NewString("_nativeArguments"); 365 Dart_Handle native_name = DartUtils::NewString("_nativeArguments");
363 if (Dart_IsError(native_name)) { 366 if (Dart_IsError(native_name)) {
364 return native_name; 367 return native_name;
365 } 368 }
366 369
367 return Dart_SetField(runtime_options_class, native_name, dart_arguments); 370 return Dart_SetField(runtime_options_class, native_name, dart_arguments);
368 } 371 }
369 372
370 373
371 static void DumpPprofSymbolInfo() { 374 static void DumpPprofSymbolInfo() {
372 if (generate_pprof_symbols_filename != NULL) { 375 if (generate_pprof_symbols_filename != NULL) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 550
548 551
549 static Dart_Handle SetBreakpoint(const char* breakpoint_at, 552 static Dart_Handle SetBreakpoint(const char* breakpoint_at,
550 Dart_Handle library) { 553 Dart_Handle library) {
551 Dart_Handle result; 554 Dart_Handle result;
552 if (strchr(breakpoint_at, ':')) { 555 if (strchr(breakpoint_at, ':')) {
553 char* bpt_line = strdup(breakpoint_at); 556 char* bpt_line = strdup(breakpoint_at);
554 char* colon = strchr(bpt_line, ':'); 557 char* colon = strchr(bpt_line, ':');
555 ASSERT(colon != NULL); 558 ASSERT(colon != NULL);
556 *colon = '\0'; 559 *colon = '\0';
557 Dart_Handle url = Dart_NewString(bpt_line); 560 Dart_Handle url = DartUtils::NewString(bpt_line);
558 Dart_Handle line_number = Dart_NewInteger(atoi(colon + 1)); 561 Dart_Handle line_number = Dart_NewInteger(atoi(colon + 1));
559 free(bpt_line); 562 free(bpt_line);
560 Dart_Breakpoint bpt; 563 Dart_Breakpoint bpt;
561 result = Dart_SetBreakpointAtLine(url, line_number, &bpt); 564 result = Dart_SetBreakpointAtLine(url, line_number, &bpt);
562 } else { 565 } else {
563 char* bpt_function = strdup(breakpoint_at); 566 char* bpt_function = strdup(breakpoint_at);
564 Dart_Handle class_name; 567 Dart_Handle class_name;
565 Dart_Handle function_name; 568 Dart_Handle function_name;
566 char* dot = strchr(bpt_function, '.'); 569 char* dot = strchr(bpt_function, '.');
567 if (dot == NULL) { 570 if (dot == NULL) {
568 class_name = Dart_NewString(""); 571 class_name = DartUtils::NewString("");
569 function_name = Dart_NewString(breakpoint_at); 572 function_name = DartUtils::NewString(breakpoint_at);
570 } else { 573 } else {
571 *dot = '\0'; 574 *dot = '\0';
572 class_name = Dart_NewString(bpt_function); 575 class_name = DartUtils::NewString(bpt_function);
573 function_name = Dart_NewString(dot + 1); 576 function_name = DartUtils::NewString(dot + 1);
574 } 577 }
575 free(bpt_function); 578 free(bpt_function);
576 Dart_Breakpoint bpt; 579 Dart_Breakpoint bpt;
577 result = Dart_SetBreakpointAtEntry( 580 result = Dart_SetBreakpointAtEntry(
578 library, class_name, function_name, &bpt); 581 library, class_name, function_name, &bpt);
579 } 582 }
580 return result; 583 return result;
581 } 584 }
582 585
583 586
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 if (breakpoint_at != NULL) { 723 if (breakpoint_at != NULL) {
721 result = SetBreakpoint(breakpoint_at, library); 724 result = SetBreakpoint(breakpoint_at, library);
722 if (Dart_IsError(result)) { 725 if (Dart_IsError(result)) {
723 return ErrorExit("Error setting breakpoint at '%s': %s\n", 726 return ErrorExit("Error setting breakpoint at '%s': %s\n",
724 breakpoint_at, 727 breakpoint_at,
725 Dart_GetError(result)); 728 Dart_GetError(result));
726 } 729 }
727 } 730 }
728 731
729 // Lookup and invoke the top level main function. 732 // Lookup and invoke the top level main function.
730 result = Dart_Invoke(library, Dart_NewString("main"), 0, NULL); 733 result = Dart_Invoke(library, DartUtils::NewString("main"), 0, NULL);
731 if (Dart_IsError(result)) { 734 if (Dart_IsError(result)) {
732 return ErrorExit("%s\n", Dart_GetError(result)); 735 return ErrorExit("%s\n", Dart_GetError(result));
733 } 736 }
734 // Keep handling messages until the last active receive port is closed. 737 // Keep handling messages until the last active receive port is closed.
735 result = Dart_RunLoop(); 738 result = Dart_RunLoop();
736 if (Dart_IsError(result)) { 739 if (Dart_IsError(result)) {
737 return ErrorExit("%s\n", Dart_GetError(result)); 740 return ErrorExit("%s\n", Dart_GetError(result));
738 } 741 }
739 742
740 Dart_ExitScope(); 743 Dart_ExitScope();
741 // Dump symbol information for the profiler. 744 // Dump symbol information for the profiler.
742 DumpPprofSymbolInfo(); 745 DumpPprofSymbolInfo();
743 // Shutdown the isolate. 746 // Shutdown the isolate.
744 Dart_ShutdownIsolate(); 747 Dart_ShutdownIsolate();
745 // Terminate process exit-code handler. 748 // Terminate process exit-code handler.
746 Process::TerminateExitCodeHandler(); 749 Process::TerminateExitCodeHandler();
747 750
748 return 0; 751 return 0;
749 } 752 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698