Пример #1
0
void CppTree2Uml::parseTranslationUnit(const ParsedFile &file)
{
    clear();
    Import_Utils::createArtifact(file.fileName(), 0, file->comment());

    TreeParser::parseTranslationUnit(file);
}
Пример #2
0
	void fileParsed( const ParsedFile& fileName )
	{
		std::cout << ( m_generateTags ? "generate tags for " : "checking " ) 
			<< QFile::encodeName( fileName.fileName() ).data() << std::endl;
		
		QValueList<Problem> l = problems( fileName.fileName() );
		QValueList<Problem>::Iterator it = l.begin();
		while ( it != l.end() )
		{
			const Problem & p = *it;
			++it;
		std::cout << QFile::encodeName( fileName.fileName() ).data() << ":" << p.line() << ":"
				<< p.column() << ": " << p.text().latin1() << std::endl;
		}
		
		takeTranslationUnit( fileName );
		
		if ( m_generateTags )
		{
			TagCreator w( fileName.fileName(), catalog );
			w.parseTranslationUnit( fileName );
		}
		
		if ( !isResolveDependencesEnabled() )
			removeAllMacrosInFile( fileName.fileName() );
	}
Пример #3
0
void BackgroundParser::fileParsed( ParsedFile& file ) {

	ParsedFilePointer translationUnitUnsafe = m_driver->takeTranslationUnit( file.fileName() );
	//now file and translationUnitUnsafe are the same
	ParsedFilePointer translationUnit;
	//Since the lexer-cache keeps many QStrings like macro-names used in the background, everything must be copied here. The safest solution is just
	//serializing and deserializing the whole thing(the serialization does not respect the AST, but that can be copied later because that's safe)
	QMemArray<char> data;
	{
	  QDataStream stream( data, IO_WriteOnly );
	  translationUnitUnsafe->write( stream );
	}
	{
	  QDataStream stream( data, IO_ReadOnly );
	  translationUnit = new ParsedFile( stream );
	}

	translationUnit->setTranslationUnit( translationUnitUnsafe->operator TranslationUnitAST *() ); //Copy the AST, doing that is thread-safe
	translationUnitUnsafe->setTranslationUnit( 0 ); //Move the AST completely out of this thread's scope. Else it might crash on dual-core machines
	file.setTranslationUnit(0); //just to be sure, set to zero on both
	
	Unit* unit = new Unit;
	unit->fileName = file.fileName();
	unit->translationUnit = translationUnit;
	unit->problems = cloneProblemList( m_driver->problems( file.fileName() ) );
	
	static_cast<KDevSourceProvider*>( m_driver->sourceProvider() ) ->setReadFromDisk( false );
	
	if ( m_unitDict.find( file.fileName() ) != m_unitDict.end() )
	{
		Unit * u = m_unitDict[ file.fileName() ];
		m_unitDict.remove( file.fileName() );
		delete( u );
		u = 0;
	}
	
	m_unitDict.insert( file.fileName(), unit );
	
	KApplication::postEvent( m_cppSupport, new FileParsedEvent( file.fileName(), unit->problems, m_readFromDisk ) );
	
	m_currentFile = QString::null;
	
  if ( m_fileList->isEmpty() )
		m_isEmpty.wakeAll();	
}
Пример #4
0
void Driver::takeTranslationUnit( const ParsedFile& file ) {
    QMap<QString, ParsedFilePointer>::Iterator it = m_parsedUnits.find( file.fileName() );
    m_parsedUnits[ file.fileName() ] = 0;
}
Пример #5
0
  Function jit(const ParsedFile& file) {
    // Function name
    string name = file.to_string("NAME");

    // Number of inputs (default 1)
    int n_in = file.has("N_IN") ? file.to_int("N_IN") : 1;

    // Number of outputs (default 1)
    int n_out = file.has("N_OUT") ? file.to_int("N_OUT") : 1;

    // Function body
    string body = file.to_text("BODY");

    // Read options
    Dict opts;
    if (file.has("JAC_BODY")) opts["jac"] = file.to_text("JAC_BODY");
    if (file.has("HESS_BODY")) opts["hess"] = file.to_text("HESS_BODY");
    if (file.has("JIT")) opts["jit"] = file.to_int("JIT");

    // Create function object
    return jit(name, n_in, n_out, body, opts);
  }