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

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

Issue 11362103: Rotating spheres sample (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More cleanup Created 8 years 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/bin.gypi ('k') | runtime/bin/main_android.cc » ('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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 541 }
542 542
543 543
544 static void ShutdownIsolate(void* callback_data) { 544 static void ShutdownIsolate(void* callback_data) {
545 IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data); 545 IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data);
546 EventHandler* handler = isolate_data->event_handler; 546 EventHandler* handler = isolate_data->event_handler;
547 if (handler != NULL) handler->Shutdown(); 547 if (handler != NULL) handler->Shutdown();
548 delete isolate_data; 548 delete isolate_data;
549 } 549 }
550 550
551 551 DART_EXPORT
552 int main(int argc, char** argv) { 552 int Dart_SO_Start(int argc, char** argv, Dart_Isolate* pmain_isolate) {
553 char* executable_name; 553 char* executable_name;
554 char* script_name; 554 char* script_name;
555 CommandLineOptions vm_options(argc); 555 CommandLineOptions vm_options(argc);
556 CommandLineOptions dart_options(argc); 556 CommandLineOptions dart_options(argc);
557 bool print_flags_seen = false; 557 bool print_flags_seen = false;
558 558
559 // Perform platform specific initialization. 559 // Perform platform specific initialization.
560 if (!Platform::Initialize()) { 560 if (!Platform::Initialize()) {
561 fprintf(stderr, "Initialization failed\n"); 561 fprintf(stderr, "Initialization failed\n");
562 return kErrorExitCode;
562 } 563 }
563 564
564 // Parse command line arguments. 565 // Parse command line arguments.
565 if (ParseArguments(argc, 566 if (ParseArguments(argc,
566 argv, 567 argv,
567 &vm_options, 568 &vm_options,
568 &executable_name, 569 &executable_name,
569 &script_name, 570 &script_name,
570 &dart_options, 571 &dart_options,
571 &print_flags_seen) < 0) { 572 &print_flags_seen) < 0) {
(...skipping 28 matching lines...) Expand all
600 &error)) { 601 &error)) {
601 fprintf(stderr, "%s\n", error); 602 fprintf(stderr, "%s\n", error);
602 free(error); 603 free(error);
603 delete [] isolate_name; 604 delete [] isolate_name;
604 return kErrorExitCode; // Indicates we encountered an error. 605 return kErrorExitCode; // Indicates we encountered an error.
605 } 606 }
606 delete [] isolate_name; 607 delete [] isolate_name;
607 608
608 Dart_Isolate isolate = Dart_CurrentIsolate(); 609 Dart_Isolate isolate = Dart_CurrentIsolate();
609 ASSERT(isolate != NULL); 610 ASSERT(isolate != NULL);
611 *pmain_isolate = isolate;
610 Dart_Handle result; 612 Dart_Handle result;
611 613
612 Dart_EnterScope(); 614 Dart_EnterScope();
613 615
614 if (has_compile_all) { 616 if (has_compile_all) {
615 result = Dart_CompileAll(); 617 result = Dart_CompileAll();
616 if (Dart_IsError(result)) { 618 if (Dart_IsError(result)) {
617 return ErrorExit("%s\n", Dart_GetError(result)); 619 return ErrorExit("%s\n", Dart_GetError(result));
618 } 620 }
619 } 621 }
(...skipping 19 matching lines...) Expand all
639 Dart_GetError(result)); 641 Dart_GetError(result));
640 } 642 }
641 } 643 }
642 644
643 // Start the debugger wire protocol handler if necessary. 645 // Start the debugger wire protocol handler if necessary.
644 if (start_debugger) { 646 if (start_debugger) {
645 ASSERT(debug_port != 0); 647 ASSERT(debug_port != 0);
646 DebuggerConnectionHandler::StartHandler(debug_ip, debug_port); 648 DebuggerConnectionHandler::StartHandler(debug_ip, debug_port);
647 } 649 }
648 650
651 Dart_ExitScope();
652 Dart_ExitIsolate();
653
654 return 0;
655 }
656
657 DART_EXPORT
658 int Dart_SO_MainLoop(Dart_Isolate isolate) {
659 Dart_EnterIsolate(isolate);
660 Dart_EnterScope();
661
662 // Lookup the library of the root script.
663 Dart_Handle library = Dart_RootLibrary();
664 if (Dart_IsNull(library)) {
665 return ErrorExit("Unable to find root library\n");
666 }
667
649 // Lookup and invoke the top level main function. 668 // Lookup and invoke the top level main function.
650 result = Dart_Invoke(library, Dart_NewString("main"), 0, NULL); 669 Dart_Handle result = Dart_Invoke(library, Dart_NewString("main"), 0, NULL);
651 if (Dart_IsError(result)) { 670 if (Dart_IsError(result)) {
652 return ErrorExit("%s\n", Dart_GetError(result)); 671 return ErrorExit("%s\n", Dart_GetError(result));
653 } 672 }
654 // Keep handling messages until the last active receive port is closed. 673 // Keep handling messages until the last active receive port is closed.
655 result = Dart_RunLoop(); 674 result = Dart_RunLoop();
656 if (Dart_IsError(result)) { 675 if (Dart_IsError(result)) {
657 return ErrorExit("%s\n", Dart_GetError(result)); 676 return ErrorExit("%s\n", Dart_GetError(result));
658 } 677 }
659 678
660 Dart_ExitScope(); 679 Dart_ExitScope();
680 Dart_ExitIsolate();
681 return 0;
682 }
683
684 DART_EXPORT
685 int Dart_SO_Finish(Dart_Isolate isolate) {
686 Dart_EnterIsolate(isolate);
661 // Dump symbol information for the profiler. 687 // Dump symbol information for the profiler.
662 DumpPprofSymbolInfo(); 688 DumpPprofSymbolInfo();
663 // Shutdown the isolate. 689 // Shutdown the isolate.
664 Dart_ShutdownIsolate(); 690 Dart_ShutdownIsolate();
665 // Terminate process exit-code handler. 691 // Terminate process exit-code handler.
666 Process::TerminateExitCodeHandler(); 692 Process::TerminateExitCodeHandler();
667 693
668 return 0; 694 return 0;
669 } 695 }
696
697 int main(int argc, char** argv) {
698 Dart_Isolate main_isolate;
699 int result = Dart_SO_Start(argc, argv, &main_isolate);
700 if (result != 0) {
701 return result;
702 }
703
704 result = Dart_SO_MainLoop(main_isolate);
705 if (result != 0) {
706 return result;
707 }
708
709 result = Dart_SO_Finish(main_isolate);
710 return result;
711 }
OLDNEW
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/bin/main_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698