00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "contexthelp.h"
00012 #include "docmanager.h"
00013 #include "logview.h"
00014 #include "microbe.h"
00015 #include "languagemanager.h"
00016
00017 #include <kdebug.h>
00018 #include <klocale.h>
00019 #include <kmessagebox.h>
00020 #include <kstandarddirs.h>
00021
00022 #include <qfile.h>
00023 #include <kprocess.h>
00024
00025 Microbe::Microbe( ProcessChain *processChain, KTechlab *parent )
00026 : ExternalLanguage( processChain, parent, "Microbe" )
00027 {
00028 m_failedMessage = i18n("*** Compilation failed ***");
00029 m_successfulMessage = i18n("*** Compilation successful ***");
00030
00031
00032 QFile file( locate("appdata",i18n("error_messages_en_gb")) );
00033 if ( file.open( IO_ReadOnly ) )
00034 {
00035 QTextStream stream( &file );
00036 QString line;
00037 while ( !stream.atEnd() )
00038 {
00039 line = stream.readLine();
00040 if ( !line.isEmpty() )
00041 {
00042 bool ok;
00043 const int pos = line.left( line.find("#") ).toInt(&ok);
00044 if (ok) {
00045 m_errorMessages[pos] = line.right(line.length()-line.find("#"));
00046 } else {
00047 kdError() << k_funcinfo << "Error parsing Microbe error-message file"<<endl;
00048 }
00049 }
00050 }
00051 file.close();
00052 }
00053 }
00054
00055 Microbe::~Microbe()
00056 {
00057 }
00058
00059
00060 void Microbe::processInput( ProcessOptions options )
00061 {
00062 resetLanguageProcess();
00063 m_processOptions = options;
00064
00065 *m_languageProcess << ("microbe");
00066
00067
00068 *m_languageProcess << ( options.inputFiles().first() );
00069
00070
00071 *m_languageProcess << ( options.intermediaryOutput() );
00072
00073 *m_languageProcess << ("--show-source");
00074
00075 if ( !start() )
00076 {
00077 KMessageBox::sorry( LanguageManager::self()->logView(), i18n("Assembly failed. Please check you have KTechlab installed properly (\"microbe\" could not be started).") );
00078 processInitFailed();
00079 return;
00080 }
00081 }
00082
00083
00084 bool Microbe::isError( const QString &message ) const
00085 {
00086 return message.contains( "Error", false );
00087 }
00088
00089 bool Microbe::isWarning( const QString &message ) const
00090 {
00091 return message.contains( "Warning", false );
00092 }
00093
00094
00095 ProcessOptions::ProcessPath::Path Microbe::outputPath( ProcessOptions::ProcessPath::Path inputPath ) const
00096 {
00097 switch (inputPath)
00098 {
00099 case ProcessOptions::ProcessPath::Microbe_AssemblyAbsolute:
00100 return ProcessOptions::ProcessPath::None;
00101
00102 case ProcessOptions::ProcessPath::Microbe_PIC:
00103 return ProcessOptions::ProcessPath::AssemblyAbsolute_PIC;
00104
00105 case ProcessOptions::ProcessPath::Microbe_Program:
00106 return ProcessOptions::ProcessPath::AssemblyAbsolute_Program;
00107
00108 case ProcessOptions::ProcessPath::AssemblyAbsolute_PIC:
00109 case ProcessOptions::ProcessPath::AssemblyAbsolute_Program:
00110 case ProcessOptions::ProcessPath::AssemblyRelocatable_Library:
00111 case ProcessOptions::ProcessPath::AssemblyRelocatable_Object:
00112 case ProcessOptions::ProcessPath::AssemblyRelocatable_PIC:
00113 case ProcessOptions::ProcessPath::AssemblyRelocatable_Program:
00114 case ProcessOptions::ProcessPath::C_AssemblyRelocatable:
00115 case ProcessOptions::ProcessPath::C_Library:
00116 case ProcessOptions::ProcessPath::C_Object:
00117 case ProcessOptions::ProcessPath::C_PIC:
00118 case ProcessOptions::ProcessPath::C_Program:
00119 case ProcessOptions::ProcessPath::FlowCode_AssemblyAbsolute:
00120 case ProcessOptions::ProcessPath::FlowCode_Microbe:
00121 case ProcessOptions::ProcessPath::FlowCode_PIC:
00122 case ProcessOptions::ProcessPath::FlowCode_Program:
00123 case ProcessOptions::ProcessPath::Object_Disassembly:
00124 case ProcessOptions::ProcessPath::Object_Library:
00125 case ProcessOptions::ProcessPath::Object_PIC:
00126 case ProcessOptions::ProcessPath::Object_Program:
00127 case ProcessOptions::ProcessPath::PIC_AssemblyAbsolute:
00128 case ProcessOptions::ProcessPath::Program_Disassembly:
00129 case ProcessOptions::ProcessPath::Program_PIC:
00130 case ProcessOptions::ProcessPath::Invalid:
00131 case ProcessOptions::ProcessPath::None:
00132 return ProcessOptions::ProcessPath::Invalid;
00133 }
00134
00135 return ProcessOptions::ProcessPath::Invalid;
00136 }