Alien-SmokeQt
view release on metacpan or search on metacpan
generator/parser/name_compiler.cpp view on Meta::CPAN
/* This file is part of KDevelop
Copyright 2002-2005 Roberto Raggi <roberto@kdevelop.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
//krazy:excludeall=cpp
#include "name_compiler.h"
#include "type_compiler.h"
#include "lexer.h"
#include "symbol.h"
#include "parsesession.h"
#include "tokens.h"
#include <QtCore/qdebug.h>
///@todo this is very expensive
QString decode(ParseSession* session, AST* ast, bool without_spaces = false)
{
QString ret;
if( without_spaces ) {
//Decode operator-names without spaces for now, since we rely on it in other places.
///@todo change this, here and in all the places that rely on it. Operators should then by written like "operator [ ]"(space between each token)
for( size_t a = ast->start_token; a < ast->end_token; a++ ) {
ret += session->token_stream->token(a).symbolString();
}
} else {
for( size_t a = ast->start_token; a < ast->end_token; a++ ) {
ret += session->token_stream->token(a).symbolString() + ' ';
}
}
return ret;
}
/*uint parseConstVolatile(ParseSession* session, const ListNode<std::size_t> *cv)
{
uint ret = AbstractType::NoModifiers;
if (cv) {
const ListNode<std::size_t> *it = cv->toFront();
const ListNode<std::size_t> *end = it;
do {
int kind = session->token_stream->kind(it->element);
if (kind == Token_const)
ret |= AbstractType::ConstModifier;
else if (kind == Token_volatile)
ret |= AbstractType::VolatileModifier;
it = it->next;
} while (it != end);
}
return ret;
}*/
/*IndexedTypeIdentifier typeIdentifierFromTemplateArgument(ParseSession* session, TemplateArgumentAST *node)
{
IndexedTypeIdentifier id;
if(node->expression) {
id = IndexedTypeIdentifier(decode(session, node), true);
}else if(node->type_id) {
//Parse the pointer operators
TypeCompiler tc(session);
tc.run(node->type_id->type_specifier);
id = IndexedTypeIdentifier(tc.identifier());
//node->type_id->type_specifier->cv
if(node->type_id->type_specifier)
id.setIsConstant(parseConstVolatile(session, node->type_id->type_specifier->cv) & AbstractType::ConstModifier);
if(node->type_id->declarator && node->type_id->declarator->ptr_ops)
{
const ListNode<PtrOperatorAST*> *it = node->type_id->declarator->ptr_ops->toFront();
const ListNode<PtrOperatorAST*> *end = it; ///@todo check ordering, eventually walk the list in reversed order
do
( run in 0.359 second using v1.01-cache-2.11-cpan-119454b85a5 )