QString Microbe::compile( const QString & url, bool optimize ) { QFile file( url ); if( file.open( IO_ReadOnly ) ) { QTextStream stream(&file); unsigned line = 0; while( !stream.atEnd() ) m_program += SourceLine( stream.readLine(), url, line++ ); file.close(); simplifyProgram(); } else { m_errorReport += i18n("Could not open file '%1'\n").arg(url); return 0; } Parser parser(this); // Extract the PIC ID if ( !m_program.isEmpty() ) { m_picType = PIC14::toType( m_program[0].text() ); m_program.remove( m_program.begin() ); } PIC14 * pic = makePic(); if ( !pic ) return 0; Code * code = parser.parse( m_program ); pic->setCode( code ); pic->addCommonFunctions( (PIC14::DelaySubroutine)m_maxDelaySubroutine ); pic->postCompileConstruct( m_usedInterrupts ); code->postCompileConstruct(); if ( optimize ) { Optimizer opt; opt.optimize( code ); } return code->generateCode( pic ); }