ConApp.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2002-2005 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #include "pent_include.h"
00020 
00021 #include "ConApp.h"
00022 
00023 #include "Kernel.h"
00024 
00025 #include "DisasmProcess.h"
00026 #include "CompileProcess.h"
00027 
00028 ConApp::ConApp(int argc, const char* const* argv)
00029         : CoreApp(argc, argv), kernel(0),
00030           weAreDisasming(false), weAreCompiling(false)
00031         // FIXME! Need a 'console' intrinsic set instead of the 0 above!
00032 {
00033         application = this;
00034 }
00035 
00036 void ConApp::startup()
00037 {
00038         CoreApp::startup();
00039 
00040         kernel = new Kernel();
00041 
00042         if(weAreDisasming==true)
00043         {
00044                 //QUIET(pout << "We Are Disassembling..." << std::endl);
00045                 con.Print(MM_INFO, "We Are Diassembling...\n");
00046                 kernel->addProcess(new DisasmProcess());
00047         }
00048         else if(weAreCompiling==true)
00049         {
00050                 //QUIET(pout << "We Are Compiling..." << std::endl);
00051                 con.Print(MM_INFO, "We Are Compiling...\n");
00052                 kernel->addProcess(new CompileProcess(filesystem));
00053         }
00054         else
00055         {
00056                 // we'll presume we're testing for the moment, but we really need to have a proper testing target in the future...
00057                 con.Print(MM_INFO, "We Are Compiling...\n");
00058                 kernel->addProcess(new CompileProcess(filesystem));
00059                 //assert(false);
00060         }
00061 }
00062 
00063 void ConApp::DeclareArgs()
00064 {
00065         CoreApp::DeclareArgs();
00066 
00067         parameters.declare("--disasm",  &weAreDisasming, true);
00068         parameters.declare("--compile", &weAreCompiling, true);
00069 }
00070 
00071 void ConApp::helpMe()
00072 {
00073         CoreApp::helpMe();
00074 
00075         //TODO: some actual help :-)
00076         //note: arguments are already parsed at this point, so we could
00077         //provide more detailed help on e.g., './llc --help --disasm' 
00078 
00079         con.Print("\t--disasm\t- disassemble\n");
00080         con.Print("\t--compile\t- compile\n");
00081 }
00082 
00083 ConApp::~ConApp()
00084 {
00085 
00086 }
00087 
00088 void ConApp::run()
00089 {
00090         isRunning = true;
00091 
00092         // Ok, the theory is that if this is set to true then we must do a repaint
00093         // At the moment only it's ignored
00094         bool repaint;
00095 
00096         while (isRunning) {
00097                 // this needs some major changes, including possibly:
00098                 // - handling events in-between processes?
00099                 //   (so have a kernel->runProcess() that runs a single process)
00100                 // - smarter painting
00101                 //    - dirty rectangles?
00102                 //    - more/less often depending on speed
00103                 //    ...
00104                 // ...
00105 
00106                 if (kernel->runProcesses()) repaint = true;
00107         
00108                 if (kernel->getNumProcesses(0, 6) == 0)
00109                         isRunning=false;
00110 
00111         }
00112 }
00113 

Generated on Fri Jul 27 22:27:11 2007 for pentagram by  doxygen 1.4.7