Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

QString Microbe::compile ( const QString &  url,
bool  showSource,
bool  optimize 
)

Call this to compile the given code. This serves as the top level of recursion as it performs initialisation of things, to recurse at levels use parseUsingChild(), or create your own Parser.

Parameters:
url is used for reporting errors

Definition at line 73 of file microbe.cpp.

References PIC14::addCommonFunctions(), Code::generateCode(), m_picType, makePic(), Optimizer::optimize(), Parser::parse(), Code::postCompileConstruct(), PIC14::postCompileConstruct(), PIC14::setCode(), simplifyProgram(), and PIC14::toType().

{
      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 );
}


Generated by  Doxygen 1.6.0   Back to index