forked from qt-creator/qt-creator
move src/shared/cplusplus/ -> src/libs/3rdparty/cplusplus/
Approved-by: legal
This commit is contained in:
4252
src/libs/3rdparty/cplusplus/AST.cpp
vendored
Normal file
4252
src/libs/3rdparty/cplusplus/AST.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4324
src/libs/3rdparty/cplusplus/AST.h
vendored
Normal file
4324
src/libs/3rdparty/cplusplus/AST.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1688
src/libs/3rdparty/cplusplus/ASTClone.cpp
vendored
Normal file
1688
src/libs/3rdparty/cplusplus/ASTClone.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1150
src/libs/3rdparty/cplusplus/ASTMatch0.cpp
vendored
Normal file
1150
src/libs/3rdparty/cplusplus/ASTMatch0.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2850
src/libs/3rdparty/cplusplus/ASTMatcher.cpp
vendored
Normal file
2850
src/libs/3rdparty/cplusplus/ASTMatcher.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
187
src/libs/3rdparty/cplusplus/ASTMatcher.h
vendored
Normal file
187
src/libs/3rdparty/cplusplus/ASTMatcher.h
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
#ifndef ASTMATCHER_H
|
||||
#define ASTMATCHER_H
|
||||
|
||||
#include "ASTfwd.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT ASTMatcher
|
||||
{
|
||||
public:
|
||||
ASTMatcher();
|
||||
virtual ~ASTMatcher();
|
||||
|
||||
virtual bool match(AccessDeclarationAST *node, AccessDeclarationAST *pattern);
|
||||
virtual bool match(QtObjectTagAST *node, QtObjectTagAST *pattern);
|
||||
virtual bool match(QtPrivateSlotAST *node, QtPrivateSlotAST *pattern);
|
||||
virtual bool match(QtPropertyDeclarationAST *node, QtPropertyDeclarationAST *pattern);
|
||||
virtual bool match(QtEnumDeclarationAST *node, QtEnumDeclarationAST *pattern);
|
||||
virtual bool match(QtFlagsDeclarationAST *node, QtFlagsDeclarationAST *pattern);
|
||||
virtual bool match(QtInterfaceNameAST *node, QtInterfaceNameAST *pattern);
|
||||
virtual bool match(QtInterfacesDeclarationAST *node, QtInterfacesDeclarationAST *pattern);
|
||||
virtual bool match(ArrayAccessAST *node, ArrayAccessAST *pattern);
|
||||
virtual bool match(ArrayDeclaratorAST *node, ArrayDeclaratorAST *pattern);
|
||||
virtual bool match(ArrayInitializerAST *node, ArrayInitializerAST *pattern);
|
||||
virtual bool match(AsmDefinitionAST *node, AsmDefinitionAST *pattern);
|
||||
virtual bool match(AttributeSpecifierAST *node, AttributeSpecifierAST *pattern);
|
||||
virtual bool match(AttributeAST *node, AttributeAST *pattern);
|
||||
virtual bool match(BaseSpecifierAST *node, BaseSpecifierAST *pattern);
|
||||
virtual bool match(BinaryExpressionAST *node, BinaryExpressionAST *pattern);
|
||||
virtual bool match(BoolLiteralAST *node, BoolLiteralAST *pattern);
|
||||
virtual bool match(BreakStatementAST *node, BreakStatementAST *pattern);
|
||||
virtual bool match(CallAST *node, CallAST *pattern);
|
||||
virtual bool match(CaseStatementAST *node, CaseStatementAST *pattern);
|
||||
virtual bool match(CastExpressionAST *node, CastExpressionAST *pattern);
|
||||
virtual bool match(CatchClauseAST *node, CatchClauseAST *pattern);
|
||||
virtual bool match(ClassSpecifierAST *node, ClassSpecifierAST *pattern);
|
||||
virtual bool match(CompoundExpressionAST *node, CompoundExpressionAST *pattern);
|
||||
virtual bool match(CompoundLiteralAST *node, CompoundLiteralAST *pattern);
|
||||
virtual bool match(CompoundStatementAST *node, CompoundStatementAST *pattern);
|
||||
virtual bool match(ConditionAST *node, ConditionAST *pattern);
|
||||
virtual bool match(ConditionalExpressionAST *node, ConditionalExpressionAST *pattern);
|
||||
virtual bool match(ContinueStatementAST *node, ContinueStatementAST *pattern);
|
||||
virtual bool match(ConversionFunctionIdAST *node, ConversionFunctionIdAST *pattern);
|
||||
virtual bool match(CppCastExpressionAST *node, CppCastExpressionAST *pattern);
|
||||
virtual bool match(CtorInitializerAST *node, CtorInitializerAST *pattern);
|
||||
virtual bool match(DeclaratorAST *node, DeclaratorAST *pattern);
|
||||
virtual bool match(DeclarationStatementAST *node, DeclarationStatementAST *pattern);
|
||||
virtual bool match(DeclaratorIdAST *node, DeclaratorIdAST *pattern);
|
||||
virtual bool match(DeleteExpressionAST *node, DeleteExpressionAST *pattern);
|
||||
virtual bool match(DestructorNameAST *node, DestructorNameAST *pattern);
|
||||
virtual bool match(DoStatementAST *node, DoStatementAST *pattern);
|
||||
virtual bool match(ElaboratedTypeSpecifierAST *node, ElaboratedTypeSpecifierAST *pattern);
|
||||
virtual bool match(EmptyDeclarationAST *node, EmptyDeclarationAST *pattern);
|
||||
virtual bool match(EnumSpecifierAST *node, EnumSpecifierAST *pattern);
|
||||
virtual bool match(EnumeratorAST *node, EnumeratorAST *pattern);
|
||||
virtual bool match(ExceptionDeclarationAST *node, ExceptionDeclarationAST *pattern);
|
||||
virtual bool match(ExceptionSpecificationAST *node, ExceptionSpecificationAST *pattern);
|
||||
virtual bool match(ExpressionOrDeclarationStatementAST *node, ExpressionOrDeclarationStatementAST *pattern);
|
||||
virtual bool match(ExpressionStatementAST *node, ExpressionStatementAST *pattern);
|
||||
virtual bool match(ForeachStatementAST *node, ForeachStatementAST *pattern);
|
||||
virtual bool match(ForStatementAST *node, ForStatementAST *pattern);
|
||||
virtual bool match(FunctionDeclaratorAST *node, FunctionDeclaratorAST *pattern);
|
||||
virtual bool match(FunctionDefinitionAST *node, FunctionDefinitionAST *pattern);
|
||||
virtual bool match(GotoStatementAST *node, GotoStatementAST *pattern);
|
||||
virtual bool match(IdExpressionAST *node, IdExpressionAST *pattern);
|
||||
virtual bool match(IfStatementAST *node, IfStatementAST *pattern);
|
||||
virtual bool match(LabeledStatementAST *node, LabeledStatementAST *pattern);
|
||||
virtual bool match(LinkageBodyAST *node, LinkageBodyAST *pattern);
|
||||
virtual bool match(LinkageSpecificationAST *node, LinkageSpecificationAST *pattern);
|
||||
virtual bool match(MemInitializerAST *node, MemInitializerAST *pattern);
|
||||
virtual bool match(MemberAccessAST *node, MemberAccessAST *pattern);
|
||||
virtual bool match(NamedTypeSpecifierAST *node, NamedTypeSpecifierAST *pattern);
|
||||
virtual bool match(NamespaceAST *node, NamespaceAST *pattern);
|
||||
virtual bool match(NamespaceAliasDefinitionAST *node, NamespaceAliasDefinitionAST *pattern);
|
||||
virtual bool match(NestedDeclaratorAST *node, NestedDeclaratorAST *pattern);
|
||||
virtual bool match(NestedExpressionAST *node, NestedExpressionAST *pattern);
|
||||
virtual bool match(NestedNameSpecifierAST *node, NestedNameSpecifierAST *pattern);
|
||||
virtual bool match(NewPlacementAST *node, NewPlacementAST *pattern);
|
||||
virtual bool match(NewArrayDeclaratorAST *node, NewArrayDeclaratorAST *pattern);
|
||||
virtual bool match(NewExpressionAST *node, NewExpressionAST *pattern);
|
||||
virtual bool match(NewInitializerAST *node, NewInitializerAST *pattern);
|
||||
virtual bool match(NewTypeIdAST *node, NewTypeIdAST *pattern);
|
||||
virtual bool match(NumericLiteralAST *node, NumericLiteralAST *pattern);
|
||||
virtual bool match(OperatorAST *node, OperatorAST *pattern);
|
||||
virtual bool match(OperatorFunctionIdAST *node, OperatorFunctionIdAST *pattern);
|
||||
virtual bool match(ParameterDeclarationAST *node, ParameterDeclarationAST *pattern);
|
||||
virtual bool match(ParameterDeclarationClauseAST *node, ParameterDeclarationClauseAST *pattern);
|
||||
virtual bool match(PointerAST *node, PointerAST *pattern);
|
||||
virtual bool match(PointerToMemberAST *node, PointerToMemberAST *pattern);
|
||||
virtual bool match(PostIncrDecrAST *node, PostIncrDecrAST *pattern);
|
||||
virtual bool match(QualifiedNameAST *node, QualifiedNameAST *pattern);
|
||||
virtual bool match(ReferenceAST *node, ReferenceAST *pattern);
|
||||
virtual bool match(ReturnStatementAST *node, ReturnStatementAST *pattern);
|
||||
virtual bool match(SimpleDeclarationAST *node, SimpleDeclarationAST *pattern);
|
||||
virtual bool match(SimpleNameAST *node, SimpleNameAST *pattern);
|
||||
virtual bool match(SimpleSpecifierAST *node, SimpleSpecifierAST *pattern);
|
||||
virtual bool match(SizeofExpressionAST *node, SizeofExpressionAST *pattern);
|
||||
virtual bool match(StringLiteralAST *node, StringLiteralAST *pattern);
|
||||
virtual bool match(SwitchStatementAST *node, SwitchStatementAST *pattern);
|
||||
virtual bool match(TemplateDeclarationAST *node, TemplateDeclarationAST *pattern);
|
||||
virtual bool match(TemplateIdAST *node, TemplateIdAST *pattern);
|
||||
virtual bool match(TemplateTypeParameterAST *node, TemplateTypeParameterAST *pattern);
|
||||
virtual bool match(ThisExpressionAST *node, ThisExpressionAST *pattern);
|
||||
virtual bool match(ThrowExpressionAST *node, ThrowExpressionAST *pattern);
|
||||
virtual bool match(TranslationUnitAST *node, TranslationUnitAST *pattern);
|
||||
virtual bool match(TryBlockStatementAST *node, TryBlockStatementAST *pattern);
|
||||
virtual bool match(TypeConstructorCallAST *node, TypeConstructorCallAST *pattern);
|
||||
virtual bool match(TypeIdAST *node, TypeIdAST *pattern);
|
||||
virtual bool match(TypeidExpressionAST *node, TypeidExpressionAST *pattern);
|
||||
virtual bool match(TypeofSpecifierAST *node, TypeofSpecifierAST *pattern);
|
||||
virtual bool match(TypenameCallExpressionAST *node, TypenameCallExpressionAST *pattern);
|
||||
virtual bool match(TypenameTypeParameterAST *node, TypenameTypeParameterAST *pattern);
|
||||
virtual bool match(UnaryExpressionAST *node, UnaryExpressionAST *pattern);
|
||||
virtual bool match(UsingAST *node, UsingAST *pattern);
|
||||
virtual bool match(UsingDirectiveAST *node, UsingDirectiveAST *pattern);
|
||||
virtual bool match(WhileStatementAST *node, WhileStatementAST *pattern);
|
||||
virtual bool match(QtMethodAST *node, QtMethodAST *pattern);
|
||||
virtual bool match(QtMemberDeclarationAST *node, QtMemberDeclarationAST *pattern);
|
||||
virtual bool match(ObjCClassDeclarationAST *node, ObjCClassDeclarationAST *pattern);
|
||||
virtual bool match(QtPropertyDeclarationItemAST *node, QtPropertyDeclarationItemAST *pattern);
|
||||
virtual bool match(ObjCClassForwardDeclarationAST *node, ObjCClassForwardDeclarationAST *pattern);
|
||||
virtual bool match(ObjCProtocolDeclarationAST *node, ObjCProtocolDeclarationAST *pattern);
|
||||
virtual bool match(ObjCProtocolForwardDeclarationAST *node, ObjCProtocolForwardDeclarationAST *pattern);
|
||||
virtual bool match(ObjCProtocolRefsAST *node, ObjCProtocolRefsAST *pattern);
|
||||
virtual bool match(ObjCSelectorAST *node, ObjCSelectorAST *pattern);
|
||||
virtual bool match(ObjCMessageExpressionAST *node, ObjCMessageExpressionAST *pattern);
|
||||
virtual bool match(ObjCMessageArgumentAST *node, ObjCMessageArgumentAST *pattern);
|
||||
virtual bool match(ObjCProtocolExpressionAST *node, ObjCProtocolExpressionAST *pattern);
|
||||
virtual bool match(ObjCTypeNameAST *node, ObjCTypeNameAST *pattern);
|
||||
virtual bool match(ObjCEncodeExpressionAST *node, ObjCEncodeExpressionAST *pattern);
|
||||
virtual bool match(ObjCSelectorArgumentAST *node, ObjCSelectorArgumentAST *pattern);
|
||||
virtual bool match(ObjCSelectorExpressionAST *node, ObjCSelectorExpressionAST *pattern);
|
||||
virtual bool match(ObjCInstanceVariablesDeclarationAST *node, ObjCInstanceVariablesDeclarationAST *pattern);
|
||||
virtual bool match(ObjCVisibilityDeclarationAST *node, ObjCVisibilityDeclarationAST *pattern);
|
||||
virtual bool match(ObjCPropertyAttributeAST *node, ObjCPropertyAttributeAST *pattern);
|
||||
virtual bool match(ObjCPropertyDeclarationAST *node, ObjCPropertyDeclarationAST *pattern);
|
||||
virtual bool match(ObjCMethodPrototypeAST *node, ObjCMethodPrototypeAST *pattern);
|
||||
virtual bool match(ObjCMethodDeclarationAST *node, ObjCMethodDeclarationAST *pattern);
|
||||
virtual bool match(ObjCMessageArgumentDeclarationAST *node, ObjCMessageArgumentDeclarationAST *pattern);
|
||||
virtual bool match(ObjCSynthesizedPropertyAST *node, ObjCSynthesizedPropertyAST *pattern);
|
||||
virtual bool match(ObjCSynthesizedPropertiesDeclarationAST *node, ObjCSynthesizedPropertiesDeclarationAST *pattern);
|
||||
virtual bool match(ObjCDynamicPropertiesDeclarationAST *node, ObjCDynamicPropertiesDeclarationAST *pattern);
|
||||
virtual bool match(ObjCFastEnumerationAST *node, ObjCFastEnumerationAST *pattern);
|
||||
virtual bool match(ObjCSynchronizedStatementAST *node, ObjCSynchronizedStatementAST *pattern);
|
||||
virtual bool match(LambdaExpressionAST *node, LambdaExpressionAST *pattern);
|
||||
virtual bool match(LambdaIntroducerAST *node, LambdaIntroducerAST *pattern);
|
||||
virtual bool match(LambdaCaptureAST *node, LambdaCaptureAST *pattern);
|
||||
virtual bool match(LambdaDeclaratorAST *node, LambdaDeclaratorAST *pattern);
|
||||
virtual bool match(CaptureAST *node, CaptureAST *pattern);
|
||||
virtual bool match(TrailingReturnTypeAST *node, TrailingReturnTypeAST *pattern);
|
||||
virtual bool match(BracedInitializerAST *node, BracedInitializerAST *pattern);
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
#endif // ASTMATCHER_H
|
33
src/libs/3rdparty/cplusplus/ASTPatternBuilder.cpp
vendored
Normal file
33
src/libs/3rdparty/cplusplus/ASTPatternBuilder.cpp
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "ASTPatternBuilder.h"
|
1303
src/libs/3rdparty/cplusplus/ASTPatternBuilder.h
vendored
Normal file
1303
src/libs/3rdparty/cplusplus/ASTPatternBuilder.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1231
src/libs/3rdparty/cplusplus/ASTVisit.cpp
vendored
Normal file
1231
src/libs/3rdparty/cplusplus/ASTVisit.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
125
src/libs/3rdparty/cplusplus/ASTVisitor.cpp
vendored
Normal file
125
src/libs/3rdparty/cplusplus/ASTVisitor.cpp
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "ASTVisitor.h"
|
||||
#include "AST.h"
|
||||
#include "TranslationUnit.h"
|
||||
#include "Control.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
ASTVisitor::ASTVisitor(TranslationUnit *translationUnit)
|
||||
: _translationUnit(translationUnit)
|
||||
{ }
|
||||
|
||||
ASTVisitor::~ASTVisitor()
|
||||
{ }
|
||||
|
||||
void ASTVisitor::accept(AST *ast)
|
||||
{ AST::accept(ast, this); }
|
||||
|
||||
Control *ASTVisitor::control() const
|
||||
{
|
||||
if (_translationUnit)
|
||||
return _translationUnit->control();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TranslationUnit *ASTVisitor::translationUnit() const
|
||||
{ return _translationUnit; }
|
||||
|
||||
void ASTVisitor::setTranslationUnit(TranslationUnit *translationUnit)
|
||||
{ _translationUnit = translationUnit; }
|
||||
|
||||
unsigned ASTVisitor::tokenCount() const
|
||||
{ return translationUnit()->tokenCount(); }
|
||||
|
||||
const Token &ASTVisitor::tokenAt(unsigned index) const
|
||||
{ return translationUnit()->tokenAt(index); }
|
||||
|
||||
int ASTVisitor::tokenKind(unsigned index) const
|
||||
{ return translationUnit()->tokenKind(index); }
|
||||
|
||||
const char *ASTVisitor::spell(unsigned index) const
|
||||
{ return translationUnit()->spell(index); }
|
||||
|
||||
const Identifier *ASTVisitor::identifier(unsigned index) const
|
||||
{ return translationUnit()->identifier(index); }
|
||||
|
||||
const Literal *ASTVisitor::literal(unsigned index) const
|
||||
{ return translationUnit()->literal(index); }
|
||||
|
||||
const NumericLiteral *ASTVisitor::numericLiteral(unsigned index) const
|
||||
{ return translationUnit()->numericLiteral(index); }
|
||||
|
||||
const StringLiteral *ASTVisitor::stringLiteral(unsigned index) const
|
||||
{ return translationUnit()->stringLiteral(index); }
|
||||
|
||||
void ASTVisitor::getPosition(unsigned offset,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
const StringLiteral **fileName) const
|
||||
{ translationUnit()->getPosition(offset, line, column, fileName); }
|
||||
|
||||
void ASTVisitor::getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
const StringLiteral **fileName) const
|
||||
{ translationUnit()->getTokenPosition(index, line, column, fileName); }
|
||||
|
||||
void ASTVisitor::getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const
|
||||
{ getPosition(tokenAt(index).begin(), line, column); }
|
||||
|
||||
void ASTVisitor::getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const
|
||||
{ getPosition(tokenAt(index).end(), line, column); }
|
||||
|
||||
|
401
src/libs/3rdparty/cplusplus/ASTVisitor.h
vendored
Normal file
401
src/libs/3rdparty/cplusplus/ASTVisitor.h
vendored
Normal file
@@ -0,0 +1,401 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_ASTVISITOR_H
|
||||
#define CPLUSPLUS_ASTVISITOR_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "ASTfwd.h"
|
||||
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT ASTVisitor
|
||||
{
|
||||
ASTVisitor(const ASTVisitor &other);
|
||||
void operator =(const ASTVisitor &other);
|
||||
|
||||
public:
|
||||
ASTVisitor(TranslationUnit *unit);
|
||||
virtual ~ASTVisitor();
|
||||
|
||||
TranslationUnit *translationUnit() const;
|
||||
void setTranslationUnit(TranslationUnit *translationUnit);
|
||||
|
||||
Control *control() const;
|
||||
unsigned tokenCount() const;
|
||||
const Token &tokenAt(unsigned index) const;
|
||||
int tokenKind(unsigned index) const;
|
||||
const char *spell(unsigned index) const;
|
||||
const Identifier *identifier(unsigned index) const;
|
||||
const Literal *literal(unsigned index) const;
|
||||
const NumericLiteral *numericLiteral(unsigned index) const;
|
||||
const StringLiteral *stringLiteral(unsigned index) const;
|
||||
|
||||
void getPosition(unsigned offset,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const;
|
||||
void getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const;
|
||||
|
||||
void accept(AST *ast);
|
||||
|
||||
template <typename _Tp>
|
||||
void accept(List<_Tp> *it)
|
||||
{
|
||||
for (; it; it = it->next)
|
||||
accept(it->value);
|
||||
}
|
||||
|
||||
virtual bool preVisit(AST *) { return true; }
|
||||
virtual void postVisit(AST *) {}
|
||||
|
||||
virtual bool visit(AccessDeclarationAST *) { return true; }
|
||||
virtual bool visit(QtObjectTagAST *) { return true; }
|
||||
virtual bool visit(QtPrivateSlotAST *) { return true; }
|
||||
virtual bool visit(QtPropertyDeclarationAST *) { return true; }
|
||||
virtual bool visit(QtEnumDeclarationAST *) { return true; }
|
||||
virtual bool visit(QtFlagsDeclarationAST *) { return true; }
|
||||
virtual bool visit(ArrayAccessAST *) { return true; }
|
||||
virtual bool visit(ArrayDeclaratorAST *) { return true; }
|
||||
virtual bool visit(ArrayInitializerAST *) { return true; }
|
||||
virtual bool visit(AsmDefinitionAST *) { return true; }
|
||||
virtual bool visit(AttributeSpecifierAST *) { return true; }
|
||||
virtual bool visit(AttributeAST *) { return true; }
|
||||
virtual bool visit(BaseSpecifierAST *) { return true; }
|
||||
virtual bool visit(BinaryExpressionAST *) { return true; }
|
||||
virtual bool visit(BoolLiteralAST *) { return true; }
|
||||
virtual bool visit(BreakStatementAST *) { return true; }
|
||||
virtual bool visit(CallAST *) { return true; }
|
||||
virtual bool visit(CaseStatementAST *) { return true; }
|
||||
virtual bool visit(CastExpressionAST *) { return true; }
|
||||
virtual bool visit(CatchClauseAST *) { return true; }
|
||||
virtual bool visit(ClassSpecifierAST *) { return true; }
|
||||
virtual bool visit(CompoundExpressionAST *) { return true; }
|
||||
virtual bool visit(CompoundLiteralAST *) { return true; }
|
||||
virtual bool visit(CompoundStatementAST *) { return true; }
|
||||
virtual bool visit(ConditionAST *) { return true; }
|
||||
virtual bool visit(ConditionalExpressionAST *) { return true; }
|
||||
virtual bool visit(ContinueStatementAST *) { return true; }
|
||||
virtual bool visit(ConversionFunctionIdAST *) { return true; }
|
||||
virtual bool visit(CppCastExpressionAST *) { return true; }
|
||||
virtual bool visit(CtorInitializerAST *) { return true; }
|
||||
virtual bool visit(DeclaratorAST *) { return true; }
|
||||
virtual bool visit(DeclarationStatementAST *) { return true; }
|
||||
virtual bool visit(DeclaratorIdAST *) { return true; }
|
||||
virtual bool visit(DeleteExpressionAST *) { return true; }
|
||||
virtual bool visit(DestructorNameAST *) { return true; }
|
||||
virtual bool visit(DoStatementAST *) { return true; }
|
||||
virtual bool visit(ElaboratedTypeSpecifierAST *) { return true; }
|
||||
virtual bool visit(EmptyDeclarationAST *) { return true; }
|
||||
virtual bool visit(EnumSpecifierAST *) { return true; }
|
||||
virtual bool visit(EnumeratorAST *) { return true; }
|
||||
virtual bool visit(ExceptionDeclarationAST *) { return true; }
|
||||
virtual bool visit(ExceptionSpecificationAST *) { return true; }
|
||||
virtual bool visit(ExpressionOrDeclarationStatementAST *) { return true; }
|
||||
virtual bool visit(ExpressionStatementAST *) { return true; }
|
||||
virtual bool visit(ForeachStatementAST *) { return true; }
|
||||
virtual bool visit(ForStatementAST *) { return true; }
|
||||
virtual bool visit(FunctionDeclaratorAST *) { return true; }
|
||||
virtual bool visit(FunctionDefinitionAST *) { return true; }
|
||||
virtual bool visit(GotoStatementAST *) { return true; }
|
||||
virtual bool visit(IdExpressionAST *) { return true; }
|
||||
virtual bool visit(IfStatementAST *) { return true; }
|
||||
virtual bool visit(LabeledStatementAST *) { return true; }
|
||||
virtual bool visit(LinkageBodyAST *) { return true; }
|
||||
virtual bool visit(LinkageSpecificationAST *) { return true; }
|
||||
virtual bool visit(MemInitializerAST *) { return true; }
|
||||
virtual bool visit(MemberAccessAST *) { return true; }
|
||||
virtual bool visit(NamedTypeSpecifierAST *) { return true; }
|
||||
virtual bool visit(NamespaceAST *) { return true; }
|
||||
virtual bool visit(NamespaceAliasDefinitionAST *) { return true; }
|
||||
virtual bool visit(NestedDeclaratorAST *) { return true; }
|
||||
virtual bool visit(NestedExpressionAST *) { return true; }
|
||||
virtual bool visit(NestedNameSpecifierAST *) { return true; }
|
||||
virtual bool visit(NewPlacementAST *) { return true; }
|
||||
virtual bool visit(NewArrayDeclaratorAST *) { return true; }
|
||||
virtual bool visit(NewExpressionAST *) { return true; }
|
||||
virtual bool visit(NewInitializerAST *) { return true; }
|
||||
virtual bool visit(NewTypeIdAST *) { return true; }
|
||||
virtual bool visit(NumericLiteralAST *) { return true; }
|
||||
virtual bool visit(OperatorAST *) { return true; }
|
||||
virtual bool visit(OperatorFunctionIdAST *) { return true; }
|
||||
virtual bool visit(ParameterDeclarationAST *) { return true; }
|
||||
virtual bool visit(ParameterDeclarationClauseAST *) { return true; }
|
||||
virtual bool visit(PointerAST *) { return true; }
|
||||
virtual bool visit(PointerToMemberAST *) { return true; }
|
||||
virtual bool visit(PostIncrDecrAST *) { return true; }
|
||||
virtual bool visit(QualifiedNameAST *) { return true; }
|
||||
virtual bool visit(ReferenceAST *) { return true; }
|
||||
virtual bool visit(ReturnStatementAST *) { return true; }
|
||||
virtual bool visit(SimpleDeclarationAST *) { return true; }
|
||||
virtual bool visit(SimpleNameAST *) { return true; }
|
||||
virtual bool visit(SimpleSpecifierAST *) { return true; }
|
||||
virtual bool visit(SizeofExpressionAST *) { return true; }
|
||||
virtual bool visit(StringLiteralAST *) { return true; }
|
||||
virtual bool visit(SwitchStatementAST *) { return true; }
|
||||
virtual bool visit(TemplateDeclarationAST *) { return true; }
|
||||
virtual bool visit(TemplateIdAST *) { return true; }
|
||||
virtual bool visit(TemplateTypeParameterAST *) { return true; }
|
||||
virtual bool visit(ThisExpressionAST *) { return true; }
|
||||
virtual bool visit(ThrowExpressionAST *) { return true; }
|
||||
virtual bool visit(TranslationUnitAST *) { return true; }
|
||||
virtual bool visit(TryBlockStatementAST *) { return true; }
|
||||
virtual bool visit(TypeConstructorCallAST *) { return true; }
|
||||
virtual bool visit(TypeIdAST *) { return true; }
|
||||
virtual bool visit(TypeidExpressionAST *) { return true; }
|
||||
virtual bool visit(TypeofSpecifierAST *) { return true; }
|
||||
virtual bool visit(TypenameCallExpressionAST *) { return true; }
|
||||
virtual bool visit(TypenameTypeParameterAST *) { return true; }
|
||||
virtual bool visit(UnaryExpressionAST *) { return true; }
|
||||
virtual bool visit(UsingAST *) { return true; }
|
||||
virtual bool visit(UsingDirectiveAST *) { return true; }
|
||||
virtual bool visit(WhileStatementAST *) { return true; }
|
||||
virtual bool visit(QtMethodAST *) { return true; }
|
||||
virtual bool visit(QtMemberDeclarationAST *) { return true; }
|
||||
virtual bool visit(QtPropertyDeclarationItemAST *) { return true; }
|
||||
virtual bool visit(QtInterfacesDeclarationAST *) { return true; }
|
||||
virtual bool visit(QtInterfaceNameAST *) { return true; }
|
||||
|
||||
// C++0x
|
||||
virtual bool visit(LambdaExpressionAST *) { return true; }
|
||||
virtual bool visit(LambdaIntroducerAST *) { return true; }
|
||||
virtual bool visit(LambdaCaptureAST *) { return true; }
|
||||
virtual bool visit(LambdaDeclaratorAST *) { return true; }
|
||||
virtual bool visit(CaptureAST *) { return true; }
|
||||
virtual bool visit(TrailingReturnTypeAST *) { return true; }
|
||||
virtual bool visit(BracedInitializerAST *) { return true; }
|
||||
|
||||
// ObjC++
|
||||
virtual bool visit(ObjCClassDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCClassForwardDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCProtocolDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCProtocolForwardDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCProtocolRefsAST *) { return true; }
|
||||
virtual bool visit(ObjCSelectorAST *) { return true; }
|
||||
virtual bool visit(ObjCMessageExpressionAST *) { return true; }
|
||||
virtual bool visit(ObjCMessageArgumentAST *) { return true; }
|
||||
virtual bool visit(ObjCProtocolExpressionAST *) { return true; }
|
||||
virtual bool visit(ObjCTypeNameAST *) { return true; }
|
||||
virtual bool visit(ObjCEncodeExpressionAST *) { return true; }
|
||||
virtual bool visit(ObjCSelectorArgumentAST *) { return true; }
|
||||
virtual bool visit(ObjCSelectorExpressionAST *) { return true; }
|
||||
virtual bool visit(ObjCInstanceVariablesDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCVisibilityDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCPropertyAttributeAST *) { return true; }
|
||||
virtual bool visit(ObjCPropertyDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCMethodPrototypeAST *) { return true; }
|
||||
virtual bool visit(ObjCMethodDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCMessageArgumentDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCSynthesizedPropertyAST *) { return true; }
|
||||
virtual bool visit(ObjCSynthesizedPropertiesDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCDynamicPropertiesDeclarationAST *) { return true; }
|
||||
virtual bool visit(ObjCFastEnumerationAST *) { return true; }
|
||||
virtual bool visit(ObjCSynchronizedStatementAST *) { return true; }
|
||||
|
||||
virtual void endVisit(AccessDeclarationAST *) { }
|
||||
virtual void endVisit(QtObjectTagAST *) {}
|
||||
virtual void endVisit(QtPrivateSlotAST *) {}
|
||||
virtual void endVisit(QtPropertyDeclarationAST *) { }
|
||||
virtual void endVisit(QtEnumDeclarationAST *) { }
|
||||
virtual void endVisit(QtFlagsDeclarationAST *) { }
|
||||
virtual void endVisit(ArrayAccessAST *) { }
|
||||
virtual void endVisit(ArrayDeclaratorAST *) { }
|
||||
virtual void endVisit(ArrayInitializerAST *) { }
|
||||
virtual void endVisit(AsmDefinitionAST *) { }
|
||||
virtual void endVisit(AttributeSpecifierAST *) { }
|
||||
virtual void endVisit(AttributeAST *) { }
|
||||
virtual void endVisit(BaseSpecifierAST *) { }
|
||||
virtual void endVisit(BinaryExpressionAST *) { }
|
||||
virtual void endVisit(BoolLiteralAST *) { }
|
||||
virtual void endVisit(BreakStatementAST *) { }
|
||||
virtual void endVisit(CallAST *) { }
|
||||
virtual void endVisit(CaseStatementAST *) { }
|
||||
virtual void endVisit(CastExpressionAST *) { }
|
||||
virtual void endVisit(CatchClauseAST *) { }
|
||||
virtual void endVisit(ClassSpecifierAST *) { }
|
||||
virtual void endVisit(CompoundExpressionAST *) { }
|
||||
virtual void endVisit(CompoundLiteralAST *) { }
|
||||
virtual void endVisit(CompoundStatementAST *) { }
|
||||
virtual void endVisit(ConditionAST *) { }
|
||||
virtual void endVisit(ConditionalExpressionAST *) { }
|
||||
virtual void endVisit(ContinueStatementAST *) { }
|
||||
virtual void endVisit(ConversionFunctionIdAST *) { }
|
||||
virtual void endVisit(CppCastExpressionAST *) { }
|
||||
virtual void endVisit(CtorInitializerAST *) { }
|
||||
virtual void endVisit(DeclaratorAST *) { }
|
||||
virtual void endVisit(DeclarationStatementAST *) { }
|
||||
virtual void endVisit(DeclaratorIdAST *) { }
|
||||
virtual void endVisit(DeleteExpressionAST *) { }
|
||||
virtual void endVisit(DestructorNameAST *) { }
|
||||
virtual void endVisit(DoStatementAST *) { }
|
||||
virtual void endVisit(ElaboratedTypeSpecifierAST *) { }
|
||||
virtual void endVisit(EmptyDeclarationAST *) { }
|
||||
virtual void endVisit(EnumSpecifierAST *) { }
|
||||
virtual void endVisit(EnumeratorAST *) { }
|
||||
virtual void endVisit(ExceptionDeclarationAST *) { }
|
||||
virtual void endVisit(ExceptionSpecificationAST *) { }
|
||||
virtual void endVisit(ExpressionOrDeclarationStatementAST *) { }
|
||||
virtual void endVisit(ExpressionStatementAST *) { }
|
||||
virtual void endVisit(ForeachStatementAST *) { }
|
||||
virtual void endVisit(ForStatementAST *) { }
|
||||
virtual void endVisit(FunctionDeclaratorAST *) { }
|
||||
virtual void endVisit(FunctionDefinitionAST *) { }
|
||||
virtual void endVisit(GotoStatementAST *) { }
|
||||
virtual void endVisit(IdExpressionAST *) { }
|
||||
virtual void endVisit(IfStatementAST *) { }
|
||||
virtual void endVisit(LabeledStatementAST *) { }
|
||||
virtual void endVisit(LinkageBodyAST *) { }
|
||||
virtual void endVisit(LinkageSpecificationAST *) { }
|
||||
virtual void endVisit(MemInitializerAST *) { }
|
||||
virtual void endVisit(MemberAccessAST *) { }
|
||||
virtual void endVisit(NamedTypeSpecifierAST *) { }
|
||||
virtual void endVisit(NamespaceAST *) { }
|
||||
virtual void endVisit(NamespaceAliasDefinitionAST *) { }
|
||||
virtual void endVisit(NestedDeclaratorAST *) { }
|
||||
virtual void endVisit(NestedExpressionAST *) { }
|
||||
virtual void endVisit(NestedNameSpecifierAST *) { }
|
||||
virtual void endVisit(NewPlacementAST *) { }
|
||||
virtual void endVisit(NewArrayDeclaratorAST *) { }
|
||||
virtual void endVisit(NewExpressionAST *) { }
|
||||
virtual void endVisit(NewInitializerAST *) { }
|
||||
virtual void endVisit(NewTypeIdAST *) { }
|
||||
virtual void endVisit(NumericLiteralAST *) { }
|
||||
virtual void endVisit(OperatorAST *) { }
|
||||
virtual void endVisit(OperatorFunctionIdAST *) { }
|
||||
virtual void endVisit(ParameterDeclarationAST *) { }
|
||||
virtual void endVisit(ParameterDeclarationClauseAST *) { }
|
||||
virtual void endVisit(PointerAST *) { }
|
||||
virtual void endVisit(PointerToMemberAST *) { }
|
||||
virtual void endVisit(PostIncrDecrAST *) { }
|
||||
virtual void endVisit(QualifiedNameAST *) { }
|
||||
virtual void endVisit(ReferenceAST *) { }
|
||||
virtual void endVisit(ReturnStatementAST *) { }
|
||||
virtual void endVisit(SimpleDeclarationAST *) { }
|
||||
virtual void endVisit(SimpleNameAST *) { }
|
||||
virtual void endVisit(SimpleSpecifierAST *) { }
|
||||
virtual void endVisit(SizeofExpressionAST *) { }
|
||||
virtual void endVisit(StringLiteralAST *) { }
|
||||
virtual void endVisit(SwitchStatementAST *) { }
|
||||
virtual void endVisit(TemplateDeclarationAST *) { }
|
||||
virtual void endVisit(TemplateIdAST *) { }
|
||||
virtual void endVisit(TemplateTypeParameterAST *) { }
|
||||
virtual void endVisit(ThisExpressionAST *) { }
|
||||
virtual void endVisit(ThrowExpressionAST *) { }
|
||||
virtual void endVisit(TranslationUnitAST *) { }
|
||||
virtual void endVisit(TryBlockStatementAST *) { }
|
||||
virtual void endVisit(TypeConstructorCallAST *) { }
|
||||
virtual void endVisit(TypeIdAST *) { }
|
||||
virtual void endVisit(TypeidExpressionAST *) { }
|
||||
virtual void endVisit(TypeofSpecifierAST *) { }
|
||||
virtual void endVisit(TypenameCallExpressionAST *) { }
|
||||
virtual void endVisit(TypenameTypeParameterAST *) { }
|
||||
virtual void endVisit(UnaryExpressionAST *) { }
|
||||
virtual void endVisit(UsingAST *) { }
|
||||
virtual void endVisit(UsingDirectiveAST *) { }
|
||||
virtual void endVisit(WhileStatementAST *) { }
|
||||
virtual void endVisit(QtMethodAST *) { }
|
||||
virtual void endVisit(QtMemberDeclarationAST *) { }
|
||||
virtual void endVisit(QtPropertyDeclarationItemAST *) { }
|
||||
virtual void endVisit(QtInterfacesDeclarationAST *) { }
|
||||
virtual void endVisit(QtInterfaceNameAST *) { }
|
||||
|
||||
// C++0x
|
||||
virtual void endVisit(LambdaExpressionAST *) { }
|
||||
virtual void endVisit(LambdaIntroducerAST *) { }
|
||||
virtual void endVisit(LambdaCaptureAST *) { }
|
||||
virtual void endVisit(LambdaDeclaratorAST *) { }
|
||||
virtual void endVisit(CaptureAST *) { }
|
||||
virtual void endVisit(TrailingReturnTypeAST *) { }
|
||||
virtual void endVisit(BracedInitializerAST *) { }
|
||||
|
||||
// ObjC++
|
||||
virtual void endVisit(ObjCClassDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCClassForwardDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCProtocolDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCProtocolForwardDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCProtocolRefsAST *) { }
|
||||
virtual void endVisit(ObjCSelectorAST *) { }
|
||||
virtual void endVisit(ObjCMessageExpressionAST *) { }
|
||||
virtual void endVisit(ObjCMessageArgumentAST *) { }
|
||||
virtual void endVisit(ObjCProtocolExpressionAST *) { }
|
||||
virtual void endVisit(ObjCTypeNameAST *) { }
|
||||
virtual void endVisit(ObjCEncodeExpressionAST *) { }
|
||||
virtual void endVisit(ObjCSelectorArgumentAST *) { }
|
||||
virtual void endVisit(ObjCSelectorExpressionAST *) { }
|
||||
virtual void endVisit(ObjCInstanceVariablesDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCVisibilityDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCPropertyAttributeAST *) { }
|
||||
virtual void endVisit(ObjCPropertyDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCMethodPrototypeAST *) { }
|
||||
virtual void endVisit(ObjCMethodDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCMessageArgumentDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCSynthesizedPropertyAST *) { }
|
||||
virtual void endVisit(ObjCSynthesizedPropertiesDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCDynamicPropertiesDeclarationAST *) { }
|
||||
virtual void endVisit(ObjCFastEnumerationAST *) { }
|
||||
virtual void endVisit(ObjCSynchronizedStatementAST *) { }
|
||||
|
||||
private:
|
||||
TranslationUnit *_translationUnit;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_ASTVISITOR_H
|
244
src/libs/3rdparty/cplusplus/ASTfwd.h
vendored
Normal file
244
src/libs/3rdparty/cplusplus/ASTfwd.h
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_ASTFWD_H
|
||||
#define CPLUSPLUS_ASTFWD_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
template <typename _Tp> class List;
|
||||
|
||||
class AST;
|
||||
class ASTVisitor;
|
||||
class ASTMatcher;
|
||||
|
||||
class AccessDeclarationAST;
|
||||
class ArrayAccessAST;
|
||||
class ArrayDeclaratorAST;
|
||||
class ArrayInitializerAST;
|
||||
class AsmDefinitionAST;
|
||||
class AttributeAST;
|
||||
class AttributeSpecifierAST;
|
||||
class BaseSpecifierAST;
|
||||
class BinaryExpressionAST;
|
||||
class BoolLiteralAST;
|
||||
class BracedInitializerAST;
|
||||
class BreakStatementAST;
|
||||
class CallAST;
|
||||
class CaptureAST;
|
||||
class CaseStatementAST;
|
||||
class CastExpressionAST;
|
||||
class CatchClauseAST;
|
||||
class ClassSpecifierAST;
|
||||
class CompoundExpressionAST;
|
||||
class CompoundLiteralAST;
|
||||
class CompoundStatementAST;
|
||||
class ConditionAST;
|
||||
class ConditionalExpressionAST;
|
||||
class ContinueStatementAST;
|
||||
class ConversionFunctionIdAST;
|
||||
class CoreDeclaratorAST;
|
||||
class CppCastExpressionAST;
|
||||
class CtorInitializerAST;
|
||||
class DeclarationAST;
|
||||
class DeclarationStatementAST;
|
||||
class DeclaratorAST;
|
||||
class DeclaratorIdAST;
|
||||
class DeleteExpressionAST;
|
||||
class DestructorNameAST;
|
||||
class DoStatementAST;
|
||||
class ElaboratedTypeSpecifierAST;
|
||||
class EmptyDeclarationAST;
|
||||
class EnumSpecifierAST;
|
||||
class EnumeratorAST;
|
||||
class ExceptionDeclarationAST;
|
||||
class ExceptionSpecificationAST;
|
||||
class ExpressionAST;
|
||||
class ExpressionOrDeclarationStatementAST;
|
||||
class ExpressionStatementAST;
|
||||
class ForStatementAST;
|
||||
class ForeachStatementAST;
|
||||
class FunctionDeclaratorAST;
|
||||
class FunctionDefinitionAST;
|
||||
class GotoStatementAST;
|
||||
class IdExpressionAST;
|
||||
class IfStatementAST;
|
||||
class LabeledStatementAST;
|
||||
class LambdaCaptureAST;
|
||||
class LambdaDeclaratorAST;
|
||||
class LambdaExpressionAST;
|
||||
class LambdaIntroducerAST;
|
||||
class LinkageBodyAST;
|
||||
class LinkageSpecificationAST;
|
||||
class MemInitializerAST;
|
||||
class MemberAccessAST;
|
||||
class NameAST;
|
||||
class NamedTypeSpecifierAST;
|
||||
class NamespaceAST;
|
||||
class NamespaceAliasDefinitionAST;
|
||||
class NestedDeclaratorAST;
|
||||
class NestedExpressionAST;
|
||||
class NestedNameSpecifierAST;
|
||||
class NewArrayDeclaratorAST;
|
||||
class NewExpressionAST;
|
||||
class NewInitializerAST;
|
||||
class NewPlacementAST;
|
||||
class NewTypeIdAST;
|
||||
class NumericLiteralAST;
|
||||
class ObjCClassDeclarationAST;
|
||||
class ObjCClassForwardDeclarationAST;
|
||||
class ObjCDynamicPropertiesDeclarationAST;
|
||||
class ObjCEncodeExpressionAST;
|
||||
class ObjCFastEnumerationAST;
|
||||
class ObjCInstanceVariablesDeclarationAST;
|
||||
class ObjCMessageArgumentAST;
|
||||
class ObjCMessageArgumentDeclarationAST;
|
||||
class ObjCMessageExpressionAST;
|
||||
class ObjCMethodDeclarationAST;
|
||||
class ObjCMethodPrototypeAST;
|
||||
class ObjCPropertyAttributeAST;
|
||||
class ObjCPropertyDeclarationAST;
|
||||
class ObjCProtocolDeclarationAST;
|
||||
class ObjCProtocolExpressionAST;
|
||||
class ObjCProtocolForwardDeclarationAST;
|
||||
class ObjCProtocolRefsAST;
|
||||
class ObjCSelectorAST;
|
||||
class ObjCSelectorArgumentAST;
|
||||
class ObjCSelectorExpressionAST;
|
||||
class ObjCSynchronizedStatementAST;
|
||||
class ObjCSynthesizedPropertiesDeclarationAST;
|
||||
class ObjCSynthesizedPropertyAST;
|
||||
class ObjCTypeNameAST;
|
||||
class ObjCVisibilityDeclarationAST;
|
||||
class OperatorAST;
|
||||
class OperatorFunctionIdAST;
|
||||
class ParameterDeclarationAST;
|
||||
class ParameterDeclarationClauseAST;
|
||||
class PointerAST;
|
||||
class PointerToMemberAST;
|
||||
class PostIncrDecrAST;
|
||||
class PostfixAST;
|
||||
class PostfixDeclaratorAST;
|
||||
class PtrOperatorAST;
|
||||
class QtEnumDeclarationAST;
|
||||
class QtFlagsDeclarationAST;
|
||||
class QtInterfaceNameAST;
|
||||
class QtInterfacesDeclarationAST;
|
||||
class QtMemberDeclarationAST;
|
||||
class QtMethodAST;
|
||||
class QtObjectTagAST;
|
||||
class QtPrivateSlotAST;
|
||||
class QtPropertyDeclarationAST;
|
||||
class QtPropertyDeclarationItemAST;
|
||||
class QualifiedNameAST;
|
||||
class ReferenceAST;
|
||||
class ReturnStatementAST;
|
||||
class SimpleDeclarationAST;
|
||||
class SimpleNameAST;
|
||||
class SimpleSpecifierAST;
|
||||
class SizeofExpressionAST;
|
||||
class SpecifierAST;
|
||||
class StatementAST;
|
||||
class StringLiteralAST;
|
||||
class SwitchStatementAST;
|
||||
class TemplateDeclarationAST;
|
||||
class TemplateIdAST;
|
||||
class TemplateTypeParameterAST;
|
||||
class ThisExpressionAST;
|
||||
class ThrowExpressionAST;
|
||||
class TrailingReturnTypeAST;
|
||||
class TranslationUnitAST;
|
||||
class TryBlockStatementAST;
|
||||
class TypeConstructorCallAST;
|
||||
class TypeIdAST;
|
||||
class TypeidExpressionAST;
|
||||
class TypenameCallExpressionAST;
|
||||
class TypenameTypeParameterAST;
|
||||
class TypeofSpecifierAST;
|
||||
class UnaryExpressionAST;
|
||||
class UsingAST;
|
||||
class UsingDirectiveAST;
|
||||
class WhileStatementAST;
|
||||
|
||||
typedef List<ExpressionAST *> ExpressionListAST;
|
||||
typedef List<DeclarationAST *> DeclarationListAST;
|
||||
typedef List<StatementAST *> StatementListAST;
|
||||
typedef List<DeclaratorAST *> DeclaratorListAST;
|
||||
typedef List<BaseSpecifierAST *> BaseSpecifierListAST;
|
||||
typedef List<EnumeratorAST *> EnumeratorListAST;
|
||||
typedef List<MemInitializerAST *> MemInitializerListAST;
|
||||
typedef List<NewArrayDeclaratorAST *> NewArrayDeclaratorListAST;
|
||||
typedef List<PostfixAST *> PostfixListAST;
|
||||
typedef List<PostfixDeclaratorAST *> PostfixDeclaratorListAST;
|
||||
typedef List<AttributeAST *> AttributeListAST;
|
||||
typedef List<NestedNameSpecifierAST *> NestedNameSpecifierListAST;
|
||||
typedef List<CatchClauseAST *> CatchClauseListAST;
|
||||
typedef List<PtrOperatorAST *> PtrOperatorListAST;
|
||||
typedef List<SpecifierAST *> SpecifierListAST;
|
||||
typedef List<QtPropertyDeclarationItemAST *> QtPropertyDeclarationItemListAST;
|
||||
typedef List<NameAST *> NameListAST;
|
||||
typedef List<QtInterfaceNameAST *> QtInterfaceNameListAST;
|
||||
|
||||
typedef List<ParameterDeclarationAST *> ParameterDeclarationListAST;
|
||||
typedef List<CaptureAST *> CaptureListAST;
|
||||
|
||||
typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST;
|
||||
typedef List<ObjCSelectorArgumentAST *> ObjCSelectorArgumentListAST;
|
||||
typedef List<ObjCPropertyAttributeAST *> ObjCPropertyAttributeListAST;
|
||||
typedef List<ObjCMessageArgumentDeclarationAST *> ObjCMessageArgumentDeclarationListAST;
|
||||
typedef List<ObjCSynthesizedPropertyAST *> ObjCSynthesizedPropertyListAST;
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_ASTFWD_H
|
3086
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
Normal file
3086
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
319
src/libs/3rdparty/cplusplus/Bind.h
vendored
Normal file
319
src/libs/3rdparty/cplusplus/Bind.h
vendored
Normal file
@@ -0,0 +1,319 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_BIND_H
|
||||
#define CPLUSPLUS_BIND_H
|
||||
|
||||
#include "ASTVisitor.h"
|
||||
#include "FullySpecifiedType.h"
|
||||
#include "Names.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT Bind: protected ASTVisitor
|
||||
{
|
||||
public:
|
||||
Bind(TranslationUnit *unit);
|
||||
|
||||
void operator()(TranslationUnitAST *ast, Namespace *globalNamespace);
|
||||
void operator()(DeclarationAST *ast, Scope *scope);
|
||||
FullySpecifiedType operator()(ExpressionAST *ast, Scope *scope);
|
||||
FullySpecifiedType operator()(NewTypeIdAST *ast, Scope *scope);
|
||||
|
||||
bool skipFunctionBodies() const;
|
||||
void setSkipFunctionBodies(bool skipFunctionBodies);
|
||||
|
||||
protected:
|
||||
using ASTVisitor::translationUnit;
|
||||
|
||||
unsigned location(DeclaratorAST *ast, unsigned defaultLocation) const;
|
||||
unsigned location(CoreDeclaratorAST *ast, unsigned defaultLocation) const;
|
||||
unsigned location(NameAST *name, unsigned defaultLocation) const;
|
||||
|
||||
static int visibilityForAccessSpecifier(int tokenKind);
|
||||
static int visibilityForClassKey(int tokenKind);
|
||||
static int visibilityForObjCAccessSpecifier(int tokenKind);
|
||||
static bool isObjCClassMethod(int tokenKind);
|
||||
|
||||
void setDeclSpecifiers(Symbol *symbol, const FullySpecifiedType &declSpecifiers);
|
||||
|
||||
typedef FullySpecifiedType ExpressionTy;
|
||||
ExpressionTy expression(ExpressionAST *ast);
|
||||
|
||||
const Name *name(NameAST *ast);
|
||||
|
||||
void statement(StatementAST *ast);
|
||||
void declaration(DeclarationAST *ast);
|
||||
|
||||
FullySpecifiedType specifier(SpecifierAST *ast, const FullySpecifiedType &init);
|
||||
FullySpecifiedType ptrOperator(PtrOperatorAST *ast, const FullySpecifiedType &init);
|
||||
FullySpecifiedType coreDeclarator(CoreDeclaratorAST *ast, const FullySpecifiedType &init);
|
||||
FullySpecifiedType postfixDeclarator(PostfixDeclaratorAST *ast, const FullySpecifiedType &init);
|
||||
|
||||
Scope *switchScope(Scope *scope);
|
||||
int switchVisibility(int visibility);
|
||||
int switchMethodKey(int methodKey);
|
||||
int switchObjCVisibility(int visibility);
|
||||
|
||||
unsigned calculateScopeStart(ObjCClassDeclarationAST *ast) const;
|
||||
unsigned calculateScopeStart(ObjCProtocolDeclarationAST *ast) const;
|
||||
|
||||
const Name *objCSelectorArgument(ObjCSelectorArgumentAST *ast, bool *hasArg);
|
||||
void attribute(AttributeAST *ast);
|
||||
FullySpecifiedType declarator(DeclaratorAST *ast, const FullySpecifiedType &init, DeclaratorIdAST **declaratorId);
|
||||
void qtInterfaceName(QtInterfaceNameAST *ast);
|
||||
void baseSpecifier(BaseSpecifierAST *ast, unsigned colon_token, Class *klass);
|
||||
void ctorInitializer(CtorInitializerAST *ast, Function *fun);
|
||||
void enumerator(EnumeratorAST *ast, Enum *symbol);
|
||||
FullySpecifiedType exceptionSpecification(ExceptionSpecificationAST *ast, const FullySpecifiedType &init);
|
||||
void memInitializer(MemInitializerAST *ast, Function *fun);
|
||||
const Name *nestedNameSpecifier(NestedNameSpecifierAST *ast);
|
||||
void newPlacement(NewPlacementAST *ast);
|
||||
FullySpecifiedType newArrayDeclarator(NewArrayDeclaratorAST *ast, const FullySpecifiedType &init);
|
||||
void newInitializer(NewInitializerAST *ast);
|
||||
FullySpecifiedType newTypeId(NewTypeIdAST *ast);
|
||||
OperatorNameId::Kind cppOperator(OperatorAST *ast);
|
||||
void parameterDeclarationClause(ParameterDeclarationClauseAST *ast, unsigned lparen_token, Function *fun);
|
||||
void translationUnit(TranslationUnitAST *ast);
|
||||
void objCProtocolRefs(ObjCProtocolRefsAST *ast, Symbol *objcClassOrProtocol);
|
||||
void objCMessageArgument(ObjCMessageArgumentAST *ast);
|
||||
FullySpecifiedType objCTypeName(ObjCTypeNameAST *ast);
|
||||
void objCInstanceVariablesDeclaration(ObjCInstanceVariablesDeclarationAST *ast, ObjCClass *klass);
|
||||
void objCPropertyAttribute(ObjCPropertyAttributeAST *ast);
|
||||
void objCMessageArgumentDeclaration(ObjCMessageArgumentDeclarationAST *ast, ObjCMethod *method);
|
||||
ObjCMethod *objCMethodPrototype(ObjCMethodPrototypeAST *ast);
|
||||
void objCSynthesizedProperty(ObjCSynthesizedPropertyAST *ast);
|
||||
void lambdaIntroducer(LambdaIntroducerAST *ast);
|
||||
void lambdaCapture(LambdaCaptureAST *ast);
|
||||
void capture(CaptureAST *ast);
|
||||
void lambdaDeclarator(LambdaDeclaratorAST *ast);
|
||||
FullySpecifiedType trailingReturnType(TrailingReturnTypeAST *ast, const FullySpecifiedType &init);
|
||||
const StringLiteral *asStringLiteral(unsigned firstToken, unsigned lastToken);
|
||||
|
||||
virtual bool preVisit(AST *);
|
||||
virtual void postVisit(AST *);
|
||||
|
||||
// AST
|
||||
virtual bool visit(ObjCSelectorArgumentAST *ast);
|
||||
virtual bool visit(AttributeAST *ast);
|
||||
virtual bool visit(DeclaratorAST *ast);
|
||||
virtual bool visit(QtPropertyDeclarationItemAST *ast);
|
||||
virtual bool visit(QtInterfaceNameAST *ast);
|
||||
virtual bool visit(BaseSpecifierAST *ast);
|
||||
virtual bool visit(CtorInitializerAST *ast);
|
||||
virtual bool visit(EnumeratorAST *ast);
|
||||
virtual bool visit(ExceptionSpecificationAST *ast);
|
||||
virtual bool visit(MemInitializerAST *ast);
|
||||
virtual bool visit(NestedNameSpecifierAST *ast);
|
||||
virtual bool visit(NewPlacementAST *ast);
|
||||
virtual bool visit(NewArrayDeclaratorAST *ast);
|
||||
virtual bool visit(NewInitializerAST *ast);
|
||||
virtual bool visit(NewTypeIdAST *ast);
|
||||
virtual bool visit(OperatorAST *ast);
|
||||
virtual bool visit(ParameterDeclarationClauseAST *ast);
|
||||
virtual bool visit(TranslationUnitAST *ast);
|
||||
virtual bool visit(ObjCProtocolRefsAST *ast);
|
||||
virtual bool visit(ObjCMessageArgumentAST *ast);
|
||||
virtual bool visit(ObjCTypeNameAST *ast);
|
||||
virtual bool visit(ObjCInstanceVariablesDeclarationAST *ast);
|
||||
virtual bool visit(ObjCPropertyAttributeAST *ast);
|
||||
virtual bool visit(ObjCMessageArgumentDeclarationAST *ast);
|
||||
virtual bool visit(ObjCMethodPrototypeAST *ast);
|
||||
virtual bool visit(ObjCSynthesizedPropertyAST *ast);
|
||||
virtual bool visit(LambdaIntroducerAST *ast);
|
||||
virtual bool visit(LambdaCaptureAST *ast);
|
||||
virtual bool visit(CaptureAST *ast);
|
||||
virtual bool visit(LambdaDeclaratorAST *ast);
|
||||
virtual bool visit(TrailingReturnTypeAST *ast);
|
||||
|
||||
// StatementAST
|
||||
virtual bool visit(QtMemberDeclarationAST *ast);
|
||||
virtual bool visit(CaseStatementAST *ast);
|
||||
virtual bool visit(CompoundStatementAST *ast);
|
||||
virtual bool visit(DeclarationStatementAST *ast);
|
||||
virtual bool visit(DoStatementAST *ast);
|
||||
virtual bool visit(ExpressionOrDeclarationStatementAST *ast);
|
||||
virtual bool visit(ExpressionStatementAST *ast);
|
||||
virtual bool visit(ForeachStatementAST *ast);
|
||||
virtual bool visit(ForStatementAST *ast);
|
||||
virtual bool visit(IfStatementAST *ast);
|
||||
virtual bool visit(LabeledStatementAST *ast);
|
||||
virtual bool visit(BreakStatementAST *ast);
|
||||
virtual bool visit(ContinueStatementAST *ast);
|
||||
virtual bool visit(GotoStatementAST *ast);
|
||||
virtual bool visit(ReturnStatementAST *ast);
|
||||
virtual bool visit(SwitchStatementAST *ast);
|
||||
virtual bool visit(TryBlockStatementAST *ast);
|
||||
virtual bool visit(CatchClauseAST *ast);
|
||||
virtual bool visit(WhileStatementAST *ast);
|
||||
virtual bool visit(ObjCFastEnumerationAST *ast);
|
||||
virtual bool visit(ObjCSynchronizedStatementAST *ast);
|
||||
|
||||
// ExpressionAST
|
||||
virtual bool visit(IdExpressionAST *ast);
|
||||
virtual bool visit(CompoundExpressionAST *ast);
|
||||
virtual bool visit(CompoundLiteralAST *ast);
|
||||
virtual bool visit(QtMethodAST *ast);
|
||||
virtual bool visit(BinaryExpressionAST *ast);
|
||||
virtual bool visit(CastExpressionAST *ast);
|
||||
virtual bool visit(ConditionAST *ast);
|
||||
virtual bool visit(ConditionalExpressionAST *ast);
|
||||
virtual bool visit(CppCastExpressionAST *ast);
|
||||
virtual bool visit(DeleteExpressionAST *ast);
|
||||
virtual bool visit(ArrayInitializerAST *ast);
|
||||
virtual bool visit(NewExpressionAST *ast);
|
||||
virtual bool visit(TypeidExpressionAST *ast);
|
||||
virtual bool visit(TypenameCallExpressionAST *ast);
|
||||
virtual bool visit(TypeConstructorCallAST *ast);
|
||||
virtual bool visit(SizeofExpressionAST *ast);
|
||||
virtual bool visit(NumericLiteralAST *ast);
|
||||
virtual bool visit(BoolLiteralAST *ast);
|
||||
virtual bool visit(ThisExpressionAST *ast);
|
||||
virtual bool visit(NestedExpressionAST *ast);
|
||||
virtual bool visit(StringLiteralAST *ast);
|
||||
virtual bool visit(ThrowExpressionAST *ast);
|
||||
virtual bool visit(TypeIdAST *ast);
|
||||
virtual bool visit(UnaryExpressionAST *ast);
|
||||
virtual bool visit(ObjCMessageExpressionAST *ast);
|
||||
virtual bool visit(ObjCProtocolExpressionAST *ast);
|
||||
virtual bool visit(ObjCEncodeExpressionAST *ast);
|
||||
virtual bool visit(ObjCSelectorExpressionAST *ast);
|
||||
virtual bool visit(LambdaExpressionAST *ast);
|
||||
virtual bool visit(BracedInitializerAST *ast);
|
||||
|
||||
// DeclarationAST
|
||||
virtual bool visit(SimpleDeclarationAST *ast);
|
||||
virtual bool visit(EmptyDeclarationAST *ast);
|
||||
virtual bool visit(AccessDeclarationAST *ast);
|
||||
virtual bool visit(QtObjectTagAST *ast);
|
||||
virtual bool visit(QtPrivateSlotAST *ast);
|
||||
virtual bool visit(QtPropertyDeclarationAST *ast);
|
||||
virtual bool visit(QtEnumDeclarationAST *ast);
|
||||
virtual bool visit(QtFlagsDeclarationAST *ast);
|
||||
virtual bool visit(QtInterfacesDeclarationAST *ast);
|
||||
virtual bool visit(AsmDefinitionAST *ast);
|
||||
virtual bool visit(ExceptionDeclarationAST *ast);
|
||||
virtual bool visit(FunctionDefinitionAST *ast);
|
||||
virtual bool visit(LinkageBodyAST *ast);
|
||||
virtual bool visit(LinkageSpecificationAST *ast);
|
||||
virtual bool visit(NamespaceAST *ast);
|
||||
virtual bool visit(NamespaceAliasDefinitionAST *ast);
|
||||
virtual bool visit(ParameterDeclarationAST *ast);
|
||||
virtual bool visit(TemplateDeclarationAST *ast);
|
||||
virtual bool visit(TypenameTypeParameterAST *ast);
|
||||
virtual bool visit(TemplateTypeParameterAST *ast);
|
||||
virtual bool visit(UsingAST *ast);
|
||||
virtual bool visit(UsingDirectiveAST *ast);
|
||||
virtual bool visit(ObjCClassForwardDeclarationAST *ast);
|
||||
virtual bool visit(ObjCClassDeclarationAST *ast);
|
||||
virtual bool visit(ObjCProtocolForwardDeclarationAST *ast);
|
||||
virtual bool visit(ObjCProtocolDeclarationAST *ast);
|
||||
virtual bool visit(ObjCVisibilityDeclarationAST *ast);
|
||||
virtual bool visit(ObjCPropertyDeclarationAST *ast);
|
||||
virtual bool visit(ObjCMethodDeclarationAST *ast);
|
||||
virtual bool visit(ObjCSynthesizedPropertiesDeclarationAST *ast);
|
||||
virtual bool visit(ObjCDynamicPropertiesDeclarationAST *ast);
|
||||
|
||||
// NameAST
|
||||
virtual bool visit(ObjCSelectorAST *ast);
|
||||
virtual bool visit(QualifiedNameAST *ast);
|
||||
virtual bool visit(OperatorFunctionIdAST *ast);
|
||||
virtual bool visit(ConversionFunctionIdAST *ast);
|
||||
virtual bool visit(SimpleNameAST *ast);
|
||||
virtual bool visit(DestructorNameAST *ast);
|
||||
virtual bool visit(TemplateIdAST *ast);
|
||||
|
||||
// SpecifierAST
|
||||
virtual bool visit(SimpleSpecifierAST *ast);
|
||||
virtual bool visit(AttributeSpecifierAST *ast);
|
||||
virtual bool visit(TypeofSpecifierAST *ast);
|
||||
virtual bool visit(ClassSpecifierAST *ast);
|
||||
virtual bool visit(NamedTypeSpecifierAST *ast);
|
||||
virtual bool visit(ElaboratedTypeSpecifierAST *ast);
|
||||
virtual bool visit(EnumSpecifierAST *ast);
|
||||
|
||||
// PtrOperatorAST
|
||||
virtual bool visit(PointerToMemberAST *ast);
|
||||
virtual bool visit(PointerAST *ast);
|
||||
virtual bool visit(ReferenceAST *ast);
|
||||
|
||||
// PostfixAST
|
||||
virtual bool visit(CallAST *ast);
|
||||
virtual bool visit(ArrayAccessAST *ast);
|
||||
virtual bool visit(PostIncrDecrAST *ast);
|
||||
virtual bool visit(MemberAccessAST *ast);
|
||||
|
||||
// CoreDeclaratorAST
|
||||
virtual bool visit(DeclaratorIdAST *ast);
|
||||
virtual bool visit(NestedDeclaratorAST *ast);
|
||||
|
||||
// PostfixDeclaratorAST
|
||||
virtual bool visit(FunctionDeclaratorAST *ast);
|
||||
virtual bool visit(ArrayDeclaratorAST *ast);
|
||||
|
||||
private:
|
||||
static const int kMaxDepth;
|
||||
|
||||
Scope *_scope;
|
||||
ExpressionTy _expression;
|
||||
const Name *_name;
|
||||
FullySpecifiedType _type;
|
||||
DeclaratorIdAST **_declaratorId;
|
||||
int _visibility;
|
||||
int _objcVisibility;
|
||||
int _methodKey;
|
||||
bool _skipFunctionBodies;
|
||||
int _depth;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
#endif // CPLUSPLUS_BIND_H
|
66
src/libs/3rdparty/cplusplus/CPlusPlus.h
vendored
Normal file
66
src/libs/3rdparty/cplusplus/CPlusPlus.h
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
#ifndef CPLUSPLUS_CPLUSPLUS_H
|
||||
#define CPLUSPLUS_CPLUSPLUS_H
|
||||
|
||||
#include "AST.h"
|
||||
#include "ASTMatcher.h"
|
||||
#include "ASTPatternBuilder.h"
|
||||
#include "ASTVisitor.h"
|
||||
#include "ASTfwd.h"
|
||||
#include "Bind.h"
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "Control.h"
|
||||
#include "CoreTypes.h"
|
||||
#include "DiagnosticClient.h"
|
||||
#include "FullySpecifiedType.h"
|
||||
#include "Lexer.h"
|
||||
#include "LiteralTable.h"
|
||||
#include "Literals.h"
|
||||
#include "MemoryPool.h"
|
||||
#include "Name.h"
|
||||
#include "NameVisitor.h"
|
||||
#include "Names.h"
|
||||
#include "ObjectiveCTypeQualifiers.h"
|
||||
#include "Parser.h"
|
||||
#include "QtContextKeywords.h"
|
||||
#include "Scope.h"
|
||||
#include "Symbol.h"
|
||||
#include "SymbolVisitor.h"
|
||||
#include "Symbols.h"
|
||||
#include "Token.h"
|
||||
#include "TranslationUnit.h"
|
||||
#include "Type.h"
|
||||
#include "TypeMatcher.h"
|
||||
#include "TypeVisitor.h"
|
||||
|
||||
#endif // CPLUSPLUS_CPLUSPLUS_H
|
150
src/libs/3rdparty/cplusplus/CPlusPlusForwardDeclarations.h
vendored
Normal file
150
src/libs/3rdparty/cplusplus/CPlusPlusForwardDeclarations.h
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H
|
||||
#define CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstddef>
|
||||
|
||||
#ifndef CPLUSPLUS_WITHOUT_QT
|
||||
# include <QtCore/qglobal.h>
|
||||
|
||||
# if defined(CPLUSPLUS_BUILD_LIB)
|
||||
# define CPLUSPLUS_EXPORT Q_DECL_EXPORT
|
||||
# elif defined(CPLUSPLUS_BUILD_STATIC_LIB)
|
||||
# define CPLUSPLUS_EXPORT
|
||||
# else
|
||||
# define CPLUSPLUS_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define CPLUSPLUS_EXPORT
|
||||
#endif
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class TranslationUnit;
|
||||
class Control;
|
||||
class MemoryPool;
|
||||
class DiagnosticClient;
|
||||
|
||||
class Identifier;
|
||||
class Literal;
|
||||
class StringLiteral;
|
||||
class NumericLiteral;
|
||||
|
||||
class SymbolTable;
|
||||
|
||||
// names
|
||||
class NameVisitor;
|
||||
class Name;
|
||||
class Identifier;
|
||||
class TemplateNameId;
|
||||
class DestructorNameId;
|
||||
class OperatorNameId;
|
||||
class ConversionNameId;
|
||||
class QualifiedNameId;
|
||||
class SelectorNameId;
|
||||
|
||||
// types
|
||||
class TypeMatcher;
|
||||
class FullySpecifiedType;
|
||||
class TypeVisitor;
|
||||
class Type;
|
||||
class UndefinedType;
|
||||
class VoidType;
|
||||
class IntegerType;
|
||||
class FloatType;
|
||||
class PointerToMemberType;
|
||||
class PointerType;
|
||||
class ReferenceType;
|
||||
class ArrayType;
|
||||
class NamedType;
|
||||
|
||||
// symbols
|
||||
class SymbolVisitor;
|
||||
class Symbol;
|
||||
class Scope;
|
||||
class UsingNamespaceDirective;
|
||||
class UsingDeclaration;
|
||||
class Declaration;
|
||||
class Argument;
|
||||
class TypenameArgument;
|
||||
class Function;
|
||||
class Namespace;
|
||||
class NamespaceAlias;
|
||||
class Template;
|
||||
class BaseClass;
|
||||
class Block;
|
||||
class Class;
|
||||
class Enum;
|
||||
class EnumeratorDeclaration;
|
||||
class ForwardClassDeclaration;
|
||||
|
||||
class Token;
|
||||
|
||||
// Qt symbols
|
||||
class QtPropertyDeclaration;
|
||||
class QtEnum;
|
||||
|
||||
// Objective-C symbols
|
||||
class ObjCBaseClass;
|
||||
class ObjCBaseProtocol;
|
||||
class ObjCClass;
|
||||
class ObjCForwardClassDeclaration;
|
||||
class ObjCProtocol;
|
||||
class ObjCForwardProtocolDeclaration;
|
||||
class ObjCMethod;
|
||||
class ObjCPropertyDeclaration;
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
#endif // CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H
|
832
src/libs/3rdparty/cplusplus/Control.cpp
vendored
Normal file
832
src/libs/3rdparty/cplusplus/Control.cpp
vendored
Normal file
@@ -0,0 +1,832 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Control.h"
|
||||
#include "Literals.h"
|
||||
#include "LiteralTable.h"
|
||||
#include "TranslationUnit.h"
|
||||
#include "CoreTypes.h"
|
||||
#include "Symbols.h"
|
||||
#include "Names.h"
|
||||
#include "TypeMatcher.h"
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename _Tp>
|
||||
struct Compare;
|
||||
|
||||
template <> struct Compare<IntegerType>
|
||||
{
|
||||
bool operator()(const IntegerType &ty, const IntegerType &otherTy) const
|
||||
{ return ty.kind() < otherTy.kind(); }
|
||||
};
|
||||
|
||||
template <> struct Compare<FloatType>
|
||||
{
|
||||
bool operator()(const FloatType &ty, const FloatType &otherTy) const
|
||||
{ return ty.kind() < otherTy.kind(); }
|
||||
};
|
||||
|
||||
template <> struct Compare<PointerToMemberType>
|
||||
{
|
||||
bool operator()(const PointerToMemberType &ty, const PointerToMemberType &otherTy) const
|
||||
{
|
||||
if (ty.memberName() < otherTy.memberName())
|
||||
return true;
|
||||
|
||||
else if (ty.memberName() == otherTy.memberName())
|
||||
return ty.elementType() < otherTy.elementType();
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct Compare<PointerType>
|
||||
{
|
||||
bool operator()(const PointerType &ty, const PointerType &otherTy) const
|
||||
{
|
||||
return ty.elementType() < otherTy.elementType();
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct Compare<ReferenceType>
|
||||
{
|
||||
bool operator()(const ReferenceType &ty, const ReferenceType &otherTy) const
|
||||
{
|
||||
return ty.elementType() < otherTy.elementType();
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct Compare<NamedType>
|
||||
{
|
||||
bool operator()(const NamedType &ty, const NamedType &otherTy) const
|
||||
{
|
||||
return ty.name() < otherTy.name();
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct Compare<ArrayType>
|
||||
{
|
||||
bool operator()(const ArrayType &ty, const ArrayType &otherTy) const
|
||||
{
|
||||
if (ty.size() < otherTy.size())
|
||||
return true;
|
||||
|
||||
else if (ty.size() == otherTy.size())
|
||||
return ty.elementType() < otherTy.elementType();
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct Compare<DestructorNameId>
|
||||
{
|
||||
bool operator()(const DestructorNameId &name, const DestructorNameId &otherName) const
|
||||
{
|
||||
return name.identifier() < otherName.identifier();
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct Compare<OperatorNameId>
|
||||
{
|
||||
bool operator()(const OperatorNameId &name, const OperatorNameId &otherName) const
|
||||
{
|
||||
return name.kind() < otherName.kind();
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct Compare<ConversionNameId>
|
||||
{
|
||||
bool operator()(const ConversionNameId &name, const ConversionNameId &otherName) const
|
||||
{
|
||||
return name.type() < otherName.type();
|
||||
}
|
||||
};
|
||||
template <> struct Compare<TemplateNameId>
|
||||
{
|
||||
bool operator()(const TemplateNameId &name, const TemplateNameId &otherName) const
|
||||
{
|
||||
const Identifier *id = name.identifier();
|
||||
const Identifier *otherId = otherName.identifier();
|
||||
|
||||
if (id == otherId)
|
||||
return std::lexicographical_compare(name.firstTemplateArgument(), name.lastTemplateArgument(),
|
||||
otherName.firstTemplateArgument(), otherName.lastTemplateArgument());
|
||||
|
||||
return id < otherId;
|
||||
}
|
||||
};
|
||||
template <> struct Compare<QualifiedNameId>
|
||||
{
|
||||
bool operator()(const QualifiedNameId &name, const QualifiedNameId &otherName) const
|
||||
{
|
||||
if (name.base() == otherName.base())
|
||||
return name.name() < otherName.name();
|
||||
|
||||
return name.base() < otherName.base();
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct Compare<SelectorNameId>
|
||||
{
|
||||
bool operator()(const SelectorNameId &name, const SelectorNameId &otherName) const
|
||||
{
|
||||
if (name.hasArguments() == otherName.hasArguments())
|
||||
return std::lexicographical_compare(name.firstName(), name.lastName(),
|
||||
otherName.firstName(), otherName.lastName());
|
||||
|
||||
return name.hasArguments() < otherName.hasArguments();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename _Tp>
|
||||
class Table: public std::set<_Tp, Compare<_Tp> >
|
||||
{
|
||||
typedef std::set<_Tp, Compare<_Tp> > _Base;
|
||||
public:
|
||||
_Tp *intern(const _Tp &element)
|
||||
{ return const_cast<_Tp *>(&*_Base::insert(element).first); }
|
||||
};
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
||||
#ifdef Q_OS_SYMBIAN
|
||||
//Symbian compiler has some difficulties to understand the templates.
|
||||
static void delete_array_entries(std::vector<Symbol *> vt)
|
||||
{
|
||||
std::vector<Symbol *>::iterator it;
|
||||
for (it = vt.begin(); it != vt.end(); ++it) {
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
#else
|
||||
template <typename _Iterator>
|
||||
static void delete_array_entries(_Iterator first, _Iterator last)
|
||||
{
|
||||
for (; first != last; ++first)
|
||||
delete *first;
|
||||
}
|
||||
|
||||
template <typename _Array>
|
||||
static void delete_array_entries(const _Array &a)
|
||||
{ delete_array_entries(a.begin(), a.end()); }
|
||||
#endif
|
||||
|
||||
class Control::Data
|
||||
{
|
||||
public:
|
||||
Data(Control *control)
|
||||
: control(control)
|
||||
, translationUnit(0)
|
||||
, diagnosticClient(0)
|
||||
, deprecatedId(0)
|
||||
, unavailableId(0)
|
||||
, objcGetterId(0)
|
||||
, objcSetterId(0)
|
||||
, objcReadwriteId(0)
|
||||
, objcReadonlyId(0)
|
||||
, objcAssignId(0)
|
||||
, objcRetainId(0)
|
||||
, objcCopyId(0)
|
||||
, objcNonatomicId(0)
|
||||
, processor(0)
|
||||
{}
|
||||
|
||||
~Data()
|
||||
{
|
||||
// symbols
|
||||
delete_array_entries(symbols);
|
||||
}
|
||||
|
||||
template <typename _Iterator>
|
||||
const TemplateNameId *findOrInsertTemplateNameId(const Identifier *id, _Iterator first, _Iterator last)
|
||||
{
|
||||
return templateNameIds.intern(TemplateNameId(id, first, last));
|
||||
}
|
||||
|
||||
const DestructorNameId *findOrInsertDestructorNameId(const Identifier *id)
|
||||
{
|
||||
return destructorNameIds.intern(DestructorNameId(id));
|
||||
}
|
||||
|
||||
const OperatorNameId *findOrInsertOperatorNameId(OperatorNameId::Kind kind)
|
||||
{
|
||||
return operatorNameIds.intern(OperatorNameId(kind));
|
||||
}
|
||||
|
||||
const ConversionNameId *findOrInsertConversionNameId(const FullySpecifiedType &type)
|
||||
{
|
||||
return conversionNameIds.intern(ConversionNameId(type));
|
||||
}
|
||||
|
||||
const QualifiedNameId *findOrInsertQualifiedNameId(const Name *base, const Name *name)
|
||||
{
|
||||
return qualifiedNameIds.intern(QualifiedNameId(base, name));
|
||||
}
|
||||
|
||||
template <typename _Iterator>
|
||||
const SelectorNameId *findOrInsertSelectorNameId(_Iterator first, _Iterator last, bool hasArguments)
|
||||
{
|
||||
return selectorNameIds.intern(SelectorNameId(first, last, hasArguments));
|
||||
}
|
||||
|
||||
IntegerType *findOrInsertIntegerType(int kind)
|
||||
{
|
||||
return integerTypes.intern(IntegerType(kind));
|
||||
}
|
||||
|
||||
FloatType *findOrInsertFloatType(int kind)
|
||||
{
|
||||
return floatTypes.intern(FloatType(kind));
|
||||
}
|
||||
|
||||
PointerToMemberType *findOrInsertPointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType)
|
||||
{
|
||||
return pointerToMemberTypes.intern(PointerToMemberType(memberName, elementType));
|
||||
}
|
||||
|
||||
PointerType *findOrInsertPointerType(const FullySpecifiedType &elementType)
|
||||
{
|
||||
return pointerTypes.intern(PointerType(elementType));
|
||||
}
|
||||
|
||||
ReferenceType *findOrInsertReferenceType(const FullySpecifiedType &elementType, bool rvalueRef)
|
||||
{
|
||||
return referenceTypes.intern(ReferenceType(elementType, rvalueRef));
|
||||
}
|
||||
|
||||
ArrayType *findOrInsertArrayType(const FullySpecifiedType &elementType, unsigned size)
|
||||
{
|
||||
return arrayTypes.intern(ArrayType(elementType, size));
|
||||
}
|
||||
|
||||
NamedType *findOrInsertNamedType(const Name *name)
|
||||
{
|
||||
return namedTypes.intern(NamedType(name));
|
||||
}
|
||||
|
||||
Declaration *newDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
Declaration *declaration = new Declaration(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(declaration);
|
||||
return declaration;
|
||||
}
|
||||
|
||||
EnumeratorDeclaration *newEnumeratorDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
EnumeratorDeclaration *decl = new EnumeratorDeclaration(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(decl);
|
||||
return decl;
|
||||
}
|
||||
|
||||
Argument *newArgument(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
Argument *argument = new Argument(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(argument);
|
||||
return argument;
|
||||
}
|
||||
|
||||
TypenameArgument *newTypenameArgument(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
TypenameArgument *argument = new TypenameArgument(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(argument);
|
||||
return argument;
|
||||
}
|
||||
|
||||
Function *newFunction(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
Function *function = new Function(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(function);
|
||||
return function;
|
||||
}
|
||||
|
||||
BaseClass *newBaseClass(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
BaseClass *baseClass = new BaseClass(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(baseClass);
|
||||
return baseClass;
|
||||
}
|
||||
|
||||
Block *newBlock(unsigned sourceLocation)
|
||||
{
|
||||
Block *block = new Block(translationUnit, sourceLocation);
|
||||
symbols.push_back(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
Class *newClass(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
Class *klass = new Class(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(klass);
|
||||
return klass;
|
||||
}
|
||||
|
||||
Namespace *newNamespace(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
Namespace *ns = new Namespace(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(ns);
|
||||
return ns;
|
||||
}
|
||||
|
||||
Template *newTemplate(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
Template *ns = new Template(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(ns);
|
||||
return ns;
|
||||
}
|
||||
|
||||
NamespaceAlias *newNamespaceAlias(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
NamespaceAlias *ns = new NamespaceAlias(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(ns);
|
||||
return ns;
|
||||
}
|
||||
|
||||
UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
UsingNamespaceDirective *u = new UsingNamespaceDirective(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(u);
|
||||
return u;
|
||||
}
|
||||
|
||||
ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
ForwardClassDeclaration *c = new ForwardClassDeclaration(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
QtPropertyDeclaration *newQtPropertyDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
QtPropertyDeclaration *d = new QtPropertyDeclaration(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(d);
|
||||
return d;
|
||||
}
|
||||
|
||||
QtEnum *newQtEnum(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
QtEnum *d = new QtEnum(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(d);
|
||||
return d;
|
||||
}
|
||||
|
||||
ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
ObjCBaseClass *c = new ObjCBaseClass(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
ObjCBaseProtocol *p = new ObjCBaseProtocol(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
ObjCClass *c = new ObjCClass(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
ObjCForwardClassDeclaration *fwd = new ObjCForwardClassDeclaration(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(fwd);
|
||||
return fwd;
|
||||
}
|
||||
|
||||
ObjCProtocol *newObjCProtocol(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
ObjCProtocol *p = new ObjCProtocol(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
ObjCForwardProtocolDeclaration *fwd = new ObjCForwardProtocolDeclaration(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(fwd);
|
||||
return fwd;
|
||||
}
|
||||
|
||||
ObjCMethod *newObjCMethod(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
ObjCMethod *method = new ObjCMethod(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(method);
|
||||
return method;
|
||||
}
|
||||
|
||||
ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
ObjCPropertyDeclaration *decl = new ObjCPropertyDeclaration(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(decl);
|
||||
return decl;
|
||||
}
|
||||
|
||||
Enum *newEnum(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
Enum *e = new Enum(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(e);
|
||||
return e;
|
||||
}
|
||||
|
||||
UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{
|
||||
UsingDeclaration *u = new UsingDeclaration(translationUnit, sourceLocation, name);
|
||||
symbols.push_back(u);
|
||||
return u;
|
||||
}
|
||||
|
||||
Control *control;
|
||||
TranslationUnit *translationUnit;
|
||||
DiagnosticClient *diagnosticClient;
|
||||
|
||||
TypeMatcher matcher;
|
||||
|
||||
LiteralTable<Identifier> identifiers;
|
||||
LiteralTable<StringLiteral> stringLiterals;
|
||||
LiteralTable<NumericLiteral> numericLiterals;
|
||||
|
||||
// ### replace std::map with lookup tables. ASAP!
|
||||
|
||||
// names
|
||||
Table<DestructorNameId> destructorNameIds;
|
||||
Table<OperatorNameId> operatorNameIds;
|
||||
Table<ConversionNameId> conversionNameIds;
|
||||
Table<TemplateNameId> templateNameIds;
|
||||
Table<QualifiedNameId> qualifiedNameIds;
|
||||
Table<SelectorNameId> selectorNameIds;
|
||||
|
||||
// types
|
||||
VoidType voidType;
|
||||
Table<IntegerType> integerTypes;
|
||||
Table<FloatType> floatTypes;
|
||||
Table<PointerToMemberType> pointerToMemberTypes;
|
||||
Table<PointerType> pointerTypes;
|
||||
Table<ReferenceType> referenceTypes;
|
||||
Table<ArrayType> arrayTypes;
|
||||
Table<NamedType> namedTypes;
|
||||
|
||||
// symbols
|
||||
std::vector<Symbol *> symbols;
|
||||
|
||||
const Identifier *deprecatedId;
|
||||
const Identifier *unavailableId;
|
||||
// ObjC context keywords:
|
||||
const Identifier *objcGetterId;
|
||||
const Identifier *objcSetterId;
|
||||
const Identifier *objcReadwriteId;
|
||||
const Identifier *objcReadonlyId;
|
||||
const Identifier *objcAssignId;
|
||||
const Identifier *objcRetainId;
|
||||
const Identifier *objcCopyId;
|
||||
const Identifier *objcNonatomicId;
|
||||
TopLevelDeclarationProcessor *processor;
|
||||
};
|
||||
|
||||
Control::Control()
|
||||
{
|
||||
d = new Data(this);
|
||||
|
||||
d->deprecatedId = identifier("deprecated");
|
||||
d->unavailableId = identifier("unavailable");
|
||||
|
||||
d->objcGetterId = identifier("getter");
|
||||
d->objcSetterId = identifier("setter");
|
||||
d->objcReadwriteId = identifier("readwrite");
|
||||
d->objcReadonlyId = identifier("readonly");
|
||||
d->objcAssignId = identifier("assign");
|
||||
d->objcRetainId = identifier("retain");
|
||||
d->objcCopyId = identifier("copy");
|
||||
d->objcNonatomicId = identifier("nonatomic");
|
||||
}
|
||||
|
||||
Control::~Control()
|
||||
{ delete d; }
|
||||
|
||||
TranslationUnit *Control::translationUnit() const
|
||||
{ return d->translationUnit; }
|
||||
|
||||
TranslationUnit *Control::switchTranslationUnit(TranslationUnit *unit)
|
||||
{
|
||||
TranslationUnit *previousTranslationUnit = d->translationUnit;
|
||||
d->translationUnit = unit;
|
||||
return previousTranslationUnit;
|
||||
}
|
||||
|
||||
DiagnosticClient *Control::diagnosticClient() const
|
||||
{ return d->diagnosticClient; }
|
||||
|
||||
void Control::setDiagnosticClient(DiagnosticClient *diagnosticClient)
|
||||
{ d->diagnosticClient = diagnosticClient; }
|
||||
|
||||
const OperatorNameId *Control::findOperatorNameId(OperatorNameId::Kind operatorId) const
|
||||
{
|
||||
Table<OperatorNameId>::const_iterator i = d->operatorNameIds.find(operatorId);
|
||||
if (i == d->operatorNameIds.end())
|
||||
return 0;
|
||||
else
|
||||
return &*i;
|
||||
}
|
||||
|
||||
const Identifier *Control::findIdentifier(const char *chars, unsigned size) const
|
||||
{ return d->identifiers.findLiteral(chars, size); }
|
||||
|
||||
const Identifier *Control::identifier(const char *chars, unsigned size)
|
||||
{ return d->identifiers.findOrInsertLiteral(chars, size); }
|
||||
|
||||
const Identifier *Control::identifier(const char *chars)
|
||||
{
|
||||
unsigned length = std::strlen(chars);
|
||||
return identifier(chars, length);
|
||||
}
|
||||
|
||||
Control::IdentifierIterator Control::firstIdentifier() const
|
||||
{ return d->identifiers.begin(); }
|
||||
|
||||
Control::IdentifierIterator Control::lastIdentifier() const
|
||||
{ return d->identifiers.end(); }
|
||||
|
||||
Control::StringLiteralIterator Control::firstStringLiteral() const
|
||||
{ return d->stringLiterals.begin(); }
|
||||
|
||||
Control::StringLiteralIterator Control::lastStringLiteral() const
|
||||
{ return d->stringLiterals.end(); }
|
||||
|
||||
Control::NumericLiteralIterator Control::firstNumericLiteral() const
|
||||
{ return d->numericLiterals.begin(); }
|
||||
|
||||
Control::NumericLiteralIterator Control::lastNumericLiteral() const
|
||||
{ return d->numericLiterals.end(); }
|
||||
|
||||
const StringLiteral *Control::stringLiteral(const char *chars, unsigned size)
|
||||
{ return d->stringLiterals.findOrInsertLiteral(chars, size); }
|
||||
|
||||
const StringLiteral *Control::stringLiteral(const char *chars)
|
||||
{
|
||||
unsigned length = std::strlen(chars);
|
||||
return stringLiteral(chars, length);
|
||||
}
|
||||
|
||||
const NumericLiteral *Control::numericLiteral(const char *chars, unsigned size)
|
||||
{ return d->numericLiterals.findOrInsertLiteral(chars, size); }
|
||||
|
||||
const NumericLiteral *Control::numericLiteral(const char *chars)
|
||||
{
|
||||
unsigned length = std::strlen(chars);
|
||||
return numericLiteral(chars, length);
|
||||
}
|
||||
|
||||
const TemplateNameId *Control::templateNameId(const Identifier *id,
|
||||
const FullySpecifiedType *const args,
|
||||
unsigned argv)
|
||||
{
|
||||
return d->findOrInsertTemplateNameId(id, args, args + argv);
|
||||
}
|
||||
|
||||
const DestructorNameId *Control::destructorNameId(const Identifier *id)
|
||||
{ return d->findOrInsertDestructorNameId(id); }
|
||||
|
||||
const OperatorNameId *Control::operatorNameId(OperatorNameId::Kind kind)
|
||||
{ return d->findOrInsertOperatorNameId(kind); }
|
||||
|
||||
const ConversionNameId *Control::conversionNameId(const FullySpecifiedType &type)
|
||||
{ return d->findOrInsertConversionNameId(type); }
|
||||
|
||||
const QualifiedNameId *Control::qualifiedNameId(const Name *base, const Name *name)
|
||||
{
|
||||
return d->findOrInsertQualifiedNameId(base, name);
|
||||
}
|
||||
|
||||
const SelectorNameId *Control::selectorNameId(const Name *const *names,
|
||||
unsigned nameCount,
|
||||
bool hasArguments)
|
||||
{
|
||||
return d->findOrInsertSelectorNameId(names, names + nameCount, hasArguments);
|
||||
}
|
||||
|
||||
|
||||
VoidType *Control::voidType()
|
||||
{ return &d->voidType; }
|
||||
|
||||
IntegerType *Control::integerType(int kind)
|
||||
{ return d->findOrInsertIntegerType(kind); }
|
||||
|
||||
FloatType *Control::floatType(int kind)
|
||||
{ return d->findOrInsertFloatType(kind); }
|
||||
|
||||
PointerToMemberType *Control::pointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType)
|
||||
{ return d->findOrInsertPointerToMemberType(memberName, elementType); }
|
||||
|
||||
PointerType *Control::pointerType(const FullySpecifiedType &elementType)
|
||||
{ return d->findOrInsertPointerType(elementType); }
|
||||
|
||||
ReferenceType *Control::referenceType(const FullySpecifiedType &elementType, bool rvalueRef)
|
||||
{ return d->findOrInsertReferenceType(elementType, rvalueRef); }
|
||||
|
||||
ArrayType *Control::arrayType(const FullySpecifiedType &elementType, unsigned size)
|
||||
{ return d->findOrInsertArrayType(elementType, size); }
|
||||
|
||||
NamedType *Control::namedType(const Name *name)
|
||||
{ return d->findOrInsertNamedType(name); }
|
||||
|
||||
Argument *Control::newArgument(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newArgument(sourceLocation, name); }
|
||||
|
||||
TypenameArgument *Control::newTypenameArgument(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newTypenameArgument(sourceLocation, name); }
|
||||
|
||||
Function *Control::newFunction(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newFunction(sourceLocation, name); }
|
||||
|
||||
Namespace *Control::newNamespace(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newNamespace(sourceLocation, name); }
|
||||
|
||||
Template *Control::newTemplate(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newTemplate(sourceLocation, name); }
|
||||
|
||||
NamespaceAlias *Control::newNamespaceAlias(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newNamespaceAlias(sourceLocation, name); }
|
||||
|
||||
BaseClass *Control::newBaseClass(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newBaseClass(sourceLocation, name); }
|
||||
|
||||
Class *Control::newClass(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newClass(sourceLocation, name); }
|
||||
|
||||
Enum *Control::newEnum(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newEnum(sourceLocation, name); }
|
||||
|
||||
Block *Control::newBlock(unsigned sourceLocation)
|
||||
{ return d->newBlock(sourceLocation); }
|
||||
|
||||
Declaration *Control::newDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newDeclaration(sourceLocation, name); }
|
||||
|
||||
EnumeratorDeclaration *Control::newEnumeratorDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newEnumeratorDeclaration(sourceLocation, name); }
|
||||
|
||||
UsingNamespaceDirective *Control::newUsingNamespaceDirective(unsigned sourceLocation,
|
||||
const Name *name)
|
||||
{ return d->newUsingNamespaceDirective(sourceLocation, name); }
|
||||
|
||||
UsingDeclaration *Control::newUsingDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newUsingDeclaration(sourceLocation, name); }
|
||||
|
||||
ForwardClassDeclaration *Control::newForwardClassDeclaration(unsigned sourceLocation,
|
||||
const Name *name)
|
||||
{ return d->newForwardClassDeclaration(sourceLocation, name); }
|
||||
|
||||
QtPropertyDeclaration *Control::newQtPropertyDeclaration(unsigned sourceLocation,
|
||||
const Name *name)
|
||||
{ return d->newQtPropertyDeclaration(sourceLocation, name); }
|
||||
|
||||
QtEnum *Control::newQtEnum(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newQtEnum(sourceLocation, name); }
|
||||
|
||||
ObjCBaseClass *Control::newObjCBaseClass(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newObjCBaseClass(sourceLocation, name); }
|
||||
|
||||
ObjCBaseProtocol *Control::newObjCBaseProtocol(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newObjCBaseProtocol(sourceLocation, name); }
|
||||
|
||||
ObjCClass *Control::newObjCClass(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newObjCClass(sourceLocation, name); }
|
||||
|
||||
ObjCForwardClassDeclaration *Control::newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newObjCForwardClassDeclaration(sourceLocation, name); }
|
||||
|
||||
ObjCProtocol *Control::newObjCProtocol(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newObjCProtocol(sourceLocation, name); }
|
||||
|
||||
ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newObjCForwardProtocolDeclaration(sourceLocation, name); }
|
||||
|
||||
ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newObjCMethod(sourceLocation, name); }
|
||||
|
||||
ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name)
|
||||
{ return d->newObjCPropertyDeclaration(sourceLocation, name); }
|
||||
|
||||
const Identifier *Control::deprecatedId() const
|
||||
{ return d->deprecatedId; }
|
||||
|
||||
const Identifier *Control::unavailableId() const
|
||||
{ return d->unavailableId; }
|
||||
|
||||
const Identifier *Control::objcGetterId() const
|
||||
{ return d->objcGetterId; }
|
||||
|
||||
const Identifier *Control::objcSetterId() const
|
||||
{ return d->objcSetterId; }
|
||||
|
||||
const Identifier *Control::objcReadwriteId() const
|
||||
{ return d->objcReadwriteId; }
|
||||
|
||||
const Identifier *Control::objcReadonlyId() const
|
||||
{ return d->objcReadonlyId; }
|
||||
|
||||
const Identifier *Control::objcAssignId() const
|
||||
{ return d->objcAssignId; }
|
||||
|
||||
const Identifier *Control::objcRetainId() const
|
||||
{ return d->objcRetainId; }
|
||||
|
||||
const Identifier *Control::objcCopyId() const
|
||||
{ return d->objcCopyId; }
|
||||
|
||||
const Identifier *Control::objcNonatomicId() const
|
||||
{ return d->objcNonatomicId; }
|
||||
|
||||
Symbol **Control::firstSymbol() const
|
||||
{
|
||||
if (d->symbols.empty())
|
||||
return 0;
|
||||
|
||||
return &*d->symbols.begin();
|
||||
}
|
||||
|
||||
Symbol **Control::lastSymbol() const
|
||||
{
|
||||
if (d->symbols.empty())
|
||||
return 0;
|
||||
|
||||
return &*d->symbols.begin() + d->symbols.size();
|
||||
}
|
||||
|
||||
bool Control::hasSymbol(Symbol *symbol) const
|
||||
{
|
||||
return std::find(d->symbols.begin(), d->symbols.end(), symbol) != d->symbols.end();
|
||||
}
|
||||
|
||||
void Control::squeeze()
|
||||
{
|
||||
d->numericLiterals.reset();
|
||||
}
|
||||
|
||||
TopLevelDeclarationProcessor *Control::topLevelDeclarationProcessor() const
|
||||
{
|
||||
return d->processor;
|
||||
}
|
||||
|
||||
void Control::setTopLevelDeclarationProcessor(CPlusPlus::TopLevelDeclarationProcessor *processor)
|
||||
{
|
||||
d->processor = processor;
|
||||
}
|
254
src/libs/3rdparty/cplusplus/Control.h
vendored
Normal file
254
src/libs/3rdparty/cplusplus/Control.h
vendored
Normal file
@@ -0,0 +1,254 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_CONTROL_H
|
||||
#define CPLUSPLUS_CONTROL_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "ASTfwd.h"
|
||||
#include "Names.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT TopLevelDeclarationProcessor
|
||||
{
|
||||
public:
|
||||
virtual ~TopLevelDeclarationProcessor() {}
|
||||
virtual bool processDeclaration(DeclarationAST *ast) = 0;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Control
|
||||
{
|
||||
public:
|
||||
Control();
|
||||
~Control();
|
||||
|
||||
TranslationUnit *translationUnit() const;
|
||||
TranslationUnit *switchTranslationUnit(TranslationUnit *unit);
|
||||
|
||||
TopLevelDeclarationProcessor *topLevelDeclarationProcessor() const;
|
||||
void setTopLevelDeclarationProcessor(TopLevelDeclarationProcessor *processor);
|
||||
|
||||
DiagnosticClient *diagnosticClient() const;
|
||||
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
|
||||
|
||||
/// Returns the canonical template name id.
|
||||
const TemplateNameId *templateNameId(const Identifier *id,
|
||||
const FullySpecifiedType *const args = 0,
|
||||
unsigned argc = 0);
|
||||
|
||||
/// Returns the canonical destructor name id.
|
||||
const DestructorNameId *destructorNameId(const Identifier *id);
|
||||
|
||||
/// Returns the canonical operator name id.
|
||||
const OperatorNameId *operatorNameId(OperatorNameId::Kind operatorId);
|
||||
|
||||
/// Returns the canonical conversion name id.
|
||||
const ConversionNameId *conversionNameId(const FullySpecifiedType &type);
|
||||
|
||||
/// Returns the canonical qualified name id.
|
||||
const QualifiedNameId *qualifiedNameId(const Name *base, const Name *name);
|
||||
|
||||
const SelectorNameId *selectorNameId(const Name *const *names,
|
||||
unsigned nameCount,
|
||||
bool hasArguments);
|
||||
|
||||
/// Returns a Type object of type VoidType.
|
||||
VoidType *voidType();
|
||||
|
||||
/// Returns a Type object of type IntegerType.
|
||||
IntegerType *integerType(int integerId);
|
||||
|
||||
/// Returns a Type object of type FloatType.
|
||||
FloatType *floatType(int floatId);
|
||||
|
||||
/// Returns a Type object of type PointertoMemberType.
|
||||
PointerToMemberType *pointerToMemberType(const Name *memberName,
|
||||
const FullySpecifiedType &elementType);
|
||||
|
||||
/// Returns a Type object of type PointerType.
|
||||
PointerType *pointerType(const FullySpecifiedType &elementType);
|
||||
|
||||
/// Returns a Type object of type ReferenceType.
|
||||
ReferenceType *referenceType(const FullySpecifiedType &elementType, bool rvalueRef = false);
|
||||
|
||||
/// Retruns a Type object of type ArrayType.
|
||||
ArrayType *arrayType(const FullySpecifiedType &elementType, unsigned size = 0);
|
||||
|
||||
/// Returns a Type object of type NamedType.
|
||||
NamedType *namedType(const Name *name);
|
||||
|
||||
/// Creates a new Declaration symbol.
|
||||
Declaration *newDeclaration(unsigned sourceLocation, const Name *name);
|
||||
|
||||
/// Creates a new EnumeratorDeclaration symbol.
|
||||
EnumeratorDeclaration *newEnumeratorDeclaration(unsigned sourceLocation, const Name *name);
|
||||
|
||||
/// Creates a new Argument symbol.
|
||||
Argument *newArgument(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Argument symbol.
|
||||
TypenameArgument *newTypenameArgument(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Function symbol.
|
||||
Function *newFunction(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Namespace symbol.
|
||||
Namespace *newNamespace(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Template symbol.
|
||||
Template *newTemplate(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Namespace symbol.
|
||||
NamespaceAlias *newNamespaceAlias(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new BaseClass symbol.
|
||||
BaseClass *newBaseClass(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Class symbol.
|
||||
Class *newClass(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Enum symbol.
|
||||
Enum *newEnum(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Block symbol.
|
||||
Block *newBlock(unsigned sourceLocation);
|
||||
|
||||
/// Creates a new UsingNamespaceDirective symbol.
|
||||
UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new UsingDeclaration symbol.
|
||||
UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new ForwardClassDeclaration symbol.
|
||||
ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new QtPropertyDeclaration symbol.
|
||||
QtPropertyDeclaration *newQtPropertyDeclaration(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new QtEnum symbol.
|
||||
QtEnum *newQtEnum(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name);
|
||||
ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name);
|
||||
|
||||
/// Creates a new Objective-C class symbol.
|
||||
ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Objective-C class forward declaration symbol.
|
||||
ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Objective-C protocol symbol.
|
||||
ObjCProtocol *newObjCProtocol(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Objective-C protocol forward declaration symbol.
|
||||
ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Objective-C method symbol.
|
||||
ObjCMethod *newObjCMethod(unsigned sourceLocation, const Name *name = 0);
|
||||
|
||||
/// Creates a new Objective-C @property declaration symbol.
|
||||
ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name);
|
||||
|
||||
const Identifier *deprecatedId() const;
|
||||
const Identifier *unavailableId() const;
|
||||
// Objective-C specific context keywords.
|
||||
const Identifier *objcGetterId() const;
|
||||
const Identifier *objcSetterId() const;
|
||||
const Identifier *objcReadwriteId() const;
|
||||
const Identifier *objcReadonlyId() const;
|
||||
const Identifier *objcAssignId() const;
|
||||
const Identifier *objcRetainId() const;
|
||||
const Identifier *objcCopyId() const;
|
||||
const Identifier *objcNonatomicId() const;
|
||||
|
||||
const OperatorNameId *findOperatorNameId(OperatorNameId::Kind operatorId) const;
|
||||
|
||||
const Identifier *findIdentifier(const char *chars, unsigned size) const;
|
||||
const Identifier *identifier(const char *chars, unsigned size);
|
||||
const Identifier *identifier(const char *chars);
|
||||
|
||||
typedef const Identifier *const *IdentifierIterator;
|
||||
typedef const StringLiteral *const *StringLiteralIterator;
|
||||
typedef const NumericLiteral *const *NumericLiteralIterator;
|
||||
|
||||
IdentifierIterator firstIdentifier() const;
|
||||
IdentifierIterator lastIdentifier() const;
|
||||
|
||||
StringLiteralIterator firstStringLiteral() const;
|
||||
StringLiteralIterator lastStringLiteral() const;
|
||||
|
||||
NumericLiteralIterator firstNumericLiteral() const;
|
||||
NumericLiteralIterator lastNumericLiteral() const;
|
||||
|
||||
const StringLiteral *stringLiteral(const char *chars, unsigned size);
|
||||
const StringLiteral *stringLiteral(const char *chars);
|
||||
|
||||
const NumericLiteral *numericLiteral(const char *chars, unsigned size);
|
||||
const NumericLiteral *numericLiteral(const char *chars);
|
||||
|
||||
Symbol **firstSymbol() const;
|
||||
Symbol **lastSymbol() const;
|
||||
|
||||
bool hasSymbol(Symbol *symbol) const;
|
||||
|
||||
void squeeze();
|
||||
|
||||
private:
|
||||
class Data;
|
||||
friend class Data;
|
||||
Data *d;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_CONTROL_H
|
322
src/libs/3rdparty/cplusplus/CoreTypes.cpp
vendored
Normal file
322
src/libs/3rdparty/cplusplus/CoreTypes.cpp
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "CoreTypes.h"
|
||||
#include "TypeVisitor.h"
|
||||
#include "TypeMatcher.h"
|
||||
#include "Names.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
bool UndefinedType::isEqualTo(const Type *other) const
|
||||
{
|
||||
if (other->isUndefinedType())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void UndefinedType::accept0(TypeVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
bool UndefinedType::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
||||
{
|
||||
if (const UndefinedType *otherUndefinedTy = otherType->asUndefinedType())
|
||||
return matcher->match(this, otherUndefinedTy);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VoidType::isEqualTo(const Type *other) const
|
||||
{
|
||||
const VoidType *o = other->asVoidType();
|
||||
return o != 0;
|
||||
}
|
||||
|
||||
void VoidType::accept0(TypeVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
bool VoidType::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
||||
{
|
||||
if (const VoidType *otherVoidTy = otherType->asVoidType())
|
||||
return matcher->match(this, otherVoidTy);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
PointerToMemberType::PointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType)
|
||||
: _memberName(memberName),
|
||||
_elementType(elementType)
|
||||
{ }
|
||||
|
||||
PointerToMemberType::~PointerToMemberType()
|
||||
{ }
|
||||
|
||||
const Name *PointerToMemberType::memberName() const
|
||||
{ return _memberName; }
|
||||
|
||||
FullySpecifiedType PointerToMemberType::elementType() const
|
||||
{ return _elementType; }
|
||||
|
||||
bool PointerToMemberType::isEqualTo(const Type *other) const
|
||||
{
|
||||
const PointerToMemberType *o = other->asPointerToMemberType();
|
||||
if (! o)
|
||||
return false;
|
||||
else if (! _memberName->isEqualTo(o->_memberName))
|
||||
return false;
|
||||
return _elementType.isEqualTo(o->_elementType);
|
||||
}
|
||||
|
||||
void PointerToMemberType::accept0(TypeVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
bool PointerToMemberType::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
||||
{
|
||||
if (const PointerToMemberType *otherTy = otherType->asPointerToMemberType())
|
||||
return matcher->match(this, otherTy);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
PointerType::PointerType(const FullySpecifiedType &elementType)
|
||||
: _elementType(elementType)
|
||||
{ }
|
||||
|
||||
PointerType::~PointerType()
|
||||
{ }
|
||||
|
||||
bool PointerType::isEqualTo(const Type *other) const
|
||||
{
|
||||
const PointerType *o = other->asPointerType();
|
||||
if (! o)
|
||||
return false;
|
||||
return _elementType.isEqualTo(o->_elementType);
|
||||
}
|
||||
|
||||
void PointerType::accept0(TypeVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
bool PointerType::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
||||
{
|
||||
if (const PointerType *otherTy = otherType->asPointerType())
|
||||
return matcher->match(this, otherTy);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FullySpecifiedType PointerType::elementType() const
|
||||
{ return _elementType; }
|
||||
|
||||
ReferenceType::ReferenceType(const FullySpecifiedType &elementType, bool rvalueRef)
|
||||
: _elementType(elementType), _rvalueReference(rvalueRef)
|
||||
{ }
|
||||
|
||||
ReferenceType::~ReferenceType()
|
||||
{ }
|
||||
|
||||
bool ReferenceType::isEqualTo(const Type *other) const
|
||||
{
|
||||
const ReferenceType *o = other->asReferenceType();
|
||||
if (! o)
|
||||
return false;
|
||||
else if (isRvalueReference() != o->isRvalueReference())
|
||||
return false;
|
||||
return _elementType.isEqualTo(o->_elementType);
|
||||
}
|
||||
|
||||
void ReferenceType::accept0(TypeVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
bool ReferenceType::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
||||
{
|
||||
if (const ReferenceType *otherTy = otherType->asReferenceType())
|
||||
return matcher->match(this, otherTy);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FullySpecifiedType ReferenceType::elementType() const
|
||||
{ return _elementType; }
|
||||
|
||||
bool ReferenceType::isRvalueReference() const
|
||||
{ return _rvalueReference; }
|
||||
|
||||
IntegerType::IntegerType(int kind)
|
||||
: _kind(kind)
|
||||
{ }
|
||||
|
||||
IntegerType::~IntegerType()
|
||||
{ }
|
||||
|
||||
bool IntegerType::isEqualTo(const Type *other) const
|
||||
{
|
||||
const IntegerType *o = other->asIntegerType();
|
||||
if (! o)
|
||||
return false;
|
||||
return _kind == o->_kind;
|
||||
}
|
||||
|
||||
void IntegerType::accept0(TypeVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
bool IntegerType::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
||||
{
|
||||
if (const IntegerType *otherTy = otherType->asIntegerType())
|
||||
return matcher->match(this, otherTy);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int IntegerType::kind() const
|
||||
{ return _kind; }
|
||||
|
||||
FloatType::FloatType(int kind)
|
||||
: _kind(kind)
|
||||
{ }
|
||||
|
||||
FloatType::~FloatType()
|
||||
{ }
|
||||
|
||||
void FloatType::accept0(TypeVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
bool FloatType::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
||||
{
|
||||
if (const FloatType *otherTy = otherType->asFloatType())
|
||||
return matcher->match(this, otherTy);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int FloatType::kind() const
|
||||
{ return _kind; }
|
||||
|
||||
bool FloatType::isEqualTo(const Type *other) const
|
||||
{
|
||||
const FloatType *o = other->asFloatType();
|
||||
if (! o)
|
||||
return false;
|
||||
return _kind == o->_kind;
|
||||
}
|
||||
|
||||
ArrayType::ArrayType(const FullySpecifiedType &elementType, unsigned size)
|
||||
: _elementType(elementType), _size(size)
|
||||
{ }
|
||||
|
||||
ArrayType::~ArrayType()
|
||||
{ }
|
||||
|
||||
bool ArrayType::isEqualTo(const Type *other) const
|
||||
{
|
||||
const ArrayType *o = other->asArrayType();
|
||||
if (! o)
|
||||
return false;
|
||||
else if (_size != o->_size)
|
||||
return false;
|
||||
return _elementType.isEqualTo(o->_elementType);
|
||||
}
|
||||
|
||||
void ArrayType::accept0(TypeVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
bool ArrayType::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
||||
{
|
||||
if (const ArrayType *otherTy = otherType->asArrayType())
|
||||
return matcher->match(this, otherTy);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FullySpecifiedType ArrayType::elementType() const
|
||||
{ return _elementType; }
|
||||
|
||||
unsigned ArrayType::size() const
|
||||
{ return _size; }
|
||||
|
||||
NamedType::NamedType(const Name *name)
|
||||
: _name(name)
|
||||
{ }
|
||||
|
||||
NamedType::~NamedType()
|
||||
{ }
|
||||
|
||||
const Name *NamedType::name() const
|
||||
{ return _name; }
|
||||
|
||||
bool NamedType::isEqualTo(const Type *other) const
|
||||
{
|
||||
const NamedType *o = other->asNamedType();
|
||||
if (! o)
|
||||
return false;
|
||||
|
||||
const Name *name = _name;
|
||||
if (const QualifiedNameId *q = name->asQualifiedNameId())
|
||||
name = q->name();
|
||||
|
||||
const Name *otherName = o->name();
|
||||
if (const QualifiedNameId *q = otherName->asQualifiedNameId())
|
||||
otherName = q->name();
|
||||
|
||||
return name->isEqualTo(otherName);
|
||||
}
|
||||
|
||||
void NamedType::accept0(TypeVisitor *visitor)
|
||||
{ visitor->visit(this); }
|
||||
|
||||
bool NamedType::matchType0(const Type *otherType, TypeMatcher *matcher) const
|
||||
{
|
||||
if (const NamedType *otherTy = otherType->asNamedType())
|
||||
return matcher->match(this, otherTy);
|
||||
|
||||
return false;
|
||||
}
|
293
src/libs/3rdparty/cplusplus/CoreTypes.h
vendored
Normal file
293
src/libs/3rdparty/cplusplus/CoreTypes.h
vendored
Normal file
@@ -0,0 +1,293 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_CORETYPES_H
|
||||
#define CPLUSPLUS_CORETYPES_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "Type.h"
|
||||
#include "FullySpecifiedType.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT UndefinedType : public Type
|
||||
{
|
||||
public:
|
||||
static UndefinedType *instance()
|
||||
{
|
||||
static UndefinedType t;
|
||||
return &t;
|
||||
}
|
||||
|
||||
virtual const UndefinedType *asUndefinedType() const
|
||||
{ return this; }
|
||||
|
||||
virtual UndefinedType *asUndefinedType()
|
||||
{ return this; }
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
protected:
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT VoidType: public Type
|
||||
{
|
||||
public:
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const VoidType *asVoidType() const
|
||||
{ return this; }
|
||||
|
||||
virtual VoidType *asVoidType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT IntegerType: public Type
|
||||
{
|
||||
public:
|
||||
enum Kind {
|
||||
Char,
|
||||
WideChar,
|
||||
Bool,
|
||||
Short,
|
||||
Int,
|
||||
Long,
|
||||
LongLong
|
||||
};
|
||||
|
||||
public:
|
||||
IntegerType(int kind);
|
||||
virtual ~IntegerType();
|
||||
|
||||
int kind() const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual IntegerType *asIntegerType()
|
||||
{ return this; }
|
||||
|
||||
virtual const IntegerType *asIntegerType() const
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
int _kind;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT FloatType: public Type
|
||||
{
|
||||
public:
|
||||
enum Kind {
|
||||
Float,
|
||||
Double,
|
||||
LongDouble
|
||||
};
|
||||
|
||||
public:
|
||||
FloatType(int kind);
|
||||
virtual ~FloatType();
|
||||
|
||||
int kind() const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const FloatType *asFloatType() const
|
||||
{ return this; }
|
||||
|
||||
virtual FloatType *asFloatType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
int _kind;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT PointerType: public Type
|
||||
{
|
||||
public:
|
||||
PointerType(const FullySpecifiedType &elementType);
|
||||
virtual ~PointerType();
|
||||
|
||||
FullySpecifiedType elementType() const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const PointerType *asPointerType() const
|
||||
{ return this; }
|
||||
|
||||
virtual PointerType *asPointerType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
FullySpecifiedType _elementType;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT PointerToMemberType: public Type
|
||||
{
|
||||
public:
|
||||
PointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType);
|
||||
virtual ~PointerToMemberType();
|
||||
|
||||
const Name *memberName() const;
|
||||
FullySpecifiedType elementType() const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const PointerToMemberType *asPointerToMemberType() const
|
||||
{ return this; }
|
||||
|
||||
virtual PointerToMemberType *asPointerToMemberType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
const Name *_memberName;
|
||||
FullySpecifiedType _elementType;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ReferenceType: public Type
|
||||
{
|
||||
public:
|
||||
ReferenceType(const FullySpecifiedType &elementType, bool rvalueRef);
|
||||
virtual ~ReferenceType();
|
||||
|
||||
FullySpecifiedType elementType() const;
|
||||
bool isRvalueReference() const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const ReferenceType *asReferenceType() const
|
||||
{ return this; }
|
||||
|
||||
virtual ReferenceType *asReferenceType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
FullySpecifiedType _elementType;
|
||||
bool _rvalueReference;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ArrayType: public Type
|
||||
{
|
||||
public:
|
||||
ArrayType(const FullySpecifiedType &elementType, unsigned size);
|
||||
virtual ~ArrayType();
|
||||
|
||||
FullySpecifiedType elementType() const;
|
||||
unsigned size() const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const ArrayType *asArrayType() const
|
||||
{ return this; }
|
||||
|
||||
virtual ArrayType *asArrayType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
FullySpecifiedType _elementType;
|
||||
unsigned _size;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT NamedType: public Type
|
||||
{
|
||||
public:
|
||||
NamedType(const Name *name);
|
||||
virtual ~NamedType();
|
||||
|
||||
const Name *name() const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const NamedType *asNamedType() const
|
||||
{ return this; }
|
||||
|
||||
virtual NamedType *asNamedType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
const Name *_name;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
#endif // CPLUSPLUS_CORETYPES_H
|
62
src/libs/3rdparty/cplusplus/DiagnosticClient.cpp
vendored
Normal file
62
src/libs/3rdparty/cplusplus/DiagnosticClient.cpp
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "DiagnosticClient.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
DiagnosticClient::DiagnosticClient()
|
||||
{ }
|
||||
|
||||
DiagnosticClient::~DiagnosticClient()
|
||||
{ }
|
||||
|
||||
|
84
src/libs/3rdparty/cplusplus/DiagnosticClient.h
vendored
Normal file
84
src/libs/3rdparty/cplusplus/DiagnosticClient.h
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_DIAGNOSTICCLIENT_H
|
||||
#define CPLUSPLUS_DIAGNOSTICCLIENT_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include <cstdarg>
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT DiagnosticClient
|
||||
{
|
||||
DiagnosticClient(const DiagnosticClient &other);
|
||||
void operator =(const DiagnosticClient &other);
|
||||
|
||||
public:
|
||||
enum Level {
|
||||
Warning,
|
||||
Error,
|
||||
Fatal
|
||||
};
|
||||
|
||||
DiagnosticClient();
|
||||
virtual ~DiagnosticClient();
|
||||
|
||||
virtual void report(int level,
|
||||
const StringLiteral *fileName,
|
||||
unsigned line, unsigned column,
|
||||
const char *format, va_list ap) = 0;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_DIAGNOSTICCLIENT_H
|
270
src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp
vendored
Normal file
270
src/libs/3rdparty/cplusplus/FullySpecifiedType.cpp
vendored
Normal file
@@ -0,0 +1,270 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "FullySpecifiedType.h"
|
||||
#include "Type.h"
|
||||
#include "CoreTypes.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
FullySpecifiedType::FullySpecifiedType(Type *type) :
|
||||
_type(type), _flags(0)
|
||||
{
|
||||
if (! type)
|
||||
_type = UndefinedType::instance();
|
||||
}
|
||||
|
||||
FullySpecifiedType::~FullySpecifiedType()
|
||||
{ }
|
||||
|
||||
bool FullySpecifiedType::isValid() const
|
||||
{ return _type != UndefinedType::instance(); }
|
||||
|
||||
Type *FullySpecifiedType::type() const
|
||||
{ return _type; }
|
||||
|
||||
void FullySpecifiedType::setType(Type *type)
|
||||
{ _type = type; }
|
||||
|
||||
FullySpecifiedType FullySpecifiedType::qualifiedType() const
|
||||
{
|
||||
FullySpecifiedType ty = *this;
|
||||
ty.setFriend(false);
|
||||
ty.setAuto(false);
|
||||
ty.setRegister(false);
|
||||
ty.setStatic(false);
|
||||
ty.setExtern(false);
|
||||
ty.setMutable(false);
|
||||
ty.setTypedef(false);
|
||||
|
||||
ty.setInline(false);
|
||||
ty.setVirtual(false);
|
||||
ty.setExplicit(false);
|
||||
|
||||
ty.setDeprecated(false);
|
||||
ty.setUnavailable(false);
|
||||
return ty;
|
||||
}
|
||||
|
||||
bool FullySpecifiedType::isConst() const
|
||||
{ return f._isConst; }
|
||||
|
||||
void FullySpecifiedType::setConst(bool isConst)
|
||||
{ f._isConst = isConst; }
|
||||
|
||||
bool FullySpecifiedType::isVolatile() const
|
||||
{ return f._isVolatile; }
|
||||
|
||||
void FullySpecifiedType::setVolatile(bool isVolatile)
|
||||
{ f._isVolatile = isVolatile; }
|
||||
|
||||
bool FullySpecifiedType::isSigned() const
|
||||
{ return f._isSigned; }
|
||||
|
||||
void FullySpecifiedType::setSigned(bool isSigned)
|
||||
{ f._isSigned = isSigned; }
|
||||
|
||||
bool FullySpecifiedType::isUnsigned() const
|
||||
{ return f._isUnsigned; }
|
||||
|
||||
void FullySpecifiedType::setUnsigned(bool isUnsigned)
|
||||
{ f._isUnsigned = isUnsigned; }
|
||||
|
||||
bool FullySpecifiedType::isFriend() const
|
||||
{ return f._isFriend; }
|
||||
|
||||
void FullySpecifiedType::setFriend(bool isFriend)
|
||||
{ f._isFriend = isFriend; }
|
||||
|
||||
bool FullySpecifiedType::isAuto() const
|
||||
{ return f._isAuto; }
|
||||
|
||||
void FullySpecifiedType::setAuto(bool isAuto)
|
||||
{ f._isAuto = isAuto; }
|
||||
|
||||
bool FullySpecifiedType::isRegister() const
|
||||
{ return f._isRegister; }
|
||||
|
||||
void FullySpecifiedType::setRegister(bool isRegister)
|
||||
{ f._isRegister = isRegister; }
|
||||
|
||||
bool FullySpecifiedType::isStatic() const
|
||||
{ return f._isStatic; }
|
||||
|
||||
void FullySpecifiedType::setStatic(bool isStatic)
|
||||
{ f._isStatic = isStatic; }
|
||||
|
||||
bool FullySpecifiedType::isExtern() const
|
||||
{ return f._isExtern; }
|
||||
|
||||
void FullySpecifiedType::setExtern(bool isExtern)
|
||||
{ f._isExtern = isExtern; }
|
||||
|
||||
bool FullySpecifiedType::isMutable() const
|
||||
{ return f._isMutable; }
|
||||
|
||||
void FullySpecifiedType::setMutable(bool isMutable)
|
||||
{ f._isMutable = isMutable; }
|
||||
|
||||
bool FullySpecifiedType::isTypedef() const
|
||||
{ return f._isTypedef; }
|
||||
|
||||
void FullySpecifiedType::setTypedef(bool isTypedef)
|
||||
{ f._isTypedef = isTypedef; }
|
||||
|
||||
bool FullySpecifiedType::isInline() const
|
||||
{ return f._isInline; }
|
||||
|
||||
void FullySpecifiedType::setInline(bool isInline)
|
||||
{ f._isInline = isInline; }
|
||||
|
||||
bool FullySpecifiedType::isVirtual() const
|
||||
{ return f._isVirtual; }
|
||||
|
||||
void FullySpecifiedType::setVirtual(bool isVirtual)
|
||||
{ f._isVirtual = isVirtual; }
|
||||
|
||||
bool FullySpecifiedType::isExplicit() const
|
||||
{ return f._isExplicit; }
|
||||
|
||||
void FullySpecifiedType::setExplicit(bool isExplicit)
|
||||
{ f._isExplicit = isExplicit; }
|
||||
|
||||
bool FullySpecifiedType::isDeprecated() const
|
||||
{ return f._isDeprecated; }
|
||||
|
||||
void FullySpecifiedType::setDeprecated(bool isDeprecated)
|
||||
{ f._isDeprecated = isDeprecated; }
|
||||
|
||||
bool FullySpecifiedType::isUnavailable() const
|
||||
{ return f._isUnavailable; }
|
||||
|
||||
void FullySpecifiedType::setUnavailable(bool isUnavailable)
|
||||
{ f._isUnavailable = isUnavailable; }
|
||||
|
||||
bool FullySpecifiedType::isEqualTo(const FullySpecifiedType &other) const
|
||||
{
|
||||
if (_flags != other._flags)
|
||||
return false;
|
||||
if (_type == other._type)
|
||||
return true;
|
||||
else if (! _type)
|
||||
return false;
|
||||
else
|
||||
return _type->isEqualTo(other._type);
|
||||
}
|
||||
|
||||
Type &FullySpecifiedType::operator*()
|
||||
{ return *_type; }
|
||||
|
||||
FullySpecifiedType::operator bool() const
|
||||
{ return _type != UndefinedType::instance(); }
|
||||
|
||||
const Type &FullySpecifiedType::operator*() const
|
||||
{ return *_type; }
|
||||
|
||||
Type *FullySpecifiedType::operator->()
|
||||
{ return _type; }
|
||||
|
||||
const Type *FullySpecifiedType::operator->() const
|
||||
{ return _type; }
|
||||
|
||||
bool FullySpecifiedType::operator == (const FullySpecifiedType &other) const
|
||||
{ return _type == other._type && _flags == other._flags; }
|
||||
|
||||
bool FullySpecifiedType::operator != (const FullySpecifiedType &other) const
|
||||
{ return ! operator ==(other); }
|
||||
|
||||
bool FullySpecifiedType::operator < (const FullySpecifiedType &other) const
|
||||
{
|
||||
if (_type == other._type)
|
||||
return _flags < other._flags;
|
||||
return _type < other._type;
|
||||
}
|
||||
|
||||
FullySpecifiedType FullySpecifiedType::simplified() const
|
||||
{
|
||||
if (const ReferenceType *refTy = type()->asReferenceType())
|
||||
return refTy->elementType().simplified();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned FullySpecifiedType::flags() const
|
||||
{ return _flags; }
|
||||
|
||||
void FullySpecifiedType::setFlags(unsigned flags)
|
||||
{ _flags = flags; }
|
||||
|
||||
void FullySpecifiedType::copySpecifiers(const FullySpecifiedType &type)
|
||||
{
|
||||
// class storage specifiers
|
||||
f._isFriend = type.f._isFriend;
|
||||
f._isAuto = type.f._isAuto;
|
||||
f._isRegister = type.f._isRegister;
|
||||
f._isStatic = type.f._isStatic;
|
||||
f._isExtern = type.f._isExtern;
|
||||
f._isMutable = type.f._isMutable;
|
||||
f._isTypedef = type.f._isTypedef;
|
||||
|
||||
// function specifiers
|
||||
f._isInline = type.f._isInline;
|
||||
f._isVirtual = type.f._isVirtual;
|
||||
f._isExplicit = type.f._isExplicit;
|
||||
}
|
||||
|
||||
bool FullySpecifiedType::match(const FullySpecifiedType &otherTy, TypeMatcher *matcher) const
|
||||
{
|
||||
if (_flags != otherTy._flags)
|
||||
return false;
|
||||
|
||||
return type()->matchType(otherTy.type(), matcher);
|
||||
}
|
181
src/libs/3rdparty/cplusplus/FullySpecifiedType.h
vendored
Normal file
181
src/libs/3rdparty/cplusplus/FullySpecifiedType.h
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_FULLYSPECIFIEDTYPE_H
|
||||
#define CPLUSPLUS_FULLYSPECIFIEDTYPE_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT FullySpecifiedType
|
||||
{
|
||||
public:
|
||||
FullySpecifiedType(Type *type = 0);
|
||||
~FullySpecifiedType();
|
||||
|
||||
bool isValid() const;
|
||||
operator bool() const;
|
||||
|
||||
Type *type() const;
|
||||
void setType(Type *type);
|
||||
|
||||
FullySpecifiedType qualifiedType() const;
|
||||
|
||||
bool isConst() const;
|
||||
void setConst(bool isConst);
|
||||
|
||||
bool isVolatile() const;
|
||||
void setVolatile(bool isVolatile);
|
||||
|
||||
bool isSigned() const;
|
||||
void setSigned(bool isSigned);
|
||||
|
||||
bool isUnsigned() const;
|
||||
void setUnsigned(bool isUnsigned);
|
||||
|
||||
bool isFriend() const;
|
||||
void setFriend(bool isFriend);
|
||||
|
||||
bool isAuto() const;
|
||||
void setAuto(bool isAuto);
|
||||
|
||||
bool isRegister() const;
|
||||
void setRegister(bool isRegister);
|
||||
|
||||
bool isStatic() const;
|
||||
void setStatic(bool isStatic);
|
||||
|
||||
bool isExtern() const;
|
||||
void setExtern(bool isExtern);
|
||||
|
||||
bool isMutable() const;
|
||||
void setMutable(bool isMutable);
|
||||
|
||||
bool isTypedef() const;
|
||||
void setTypedef(bool isTypedef);
|
||||
|
||||
bool isInline() const;
|
||||
void setInline(bool isInline);
|
||||
|
||||
bool isVirtual() const;
|
||||
void setVirtual(bool isVirtual);
|
||||
|
||||
bool isExplicit() const;
|
||||
void setExplicit(bool isExplicit);
|
||||
|
||||
bool isDeprecated() const;
|
||||
void setDeprecated(bool isDeprecated);
|
||||
|
||||
bool isUnavailable() const;
|
||||
void setUnavailable(bool isUnavailable);
|
||||
|
||||
bool isEqualTo(const FullySpecifiedType &other) const;
|
||||
|
||||
Type &operator*();
|
||||
const Type &operator*() const;
|
||||
|
||||
Type *operator->();
|
||||
const Type *operator->() const;
|
||||
|
||||
bool operator == (const FullySpecifiedType &other) const;
|
||||
bool operator != (const FullySpecifiedType &other) const;
|
||||
bool operator < (const FullySpecifiedType &other) const;
|
||||
|
||||
bool match(const FullySpecifiedType &otherTy, TypeMatcher *matcher) const;
|
||||
|
||||
FullySpecifiedType simplified() const;
|
||||
|
||||
void copySpecifiers(const FullySpecifiedType &type);
|
||||
|
||||
unsigned flags() const;
|
||||
void setFlags(unsigned flags);
|
||||
|
||||
private:
|
||||
Type *_type;
|
||||
struct Flags {
|
||||
// cv qualifiers
|
||||
unsigned _isConst: 1;
|
||||
unsigned _isVolatile: 1;
|
||||
|
||||
// sign
|
||||
unsigned _isSigned: 1;
|
||||
unsigned _isUnsigned: 1;
|
||||
|
||||
// storage class specifiers
|
||||
unsigned _isFriend: 1;
|
||||
unsigned _isAuto: 1;
|
||||
unsigned _isRegister: 1;
|
||||
unsigned _isStatic: 1;
|
||||
unsigned _isExtern: 1;
|
||||
unsigned _isMutable: 1;
|
||||
unsigned _isTypedef: 1;
|
||||
|
||||
// function specifiers
|
||||
unsigned _isInline: 1;
|
||||
unsigned _isVirtual: 1;
|
||||
unsigned _isExplicit: 1;
|
||||
|
||||
// speficiers from attributes
|
||||
unsigned _isDeprecated: 1;
|
||||
unsigned _isUnavailable: 1;
|
||||
};
|
||||
union {
|
||||
unsigned _flags;
|
||||
Flags f;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_FULLYSPECIFIEDTYPE_H
|
1688
src/libs/3rdparty/cplusplus/Keywords.cpp
vendored
Normal file
1688
src/libs/3rdparty/cplusplus/Keywords.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
86
src/libs/3rdparty/cplusplus/Keywords.kwgen
vendored
Normal file
86
src/libs/3rdparty/cplusplus/Keywords.kwgen
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
|
||||
#include "Lexer.h"
|
||||
#include "Token.h"
|
||||
|
||||
%token-prefix=T_
|
||||
%toupper
|
||||
%no-enums
|
||||
%namespace=Lexer
|
||||
|
||||
%%
|
||||
__asm
|
||||
__asm__
|
||||
__attribute
|
||||
__attribute__
|
||||
__const
|
||||
__const__
|
||||
__inline
|
||||
__inline__
|
||||
__typeof
|
||||
__typeof__
|
||||
__volatile
|
||||
__volatile__
|
||||
asm
|
||||
auto
|
||||
bool
|
||||
break
|
||||
case
|
||||
catch
|
||||
char
|
||||
class
|
||||
const
|
||||
const_cast
|
||||
continue
|
||||
default
|
||||
delete
|
||||
do
|
||||
double
|
||||
dynamic_cast
|
||||
else
|
||||
enum
|
||||
explicit
|
||||
export
|
||||
extern
|
||||
false
|
||||
float
|
||||
for
|
||||
friend
|
||||
goto
|
||||
if
|
||||
inline
|
||||
int
|
||||
long
|
||||
mutable
|
||||
namespace
|
||||
new
|
||||
operator
|
||||
private
|
||||
protected
|
||||
public
|
||||
register
|
||||
reinterpret_cast
|
||||
return
|
||||
short
|
||||
signed
|
||||
sizeof
|
||||
static
|
||||
static_cast
|
||||
struct
|
||||
switch
|
||||
template
|
||||
this
|
||||
throw
|
||||
true
|
||||
try
|
||||
typedef
|
||||
typeid
|
||||
typename
|
||||
typeof
|
||||
union
|
||||
unsigned
|
||||
using
|
||||
virtual
|
||||
void
|
||||
volatile
|
||||
wchar_t
|
||||
while
|
732
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
Normal file
732
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
Normal file
@@ -0,0 +1,732 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Lexer.h"
|
||||
#include "Control.h"
|
||||
#include "TranslationUnit.h"
|
||||
#include "Literals.h"
|
||||
#include <cctype>
|
||||
#include <cassert>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
Lexer::Lexer(TranslationUnit *unit)
|
||||
: _translationUnit(unit),
|
||||
_state(State_Default),
|
||||
_flags(0),
|
||||
_currentLine(1)
|
||||
{
|
||||
f._scanKeywords = true;
|
||||
setSource(_translationUnit->firstSourceChar(),
|
||||
_translationUnit->lastSourceChar());
|
||||
}
|
||||
|
||||
Lexer::Lexer(const char *firstChar, const char *lastChar)
|
||||
: _translationUnit(0),
|
||||
_state(State_Default),
|
||||
_flags(0),
|
||||
_currentLine(1)
|
||||
{
|
||||
f._scanKeywords = true;
|
||||
setSource(firstChar, lastChar);
|
||||
}
|
||||
|
||||
Lexer::~Lexer()
|
||||
{ }
|
||||
|
||||
TranslationUnit *Lexer::translationUnit() const
|
||||
{ return _translationUnit; }
|
||||
|
||||
Control *Lexer::control() const
|
||||
{
|
||||
if (_translationUnit)
|
||||
return _translationUnit->control();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Lexer::setSource(const char *firstChar, const char *lastChar)
|
||||
{
|
||||
_firstChar = firstChar;
|
||||
_lastChar = lastChar;
|
||||
_currentChar = _firstChar - 1;
|
||||
_tokenStart = _currentChar;
|
||||
_yychar = '\n';
|
||||
}
|
||||
|
||||
void Lexer::setStartWithNewline(bool enabled)
|
||||
{
|
||||
if (enabled)
|
||||
_yychar = '\n';
|
||||
else
|
||||
_yychar = ' ';
|
||||
}
|
||||
|
||||
int Lexer::state() const
|
||||
{ return _state; }
|
||||
|
||||
void Lexer::setState(int state)
|
||||
{ _state = state; }
|
||||
|
||||
bool Lexer::qtMocRunEnabled() const
|
||||
{ return f._qtMocRunEnabled; }
|
||||
|
||||
void Lexer::setQtMocRunEnabled(bool onoff)
|
||||
{ f._qtMocRunEnabled = onoff; }
|
||||
|
||||
bool Lexer::cxx0xEnabled() const
|
||||
{ return f._cxx0xEnabled; }
|
||||
|
||||
void Lexer::setCxxOxEnabled(bool onoff)
|
||||
{ f._cxx0xEnabled = onoff; }
|
||||
|
||||
bool Lexer::objCEnabled() const
|
||||
{ return f._objCEnabled; }
|
||||
|
||||
void Lexer::setObjCEnabled(bool onoff)
|
||||
{ f._objCEnabled = onoff; }
|
||||
|
||||
bool Lexer::isIncremental() const
|
||||
{ return f._isIncremental; }
|
||||
|
||||
void Lexer::setIncremental(bool isIncremental)
|
||||
{ f._isIncremental = isIncremental; }
|
||||
|
||||
bool Lexer::scanCommentTokens() const
|
||||
{ return f._scanCommentTokens; }
|
||||
|
||||
void Lexer::setScanCommentTokens(bool onoff)
|
||||
{ f._scanCommentTokens = onoff; }
|
||||
|
||||
bool Lexer::scanKeywords() const
|
||||
{ return f._scanKeywords; }
|
||||
|
||||
void Lexer::setScanKeywords(bool onoff)
|
||||
{ f._scanKeywords = onoff; }
|
||||
|
||||
void Lexer::setScanAngleStringLiteralTokens(bool onoff)
|
||||
{ f._scanAngleStringLiteralTokens = onoff; }
|
||||
|
||||
void Lexer::pushLineStartOffset()
|
||||
{
|
||||
++_currentLine;
|
||||
|
||||
if (_translationUnit)
|
||||
_translationUnit->pushLineOffset(_currentChar - _firstChar);
|
||||
}
|
||||
|
||||
unsigned Lexer::tokenOffset() const
|
||||
{ return _tokenStart - _firstChar; }
|
||||
|
||||
unsigned Lexer::tokenLength() const
|
||||
{ return _currentChar - _tokenStart; }
|
||||
|
||||
const char *Lexer::tokenBegin() const
|
||||
{ return _tokenStart; }
|
||||
|
||||
const char *Lexer::tokenEnd() const
|
||||
{ return _currentChar; }
|
||||
|
||||
unsigned Lexer::currentLine() const
|
||||
{ return _currentLine; }
|
||||
|
||||
void Lexer::scan(Token *tok)
|
||||
{
|
||||
tok->reset();
|
||||
scan_helper(tok);
|
||||
tok->f.length = _currentChar - _tokenStart;
|
||||
}
|
||||
|
||||
void Lexer::scan_helper(Token *tok)
|
||||
{
|
||||
_Lagain:
|
||||
while (_yychar && std::isspace(_yychar)) {
|
||||
if (_yychar == '\n') {
|
||||
tok->f.joined = false;
|
||||
tok->f.newline = true;
|
||||
} else {
|
||||
tok->f.whitespace = true;
|
||||
}
|
||||
yyinp();
|
||||
}
|
||||
|
||||
if (! _translationUnit)
|
||||
tok->lineno = _currentLine;
|
||||
|
||||
_tokenStart = _currentChar;
|
||||
tok->offset = _currentChar - _firstChar;
|
||||
|
||||
if (_state == State_MultiLineComment || _state == State_MultiLineDoxyComment) {
|
||||
const int originalState = _state;
|
||||
|
||||
if (! _yychar) {
|
||||
tok->f.kind = T_EOF_SYMBOL;
|
||||
return;
|
||||
}
|
||||
|
||||
while (_yychar) {
|
||||
if (_yychar != '*')
|
||||
yyinp();
|
||||
else {
|
||||
yyinp();
|
||||
if (_yychar == '/') {
|
||||
yyinp();
|
||||
_state = State_Default;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! f._scanCommentTokens)
|
||||
goto _Lagain;
|
||||
|
||||
else if (originalState == State_MultiLineComment)
|
||||
tok->f.kind = T_COMMENT;
|
||||
else
|
||||
tok->f.kind = T_DOXY_COMMENT;
|
||||
return; // done
|
||||
}
|
||||
|
||||
if (! _yychar) {
|
||||
tok->f.kind = T_EOF_SYMBOL;
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char ch = _yychar;
|
||||
yyinp();
|
||||
|
||||
switch (ch) {
|
||||
case '\\':
|
||||
while (_yychar != '\n' && std::isspace(_yychar))
|
||||
yyinp();
|
||||
// ### assert(! _yychar || _yychar == '\n');
|
||||
if (_yychar == '\n') {
|
||||
tok->f.joined = true;
|
||||
tok->f.newline = false;
|
||||
yyinp();
|
||||
}
|
||||
goto _Lagain;
|
||||
|
||||
case '"': case '\'': {
|
||||
const char quote = ch;
|
||||
|
||||
tok->f.kind = quote == '"'
|
||||
? T_STRING_LITERAL
|
||||
: T_CHAR_LITERAL;
|
||||
|
||||
const char *yytext = _currentChar;
|
||||
|
||||
while (_yychar && _yychar != quote) {
|
||||
if (_yychar == '\n')
|
||||
break;
|
||||
else if (_yychar != '\\')
|
||||
yyinp();
|
||||
else {
|
||||
yyinp(); // skip `\\'
|
||||
|
||||
if (_yychar)
|
||||
yyinp();
|
||||
}
|
||||
}
|
||||
// assert(_yychar == quote);
|
||||
|
||||
int yylen = _currentChar - yytext;
|
||||
|
||||
if (_yychar == quote)
|
||||
yyinp();
|
||||
|
||||
if (control())
|
||||
tok->string = control()->stringLiteral(yytext, yylen);
|
||||
} break;
|
||||
|
||||
case '{':
|
||||
tok->f.kind = T_LBRACE;
|
||||
break;
|
||||
|
||||
case '}':
|
||||
tok->f.kind = T_RBRACE;
|
||||
break;
|
||||
|
||||
case '[':
|
||||
tok->f.kind = T_LBRACKET;
|
||||
break;
|
||||
|
||||
case ']':
|
||||
tok->f.kind = T_RBRACKET;
|
||||
break;
|
||||
|
||||
case '#':
|
||||
if (_yychar == '#') {
|
||||
tok->f.kind = T_POUND_POUND;
|
||||
yyinp();
|
||||
} else {
|
||||
tok->f.kind = T_POUND;
|
||||
}
|
||||
break;
|
||||
|
||||
case '(':
|
||||
tok->f.kind = T_LPAREN;
|
||||
break;
|
||||
|
||||
case ')':
|
||||
tok->f.kind = T_RPAREN;
|
||||
break;
|
||||
|
||||
case ';':
|
||||
tok->f.kind = T_SEMICOLON;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
if (_yychar == ':') {
|
||||
yyinp();
|
||||
tok->f.kind = T_COLON_COLON;
|
||||
} else {
|
||||
tok->f.kind = T_COLON;
|
||||
}
|
||||
break;
|
||||
|
||||
case '.':
|
||||
if (_yychar == '*') {
|
||||
yyinp();
|
||||
tok->f.kind = T_DOT_STAR;
|
||||
} else if (_yychar == '.') {
|
||||
yyinp();
|
||||
// ### assert(_yychar);
|
||||
if (_yychar == '.') {
|
||||
yyinp();
|
||||
tok->f.kind = T_DOT_DOT_DOT;
|
||||
} else {
|
||||
tok->f.kind = T_ERROR;
|
||||
}
|
||||
} else if (std::isdigit(_yychar)) {
|
||||
const char *yytext = _currentChar - 2;
|
||||
do {
|
||||
if (_yychar == 'e' || _yychar == 'E') {
|
||||
yyinp();
|
||||
if (_yychar == '-' || _yychar == '+') {
|
||||
yyinp();
|
||||
// ### assert(std::isdigit(_yychar));
|
||||
}
|
||||
} else if (std::isalnum(_yychar) || _yychar == '.') {
|
||||
yyinp();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (_yychar);
|
||||
int yylen = _currentChar - yytext;
|
||||
tok->f.kind = T_NUMERIC_LITERAL;
|
||||
if (control())
|
||||
tok->number = control()->numericLiteral(yytext, yylen);
|
||||
} else {
|
||||
tok->f.kind = T_DOT;
|
||||
}
|
||||
break;
|
||||
|
||||
case '?':
|
||||
tok->f.kind = T_QUESTION;
|
||||
break;
|
||||
|
||||
case '+':
|
||||
if (_yychar == '+') {
|
||||
yyinp();
|
||||
tok->f.kind = T_PLUS_PLUS;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_PLUS_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_PLUS;
|
||||
}
|
||||
break;
|
||||
|
||||
case '-':
|
||||
if (_yychar == '-') {
|
||||
yyinp();
|
||||
tok->f.kind = T_MINUS_MINUS;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_MINUS_EQUAL;
|
||||
} else if (_yychar == '>') {
|
||||
yyinp();
|
||||
if (_yychar == '*') {
|
||||
yyinp();
|
||||
tok->f.kind = T_ARROW_STAR;
|
||||
} else {
|
||||
tok->f.kind = T_ARROW;
|
||||
}
|
||||
} else {
|
||||
tok->f.kind = T_MINUS;
|
||||
}
|
||||
break;
|
||||
|
||||
case '*':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_STAR_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_STAR;
|
||||
}
|
||||
break;
|
||||
|
||||
case '/':
|
||||
if (_yychar == '/') {
|
||||
yyinp();
|
||||
|
||||
bool doxy = false;
|
||||
|
||||
if (_yychar == '/' || _yychar == '!') {
|
||||
yyinp();
|
||||
|
||||
if (_yychar == '<')
|
||||
yyinp();
|
||||
|
||||
if (_yychar != '\n' && std::isspace(_yychar))
|
||||
doxy = true;
|
||||
}
|
||||
|
||||
while (_yychar && _yychar != '\n')
|
||||
yyinp();
|
||||
|
||||
if (! f._scanCommentTokens)
|
||||
goto _Lagain;
|
||||
|
||||
tok->f.kind = doxy ? T_CPP_DOXY_COMMENT : T_CPP_COMMENT;
|
||||
|
||||
} else if (_yychar == '*') {
|
||||
yyinp();
|
||||
|
||||
bool doxy = false;
|
||||
|
||||
if (_yychar == '*' || _yychar == '!') {
|
||||
const char ch = _yychar;
|
||||
|
||||
yyinp();
|
||||
|
||||
if (ch == '*' && _yychar == '/')
|
||||
goto _Ldone;
|
||||
|
||||
if (_yychar == '<')
|
||||
yyinp();
|
||||
|
||||
if (! _yychar || std::isspace(_yychar))
|
||||
doxy = true;
|
||||
}
|
||||
|
||||
while (_yychar) {
|
||||
if (_yychar != '*') {
|
||||
yyinp();
|
||||
} else {
|
||||
yyinp();
|
||||
if (_yychar == '/')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_Ldone:
|
||||
if (_yychar)
|
||||
yyinp();
|
||||
else
|
||||
_state = doxy ? State_MultiLineDoxyComment : State_MultiLineComment;
|
||||
|
||||
if (! f._scanCommentTokens)
|
||||
goto _Lagain;
|
||||
|
||||
tok->f.kind = doxy ? T_DOXY_COMMENT : T_COMMENT;
|
||||
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_SLASH_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_SLASH;
|
||||
}
|
||||
break;
|
||||
|
||||
case '%':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_PERCENT_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_PERCENT;
|
||||
}
|
||||
break;
|
||||
|
||||
case '^':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_CARET_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_CARET;
|
||||
}
|
||||
break;
|
||||
|
||||
case '&':
|
||||
if (_yychar == '&') {
|
||||
yyinp();
|
||||
tok->f.kind = T_AMPER_AMPER;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_AMPER_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_AMPER;
|
||||
}
|
||||
break;
|
||||
|
||||
case '|':
|
||||
if (_yychar == '|') {
|
||||
yyinp();
|
||||
tok->f.kind = T_PIPE_PIPE;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_PIPE_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_PIPE;
|
||||
}
|
||||
break;
|
||||
|
||||
case '~':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_TILDE_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_TILDE;
|
||||
}
|
||||
break;
|
||||
|
||||
case '!':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_EXCLAIM_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_EXCLAIM;
|
||||
}
|
||||
break;
|
||||
|
||||
case '=':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_EQUAL_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_EQUAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case '<':
|
||||
if (f._scanAngleStringLiteralTokens) {
|
||||
const char *yytext = _currentChar;
|
||||
while (_yychar && _yychar != '>')
|
||||
yyinp();
|
||||
int yylen = _currentChar - yytext;
|
||||
// ### assert(_yychar == '>');
|
||||
if (_yychar == '>')
|
||||
yyinp();
|
||||
if (control())
|
||||
tok->string = control()->stringLiteral(yytext, yylen);
|
||||
tok->f.kind = T_ANGLE_STRING_LITERAL;
|
||||
} else if (_yychar == '<') {
|
||||
yyinp();
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_LESS_LESS_EQUAL;
|
||||
} else
|
||||
tok->f.kind = T_LESS_LESS;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_LESS_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_LESS;
|
||||
}
|
||||
break;
|
||||
|
||||
case '>':
|
||||
if (_yychar == '>') {
|
||||
yyinp();
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_GREATER_GREATER_EQUAL;
|
||||
} else
|
||||
tok->f.kind = T_LESS_LESS;
|
||||
tok->f.kind = T_GREATER_GREATER;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->f.kind = T_GREATER_EQUAL;
|
||||
} else {
|
||||
tok->f.kind = T_GREATER;
|
||||
}
|
||||
break;
|
||||
|
||||
case ',':
|
||||
tok->f.kind = T_COMMA;
|
||||
break;
|
||||
|
||||
default: {
|
||||
if (f._objCEnabled) {
|
||||
if (ch == '@' && _yychar >= 'a' && _yychar <= 'z') {
|
||||
const char *yytext = _currentChar;
|
||||
|
||||
do {
|
||||
yyinp();
|
||||
if (! (isalnum(_yychar) || _yychar == '_' || _yychar == '$'))
|
||||
break;
|
||||
} while (_yychar);
|
||||
|
||||
const int yylen = _currentChar - yytext;
|
||||
tok->f.kind = classifyObjCAtKeyword(yytext, yylen);
|
||||
break;
|
||||
} else if (ch == '@' && _yychar == '"') {
|
||||
// objc @string literals
|
||||
ch = _yychar;
|
||||
yyinp();
|
||||
tok->f.kind = T_AT_STRING_LITERAL;
|
||||
|
||||
const char *yytext = _currentChar;
|
||||
|
||||
while (_yychar && _yychar != '"') {
|
||||
if (_yychar != '\\')
|
||||
yyinp();
|
||||
else {
|
||||
yyinp(); // skip `\\'
|
||||
|
||||
if (_yychar)
|
||||
yyinp();
|
||||
}
|
||||
}
|
||||
// assert(_yychar == '"');
|
||||
|
||||
int yylen = _currentChar - yytext;
|
||||
|
||||
if (_yychar == '"')
|
||||
yyinp();
|
||||
|
||||
if (control())
|
||||
tok->string = control()->stringLiteral(yytext, yylen);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ch == 'L' && (_yychar == '"' || _yychar == '\'')) {
|
||||
// wide char/string literals
|
||||
ch = _yychar;
|
||||
yyinp();
|
||||
|
||||
const char quote = ch;
|
||||
|
||||
tok->f.kind = quote == '"'
|
||||
? T_WIDE_STRING_LITERAL
|
||||
: T_WIDE_CHAR_LITERAL;
|
||||
|
||||
const char *yytext = _currentChar;
|
||||
|
||||
while (_yychar && _yychar != quote) {
|
||||
if (_yychar != '\\')
|
||||
yyinp();
|
||||
else {
|
||||
yyinp(); // skip `\\'
|
||||
|
||||
if (_yychar)
|
||||
yyinp();
|
||||
}
|
||||
}
|
||||
// assert(_yychar == quote);
|
||||
|
||||
int yylen = _currentChar - yytext;
|
||||
|
||||
if (_yychar == quote)
|
||||
yyinp();
|
||||
|
||||
if (control())
|
||||
tok->string = control()->stringLiteral(yytext, yylen);
|
||||
} else if (std::isalpha(ch) || ch == '_' || ch == '$') {
|
||||
const char *yytext = _currentChar - 1;
|
||||
while (std::isalnum(_yychar) || _yychar == '_' || _yychar == '$')
|
||||
yyinp();
|
||||
int yylen = _currentChar - yytext;
|
||||
if (f._scanKeywords)
|
||||
tok->f.kind = classify(yytext, yylen, f._qtMocRunEnabled, f._cxx0xEnabled);
|
||||
else
|
||||
tok->f.kind = T_IDENTIFIER;
|
||||
|
||||
if (tok->f.kind == T_IDENTIFIER) {
|
||||
tok->f.kind = classifyOperator(yytext, yylen);
|
||||
|
||||
if (control())
|
||||
tok->identifier = control()->identifier(yytext, yylen);
|
||||
}
|
||||
break;
|
||||
} else if (std::isdigit(ch)) {
|
||||
const char *yytext = _currentChar - 1;
|
||||
while (_yychar) {
|
||||
if (_yychar == 'e' || _yychar == 'E') {
|
||||
yyinp();
|
||||
if (_yychar == '-' || _yychar == '+') {
|
||||
yyinp();
|
||||
// ### assert(std::isdigit(_yychar));
|
||||
}
|
||||
} else if (std::isalnum(_yychar) || _yychar == '.') {
|
||||
yyinp();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int yylen = _currentChar - yytext;
|
||||
tok->f.kind = T_NUMERIC_LITERAL;
|
||||
if (control())
|
||||
tok->number = control()->numericLiteral(yytext, yylen);
|
||||
break;
|
||||
} else {
|
||||
tok->f.kind = T_ERROR;
|
||||
break;
|
||||
}
|
||||
} // default
|
||||
|
||||
} // switch
|
||||
}
|
||||
|
||||
|
165
src/libs/3rdparty/cplusplus/Lexer.h
vendored
Normal file
165
src/libs/3rdparty/cplusplus/Lexer.h
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_LEXER_H
|
||||
#define CPLUSPLUS_LEXER_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "Token.h"
|
||||
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT Lexer
|
||||
{
|
||||
Lexer(const Lexer &other);
|
||||
void operator =(const Lexer &other);
|
||||
|
||||
public:
|
||||
enum State {
|
||||
State_Default,
|
||||
State_MultiLineComment,
|
||||
State_MultiLineDoxyComment
|
||||
};
|
||||
|
||||
Lexer(TranslationUnit *unit);
|
||||
Lexer(const char *firstChar, const char *lastChar);
|
||||
~Lexer();
|
||||
|
||||
Control *control() const;
|
||||
TranslationUnit *translationUnit() const;
|
||||
|
||||
bool qtMocRunEnabled() const;
|
||||
void setQtMocRunEnabled(bool onoff);
|
||||
|
||||
bool cxx0xEnabled() const;
|
||||
void setCxxOxEnabled(bool onoff);
|
||||
|
||||
bool objCEnabled() const;
|
||||
void setObjCEnabled(bool onoff);
|
||||
|
||||
void scan(Token *tok);
|
||||
|
||||
inline void operator()(Token *tok)
|
||||
{ scan(tok); }
|
||||
|
||||
unsigned tokenOffset() const;
|
||||
unsigned tokenLength() const;
|
||||
const char *tokenBegin() const;
|
||||
const char *tokenEnd() const;
|
||||
unsigned currentLine() const;
|
||||
|
||||
bool scanCommentTokens() const;
|
||||
void setScanCommentTokens(bool onoff);
|
||||
|
||||
bool scanKeywords() const;
|
||||
void setScanKeywords(bool onoff);
|
||||
|
||||
bool scanAngleStringLiteralTokens() const;
|
||||
void setScanAngleStringLiteralTokens(bool onoff);
|
||||
|
||||
void setStartWithNewline(bool enabled);
|
||||
|
||||
int state() const;
|
||||
void setState(int state);
|
||||
|
||||
bool isIncremental() const;
|
||||
void setIncremental(bool isIncremental);
|
||||
|
||||
private:
|
||||
void scan_helper(Token *tok);
|
||||
void setSource(const char *firstChar, const char *lastChar);
|
||||
static int classify(const char *string, int length, bool q, bool cxx0x);
|
||||
static int classifyObjCAtKeyword(const char *s, int n);
|
||||
static int classifyOperator(const char *string, int length);
|
||||
|
||||
inline void yyinp()
|
||||
{
|
||||
if (++_currentChar == _lastChar)
|
||||
_yychar = 0;
|
||||
else {
|
||||
_yychar = *_currentChar;
|
||||
if (_yychar == '\n')
|
||||
pushLineStartOffset();
|
||||
}
|
||||
}
|
||||
|
||||
void pushLineStartOffset();
|
||||
|
||||
private:
|
||||
struct Flags {
|
||||
unsigned _isIncremental: 1;
|
||||
unsigned _scanCommentTokens: 1;
|
||||
unsigned _scanKeywords: 1;
|
||||
unsigned _scanAngleStringLiteralTokens: 1;
|
||||
unsigned _qtMocRunEnabled: 1;
|
||||
unsigned _cxx0xEnabled: 1;
|
||||
unsigned _objCEnabled: 1;
|
||||
};
|
||||
|
||||
TranslationUnit *_translationUnit;
|
||||
const char *_firstChar;
|
||||
const char *_currentChar;
|
||||
const char *_lastChar;
|
||||
const char *_tokenStart;
|
||||
unsigned char _yychar;
|
||||
int _state;
|
||||
union {
|
||||
unsigned _flags;
|
||||
Flags f;
|
||||
};
|
||||
unsigned _currentLine;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_LEXER_H
|
33
src/libs/3rdparty/cplusplus/LiteralTable.cpp
vendored
Normal file
33
src/libs/3rdparty/cplusplus/LiteralTable.cpp
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "LiteralTable.h"
|
200
src/libs/3rdparty/cplusplus/LiteralTable.h
vendored
Normal file
200
src/libs/3rdparty/cplusplus/LiteralTable.h
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_LITERALTABLE_H
|
||||
#define CPLUSPLUS_LITERALTABLE_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include <cstring>
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
template <typename _Literal>
|
||||
class LiteralTable
|
||||
{
|
||||
LiteralTable(const LiteralTable &other);
|
||||
void operator =(const LiteralTable &other);
|
||||
|
||||
public:
|
||||
typedef _Literal *const *iterator;
|
||||
|
||||
public:
|
||||
LiteralTable()
|
||||
: _literals(0),
|
||||
_buckets(0),
|
||||
_allocatedLiterals(0),
|
||||
_literalCount(-1),
|
||||
_allocatedBuckets(0)
|
||||
{ }
|
||||
|
||||
~LiteralTable()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
if (_literals) {
|
||||
_Literal **lastLiteral = _literals + _literalCount + 1;
|
||||
for (_Literal **it = _literals; it != lastLiteral; ++it)
|
||||
delete *it;
|
||||
std::free(_literals);
|
||||
}
|
||||
if (_buckets)
|
||||
std::free(_buckets);
|
||||
|
||||
_literals = 0;
|
||||
_buckets = 0;
|
||||
_allocatedLiterals = 0;
|
||||
_literalCount = -1;
|
||||
_allocatedBuckets = 0;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{ return _literalCount == -1; }
|
||||
|
||||
unsigned size() const
|
||||
{ return _literalCount + 1; }
|
||||
|
||||
const _Literal *at(unsigned index) const
|
||||
{ return _literals[index]; }
|
||||
|
||||
iterator begin() const
|
||||
{ return _literals; }
|
||||
|
||||
iterator end() const
|
||||
{ return _literals + _literalCount + 1; }
|
||||
|
||||
const _Literal *findLiteral(const char *chars, unsigned size) const
|
||||
{
|
||||
if (_buckets) {
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const _Literal *findOrInsertLiteral(const char *chars, unsigned size)
|
||||
{
|
||||
if (_buckets) {
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
|
||||
_Literal *literal = new _Literal(chars, size);
|
||||
|
||||
if (++_literalCount == _allocatedLiterals) {
|
||||
if (! _allocatedLiterals)
|
||||
_allocatedLiterals = 4;
|
||||
else
|
||||
_allocatedLiterals <<= 1;
|
||||
|
||||
_literals = (_Literal **) std::realloc(_literals, sizeof(_Literal *) * _allocatedLiterals);
|
||||
}
|
||||
|
||||
_literals[_literalCount] = literal;
|
||||
|
||||
if (! _buckets || _literalCount * 5 >= _allocatedBuckets * 3)
|
||||
rehash();
|
||||
else {
|
||||
unsigned h = literal->hashCode() % _allocatedBuckets;
|
||||
literal->_next = _buckets[h];
|
||||
_buckets[h] = literal;
|
||||
}
|
||||
|
||||
return literal;
|
||||
}
|
||||
|
||||
protected:
|
||||
void rehash()
|
||||
{
|
||||
if (_buckets)
|
||||
std::free(_buckets);
|
||||
|
||||
if (! _allocatedBuckets)
|
||||
_allocatedBuckets = 4;
|
||||
else
|
||||
_allocatedBuckets <<= 1;
|
||||
|
||||
_buckets = (_Literal **) std::calloc(_allocatedBuckets, sizeof(_Literal *));
|
||||
|
||||
_Literal **lastLiteral = _literals + (_literalCount + 1);
|
||||
|
||||
for (_Literal **it = _literals; it != lastLiteral; ++it) {
|
||||
_Literal *literal = *it;
|
||||
unsigned h = literal->hashCode() % _allocatedBuckets;
|
||||
|
||||
literal->_next = _buckets[h];
|
||||
_buckets[h] = literal;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
_Literal **_literals;
|
||||
_Literal **_buckets;
|
||||
int _allocatedLiterals;
|
||||
int _literalCount;
|
||||
int _allocatedBuckets;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_LITERALTABLE_H
|
233
src/libs/3rdparty/cplusplus/Literals.cpp
vendored
Normal file
233
src/libs/3rdparty/cplusplus/Literals.cpp
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Literals.h"
|
||||
#include "NameVisitor.h"
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Literal::Literal(const char *chars, unsigned size)
|
||||
: _next(0), _index(0)
|
||||
{
|
||||
_chars = new char[size + 1];
|
||||
|
||||
std::strncpy(_chars, chars, size);
|
||||
_chars[size] = '\0';
|
||||
_size = size;
|
||||
|
||||
_hashCode = hashCode(_chars, _size);
|
||||
}
|
||||
|
||||
Literal::~Literal()
|
||||
{ delete[] _chars; }
|
||||
|
||||
bool Literal::equalTo(const Literal *other) const
|
||||
{
|
||||
if (! other)
|
||||
return false;
|
||||
else if (this == other)
|
||||
return true;
|
||||
else if (hashCode() != other->hashCode())
|
||||
return false;
|
||||
else if (size() != other->size())
|
||||
return false;
|
||||
return ! std::strcmp(chars(), other->chars());
|
||||
}
|
||||
|
||||
Literal::iterator Literal::begin() const
|
||||
{ return _chars; }
|
||||
|
||||
Literal::iterator Literal::end() const
|
||||
{ return _chars + _size; }
|
||||
|
||||
const char *Literal::chars() const
|
||||
{ return _chars; }
|
||||
|
||||
char Literal::at(unsigned index) const
|
||||
{ return _chars[index]; }
|
||||
|
||||
unsigned Literal::size() const
|
||||
{ return _size; }
|
||||
|
||||
unsigned Literal::hashCode() const
|
||||
{ return _hashCode; }
|
||||
|
||||
unsigned Literal::hashCode(const char *chars, unsigned size)
|
||||
{
|
||||
unsigned h = 0;
|
||||
for (unsigned i = 0; i < size; ++i)
|
||||
h = (h >> 5) - h + chars[i];
|
||||
return h;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
StringLiteral::StringLiteral(const char *chars, unsigned size)
|
||||
: Literal(chars, size)
|
||||
{ }
|
||||
|
||||
StringLiteral::~StringLiteral()
|
||||
{ }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
enum {
|
||||
NumericLiteralIsInt,
|
||||
NumericLiteralIsFloat,
|
||||
NumericLiteralIsDouble,
|
||||
NumericLiteralIsLongDouble,
|
||||
NumericLiteralIsLong,
|
||||
NumericLiteralIsLongLong
|
||||
};
|
||||
|
||||
NumericLiteral::NumericLiteral(const char *chars, unsigned size)
|
||||
: Literal(chars, size), _flags(0)
|
||||
{
|
||||
f._type = NumericLiteralIsInt;
|
||||
|
||||
if (size > 1 && chars[0] == '0' && (chars[1] == 'x' || chars[1] == 'X')) {
|
||||
f._isHex = true;
|
||||
} else {
|
||||
const char *begin = chars;
|
||||
const char *end = begin + size;
|
||||
|
||||
bool done = false;
|
||||
const char *it = end - 1;
|
||||
|
||||
for (; it != begin - 1 && ! done; --it) {
|
||||
switch (*it) {
|
||||
case 'l': case 'L': // long suffix
|
||||
case 'u': case 'U': // unsigned suffix
|
||||
case 'f': case 'F': // floating suffix
|
||||
break;
|
||||
|
||||
default:
|
||||
done = true;
|
||||
break;
|
||||
} // switch
|
||||
}
|
||||
|
||||
for (const char *dot = it; it != begin - 1; --it) {
|
||||
if (*dot == '.')
|
||||
f._type = NumericLiteralIsDouble;
|
||||
}
|
||||
|
||||
for (++it; it != end; ++it) {
|
||||
if (*it == 'l' || *it == 'L') {
|
||||
if (f._type == NumericLiteralIsDouble) {
|
||||
f._type = NumericLiteralIsLongDouble;
|
||||
} else if (it + 1 != end && (it[1] == 'l' || it[1] == 'L')) {
|
||||
++it;
|
||||
f._type = NumericLiteralIsLongLong;
|
||||
} else {
|
||||
f._type = NumericLiteralIsLong;
|
||||
}
|
||||
} else if (*it == 'f' || *it == 'F') {
|
||||
f._type = NumericLiteralIsFloat;
|
||||
} else if (*it == 'u' || *it == 'U') {
|
||||
f._isUnsigned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NumericLiteral::~NumericLiteral()
|
||||
{ }
|
||||
|
||||
bool NumericLiteral::isHex() const
|
||||
{ return f._isHex; }
|
||||
|
||||
bool NumericLiteral::isUnsigned() const
|
||||
{ return f._isUnsigned; }
|
||||
|
||||
bool NumericLiteral::isInt() const
|
||||
{ return f._type == NumericLiteralIsInt; }
|
||||
|
||||
bool NumericLiteral::isFloat() const
|
||||
{ return f._type == NumericLiteralIsFloat; }
|
||||
|
||||
bool NumericLiteral::isDouble() const
|
||||
{ return f._type == NumericLiteralIsDouble; }
|
||||
|
||||
bool NumericLiteral::isLongDouble() const
|
||||
{ return f._type == NumericLiteralIsLongDouble; }
|
||||
|
||||
bool NumericLiteral::isLong() const
|
||||
{ return f._type == NumericLiteralIsLong; }
|
||||
|
||||
bool NumericLiteral::isLongLong() const
|
||||
{ return f._type == NumericLiteralIsLongLong; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Identifier::Identifier(const char *chars, unsigned size)
|
||||
: Literal(chars, size)
|
||||
{ }
|
||||
|
||||
Identifier::~Identifier()
|
||||
{ }
|
||||
|
||||
void Identifier::accept0(NameVisitor *visitor) const
|
||||
{ visitor->visit(this); }
|
||||
|
||||
bool Identifier::isEqualTo(const Name *other) const
|
||||
{
|
||||
if (this == other)
|
||||
return true;
|
||||
|
||||
else if (other) {
|
||||
if (const Identifier *nameId = other->asNameId()) {
|
||||
return equalTo(nameId);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
152
src/libs/3rdparty/cplusplus/Literals.h
vendored
Normal file
152
src/libs/3rdparty/cplusplus/Literals.h
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_LITERALS_H
|
||||
#define CPLUSPLUS_LITERALS_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "Token.h"
|
||||
#include "Name.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT Literal
|
||||
{
|
||||
Literal(const Literal &other);
|
||||
void operator =(const Literal &other);
|
||||
|
||||
public:
|
||||
typedef const char *iterator;
|
||||
typedef iterator const_iterator;
|
||||
|
||||
public:
|
||||
Literal(const char *chars, unsigned size);
|
||||
virtual ~Literal();
|
||||
|
||||
iterator begin() const;
|
||||
iterator end() const;
|
||||
|
||||
char at(unsigned index) const;
|
||||
const char *chars() const;
|
||||
unsigned size() const;
|
||||
|
||||
unsigned hashCode() const;
|
||||
static unsigned hashCode(const char *chars, unsigned size);
|
||||
|
||||
bool equalTo(const Literal *other) const;
|
||||
|
||||
Literal *_next; // ## private
|
||||
|
||||
private:
|
||||
char *_chars;
|
||||
unsigned _size;
|
||||
unsigned _hashCode;
|
||||
|
||||
public:
|
||||
unsigned _index; // ### private
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT StringLiteral: public Literal
|
||||
{
|
||||
public:
|
||||
StringLiteral(const char *chars, unsigned size);
|
||||
virtual ~StringLiteral();
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT NumericLiteral: public Literal
|
||||
{
|
||||
public:
|
||||
NumericLiteral(const char *chars, unsigned size);
|
||||
virtual ~NumericLiteral();
|
||||
|
||||
bool isInt() const;
|
||||
bool isFloat() const;
|
||||
bool isDouble() const;
|
||||
bool isLongDouble() const;
|
||||
bool isLong() const;
|
||||
bool isLongLong() const;
|
||||
|
||||
bool isUnsigned() const;
|
||||
bool isHex() const;
|
||||
|
||||
private:
|
||||
struct Flags {
|
||||
unsigned _type : 8;
|
||||
unsigned _isHex : 1;
|
||||
unsigned _isUnsigned: 1;
|
||||
};
|
||||
union {
|
||||
unsigned _flags;
|
||||
Flags f;
|
||||
};
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Identifier: public Literal, public Name
|
||||
{
|
||||
public:
|
||||
Identifier(const char *chars, unsigned size);
|
||||
virtual ~Identifier();
|
||||
|
||||
virtual const Identifier *identifier() const { return this; }
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const Identifier *asNameId() const
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(NameVisitor *visitor) const;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_LITERALS_H
|
142
src/libs/3rdparty/cplusplus/MemoryPool.cpp
vendored
Normal file
142
src/libs/3rdparty/cplusplus/MemoryPool.cpp
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "MemoryPool.h"
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
MemoryPool::MemoryPool()
|
||||
: _blocks(0),
|
||||
_allocatedBlocks(0),
|
||||
_blockCount(-1),
|
||||
_ptr(0),
|
||||
_end(0)
|
||||
{ }
|
||||
|
||||
MemoryPool::~MemoryPool()
|
||||
{
|
||||
if (_blocks) {
|
||||
for (int i = 0; i < _allocatedBlocks; ++i) {
|
||||
if (char *b = _blocks[i])
|
||||
std::free(b);
|
||||
}
|
||||
|
||||
std::free(_blocks);
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryPool::reset()
|
||||
{
|
||||
_blockCount = -1;
|
||||
_ptr = _end = 0;
|
||||
}
|
||||
|
||||
void *MemoryPool::allocate_helper(size_t size)
|
||||
{
|
||||
assert(size < BLOCK_SIZE);
|
||||
|
||||
if (++_blockCount == _allocatedBlocks) {
|
||||
if (! _allocatedBlocks)
|
||||
_allocatedBlocks = DEFAULT_BLOCK_COUNT;
|
||||
else
|
||||
_allocatedBlocks *= 2;
|
||||
|
||||
_blocks = (char **) realloc(_blocks, sizeof(char *) * _allocatedBlocks);
|
||||
|
||||
for (int index = _blockCount; index < _allocatedBlocks; ++index)
|
||||
_blocks[index] = 0;
|
||||
}
|
||||
|
||||
char *&block = _blocks[_blockCount];
|
||||
|
||||
if (! block)
|
||||
block = (char *) std::malloc(BLOCK_SIZE);
|
||||
|
||||
_ptr = block;
|
||||
_end = _ptr + BLOCK_SIZE;
|
||||
|
||||
void *addr = _ptr;
|
||||
_ptr += size;
|
||||
return addr;
|
||||
}
|
||||
|
||||
RecursiveMemoryPool::RecursiveMemoryPool(MemoryPool *pool)
|
||||
: _pool(pool),
|
||||
_blockCount(pool->_blockCount),
|
||||
_ptr(pool->_ptr),
|
||||
_end(pool->_end)
|
||||
{
|
||||
}
|
||||
|
||||
RecursiveMemoryPool::~RecursiveMemoryPool()
|
||||
{
|
||||
_pool->_blockCount = _blockCount;
|
||||
_pool->_ptr = _ptr;
|
||||
_pool->_end = _end;
|
||||
}
|
||||
|
||||
Managed::Managed()
|
||||
{ }
|
||||
|
||||
Managed::~Managed()
|
||||
{ }
|
||||
|
||||
void *Managed::operator new(size_t size, MemoryPool *pool)
|
||||
{ return pool->allocate(size); }
|
||||
|
||||
void Managed::operator delete(void *)
|
||||
{ }
|
||||
|
||||
void Managed::operator delete(void *, MemoryPool *)
|
||||
{ }
|
||||
|
133
src/libs/3rdparty/cplusplus/MemoryPool.h
vendored
Normal file
133
src/libs/3rdparty/cplusplus/MemoryPool.h
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_MEMORYPOOL_H
|
||||
#define CPLUSPLUS_MEMORYPOOL_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include <new>
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class MemoryPool;
|
||||
class RecursiveMemoryPool;
|
||||
|
||||
class CPLUSPLUS_EXPORT MemoryPool
|
||||
{
|
||||
MemoryPool(const MemoryPool &other);
|
||||
void operator =(const MemoryPool &other);
|
||||
|
||||
public:
|
||||
MemoryPool();
|
||||
~MemoryPool();
|
||||
|
||||
void reset();
|
||||
|
||||
inline void *allocate(size_t size)
|
||||
{
|
||||
size = (size + 7) & ~7;
|
||||
if (_ptr && (_ptr + size < _end)) {
|
||||
void *addr = _ptr;
|
||||
_ptr += size;
|
||||
return addr;
|
||||
}
|
||||
return allocate_helper(size);
|
||||
}
|
||||
|
||||
private:
|
||||
void *allocate_helper(size_t size);
|
||||
|
||||
private:
|
||||
char **_blocks;
|
||||
int _allocatedBlocks;
|
||||
int _blockCount;
|
||||
char *_ptr;
|
||||
char *_end;
|
||||
|
||||
enum
|
||||
{
|
||||
BLOCK_SIZE = 8 * 1024,
|
||||
DEFAULT_BLOCK_COUNT = 8
|
||||
};
|
||||
|
||||
friend class RecursiveMemoryPool;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT RecursiveMemoryPool
|
||||
{
|
||||
MemoryPool *_pool;
|
||||
int _blockCount;
|
||||
char *_ptr;
|
||||
char *_end;
|
||||
|
||||
public:
|
||||
RecursiveMemoryPool(MemoryPool *pool);
|
||||
~RecursiveMemoryPool();
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Managed
|
||||
{
|
||||
Managed(const Managed &other);
|
||||
void operator = (const Managed &other);
|
||||
|
||||
public:
|
||||
Managed();
|
||||
virtual ~Managed();
|
||||
|
||||
void *operator new(size_t size, MemoryPool *pool);
|
||||
void operator delete(void *);
|
||||
void operator delete(void *, MemoryPool *);
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_MEMORYPOOL_H
|
99
src/libs/3rdparty/cplusplus/Name.cpp
vendored
Normal file
99
src/libs/3rdparty/cplusplus/Name.cpp
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Name.h"
|
||||
#include "Names.h"
|
||||
#include "NameVisitor.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
Name::Name()
|
||||
{ }
|
||||
|
||||
Name::~Name()
|
||||
{ }
|
||||
|
||||
bool Name::isNameId() const
|
||||
{ return asNameId() != 0; }
|
||||
|
||||
bool Name::isTemplateNameId() const
|
||||
{ return asTemplateNameId() != 0; }
|
||||
|
||||
bool Name::isDestructorNameId() const
|
||||
{ return asDestructorNameId() != 0; }
|
||||
|
||||
bool Name::isOperatorNameId() const
|
||||
{ return asOperatorNameId() != 0; }
|
||||
|
||||
bool Name::isConversionNameId() const
|
||||
{ return asConversionNameId() != 0; }
|
||||
|
||||
bool Name::isQualifiedNameId() const
|
||||
{ return asQualifiedNameId() != 0; }
|
||||
|
||||
bool Name::isSelectorNameId() const
|
||||
{ return asSelectorNameId() != 0; }
|
||||
|
||||
void Name::accept(NameVisitor *visitor) const
|
||||
{
|
||||
if (visitor->preVisit(this))
|
||||
accept0(visitor);
|
||||
visitor->postVisit(this);
|
||||
}
|
||||
|
||||
void Name::accept(const Name *name, NameVisitor *visitor)
|
||||
{
|
||||
if (! name)
|
||||
return;
|
||||
name->accept(visitor);
|
||||
}
|
||||
|
||||
|
96
src/libs/3rdparty/cplusplus/Name.h
vendored
Normal file
96
src/libs/3rdparty/cplusplus/Name.h
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_NAME_H
|
||||
#define CPLUSPLUS_NAME_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT Name
|
||||
{
|
||||
public:
|
||||
Name();
|
||||
virtual ~Name();
|
||||
|
||||
virtual const Identifier *identifier() const = 0;
|
||||
|
||||
bool isNameId() const;
|
||||
bool isTemplateNameId() const;
|
||||
bool isDestructorNameId() const;
|
||||
bool isOperatorNameId() const;
|
||||
bool isConversionNameId() const;
|
||||
bool isQualifiedNameId() const;
|
||||
bool isSelectorNameId() const;
|
||||
|
||||
virtual const Identifier *asNameId() const { return 0; }
|
||||
virtual const TemplateNameId *asTemplateNameId() const { return 0; }
|
||||
virtual const DestructorNameId *asDestructorNameId() const { return 0; }
|
||||
virtual const OperatorNameId *asOperatorNameId() const { return 0; }
|
||||
virtual const ConversionNameId *asConversionNameId() const { return 0; }
|
||||
virtual const QualifiedNameId *asQualifiedNameId() const { return 0; }
|
||||
virtual const SelectorNameId *asSelectorNameId() const { return 0; }
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const = 0;
|
||||
|
||||
void accept(NameVisitor *visitor) const;
|
||||
static void accept(const Name *name, NameVisitor *visitor);
|
||||
|
||||
protected:
|
||||
virtual void accept0(NameVisitor *visitor) const = 0;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_NAME_H
|
64
src/libs/3rdparty/cplusplus/NameVisitor.cpp
vendored
Normal file
64
src/libs/3rdparty/cplusplus/NameVisitor.cpp
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "NameVisitor.h"
|
||||
#include "Names.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
NameVisitor::NameVisitor()
|
||||
{ }
|
||||
|
||||
NameVisitor::~NameVisitor()
|
||||
{ }
|
||||
|
||||
void NameVisitor::accept(const Name *name)
|
||||
{ Name::accept(name, this); }
|
86
src/libs/3rdparty/cplusplus/NameVisitor.h
vendored
Normal file
86
src/libs/3rdparty/cplusplus/NameVisitor.h
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_NAMEVISITOR_H
|
||||
#define CPLUSPLUS_NAMEVISITOR_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT NameVisitor
|
||||
{
|
||||
NameVisitor(const NameVisitor &other);
|
||||
void operator =(const NameVisitor &other);
|
||||
|
||||
public:
|
||||
NameVisitor();
|
||||
virtual ~NameVisitor();
|
||||
|
||||
void accept(const Name *name);
|
||||
|
||||
virtual bool preVisit(const Name *) { return true; }
|
||||
virtual void postVisit(const Name *) {}
|
||||
|
||||
virtual void visit(const Identifier *) {}
|
||||
virtual void visit(const TemplateNameId *) {}
|
||||
virtual void visit(const DestructorNameId *) {}
|
||||
virtual void visit(const OperatorNameId *) {}
|
||||
virtual void visit(const ConversionNameId *) {}
|
||||
virtual void visit(const QualifiedNameId *) {}
|
||||
virtual void visit(const SelectorNameId *) {}
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_NAMEVISITOR_H
|
258
src/libs/3rdparty/cplusplus/Names.cpp
vendored
Normal file
258
src/libs/3rdparty/cplusplus/Names.cpp
vendored
Normal file
@@ -0,0 +1,258 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Names.h"
|
||||
#include "NameVisitor.h"
|
||||
#include "Literals.h"
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
QualifiedNameId::~QualifiedNameId()
|
||||
{ }
|
||||
|
||||
void QualifiedNameId::accept0(NameVisitor *visitor) const
|
||||
{ visitor->visit(this); }
|
||||
|
||||
const Identifier *QualifiedNameId::identifier() const
|
||||
{
|
||||
if (const Name *u = name())
|
||||
return u->identifier();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Name *QualifiedNameId::base() const
|
||||
{ return _base; }
|
||||
|
||||
const Name *QualifiedNameId::name() const
|
||||
{ return _name; }
|
||||
|
||||
bool QualifiedNameId::isEqualTo(const Name *other) const
|
||||
{
|
||||
if (other) {
|
||||
if (const QualifiedNameId *q = other->asQualifiedNameId()) {
|
||||
if (_base == q->_base || (_base && _base->isEqualTo(q->_base))) {
|
||||
if (_name == q->_name || (_name && _name->isEqualTo(q->_name))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
DestructorNameId::DestructorNameId(const Identifier *identifier)
|
||||
: _identifier(identifier)
|
||||
{ }
|
||||
|
||||
DestructorNameId::~DestructorNameId()
|
||||
{ }
|
||||
|
||||
void DestructorNameId::accept0(NameVisitor *visitor) const
|
||||
{ visitor->visit(this); }
|
||||
|
||||
const Identifier *DestructorNameId::identifier() const
|
||||
{ return _identifier; }
|
||||
|
||||
bool DestructorNameId::isEqualTo(const Name *other) const
|
||||
{
|
||||
if (other) {
|
||||
const DestructorNameId *d = other->asDestructorNameId();
|
||||
if (! d)
|
||||
return false;
|
||||
const Identifier *l = identifier();
|
||||
const Identifier *r = d->identifier();
|
||||
return l->isEqualTo(r);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TemplateNameId::~TemplateNameId()
|
||||
{ }
|
||||
|
||||
void TemplateNameId::accept0(NameVisitor *visitor) const
|
||||
{ visitor->visit(this); }
|
||||
|
||||
const Identifier *TemplateNameId::identifier() const
|
||||
{ return _identifier; }
|
||||
|
||||
unsigned TemplateNameId::templateArgumentCount() const
|
||||
{ return _templateArguments.size(); }
|
||||
|
||||
const FullySpecifiedType &TemplateNameId::templateArgumentAt(unsigned index) const
|
||||
{ return _templateArguments[index]; }
|
||||
|
||||
bool TemplateNameId::isEqualTo(const Name *other) const
|
||||
{
|
||||
if (other) {
|
||||
const TemplateNameId *t = other->asTemplateNameId();
|
||||
if (! t)
|
||||
return false;
|
||||
const Identifier *l = identifier();
|
||||
const Identifier *r = t->identifier();
|
||||
if (! l->isEqualTo(r))
|
||||
return false;
|
||||
if (templateArgumentCount() != t->templateArgumentCount())
|
||||
return false;
|
||||
for (unsigned i = 0; i < templateArgumentCount(); ++i) {
|
||||
const FullySpecifiedType &l = _templateArguments[i];
|
||||
const FullySpecifiedType &r = t->_templateArguments[i];
|
||||
if (! l.isEqualTo(r))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
OperatorNameId::OperatorNameId(Kind kind)
|
||||
: _kind(kind)
|
||||
{ }
|
||||
|
||||
OperatorNameId::~OperatorNameId()
|
||||
{ }
|
||||
|
||||
void OperatorNameId::accept0(NameVisitor *visitor) const
|
||||
{ visitor->visit(this); }
|
||||
|
||||
OperatorNameId::Kind OperatorNameId::kind() const
|
||||
{ return _kind; }
|
||||
|
||||
const Identifier *OperatorNameId::identifier() const
|
||||
{ return 0; }
|
||||
|
||||
bool OperatorNameId::isEqualTo(const Name *other) const
|
||||
{
|
||||
if (other) {
|
||||
const OperatorNameId *o = other->asOperatorNameId();
|
||||
if (! o)
|
||||
return false;
|
||||
return _kind == o->kind();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ConversionNameId::ConversionNameId(const FullySpecifiedType &type)
|
||||
: _type(type)
|
||||
{ }
|
||||
|
||||
ConversionNameId::~ConversionNameId()
|
||||
{ }
|
||||
|
||||
void ConversionNameId::accept0(NameVisitor *visitor) const
|
||||
{ visitor->visit(this); }
|
||||
|
||||
FullySpecifiedType ConversionNameId::type() const
|
||||
{ return _type; }
|
||||
|
||||
const Identifier *ConversionNameId::identifier() const
|
||||
{ return 0; }
|
||||
|
||||
bool ConversionNameId::isEqualTo(const Name *other) const
|
||||
{
|
||||
if (other) {
|
||||
const ConversionNameId *c = other->asConversionNameId();
|
||||
if (! c)
|
||||
return false;
|
||||
return _type.isEqualTo(c->type());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SelectorNameId::~SelectorNameId()
|
||||
{ }
|
||||
|
||||
void SelectorNameId::accept0(NameVisitor *visitor) const
|
||||
{ visitor->visit(this); }
|
||||
|
||||
const Identifier *SelectorNameId::identifier() const
|
||||
{
|
||||
if (_names.empty())
|
||||
return 0;
|
||||
|
||||
return nameAt(0)->identifier();
|
||||
}
|
||||
|
||||
unsigned SelectorNameId::nameCount() const
|
||||
{ return _names.size(); }
|
||||
|
||||
const Name *SelectorNameId::nameAt(unsigned index) const
|
||||
{ return _names[index]; }
|
||||
|
||||
bool SelectorNameId::hasArguments() const
|
||||
{ return _hasArguments; }
|
||||
|
||||
bool SelectorNameId::isEqualTo(const Name *other) const
|
||||
{
|
||||
if (other) {
|
||||
const SelectorNameId *q = other->asSelectorNameId();
|
||||
if (! q)
|
||||
return false;
|
||||
else if (hasArguments() != q->hasArguments())
|
||||
return false;
|
||||
else {
|
||||
const unsigned count = nameCount();
|
||||
if (count != q->nameCount())
|
||||
return false;
|
||||
for (unsigned i = 0; i < count; ++i) {
|
||||
const Name *l = nameAt(i);
|
||||
const Name *r = q->nameAt(i);
|
||||
if (! l->isEqualTo(r))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
273
src/libs/3rdparty/cplusplus/Names.h
vendored
Normal file
273
src/libs/3rdparty/cplusplus/Names.h
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_NAMES_H
|
||||
#define CPLUSPLUS_NAMES_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "Name.h"
|
||||
#include "FullySpecifiedType.h"
|
||||
#include <vector>
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT QualifiedNameId: public Name
|
||||
{
|
||||
public:
|
||||
QualifiedNameId(const Name *base, const Name *name)
|
||||
: _base(base), _name(name) {}
|
||||
|
||||
virtual ~QualifiedNameId();
|
||||
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
const Name *base() const;
|
||||
const Name *name() const;
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const QualifiedNameId *asQualifiedNameId() const
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(NameVisitor *visitor) const;
|
||||
|
||||
private:
|
||||
const Name *_base;
|
||||
const Name *_name;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT DestructorNameId: public Name
|
||||
{
|
||||
public:
|
||||
DestructorNameId(const Identifier *identifier);
|
||||
virtual ~DestructorNameId();
|
||||
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const DestructorNameId *asDestructorNameId() const
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(NameVisitor *visitor) const;
|
||||
|
||||
private:
|
||||
const Identifier *_identifier;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT TemplateNameId: public Name
|
||||
{
|
||||
public:
|
||||
template <typename _Iterator>
|
||||
TemplateNameId(const Identifier *identifier, _Iterator first, _Iterator last)
|
||||
: _identifier(identifier), _templateArguments(first, last) {}
|
||||
|
||||
virtual ~TemplateNameId();
|
||||
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
// ### find a better name
|
||||
unsigned templateArgumentCount() const;
|
||||
const FullySpecifiedType &templateArgumentAt(unsigned index) const;
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const TemplateNameId *asTemplateNameId() const
|
||||
{ return this; }
|
||||
|
||||
typedef std::vector<FullySpecifiedType>::const_iterator TemplateArgumentIterator;
|
||||
|
||||
TemplateArgumentIterator firstTemplateArgument() const { return _templateArguments.begin(); }
|
||||
TemplateArgumentIterator lastTemplateArgument() const { return _templateArguments.end(); }
|
||||
|
||||
protected:
|
||||
virtual void accept0(NameVisitor *visitor) const;
|
||||
|
||||
private:
|
||||
const Identifier *_identifier;
|
||||
std::vector<FullySpecifiedType> _templateArguments;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT OperatorNameId: public Name
|
||||
{
|
||||
public:
|
||||
/*
|
||||
new delete new[] delete[]
|
||||
+ - * / % ^ & | ~
|
||||
! = < > += -= *= /= %=
|
||||
^= &= |= << >> >>= <<= == !=
|
||||
<= >= && || ++ -- , ->* ->
|
||||
() []
|
||||
*/
|
||||
enum Kind {
|
||||
InvalidOp,
|
||||
NewOp,
|
||||
DeleteOp,
|
||||
NewArrayOp,
|
||||
DeleteArrayOp,
|
||||
PlusOp,
|
||||
MinusOp,
|
||||
StarOp,
|
||||
SlashOp,
|
||||
PercentOp,
|
||||
CaretOp,
|
||||
AmpOp,
|
||||
PipeOp,
|
||||
TildeOp,
|
||||
ExclaimOp,
|
||||
EqualOp,
|
||||
LessOp,
|
||||
GreaterOp,
|
||||
PlusEqualOp,
|
||||
MinusEqualOp,
|
||||
StarEqualOp,
|
||||
SlashEqualOp,
|
||||
PercentEqualOp,
|
||||
CaretEqualOp,
|
||||
AmpEqualOp,
|
||||
PipeEqualOp,
|
||||
LessLessOp,
|
||||
GreaterGreaterOp,
|
||||
LessLessEqualOp,
|
||||
GreaterGreaterEqualOp,
|
||||
EqualEqualOp,
|
||||
ExclaimEqualOp,
|
||||
LessEqualOp,
|
||||
GreaterEqualOp,
|
||||
AmpAmpOp,
|
||||
PipePipeOp,
|
||||
PlusPlusOp,
|
||||
MinusMinusOp,
|
||||
CommaOp,
|
||||
ArrowStarOp,
|
||||
ArrowOp,
|
||||
FunctionCallOp,
|
||||
ArrayAccessOp
|
||||
};
|
||||
|
||||
public:
|
||||
OperatorNameId(Kind kind);
|
||||
virtual ~OperatorNameId();
|
||||
|
||||
Kind kind() const;
|
||||
|
||||
virtual const Identifier *identifier() const;
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const OperatorNameId *asOperatorNameId() const
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(NameVisitor *visitor) const;
|
||||
|
||||
private:
|
||||
Kind _kind;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ConversionNameId: public Name
|
||||
{
|
||||
public:
|
||||
ConversionNameId(const FullySpecifiedType &type);
|
||||
virtual ~ConversionNameId();
|
||||
|
||||
FullySpecifiedType type() const;
|
||||
|
||||
virtual const Identifier *identifier() const;
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const ConversionNameId *asConversionNameId() const
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void accept0(NameVisitor *visitor) const;
|
||||
|
||||
private:
|
||||
FullySpecifiedType _type;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT SelectorNameId: public Name
|
||||
{
|
||||
public:
|
||||
template <typename _Iterator>
|
||||
SelectorNameId(_Iterator first, _Iterator last, bool hasArguments)
|
||||
: _names(first, last), _hasArguments(hasArguments) {}
|
||||
|
||||
virtual ~SelectorNameId();
|
||||
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
unsigned nameCount() const;
|
||||
const Name *nameAt(unsigned index) const;
|
||||
bool hasArguments() const;
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
|
||||
virtual const SelectorNameId *asSelectorNameId() const
|
||||
{ return this; }
|
||||
|
||||
typedef std::vector<const Name *>::const_iterator NameIterator;
|
||||
|
||||
NameIterator firstName() const { return _names.begin(); }
|
||||
NameIterator lastName() const { return _names.end(); }
|
||||
|
||||
protected:
|
||||
virtual void accept0(NameVisitor *visitor) const;
|
||||
|
||||
private:
|
||||
std::vector<const Name *> _names;
|
||||
bool _hasArguments;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
#endif // CPLUSPLUS_NAMES_H
|
494
src/libs/3rdparty/cplusplus/ObjectiveCAtKeywords.cpp
vendored
Normal file
494
src/libs/3rdparty/cplusplus/ObjectiveCAtKeywords.cpp
vendored
Normal file
@@ -0,0 +1,494 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "Lexer.h"
|
||||
#include "Token.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
static inline int classify3(const char *s) {
|
||||
if (s[0] == 'e') {
|
||||
if (s[1] == 'n') {
|
||||
if (s[2] == 'd') {
|
||||
return T_AT_END;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 't') {
|
||||
if (s[1] == 'r') {
|
||||
if (s[2] == 'y') {
|
||||
return T_AT_TRY;
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify4(const char *s) {
|
||||
if (s[0] == 'd') {
|
||||
if (s[1] == 'e') {
|
||||
if (s[2] == 'f') {
|
||||
if (s[3] == 's') {
|
||||
return T_AT_DEFS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify5(const char *s) {
|
||||
if (s[0] == 'c') {
|
||||
if (s[1] == 'a') {
|
||||
if (s[2] == 't') {
|
||||
if (s[3] == 'c') {
|
||||
if (s[4] == 'h') {
|
||||
return T_AT_CATCH;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[1] == 'l') {
|
||||
if (s[2] == 'a') {
|
||||
if (s[3] == 's') {
|
||||
if (s[4] == 's') {
|
||||
return T_AT_CLASS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 't') {
|
||||
if (s[1] == 'h') {
|
||||
if (s[2] == 'r') {
|
||||
if (s[3] == 'o') {
|
||||
if (s[4] == 'w') {
|
||||
return T_AT_THROW;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify6(const char *s) {
|
||||
if (s[0] == 'e') {
|
||||
if (s[1] == 'n') {
|
||||
if (s[2] == 'c') {
|
||||
if (s[3] == 'o') {
|
||||
if (s[4] == 'd') {
|
||||
if (s[5] == 'e') {
|
||||
return T_AT_ENCODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'p') {
|
||||
if (s[1] == 'u') {
|
||||
if (s[2] == 'b') {
|
||||
if (s[3] == 'l') {
|
||||
if (s[4] == 'i') {
|
||||
if (s[5] == 'c') {
|
||||
return T_AT_PUBLIC;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify7(const char *s) {
|
||||
if (s[0] == 'd') {
|
||||
if (s[1] == 'y') {
|
||||
if (s[2] == 'n') {
|
||||
if (s[3] == 'a') {
|
||||
if (s[4] == 'm') {
|
||||
if (s[5] == 'i') {
|
||||
if (s[6] == 'c') {
|
||||
return T_AT_DYNAMIC;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'f') {
|
||||
if (s[1] == 'i') {
|
||||
if (s[2] == 'n') {
|
||||
if (s[3] == 'a') {
|
||||
if (s[4] == 'l') {
|
||||
if (s[5] == 'l') {
|
||||
if (s[6] == 'y') {
|
||||
return T_AT_FINALLY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'p') {
|
||||
if (s[1] == 'a') {
|
||||
if (s[2] == 'c') {
|
||||
if (s[3] == 'k') {
|
||||
if (s[4] == 'a') {
|
||||
if (s[5] == 'g') {
|
||||
if (s[6] == 'e') {
|
||||
return T_AT_PACKAGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[1] == 'r') {
|
||||
if (s[2] == 'i') {
|
||||
if (s[3] == 'v') {
|
||||
if (s[4] == 'a') {
|
||||
if (s[5] == 't') {
|
||||
if (s[6] == 'e') {
|
||||
return T_AT_PRIVATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify8(const char *s) {
|
||||
if (s[0] == 'o') {
|
||||
if (s[1] == 'p') {
|
||||
if (s[2] == 't') {
|
||||
if (s[3] == 'i') {
|
||||
if (s[4] == 'o') {
|
||||
if (s[5] == 'n') {
|
||||
if (s[6] == 'a') {
|
||||
if (s[7] == 'l') {
|
||||
return T_AT_OPTIONAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'p') {
|
||||
if (s[1] == 'r') {
|
||||
if (s[2] == 'o') {
|
||||
if (s[3] == 'p') {
|
||||
if (s[4] == 'e') {
|
||||
if (s[5] == 'r') {
|
||||
if (s[6] == 't') {
|
||||
if (s[7] == 'y') {
|
||||
return T_AT_PROPERTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[3] == 't') {
|
||||
if (s[4] == 'o') {
|
||||
if (s[5] == 'c') {
|
||||
if (s[6] == 'o') {
|
||||
if (s[7] == 'l') {
|
||||
return T_AT_PROTOCOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'r') {
|
||||
if (s[1] == 'e') {
|
||||
if (s[2] == 'q') {
|
||||
if (s[3] == 'u') {
|
||||
if (s[4] == 'i') {
|
||||
if (s[5] == 'r') {
|
||||
if (s[6] == 'e') {
|
||||
if (s[7] == 'd') {
|
||||
return T_AT_REQUIRED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 's') {
|
||||
if (s[1] == 'e') {
|
||||
if (s[2] == 'l') {
|
||||
if (s[3] == 'e') {
|
||||
if (s[4] == 'c') {
|
||||
if (s[5] == 't') {
|
||||
if (s[6] == 'o') {
|
||||
if (s[7] == 'r') {
|
||||
return T_AT_SELECTOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify9(const char *s) {
|
||||
if (s[0] == 'i') {
|
||||
if (s[1] == 'n') {
|
||||
if (s[2] == 't') {
|
||||
if (s[3] == 'e') {
|
||||
if (s[4] == 'r') {
|
||||
if (s[5] == 'f') {
|
||||
if (s[6] == 'a') {
|
||||
if (s[7] == 'c') {
|
||||
if (s[8] == 'e') {
|
||||
return T_AT_INTERFACE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'p') {
|
||||
if (s[1] == 'r') {
|
||||
if (s[2] == 'o') {
|
||||
if (s[3] == 't') {
|
||||
if (s[4] == 'e') {
|
||||
if (s[5] == 'c') {
|
||||
if (s[6] == 't') {
|
||||
if (s[7] == 'e') {
|
||||
if (s[8] == 'd') {
|
||||
return T_AT_PROTECTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify10(const char *s) {
|
||||
if (s[0] == 's') {
|
||||
if (s[1] == 'y') {
|
||||
if (s[2] == 'n') {
|
||||
if (s[3] == 't') {
|
||||
if (s[4] == 'h') {
|
||||
if (s[5] == 'e') {
|
||||
if (s[6] == 's') {
|
||||
if (s[7] == 'i') {
|
||||
if (s[8] == 'z') {
|
||||
if (s[9] == 'e') {
|
||||
return T_AT_SYNTHESIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify11(const char *s) {
|
||||
if (s[0] == 'n') {
|
||||
if (s[1] == 'o') {
|
||||
if (s[2] == 't') {
|
||||
if (s[3] == '_') {
|
||||
if (s[4] == 'k') {
|
||||
if (s[5] == 'e') {
|
||||
if (s[6] == 'y') {
|
||||
if (s[7] == 'w') {
|
||||
if (s[8] == 'o') {
|
||||
if (s[9] == 'r') {
|
||||
if (s[10] == 'd') {
|
||||
return T_AT_NOT_KEYWORD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify12(const char *s) {
|
||||
if (s[0] == 's') {
|
||||
if (s[1] == 'y') {
|
||||
if (s[2] == 'n') {
|
||||
if (s[3] == 'c') {
|
||||
if (s[4] == 'h') {
|
||||
if (s[5] == 'r') {
|
||||
if (s[6] == 'o') {
|
||||
if (s[7] == 'n') {
|
||||
if (s[8] == 'i') {
|
||||
if (s[9] == 'z') {
|
||||
if (s[10] == 'e') {
|
||||
if (s[11] == 'd') {
|
||||
return T_AT_SYNCHRONIZED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify14(const char *s) {
|
||||
if (s[0] == 'i') {
|
||||
if (s[1] == 'm') {
|
||||
if (s[2] == 'p') {
|
||||
if (s[3] == 'l') {
|
||||
if (s[4] == 'e') {
|
||||
if (s[5] == 'm') {
|
||||
if (s[6] == 'e') {
|
||||
if (s[7] == 'n') {
|
||||
if (s[8] == 't') {
|
||||
if (s[9] == 'a') {
|
||||
if (s[10] == 't') {
|
||||
if (s[11] == 'i') {
|
||||
if (s[12] == 'o') {
|
||||
if (s[13] == 'n') {
|
||||
return T_AT_IMPLEMENTATION;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
static inline int classify19(const char *s) {
|
||||
if (s[0] == 'c') {
|
||||
if (s[1] == 'o') {
|
||||
if (s[2] == 'm') {
|
||||
if (s[3] == 'p') {
|
||||
if (s[4] == 'a') {
|
||||
if (s[5] == 't') {
|
||||
if (s[6] == 'i') {
|
||||
if (s[7] == 'b') {
|
||||
if (s[8] == 'i') {
|
||||
if (s[9] == 'l') {
|
||||
if (s[10] == 'i') {
|
||||
if (s[11] == 't') {
|
||||
if (s[12] == 'y') {
|
||||
if (s[13] == '_') {
|
||||
if (s[14] == 'a') {
|
||||
if (s[15] == 'l') {
|
||||
if (s[16] == 'i') {
|
||||
if (s[17] == 'a') {
|
||||
if (s[18] == 's') {
|
||||
return T_AT_COMPATIBILITY_ALIAS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return T_ERROR;
|
||||
}
|
||||
|
||||
int Lexer::classifyObjCAtKeyword(const char *s, int n) {
|
||||
switch (n) {
|
||||
case 3: return classify3(s);
|
||||
case 4: return classify4(s);
|
||||
case 5: return classify5(s);
|
||||
case 6: return classify6(s);
|
||||
case 7: return classify7(s);
|
||||
case 8: return classify8(s);
|
||||
case 9: return classify9(s);
|
||||
case 10: return classify10(s);
|
||||
case 11: return classify11(s);
|
||||
case 12: return classify12(s);
|
||||
case 14: return classify14(s);
|
||||
case 19: return classify19(s);
|
||||
default: return T_ERROR;
|
||||
} // switch
|
||||
}
|
253
src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.cpp
vendored
Normal file
253
src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.cpp
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "ObjectiveCTypeQualifiers.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
static inline int classify2(const char *s) {
|
||||
if (s[0] == 'i') {
|
||||
if (s[1] == 'n') {
|
||||
return Token_in;
|
||||
}
|
||||
}
|
||||
return Token_identifier;
|
||||
}
|
||||
|
||||
static inline int classify3(const char *s) {
|
||||
if (s[0] == 'o') {
|
||||
if (s[1] == 'u') {
|
||||
if (s[2] == 't') {
|
||||
return Token_out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_identifier;
|
||||
}
|
||||
|
||||
static inline int classify4(const char *s) {
|
||||
if (s[0] == 'c') {
|
||||
if (s[1] == 'o') {
|
||||
if (s[2] == 'p') {
|
||||
if (s[3] == 'y') {
|
||||
return Token_copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_identifier;
|
||||
}
|
||||
|
||||
static inline int classify5(const char *s) {
|
||||
if (s[0] == 'b') {
|
||||
if (s[1] == 'y') {
|
||||
if (s[2] == 'r') {
|
||||
if (s[3] == 'e') {
|
||||
if (s[4] == 'f') {
|
||||
return Token_byref;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'i') {
|
||||
if (s[1] == 'n') {
|
||||
if (s[2] == 'o') {
|
||||
if (s[3] == 'u') {
|
||||
if (s[4] == 't') {
|
||||
return Token_inout;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_identifier;
|
||||
}
|
||||
|
||||
static inline int classify6(const char *s) {
|
||||
if (s[0] == 'a') {
|
||||
if (s[1] == 's') {
|
||||
if (s[2] == 's') {
|
||||
if (s[3] == 'i') {
|
||||
if (s[4] == 'g') {
|
||||
if (s[5] == 'n') {
|
||||
return Token_assign;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'b') {
|
||||
if (s[1] == 'y') {
|
||||
if (s[2] == 'c') {
|
||||
if (s[3] == 'o') {
|
||||
if (s[4] == 'p') {
|
||||
if (s[5] == 'y') {
|
||||
return Token_bycopy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'g') {
|
||||
if (s[1] == 'e') {
|
||||
if (s[2] == 't') {
|
||||
if (s[3] == 't') {
|
||||
if (s[4] == 'e') {
|
||||
if (s[5] == 'r') {
|
||||
return Token_getter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 's') {
|
||||
if (s[1] == 'e') {
|
||||
if (s[2] == 't') {
|
||||
if (s[3] == 't') {
|
||||
if (s[4] == 'e') {
|
||||
if (s[5] == 'r') {
|
||||
return Token_setter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'o') {
|
||||
if (s[1] == 'n') {
|
||||
if (s[2] == 'e') {
|
||||
if (s[3] == 'w') {
|
||||
if (s[4] == 'a') {
|
||||
if (s[5] == 'y') {
|
||||
return Token_oneway;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'r') {
|
||||
if (s[1] == 'e') {
|
||||
if (s[2] == 't') {
|
||||
if (s[3] == 'a') {
|
||||
if (s[4] == 'i') {
|
||||
if (s[5] == 'n') {
|
||||
return Token_retain;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_identifier;
|
||||
}
|
||||
|
||||
static inline int classify8(const char *s) {
|
||||
if (s[0] == 'r') {
|
||||
if (s[1] == 'e') {
|
||||
if (s[2] == 'a') {
|
||||
if (s[3] == 'd') {
|
||||
if (s[4] == 'o') {
|
||||
if (s[5] == 'n') {
|
||||
if (s[6] == 'l') {
|
||||
if (s[7] == 'y') {
|
||||
return Token_readonly;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_identifier;
|
||||
}
|
||||
|
||||
static inline int classify9(const char *s) {
|
||||
if (s[0] == 'n') {
|
||||
if (s[1] == 'o') {
|
||||
if (s[2] == 'n') {
|
||||
if (s[3] == 'a') {
|
||||
if (s[4] == 't') {
|
||||
if (s[5] == 'o') {
|
||||
if (s[6] == 'm') {
|
||||
if (s[7] == 'i') {
|
||||
if (s[8] == 'c') {
|
||||
return Token_nonatomic;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (s[0] == 'r') {
|
||||
if (s[1] == 'e') {
|
||||
if (s[2] == 'a') {
|
||||
if (s[3] == 'd') {
|
||||
if (s[4] == 'w') {
|
||||
if (s[5] == 'r') {
|
||||
if (s[6] == 'i') {
|
||||
if (s[7] == 't') {
|
||||
if (s[8] == 'e') {
|
||||
return Token_readwrite;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_identifier;
|
||||
}
|
||||
|
||||
int CPlusPlus::classifyObjectiveCContextKeyword(const char *s, int n) {
|
||||
switch (n) {
|
||||
case 2: return classify2(s);
|
||||
case 3: return classify3(s);
|
||||
case 4: return classify4(s);
|
||||
case 5: return classify5(s);
|
||||
case 6: return classify6(s);
|
||||
case 8: return classify8(s);
|
||||
case 9: return classify9(s);
|
||||
default: return Token_identifier;
|
||||
} // switch
|
||||
}
|
||||
|
||||
|
63
src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.h
vendored
Normal file
63
src/libs/3rdparty/cplusplus/ObjectiveCTypeQualifiers.h
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
#ifndef CPLUSPLUS_OBJC_TYPEQUALIFIERS_H
|
||||
#define CPLUSPLUS_OBJC_TYPEQUALIFIERS_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
enum {
|
||||
Token_in,
|
||||
Token_out,
|
||||
Token_copy,
|
||||
Token_byref,
|
||||
Token_inout,
|
||||
Token_assign,
|
||||
Token_bycopy,
|
||||
Token_getter,
|
||||
Token_retain,
|
||||
Token_setter,
|
||||
Token_oneway,
|
||||
Token_readonly,
|
||||
Token_nonatomic,
|
||||
Token_readwrite,
|
||||
Token_identifier
|
||||
};
|
||||
|
||||
CPLUSPLUS_EXPORT int classifyObjectiveCContextKeyword(const char *s, int n);
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_OBJC_TYPEQUALIFIERS_H
|
6040
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
Normal file
6040
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
364
src/libs/3rdparty/cplusplus/Parser.h
vendored
Normal file
364
src/libs/3rdparty/cplusplus/Parser.h
vendored
Normal file
@@ -0,0 +1,364 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_PARSER_H
|
||||
#define CPLUSPLUS_PARSER_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "ASTfwd.h"
|
||||
#include "Token.h"
|
||||
#include "TranslationUnit.h"
|
||||
#include "MemoryPool.h"
|
||||
#include <map>
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT Parser
|
||||
{
|
||||
public:
|
||||
Parser(TranslationUnit *translationUnit);
|
||||
~Parser();
|
||||
|
||||
bool qtMocRunEnabled() const;
|
||||
void setQtMocRunEnabled(bool onoff);
|
||||
|
||||
bool cxx0xEnabled() const;
|
||||
void setCxxOxEnabled(bool onoff);
|
||||
|
||||
bool objCEnabled() const;
|
||||
void setObjCEnabled(bool onoff);
|
||||
|
||||
bool parseTranslationUnit(TranslationUnitAST *&node);
|
||||
|
||||
public:
|
||||
bool parseAccessSpecifier(SpecifierAST *&node);
|
||||
bool parseExpressionList(ExpressionListAST *&node);
|
||||
bool parseAbstractCoreDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list);
|
||||
bool parseAbstractDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list);
|
||||
bool parseEmptyDeclaration(DeclarationAST *&node);
|
||||
bool parseAccessDeclaration(DeclarationAST *&node);
|
||||
bool parseQtPropertyDeclaration(DeclarationAST *&node);
|
||||
bool parseQtEnumDeclaration(DeclarationAST *&node);
|
||||
bool parseQtFlags(DeclarationAST *&node);
|
||||
bool parseQtInterfaces(DeclarationAST *&node);
|
||||
bool parseAdditiveExpression(ExpressionAST *&node);
|
||||
bool parseAndExpression(ExpressionAST *&node);
|
||||
bool parseAsmDefinition(DeclarationAST *&node);
|
||||
bool parseAsmOperandList();
|
||||
bool parseAsmOperand();
|
||||
bool parseAsmClobberList();
|
||||
bool parseAssignmentExpression(ExpressionAST *&node);
|
||||
bool parseBaseClause(BaseSpecifierListAST *&node);
|
||||
bool parseBaseSpecifier(BaseSpecifierListAST *&node);
|
||||
bool parseBlockDeclaration(DeclarationAST *&node);
|
||||
bool parseCppCastExpression(ExpressionAST *&node);
|
||||
bool parseCastExpression(ExpressionAST *&node);
|
||||
bool parseClassSpecifier(SpecifierListAST *&node);
|
||||
bool parseCommaExpression(ExpressionAST *&node);
|
||||
bool parseCompoundStatement(StatementAST *&node);
|
||||
bool parseBreakStatement(StatementAST *&node);
|
||||
bool parseContinueStatement(StatementAST *&node);
|
||||
bool parseGotoStatement(StatementAST *&node);
|
||||
bool parseReturnStatement(StatementAST *&node);
|
||||
bool parseCondition(ExpressionAST *&node);
|
||||
bool parseConditionalExpression(ExpressionAST *&node);
|
||||
bool parseConstantExpression(ExpressionAST *&node);
|
||||
bool parseCtorInitializer(CtorInitializerAST *&node);
|
||||
bool parseCvQualifiers(SpecifierListAST *&node);
|
||||
bool parseDeclaratorOrAbstractDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list);
|
||||
bool parseDeclaration(DeclarationAST *&node);
|
||||
bool parseSimpleDeclaration(DeclarationAST *&node, ClassSpecifierAST *declaringClass = 0);
|
||||
bool parseDeclarationStatement(StatementAST *&node);
|
||||
bool parseCoreDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, ClassSpecifierAST *declaringClass);
|
||||
bool parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, ClassSpecifierAST *declaringClass = 0);
|
||||
bool parseDeleteExpression(ExpressionAST *&node);
|
||||
bool parseDoStatement(StatementAST *&node);
|
||||
bool parseElaboratedTypeSpecifier(SpecifierListAST *&node);
|
||||
bool parseEnumSpecifier(SpecifierListAST *&node);
|
||||
bool parseEnumerator(EnumeratorListAST *&node);
|
||||
bool parseEqualityExpression(ExpressionAST *&node);
|
||||
bool parseExceptionDeclaration(ExceptionDeclarationAST *&node);
|
||||
bool parseExceptionSpecification(ExceptionSpecificationAST *&node);
|
||||
bool parseExclusiveOrExpression(ExpressionAST *&node);
|
||||
bool parseExpression(ExpressionAST *&node);
|
||||
bool parseExpressionOrDeclarationStatement(StatementAST *&node);
|
||||
bool parseExpressionStatement(StatementAST *&node);
|
||||
bool parseForInitStatement(StatementAST *&node);
|
||||
bool parseForeachStatement(StatementAST *&node);
|
||||
bool parseForStatement(StatementAST *&node);
|
||||
bool parseFunctionBody(StatementAST *&node);
|
||||
bool parseIfStatement(StatementAST *&node);
|
||||
bool parseInclusiveOrExpression(ExpressionAST *&node);
|
||||
bool parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specifier_list, ClassSpecifierAST *declaringClass);
|
||||
bool parseInitializerList(ExpressionListAST *&node);
|
||||
bool parseInitializer(ExpressionAST *&node, unsigned *equals_token);
|
||||
bool parseInitializerClause(ExpressionAST *&node);
|
||||
bool parseLabeledStatement(StatementAST *&node);
|
||||
bool parseLinkageBody(DeclarationAST *&node);
|
||||
bool parseLinkageSpecification(DeclarationAST *&node);
|
||||
bool parseLogicalAndExpression(ExpressionAST *&node);
|
||||
bool parseLogicalOrExpression(ExpressionAST *&node);
|
||||
bool parseMemInitializer(MemInitializerListAST *&node);
|
||||
bool parseMemInitializerList(MemInitializerListAST *&node);
|
||||
bool parseMemberSpecification(DeclarationAST *&node, ClassSpecifierAST *declaringClass);
|
||||
bool parseMultiplicativeExpression(ExpressionAST *&node);
|
||||
bool parseTemplateId(NameAST *&node, unsigned template_token = 0);
|
||||
bool parseClassOrNamespaceName(NameAST *&node);
|
||||
bool parseNameId(NameAST *&node);
|
||||
bool parseName(NameAST *&node, bool acceptTemplateId = true);
|
||||
bool parseNestedNameSpecifier(NestedNameSpecifierListAST *&node, bool acceptTemplateId);
|
||||
bool parseNestedNameSpecifierOpt(NestedNameSpecifierListAST *&name, bool acceptTemplateId);
|
||||
bool parseNamespace(DeclarationAST *&node);
|
||||
bool parseNamespaceAliasDefinition(DeclarationAST *&node);
|
||||
bool parseNewArrayDeclarator(NewArrayDeclaratorListAST *&node);
|
||||
bool parseNewExpression(ExpressionAST *&node);
|
||||
bool parseNewPlacement(NewPlacementAST *&node);
|
||||
bool parseNewInitializer(NewInitializerAST *&node);
|
||||
bool parseNewTypeId(NewTypeIdAST *&node);
|
||||
bool parseOperator(OperatorAST *&node);
|
||||
bool parseConversionFunctionId(NameAST *&node);
|
||||
bool parseOperatorFunctionId(NameAST *&node);
|
||||
bool parseParameterDeclaration(ParameterDeclarationAST *&node);
|
||||
bool parseParameterDeclarationClause(ParameterDeclarationClauseAST *&node);
|
||||
bool parseParameterDeclarationList(ParameterDeclarationListAST *&node);
|
||||
bool parsePmExpression(ExpressionAST *&node);
|
||||
bool parseTypeidExpression(ExpressionAST *&node);
|
||||
bool parseTypenameCallExpression(ExpressionAST *&node);
|
||||
bool parseCorePostfixExpression(ExpressionAST *&node);
|
||||
bool parsePostfixExpression(ExpressionAST *&node);
|
||||
bool parsePostfixExpressionInternal(ExpressionAST *&node);
|
||||
bool parsePrimaryExpression(ExpressionAST *&node);
|
||||
bool parseNestedExpression(ExpressionAST *&node);
|
||||
bool parsePtrOperator(PtrOperatorListAST *&node);
|
||||
bool parseRelationalExpression(ExpressionAST *&node);
|
||||
bool parseShiftExpression(ExpressionAST *&node);
|
||||
bool parseStatement(StatementAST *&node);
|
||||
bool parseThisExpression(ExpressionAST *&node);
|
||||
bool parseBoolLiteral(ExpressionAST *&node);
|
||||
bool parseNumericLiteral(ExpressionAST *&node);
|
||||
bool parseStringLiteral(ExpressionAST *&node);
|
||||
bool parseSwitchStatement(StatementAST *&node);
|
||||
bool parseTemplateArgument(ExpressionAST *&node);
|
||||
bool parseTemplateArgumentList(ExpressionListAST *&node);
|
||||
bool parseTemplateDeclaration(DeclarationAST *&node);
|
||||
bool parseTemplateParameter(DeclarationAST *&node);
|
||||
bool parseTemplateParameterList(DeclarationListAST *&node);
|
||||
bool parseThrowExpression(ExpressionAST *&node);
|
||||
bool parseTryBlockStatement(StatementAST *&node);
|
||||
bool parseCatchClause(CatchClauseListAST *&node);
|
||||
bool parseTypeId(ExpressionAST *&node);
|
||||
bool parseTypeIdList(ExpressionListAST *&node);
|
||||
bool parseTypenameTypeParameter(DeclarationAST *&node);
|
||||
bool parseTemplateTypeParameter(DeclarationAST *&node);
|
||||
bool parseTypeParameter(DeclarationAST *&node);
|
||||
|
||||
bool parseBuiltinTypeSpecifier(SpecifierListAST *&node);
|
||||
bool parseAttributeSpecifier(SpecifierListAST *&node);
|
||||
bool parseAttributeList(AttributeListAST *&node);
|
||||
|
||||
bool parseSimpleTypeSpecifier(SpecifierListAST *&node)
|
||||
{ return parseDeclSpecifierSeq(node, true, true); }
|
||||
|
||||
bool parseTypeSpecifier(SpecifierListAST *&node)
|
||||
{ return parseDeclSpecifierSeq(node, true); }
|
||||
|
||||
bool parseDeclSpecifierSeq(SpecifierListAST *&node,
|
||||
bool onlyTypeSpecifiers = false,
|
||||
bool simplified = false);
|
||||
bool parseUnaryExpression(ExpressionAST *&node);
|
||||
bool parseUnqualifiedName(NameAST *&node, bool acceptTemplateId = true);
|
||||
bool parseUsing(DeclarationAST *&node);
|
||||
bool parseUsingDirective(DeclarationAST *&node);
|
||||
bool parseWhileStatement(StatementAST *&node);
|
||||
|
||||
void parseExpressionWithOperatorPrecedence(ExpressionAST *&lhs, int minPrecedence);
|
||||
|
||||
// Qt MOC run
|
||||
bool parseQtMethod(ExpressionAST *&node);
|
||||
|
||||
// C++0x
|
||||
bool parseInitializer0x(ExpressionAST *&node, unsigned *equals_token);
|
||||
bool parseBraceOrEqualInitializer0x(ExpressionAST *&node);
|
||||
bool parseInitializerClause0x(ExpressionAST *&node);
|
||||
bool parseInitializerList0x(ExpressionListAST *&node);
|
||||
bool parseBracedInitList0x(ExpressionAST *&node);
|
||||
|
||||
bool parseLambdaExpression(ExpressionAST *&node);
|
||||
bool parseLambdaIntroducer(LambdaIntroducerAST *&node);
|
||||
bool parseLambdaCapture(LambdaCaptureAST *&node);
|
||||
bool parseLambdaDeclarator(LambdaDeclaratorAST *&node);
|
||||
bool parseCapture(CaptureAST *&node);
|
||||
bool parseCaptureList(CaptureListAST *&node);
|
||||
bool parseTrailingReturnType(TrailingReturnTypeAST *&node);
|
||||
bool parseTrailingTypeSpecifierSeq(SpecifierListAST *&node);
|
||||
|
||||
// ObjC++
|
||||
bool parseObjCExpression(ExpressionAST *&node);
|
||||
bool parseObjCClassForwardDeclaration(DeclarationAST *&node);
|
||||
bool parseObjCInterface(DeclarationAST *&node,
|
||||
SpecifierListAST *attributes = 0);
|
||||
bool parseObjCProtocol(DeclarationAST *&node,
|
||||
SpecifierListAST *attributes = 0);
|
||||
|
||||
bool parseObjCSynchronizedStatement(StatementAST *&node);
|
||||
bool parseObjCEncodeExpression(ExpressionAST *&node);
|
||||
bool parseObjCProtocolExpression(ExpressionAST *&node);
|
||||
bool parseObjCSelectorExpression(ExpressionAST *&node);
|
||||
bool parseObjCStringLiteral(ExpressionAST *&node);
|
||||
bool parseObjCMessageExpression(ExpressionAST *&node);
|
||||
bool parseObjCMessageReceiver(ExpressionAST *&node);
|
||||
bool parseObjCMessageArguments(ObjCSelectorAST *&selNode, ObjCMessageArgumentListAST *& argNode);
|
||||
bool parseObjCSelectorArg(ObjCSelectorArgumentAST *&selNode, ObjCMessageArgumentAST *&argNode);
|
||||
bool parseObjCMethodDefinitionList(DeclarationListAST *&node);
|
||||
bool parseObjCMethodDefinition(DeclarationAST *&node);
|
||||
|
||||
bool parseObjCProtocolRefs(ObjCProtocolRefsAST *&node);
|
||||
bool parseObjClassInstanceVariables(ObjCInstanceVariablesDeclarationAST *&node);
|
||||
bool parseObjCInterfaceMemberDeclaration(DeclarationAST *&node);
|
||||
bool parseObjCInstanceVariableDeclaration(DeclarationAST *&node);
|
||||
bool parseObjCPropertyDeclaration(DeclarationAST *&node,
|
||||
SpecifierListAST *attributes = 0);
|
||||
bool parseObjCImplementation(DeclarationAST *&node);
|
||||
bool parseObjCMethodPrototype(ObjCMethodPrototypeAST *&node);
|
||||
bool parseObjCPropertyAttribute(ObjCPropertyAttributeAST *&node);
|
||||
bool parseObjCTypeName(ObjCTypeNameAST *&node);
|
||||
bool parseObjCSelector(unsigned &selector_token);
|
||||
bool parseObjCKeywordDeclaration(ObjCSelectorArgumentAST *&argument, ObjCMessageArgumentDeclarationAST *&node);
|
||||
bool parseObjCTypeQualifiers(unsigned &type_qualifier);
|
||||
bool peekAtObjCContextKeyword(int kind);
|
||||
bool parseObjCContextKeyword(int kind, unsigned &in_token);
|
||||
|
||||
bool lookAtObjCSelector() const;
|
||||
|
||||
bool skipUntil(int token);
|
||||
void skipUntilDeclaration();
|
||||
bool skipUntilStatement();
|
||||
bool skip(int l, int r);
|
||||
|
||||
bool lookAtTypeParameter() const;
|
||||
bool lookAtCVQualifier() const;
|
||||
bool lookAtFunctionSpecifier() const;
|
||||
bool lookAtStorageClassSpecifier() const;
|
||||
bool lookAtBuiltinTypeSpecifier() const;
|
||||
bool lookAtClassKey() const;
|
||||
|
||||
const Identifier *className(ClassSpecifierAST *ast) const;
|
||||
const Identifier *identifier(NameAST *name) const;
|
||||
|
||||
void match(int kind, unsigned *token);
|
||||
|
||||
bool maybeAmbiguousStatement(DeclarationStatementAST *ast, StatementAST *&node);
|
||||
bool maybeForwardOrClassDeclaration(SpecifierListAST *decl_specifier_seq) const;
|
||||
|
||||
int peekAtQtContextKeyword() const;
|
||||
|
||||
bool switchTemplateArguments(bool templateArguments);
|
||||
|
||||
bool blockErrors(bool block);
|
||||
void warning(unsigned index, const char *format, ...);
|
||||
void error(unsigned index, const char *format, ...);
|
||||
void fatal(unsigned index, const char *format, ...);
|
||||
|
||||
inline const Token &tok(int i = 1) const
|
||||
{ return _translationUnit->tokenAt(_tokenIndex + i - 1); }
|
||||
|
||||
inline int LA(int n = 1) const
|
||||
{ return _translationUnit->tokenKind(_tokenIndex + n - 1); }
|
||||
|
||||
inline int consumeToken()
|
||||
{ return _tokenIndex++; }
|
||||
|
||||
inline unsigned cursor() const
|
||||
{ return _tokenIndex; }
|
||||
|
||||
void rewind(unsigned cursor);
|
||||
|
||||
struct TemplateArgumentListEntry {
|
||||
unsigned index;
|
||||
unsigned cursor;
|
||||
ExpressionListAST *ast;
|
||||
|
||||
TemplateArgumentListEntry(unsigned index = 0, unsigned cursor = 0, ExpressionListAST *ast = 0)
|
||||
: index(index), cursor(cursor), ast(ast) {}
|
||||
};
|
||||
|
||||
TemplateArgumentListEntry *templateArgumentListEntry(unsigned tokenIndex);
|
||||
void clearTemplateArgumentList() { _templateArgumentList.clear(); }
|
||||
|
||||
private:
|
||||
TranslationUnit *_translationUnit;
|
||||
Control *_control;
|
||||
MemoryPool *_pool;
|
||||
unsigned _tokenIndex;
|
||||
bool _templateArguments: 1;
|
||||
bool _qtMocRunEnabled: 1;
|
||||
bool _cxx0xEnabled: 1;
|
||||
bool _objCEnabled: 1;
|
||||
bool _inFunctionBody: 1;
|
||||
bool _inObjCImplementationContext: 1;
|
||||
bool _inExpressionStatement: 1;
|
||||
int _expressionDepth;
|
||||
|
||||
MemoryPool _expressionStatementTempPool;
|
||||
std::map<unsigned, TemplateArgumentListEntry> _templateArgumentList;
|
||||
|
||||
class Rewind;
|
||||
friend class Rewind;
|
||||
|
||||
private:
|
||||
Parser(const Parser& source);
|
||||
void operator =(const Parser& source);
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_PARSER_H
|
202
src/libs/3rdparty/cplusplus/QtContextKeywords.cpp
vendored
Normal file
202
src/libs/3rdparty/cplusplus/QtContextKeywords.cpp
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "QtContextKeywords.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
static inline int classify4(const char *s) {
|
||||
if (s[0] == 'R') {
|
||||
if (s[1] == 'E') {
|
||||
if (s[2] == 'A') {
|
||||
if (s[3] == 'D') {
|
||||
return Token_READ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'U') {
|
||||
if (s[1] == 'S') {
|
||||
if (s[2] == 'E') {
|
||||
if (s[3] == 'R') {
|
||||
return Token_USER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_not_Qt_context_keyword;
|
||||
}
|
||||
|
||||
static inline int classify5(const char *s) {
|
||||
if (s[0] == 'F') {
|
||||
if (s[1] == 'I') {
|
||||
if (s[2] == 'N') {
|
||||
if (s[3] == 'A') {
|
||||
if (s[4] == 'L') {
|
||||
return Token_FINAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'R') {
|
||||
if (s[1] == 'E') {
|
||||
if (s[2] == 'S') {
|
||||
if (s[3] == 'E') {
|
||||
if (s[4] == 'T') {
|
||||
return Token_RESET;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'W') {
|
||||
if (s[1] == 'R') {
|
||||
if (s[2] == 'I') {
|
||||
if (s[3] == 'T') {
|
||||
if (s[4] == 'E') {
|
||||
return Token_WRITE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_not_Qt_context_keyword;
|
||||
}
|
||||
|
||||
static inline int classify6(const char *s) {
|
||||
if (s[0] == 'N') {
|
||||
if (s[1] == 'O') {
|
||||
if (s[2] == 'T') {
|
||||
if (s[3] == 'I') {
|
||||
if (s[4] == 'F') {
|
||||
if (s[5] == 'Y') {
|
||||
return Token_NOTIFY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'S') {
|
||||
if (s[1] == 'T') {
|
||||
if (s[2] == 'O') {
|
||||
if (s[3] == 'R') {
|
||||
if (s[4] == 'E') {
|
||||
if (s[5] == 'D') {
|
||||
return Token_STORED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_not_Qt_context_keyword;
|
||||
}
|
||||
|
||||
static inline int classify8(const char *s) {
|
||||
if (s[0] == 'C') {
|
||||
if (s[1] == 'O') {
|
||||
if (s[2] == 'N') {
|
||||
if (s[3] == 'S') {
|
||||
if (s[4] == 'T') {
|
||||
if (s[5] == 'A') {
|
||||
if (s[6] == 'N') {
|
||||
if (s[7] == 'T') {
|
||||
return Token_CONSTANT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_not_Qt_context_keyword;
|
||||
}
|
||||
|
||||
static inline int classify10(const char *s) {
|
||||
if (s[0] == 'D') {
|
||||
if (s[1] == 'E') {
|
||||
if (s[2] == 'S') {
|
||||
if (s[3] == 'I') {
|
||||
if (s[4] == 'G') {
|
||||
if (s[5] == 'N') {
|
||||
if (s[6] == 'A') {
|
||||
if (s[7] == 'B') {
|
||||
if (s[8] == 'L') {
|
||||
if (s[9] == 'E') {
|
||||
return Token_DESIGNABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (s[0] == 'S') {
|
||||
if (s[1] == 'C') {
|
||||
if (s[2] == 'R') {
|
||||
if (s[3] == 'I') {
|
||||
if (s[4] == 'P') {
|
||||
if (s[5] == 'T') {
|
||||
if (s[6] == 'A') {
|
||||
if (s[7] == 'B') {
|
||||
if (s[8] == 'L') {
|
||||
if (s[9] == 'E') {
|
||||
return Token_SCRIPTABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Token_not_Qt_context_keyword;
|
||||
}
|
||||
|
||||
int CPlusPlus::classifyQtContextKeyword(const char *s, int n) {
|
||||
switch (n) {
|
||||
case 4: return classify4(s);
|
||||
case 5: return classify5(s);
|
||||
case 6: return classify6(s);
|
||||
case 8: return classify8(s);
|
||||
case 10: return classify10(s);
|
||||
default: return Token_not_Qt_context_keyword;
|
||||
} // switch
|
||||
}
|
57
src/libs/3rdparty/cplusplus/QtContextKeywords.h
vendored
Normal file
57
src/libs/3rdparty/cplusplus/QtContextKeywords.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QTCONTEXTKEYWORDS_H
|
||||
#define QTCONTEXTKEYWORDS_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
enum {
|
||||
Token_not_Qt_context_keyword = 0,
|
||||
Token_READ,
|
||||
Token_USER,
|
||||
Token_FINAL,
|
||||
Token_RESET,
|
||||
Token_WRITE,
|
||||
Token_NOTIFY,
|
||||
Token_STORED,
|
||||
Token_CONSTANT,
|
||||
Token_DESIGNABLE,
|
||||
Token_SCRIPTABLE
|
||||
};
|
||||
|
||||
CPLUSPLUS_EXPORT int classifyQtContextKeyword(const char *s, int n);
|
||||
} // namespace CPlusPlus;
|
||||
|
||||
#endif // QTCONTEXTKEYWORDS_H
|
312
src/libs/3rdparty/cplusplus/Scope.cpp
vendored
Normal file
312
src/libs/3rdparty/cplusplus/Scope.cpp
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Scope.h"
|
||||
#include "Symbols.h"
|
||||
#include "Names.h"
|
||||
#include "Literals.h"
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
class CPlusPlus::SymbolTable
|
||||
{
|
||||
SymbolTable(const SymbolTable &other);
|
||||
void operator =(const SymbolTable &other);
|
||||
|
||||
public:
|
||||
typedef Symbol **iterator;
|
||||
|
||||
public:
|
||||
/// Constructs an empty Scope.
|
||||
SymbolTable(Scope *owner = 0);
|
||||
|
||||
/// Destroy this scope.
|
||||
~SymbolTable();
|
||||
|
||||
/// Returns this scope's owner Symbol.
|
||||
Scope *owner() const;
|
||||
|
||||
/// Sets this scope's owner Symbol.
|
||||
void setOwner(Scope *owner); // ### remove me
|
||||
|
||||
/// Adds a Symbol to this Scope.
|
||||
void enterSymbol(Symbol *symbol);
|
||||
|
||||
/// Returns true if this Scope is empty; otherwise returns false.
|
||||
bool isEmpty() const;
|
||||
|
||||
/// Returns the number of symbols is in the scope.
|
||||
unsigned symbolCount() const;
|
||||
|
||||
/// Returns the Symbol at the given position.
|
||||
Symbol *symbolAt(unsigned index) const;
|
||||
|
||||
/// Returns the first Symbol in the scope.
|
||||
iterator firstSymbol() const;
|
||||
|
||||
/// Returns the last Symbol in the scope.
|
||||
iterator lastSymbol() const;
|
||||
|
||||
Symbol *lookat(const Identifier *id) const;
|
||||
Symbol *lookat(OperatorNameId::Kind operatorId) const;
|
||||
|
||||
private:
|
||||
/// Returns the hash value for the given Symbol.
|
||||
unsigned hashValue(Symbol *symbol) const;
|
||||
|
||||
/// Updates the hash table.
|
||||
void rehash();
|
||||
|
||||
private:
|
||||
enum { DefaultInitialSize = 4 };
|
||||
|
||||
Scope *_owner;
|
||||
Symbol **_symbols;
|
||||
Symbol **_hash;
|
||||
int _allocatedSymbols;
|
||||
int _symbolCount;
|
||||
int _hashSize;
|
||||
};
|
||||
|
||||
SymbolTable::SymbolTable(Scope *owner)
|
||||
: _owner(owner),
|
||||
_symbols(0),
|
||||
_hash(0),
|
||||
_allocatedSymbols(0),
|
||||
_symbolCount(-1),
|
||||
_hashSize(0)
|
||||
{ }
|
||||
|
||||
SymbolTable::~SymbolTable()
|
||||
{
|
||||
if (_symbols)
|
||||
free(_symbols);
|
||||
if (_hash)
|
||||
free(_hash);
|
||||
}
|
||||
|
||||
void SymbolTable::enterSymbol(Symbol *symbol)
|
||||
{
|
||||
if (++_symbolCount == _allocatedSymbols) {
|
||||
_allocatedSymbols <<= 1;
|
||||
if (! _allocatedSymbols)
|
||||
_allocatedSymbols = DefaultInitialSize;
|
||||
|
||||
_symbols = reinterpret_cast<Symbol **>(realloc(_symbols, sizeof(Symbol *) * _allocatedSymbols));
|
||||
}
|
||||
|
||||
assert(! symbol->_scope || symbol->enclosingScope() == _owner);
|
||||
symbol->_index = _symbolCount;
|
||||
symbol->_scope = _owner;
|
||||
_symbols[_symbolCount] = symbol;
|
||||
|
||||
if (_symbolCount * 5 >= _hashSize * 3)
|
||||
rehash();
|
||||
else {
|
||||
const unsigned h = hashValue(symbol);
|
||||
symbol->_next = _hash[h];
|
||||
_hash[h] = symbol;
|
||||
}
|
||||
}
|
||||
|
||||
Symbol *SymbolTable::lookat(const Identifier *id) const
|
||||
{
|
||||
if (! _hash || ! id)
|
||||
return 0;
|
||||
|
||||
const unsigned h = id->hashCode() % _hashSize;
|
||||
Symbol *symbol = _hash[h];
|
||||
for (; symbol; symbol = symbol->_next) {
|
||||
const Name *identity = symbol->unqualifiedName();
|
||||
if (! identity) {
|
||||
continue;
|
||||
} else if (const Identifier *nameId = identity->asNameId()) {
|
||||
if (nameId->identifier()->isEqualTo(id))
|
||||
break;
|
||||
} else if (const TemplateNameId *t = identity->asTemplateNameId()) {
|
||||
if (t->identifier()->isEqualTo(id))
|
||||
break;
|
||||
} else if (const DestructorNameId *d = identity->asDestructorNameId()) {
|
||||
if (d->identifier()->isEqualTo(id))
|
||||
break;
|
||||
} else if (identity->isQualifiedNameId()) {
|
||||
return 0;
|
||||
} else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) {
|
||||
if (selectorNameId->identifier()->isEqualTo(id))
|
||||
break;
|
||||
}
|
||||
}
|
||||
return symbol;
|
||||
}
|
||||
|
||||
Symbol *SymbolTable::lookat(OperatorNameId::Kind operatorId) const
|
||||
{
|
||||
if (! _hash)
|
||||
return 0;
|
||||
|
||||
const unsigned h = operatorId % _hashSize;
|
||||
Symbol *symbol = _hash[h];
|
||||
for (; symbol; symbol = symbol->_next) {
|
||||
if (const Name *identity = symbol->unqualifiedName()) {
|
||||
if (const OperatorNameId *op = identity->asOperatorNameId()) {
|
||||
if (op->kind() == operatorId)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return symbol;
|
||||
}
|
||||
|
||||
void SymbolTable::rehash()
|
||||
{
|
||||
_hashSize <<= 1;
|
||||
|
||||
if (! _hashSize)
|
||||
_hashSize = DefaultInitialSize;
|
||||
|
||||
_hash = reinterpret_cast<Symbol **>(realloc(_hash, sizeof(Symbol *) * _hashSize));
|
||||
std::memset(_hash, 0, sizeof(Symbol *) * _hashSize);
|
||||
|
||||
for (int index = 0; index < _symbolCount + 1; ++index) {
|
||||
Symbol *symbol = _symbols[index];
|
||||
const unsigned h = hashValue(symbol);
|
||||
symbol->_next = _hash[h];
|
||||
_hash[h] = symbol;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned SymbolTable::hashValue(Symbol *symbol) const
|
||||
{
|
||||
if (! symbol)
|
||||
return 0;
|
||||
|
||||
return symbol->hashCode() % _hashSize;
|
||||
}
|
||||
|
||||
bool SymbolTable::isEmpty() const
|
||||
{ return _symbolCount == -1; }
|
||||
|
||||
unsigned SymbolTable::symbolCount() const
|
||||
{ return _symbolCount + 1; }
|
||||
|
||||
Symbol *SymbolTable::symbolAt(unsigned index) const
|
||||
{
|
||||
if (! _symbols)
|
||||
return 0;
|
||||
return _symbols[index];
|
||||
}
|
||||
|
||||
SymbolTable::iterator SymbolTable::firstSymbol() const
|
||||
{ return _symbols; }
|
||||
|
||||
SymbolTable::iterator SymbolTable::lastSymbol() const
|
||||
{ return _symbols + _symbolCount + 1; }
|
||||
|
||||
Scope::Scope(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
||||
: Symbol(translationUnit, sourceLocation, name),
|
||||
_members(0),
|
||||
_startOffset(0),
|
||||
_endOffset(0)
|
||||
{ }
|
||||
|
||||
Scope::~Scope()
|
||||
{ delete _members; }
|
||||
|
||||
/// Adds a Symbol to this Scope.
|
||||
void Scope::addMember(Symbol *symbol)
|
||||
{
|
||||
if (! _members)
|
||||
_members = new SymbolTable(this);
|
||||
|
||||
_members->enterSymbol(symbol);
|
||||
}
|
||||
|
||||
/// Returns true if this Scope is empty; otherwise returns false.
|
||||
bool Scope::isEmpty() const
|
||||
{ return _members ? _members->isEmpty() : true; }
|
||||
|
||||
/// Returns the number of symbols is in the scope.
|
||||
unsigned Scope::memberCount() const
|
||||
{ return _members ? _members->symbolCount() : 0; }
|
||||
|
||||
/// Returns the Symbol at the given position.
|
||||
Symbol *Scope::memberAt(unsigned index) const
|
||||
{ return _members ? _members->symbolAt(index) : 0; }
|
||||
|
||||
/// Returns the first Symbol in the scope.
|
||||
Scope::iterator Scope::firstMember() const
|
||||
{ return _members ? _members->firstSymbol() : 0; }
|
||||
|
||||
/// Returns the last Symbol in the scope.
|
||||
Scope::iterator Scope::lastMember() const
|
||||
{ return _members ? _members->lastSymbol() : 0; }
|
||||
|
||||
Symbol *Scope::find(const Identifier *id) const
|
||||
{ return _members ? _members->lookat(id) : 0; }
|
||||
|
||||
Symbol *Scope::find(OperatorNameId::Kind operatorId) const
|
||||
{ return _members ? _members->lookat(operatorId) : 0; }
|
||||
|
||||
/// Set the start offset of the scope
|
||||
unsigned Scope::startOffset() const
|
||||
{ return _startOffset; }
|
||||
|
||||
void Scope::setStartOffset(unsigned offset)
|
||||
{ _startOffset = offset; }
|
||||
|
||||
/// Set the end offset of the scope
|
||||
unsigned Scope::endOffset() const
|
||||
{ return _endOffset; }
|
||||
|
||||
void Scope::setEndOffset(unsigned offset)
|
||||
{ _endOffset = offset; }
|
113
src/libs/3rdparty/cplusplus/Scope.h
vendored
Normal file
113
src/libs/3rdparty/cplusplus/Scope.h
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_SCOPE_H
|
||||
#define CPLUSPLUS_SCOPE_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "Symbol.h"
|
||||
#include "Names.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT Scope: public Symbol
|
||||
{
|
||||
public:
|
||||
Scope(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~Scope();
|
||||
|
||||
/// Adds a Symbol to this Scope.
|
||||
void addMember(Symbol *symbol);
|
||||
|
||||
/// Returns true if this Scope is empty; otherwise returns false.
|
||||
bool isEmpty() const;
|
||||
|
||||
/// Returns the number of symbols is in the scope.
|
||||
unsigned memberCount() const;
|
||||
|
||||
/// Returns the Symbol at the given position.
|
||||
Symbol *memberAt(unsigned index) const;
|
||||
|
||||
typedef Symbol **iterator;
|
||||
|
||||
/// Returns the first Symbol in the scope.
|
||||
iterator firstMember() const;
|
||||
|
||||
/// Returns the last Symbol in the scope.
|
||||
iterator lastMember() const;
|
||||
|
||||
Symbol *find(const Identifier *id) const;
|
||||
Symbol *find(OperatorNameId::Kind operatorId) const;
|
||||
|
||||
/// Set the start offset of the scope
|
||||
unsigned startOffset() const;
|
||||
void setStartOffset(unsigned offset);
|
||||
|
||||
/// Set the end offset of the scope
|
||||
unsigned endOffset() const;
|
||||
void setEndOffset(unsigned offset);
|
||||
|
||||
virtual const Scope *asScope() const
|
||||
{ return this; }
|
||||
|
||||
virtual Scope *asScope()
|
||||
{ return this; }
|
||||
|
||||
private:
|
||||
SymbolTable *_members;
|
||||
unsigned _startOffset;
|
||||
unsigned _endOffset;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_SCOPE_H
|
442
src/libs/3rdparty/cplusplus/Symbol.cpp
vendored
Normal file
442
src/libs/3rdparty/cplusplus/Symbol.cpp
vendored
Normal file
@@ -0,0 +1,442 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Symbol.h"
|
||||
#include "Symbols.h"
|
||||
#include "Control.h"
|
||||
#include "Names.h"
|
||||
#include "TranslationUnit.h"
|
||||
#include "Literals.h"
|
||||
#include "MemoryPool.h"
|
||||
#include "SymbolVisitor.h"
|
||||
#include "NameVisitor.h"
|
||||
#include "Scope.h"
|
||||
#include <cassert>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
class Symbol::HashCode: protected NameVisitor
|
||||
{
|
||||
public:
|
||||
HashCode()
|
||||
: _value(0)
|
||||
{ }
|
||||
|
||||
virtual ~HashCode()
|
||||
{ }
|
||||
|
||||
unsigned operator()(const Name *name)
|
||||
{
|
||||
unsigned previousValue = switchValue(0);
|
||||
accept(name);
|
||||
return switchValue(previousValue);
|
||||
}
|
||||
|
||||
protected:
|
||||
unsigned switchValue(unsigned value)
|
||||
{
|
||||
unsigned previousValue = _value;
|
||||
_value = value;
|
||||
return previousValue;
|
||||
}
|
||||
|
||||
virtual void visit(const Identifier *name)
|
||||
{ _value = name->identifier()->hashCode(); }
|
||||
|
||||
virtual void visit(const TemplateNameId *name)
|
||||
{ _value = name->identifier()->hashCode(); }
|
||||
|
||||
virtual void visit(const DestructorNameId *name)
|
||||
{ _value = name->identifier()->hashCode(); }
|
||||
|
||||
virtual void visit(const OperatorNameId *name)
|
||||
{ _value = unsigned(name->kind()); }
|
||||
|
||||
virtual void visit(const ConversionNameId *)
|
||||
{ _value = 0; } // ### TODO: implement me
|
||||
|
||||
virtual void visit(const QualifiedNameId *name)
|
||||
{ _value = operator()(name->name()); }
|
||||
|
||||
virtual void visit(const SelectorNameId *name)
|
||||
{ _value = name->identifier()->hashCode(); }
|
||||
|
||||
private:
|
||||
unsigned _value;
|
||||
};
|
||||
|
||||
Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
|
||||
: _name(0),
|
||||
_scope(0),
|
||||
_next(0),
|
||||
_fileId(0),
|
||||
_sourceLocation(0),
|
||||
_hashCode(0),
|
||||
_storage(Symbol::NoStorage),
|
||||
_visibility(Symbol::Public),
|
||||
_index(0),
|
||||
_line(0),
|
||||
_column(0),
|
||||
_isGenerated(false),
|
||||
_isDeprecated(false),
|
||||
_isUnavailable(false)
|
||||
{
|
||||
setSourceLocation(sourceLocation, translationUnit);
|
||||
setName(name);
|
||||
}
|
||||
|
||||
Symbol::~Symbol()
|
||||
{ }
|
||||
|
||||
void Symbol::visitSymbol(SymbolVisitor *visitor)
|
||||
{
|
||||
if (visitor->preVisit(this))
|
||||
visitSymbol0(visitor);
|
||||
visitor->postVisit(this);
|
||||
}
|
||||
|
||||
void Symbol::visitSymbol(Symbol *symbol, SymbolVisitor *visitor)
|
||||
{
|
||||
if (! symbol)
|
||||
return;
|
||||
|
||||
symbol->visitSymbol(visitor);
|
||||
}
|
||||
|
||||
unsigned Symbol::sourceLocation() const
|
||||
{ return _sourceLocation; }
|
||||
|
||||
bool Symbol::isGenerated() const
|
||||
{ return _isGenerated; }
|
||||
|
||||
bool Symbol::isDeprecated() const
|
||||
{ return _isDeprecated; }
|
||||
|
||||
void Symbol::setDeprecated(bool isDeprecated)
|
||||
{ _isDeprecated = isDeprecated; }
|
||||
|
||||
bool Symbol::isUnavailable() const
|
||||
{ return _isUnavailable; }
|
||||
|
||||
void Symbol::setUnavailable(bool isUnavailable)
|
||||
{ _isUnavailable = isUnavailable; }
|
||||
|
||||
void Symbol::setSourceLocation(unsigned sourceLocation, TranslationUnit *translationUnit)
|
||||
{
|
||||
_sourceLocation = sourceLocation;
|
||||
|
||||
if (translationUnit) {
|
||||
const Token &tk = translationUnit->tokenAt(sourceLocation);
|
||||
_isGenerated = tk.f.generated;
|
||||
translationUnit->getPosition(tk.offset, &_line, &_column, &_fileId);
|
||||
} else {
|
||||
_isGenerated = false;
|
||||
_line = 0;
|
||||
_column = 0;
|
||||
_fileId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned Symbol::line() const
|
||||
{
|
||||
return _line;
|
||||
}
|
||||
|
||||
unsigned Symbol::column() const
|
||||
{
|
||||
return _column;
|
||||
}
|
||||
|
||||
const StringLiteral *Symbol::fileId() const
|
||||
{
|
||||
return _fileId;
|
||||
}
|
||||
|
||||
const char *Symbol::fileName() const
|
||||
{ return fileId()->chars(); }
|
||||
|
||||
unsigned Symbol::fileNameLength() const
|
||||
{ return fileId()->size(); }
|
||||
|
||||
const Name *Symbol::unqualifiedName() const
|
||||
{
|
||||
if (! _name)
|
||||
return 0;
|
||||
|
||||
else if (const QualifiedNameId *q = _name->asQualifiedNameId())
|
||||
return q->name();
|
||||
|
||||
return _name;
|
||||
}
|
||||
|
||||
const Name *Symbol::name() const
|
||||
{ return _name; }
|
||||
|
||||
void Symbol::setName(const Name *name)
|
||||
{
|
||||
_name = name;
|
||||
|
||||
if (! _name)
|
||||
_hashCode = 0;
|
||||
else {
|
||||
HashCode hh;
|
||||
_hashCode = hh(unqualifiedName());
|
||||
}
|
||||
}
|
||||
|
||||
const Identifier *Symbol::identifier() const
|
||||
{
|
||||
if (_name)
|
||||
return _name->identifier();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Scope *Symbol::enclosingScope() const
|
||||
{ return _scope; }
|
||||
|
||||
void Symbol::setScope(Scope *scope)
|
||||
{
|
||||
assert(! _scope);
|
||||
_scope = scope;
|
||||
}
|
||||
|
||||
Namespace *Symbol::enclosingNamespace() const
|
||||
{
|
||||
for (Scope *s = _scope; s; s = s->enclosingScope()) {
|
||||
if (Namespace *ns = s->asNamespace())
|
||||
return ns;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Template *Symbol::enclosingTemplate() const
|
||||
{
|
||||
for (Scope *s = _scope; s; s = s->enclosingScope()) {
|
||||
if (Template *templ = s->asTemplate())
|
||||
return templ;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Class *Symbol::enclosingClass() const
|
||||
{
|
||||
for (Scope *s = _scope; s; s = s->enclosingScope()) {
|
||||
if (Class *klass = s->asClass())
|
||||
return klass;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Enum *Symbol::enclosingEnum() const
|
||||
{
|
||||
for (Scope *s = _scope; s; s = s->enclosingScope()) {
|
||||
if (Enum *e = s->asEnum())
|
||||
return e;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Function *Symbol::enclosingFunction() const
|
||||
{
|
||||
for (Scope *s = _scope; s; s = s->enclosingScope()) {
|
||||
if (Function *fun = s->asFunction())
|
||||
return fun;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Block *Symbol::enclosingBlock() const
|
||||
{
|
||||
for (Scope *s = _scope; s; s = s->enclosingScope()) {
|
||||
if (Block *block = s->asBlock())
|
||||
return block;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned Symbol::index() const
|
||||
{ return _index; }
|
||||
|
||||
Symbol *Symbol::next() const
|
||||
{ return _next; }
|
||||
|
||||
unsigned Symbol::hashCode() const
|
||||
{ return _hashCode; }
|
||||
|
||||
int Symbol::storage() const
|
||||
{ return _storage; }
|
||||
|
||||
void Symbol::setStorage(int storage)
|
||||
{ _storage = storage; }
|
||||
|
||||
int Symbol::visibility() const
|
||||
{ return _visibility; }
|
||||
|
||||
void Symbol::setVisibility(int visibility)
|
||||
{ _visibility = visibility; }
|
||||
|
||||
bool Symbol::isFriend() const
|
||||
{ return _storage == Friend; }
|
||||
|
||||
bool Symbol::isRegister() const
|
||||
{ return _storage == Register; }
|
||||
|
||||
bool Symbol::isStatic() const
|
||||
{ return _storage == Static; }
|
||||
|
||||
bool Symbol::isExtern() const
|
||||
{ return _storage == Extern; }
|
||||
|
||||
bool Symbol::isMutable() const
|
||||
{ return _storage == Mutable; }
|
||||
|
||||
bool Symbol::isTypedef() const
|
||||
{ return _storage == Typedef; }
|
||||
|
||||
bool Symbol::isPublic() const
|
||||
{ return _visibility == Public; }
|
||||
|
||||
bool Symbol::isProtected() const
|
||||
{ return _visibility == Protected; }
|
||||
|
||||
bool Symbol::isPrivate() const
|
||||
{ return _visibility == Private; }
|
||||
|
||||
bool Symbol::isScope() const
|
||||
{ return asScope() != 0; }
|
||||
|
||||
bool Symbol::isEnum() const
|
||||
{ return asEnum() != 0; }
|
||||
|
||||
bool Symbol::isFunction() const
|
||||
{ return asFunction() != 0; }
|
||||
|
||||
bool Symbol::isNamespace() const
|
||||
{ return asNamespace() != 0; }
|
||||
|
||||
bool Symbol::isTemplate() const
|
||||
{ return asTemplate() != 0; }
|
||||
|
||||
bool Symbol::isClass() const
|
||||
{ return asClass() != 0; }
|
||||
|
||||
bool Symbol::isForwardClassDeclaration() const
|
||||
{ return asForwardClassDeclaration() != 0; }
|
||||
|
||||
bool Symbol::isQtPropertyDeclaration() const
|
||||
{ return asQtPropertyDeclaration() != 0; }
|
||||
|
||||
bool Symbol::isQtEnum() const
|
||||
{ return asQtEnum() != 0; }
|
||||
|
||||
bool Symbol::isBlock() const
|
||||
{ return asBlock() != 0; }
|
||||
|
||||
bool Symbol::isUsingNamespaceDirective() const
|
||||
{ return asUsingNamespaceDirective() != 0; }
|
||||
|
||||
bool Symbol::isUsingDeclaration() const
|
||||
{ return asUsingDeclaration() != 0; }
|
||||
|
||||
bool Symbol::isDeclaration() const
|
||||
{ return asDeclaration() != 0; }
|
||||
|
||||
bool Symbol::isArgument() const
|
||||
{ return asArgument() != 0; }
|
||||
|
||||
bool Symbol::isTypenameArgument() const
|
||||
{ return asTypenameArgument() != 0; }
|
||||
|
||||
bool Symbol::isBaseClass() const
|
||||
{ return asBaseClass() != 0; }
|
||||
|
||||
bool Symbol::isObjCBaseClass() const
|
||||
{ return asObjCBaseClass() != 0; }
|
||||
|
||||
bool Symbol::isObjCBaseProtocol() const
|
||||
{ return asObjCBaseProtocol() != 0; }
|
||||
|
||||
bool Symbol::isObjCClass() const
|
||||
{ return asObjCClass() != 0; }
|
||||
|
||||
bool Symbol::isObjCForwardClassDeclaration() const
|
||||
{ return asObjCForwardClassDeclaration() != 0; }
|
||||
|
||||
bool Symbol::isObjCProtocol() const
|
||||
{ return asObjCProtocol() != 0; }
|
||||
|
||||
bool Symbol::isObjCForwardProtocolDeclaration() const
|
||||
{ return asObjCForwardProtocolDeclaration() != 0; }
|
||||
|
||||
bool Symbol::isObjCMethod() const
|
||||
{ return asObjCMethod() != 0; }
|
||||
|
||||
bool Symbol::isObjCPropertyDeclaration() const
|
||||
{ return asObjCPropertyDeclaration() != 0; }
|
||||
|
||||
void Symbol::copy(Symbol *other)
|
||||
{
|
||||
_sourceLocation = other->_sourceLocation;
|
||||
_name = other->_name;
|
||||
_hashCode = other->_hashCode;
|
||||
_storage = other->_storage;
|
||||
_visibility = other->_visibility;
|
||||
_scope = other->_scope;
|
||||
_index = other->_index;
|
||||
_next = other->_next;
|
||||
_fileId = other->_fileId;
|
||||
_line = other->_line;
|
||||
_column = other->_column;
|
||||
|
||||
_isGenerated = other->_isGenerated;
|
||||
_isDeprecated = other->_isDeprecated;
|
||||
}
|
359
src/libs/3rdparty/cplusplus/Symbol.h
vendored
Normal file
359
src/libs/3rdparty/cplusplus/Symbol.h
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_SYMBOL_H
|
||||
#define CPLUSPLUS_SYMBOL_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT Symbol
|
||||
{
|
||||
Symbol(const Symbol &other);
|
||||
void operator =(const Symbol &other);
|
||||
|
||||
public:
|
||||
/// Storage class specifier
|
||||
enum Storage {
|
||||
NoStorage = 0,
|
||||
Friend,
|
||||
Auto,
|
||||
Register,
|
||||
Static,
|
||||
Extern,
|
||||
Mutable,
|
||||
Typedef
|
||||
};
|
||||
|
||||
/// Access specifier.
|
||||
enum Visibility {
|
||||
Public,
|
||||
Protected,
|
||||
Private,
|
||||
Package
|
||||
};
|
||||
|
||||
public:
|
||||
/// Constructs a Symbol with the given source location, name and translation unit.
|
||||
Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
|
||||
/// Destroy this Symbol.
|
||||
virtual ~Symbol();
|
||||
|
||||
/// Returns this Symbol's source location.
|
||||
unsigned sourceLocation() const;
|
||||
|
||||
/// \returns this Symbol's line number. The line number is 1-based.
|
||||
unsigned line() const;
|
||||
|
||||
/// \returns this Symbol's column number. The column number is 1-based.
|
||||
unsigned column() const;
|
||||
|
||||
/// Returns this Symbol's file name.
|
||||
const StringLiteral *fileId() const;
|
||||
|
||||
/// Returns this Symbol's file name.
|
||||
const char *fileName() const;
|
||||
|
||||
/// Returns this Symbol's file name length.
|
||||
unsigned fileNameLength() const;
|
||||
|
||||
/// Returns this Symbol's name.
|
||||
const Name *name() const;
|
||||
|
||||
/// Sets this Symbol's name.
|
||||
void setName(const Name *name); // ### dangerous
|
||||
|
||||
/// Returns this Symbol's (optional) identifier
|
||||
const Identifier *identifier() const;
|
||||
|
||||
/// Returns this Symbol's storage class specifier.
|
||||
int storage() const;
|
||||
|
||||
/// Sets this Symbol's storage class specifier.
|
||||
void setStorage(int storage);
|
||||
|
||||
/// Returns this Symbol's visibility.
|
||||
int visibility() const;
|
||||
|
||||
/// Sets this Symbol's visibility.
|
||||
void setVisibility(int visibility);
|
||||
|
||||
/// Returns the next chained Symbol.
|
||||
Symbol *next() const;
|
||||
|
||||
/// Returns true if this Symbol has friend storage specifier.
|
||||
bool isFriend() const;
|
||||
|
||||
/// Returns true if this Symbol has register storage specifier.
|
||||
bool isRegister() const;
|
||||
|
||||
/// Returns true if this Symbol has static storage specifier.
|
||||
bool isStatic() const;
|
||||
|
||||
/// Returns true if this Symbol has extern storage specifier.
|
||||
bool isExtern() const;
|
||||
|
||||
/// Returns true if this Symbol has mutable storage specifier.
|
||||
bool isMutable() const;
|
||||
|
||||
/// Returns true if this Symbol has typedef storage specifier.
|
||||
bool isTypedef() const;
|
||||
|
||||
/// Returns true if this Symbol's visibility is public.
|
||||
bool isPublic() const;
|
||||
|
||||
/// Returns true if this Symbol's visibility is protected.
|
||||
bool isProtected() const;
|
||||
|
||||
/// Returns true if this Symbol's visibility is private.
|
||||
bool isPrivate() const;
|
||||
|
||||
/// Returns true if this Symbol is a Scope.
|
||||
bool isScope() const;
|
||||
|
||||
/// Returns true if this Symbol is an Enum.
|
||||
bool isEnum() const;
|
||||
|
||||
/// Returns true if this Symbol is an Function.
|
||||
bool isFunction() const;
|
||||
|
||||
/// Returns true if this Symbol is a Namespace.
|
||||
bool isNamespace() const;
|
||||
|
||||
/// Returns true if this Symbol is a Template.
|
||||
bool isTemplate() const;
|
||||
|
||||
/// Returns true if this Symbol is a Class.
|
||||
bool isClass() const;
|
||||
|
||||
/// Returns true if this Symbol is a Block.
|
||||
bool isBlock() const;
|
||||
|
||||
/// Returns true if this Symbol is a UsingNamespaceDirective.
|
||||
bool isUsingNamespaceDirective() const;
|
||||
|
||||
/// Returns true if this Symbol is a UsingDeclaration.
|
||||
bool isUsingDeclaration() const;
|
||||
|
||||
/// Returns true if this Symbol is a Declaration.
|
||||
bool isDeclaration() const;
|
||||
|
||||
/// Returns true if this Symbol is an Argument.
|
||||
bool isArgument() const;
|
||||
|
||||
/// Returns true if this Symbol is a Typename argument.
|
||||
bool isTypenameArgument() const;
|
||||
|
||||
/// Returns true if this Symbol is a BaseClass.
|
||||
bool isBaseClass() const;
|
||||
|
||||
/// Returns true if this Symbol is a ForwardClassDeclaration.
|
||||
bool isForwardClassDeclaration() const;
|
||||
|
||||
/// Returns true if this Symbol is a QtPropertyDeclaration.
|
||||
bool isQtPropertyDeclaration() const;
|
||||
|
||||
/// Returns true if this Symbol is a QtEnum.
|
||||
bool isQtEnum() const;
|
||||
|
||||
bool isObjCBaseClass() const;
|
||||
bool isObjCBaseProtocol() const;
|
||||
|
||||
/// Returns true if this Symbol is an Objective-C Class declaration.
|
||||
bool isObjCClass() const;
|
||||
|
||||
/// Returns true if this Symbol is an Objective-C Class forward declaration.
|
||||
bool isObjCForwardClassDeclaration() const;
|
||||
|
||||
/// Returns true if this Symbol is an Objective-C Protocol declaration.
|
||||
bool isObjCProtocol() const;
|
||||
|
||||
/// Returns true if this Symbol is an Objective-C Protocol forward declaration.
|
||||
bool isObjCForwardProtocolDeclaration() const;
|
||||
|
||||
/// Returns true if this Symbol is an Objective-C method declaration.
|
||||
bool isObjCMethod() const;
|
||||
|
||||
/// Returns true if this Symbol is an Objective-C @property declaration.
|
||||
bool isObjCPropertyDeclaration() const;
|
||||
|
||||
virtual const Scope *asScope() const { return 0; }
|
||||
virtual const Enum *asEnum() const { return 0; }
|
||||
virtual const Function *asFunction() const { return 0; }
|
||||
virtual const Namespace *asNamespace() const { return 0; }
|
||||
virtual const Template *asTemplate() const { return 0; }
|
||||
virtual const NamespaceAlias *asNamespaceAlias() const { return 0; }
|
||||
virtual const Class *asClass() const { return 0; }
|
||||
virtual const Block *asBlock() const { return 0; }
|
||||
virtual const UsingNamespaceDirective *asUsingNamespaceDirective() const { return 0; }
|
||||
virtual const UsingDeclaration *asUsingDeclaration() const { return 0; }
|
||||
virtual const Declaration *asDeclaration() const { return 0; }
|
||||
virtual const Argument *asArgument() const { return 0; }
|
||||
virtual const TypenameArgument *asTypenameArgument() const { return 0; }
|
||||
virtual const BaseClass *asBaseClass() const { return 0; }
|
||||
virtual const ForwardClassDeclaration *asForwardClassDeclaration() const { return 0; }
|
||||
virtual const QtPropertyDeclaration *asQtPropertyDeclaration() const { return 0; }
|
||||
virtual const QtEnum *asQtEnum() const { return 0; }
|
||||
virtual const ObjCBaseClass *asObjCBaseClass() const { return 0; }
|
||||
virtual const ObjCBaseProtocol *asObjCBaseProtocol() const { return 0; }
|
||||
virtual const ObjCClass *asObjCClass() const { return 0; }
|
||||
virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() const { return 0; }
|
||||
virtual const ObjCProtocol *asObjCProtocol() const { return 0; }
|
||||
virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() const { return 0; }
|
||||
virtual const ObjCMethod *asObjCMethod() const { return 0; }
|
||||
virtual const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const { return 0; }
|
||||
|
||||
virtual Scope *asScope() { return 0; }
|
||||
virtual Enum *asEnum() { return 0; }
|
||||
virtual Function *asFunction() { return 0; }
|
||||
virtual Namespace *asNamespace() { return 0; }
|
||||
virtual Template *asTemplate() { return 0; }
|
||||
virtual NamespaceAlias *asNamespaceAlias() { return 0; }
|
||||
virtual Class *asClass() { return 0; }
|
||||
virtual Block *asBlock() { return 0; }
|
||||
virtual UsingNamespaceDirective *asUsingNamespaceDirective() { return 0; }
|
||||
virtual UsingDeclaration *asUsingDeclaration() { return 0; }
|
||||
virtual Declaration *asDeclaration() { return 0; }
|
||||
virtual Argument *asArgument() { return 0; }
|
||||
virtual TypenameArgument *asTypenameArgument() { return 0; }
|
||||
virtual BaseClass *asBaseClass() { return 0; }
|
||||
virtual ForwardClassDeclaration *asForwardClassDeclaration() { return 0; }
|
||||
virtual QtPropertyDeclaration *asQtPropertyDeclaration() { return 0; }
|
||||
virtual QtEnum *asQtEnum() { return 0; }
|
||||
virtual ObjCBaseClass *asObjCBaseClass() { return 0; }
|
||||
virtual ObjCBaseProtocol *asObjCBaseProtocol() { return 0; }
|
||||
virtual ObjCClass *asObjCClass() { return 0; }
|
||||
virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() { return 0; }
|
||||
virtual ObjCProtocol *asObjCProtocol() { return 0; }
|
||||
virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() { return 0; }
|
||||
virtual ObjCMethod *asObjCMethod() { return 0; }
|
||||
virtual ObjCPropertyDeclaration *asObjCPropertyDeclaration() { return 0; }
|
||||
|
||||
/// Returns this Symbol's type.
|
||||
virtual FullySpecifiedType type() const = 0;
|
||||
|
||||
/// Returns this Symbol's hash value.
|
||||
unsigned hashCode() const;
|
||||
|
||||
/// Returns this Symbol's index.
|
||||
unsigned index() const;
|
||||
|
||||
const Name *unqualifiedName() const;
|
||||
|
||||
bool isGenerated() const;
|
||||
|
||||
bool isDeprecated() const;
|
||||
void setDeprecated(bool isDeprecated);
|
||||
|
||||
bool isUnavailable() const;
|
||||
void setUnavailable(bool isUnavailable);
|
||||
|
||||
/// Returns this Symbol's eclosing scope.
|
||||
Scope *enclosingScope() const;
|
||||
|
||||
/// Returns the eclosing namespace scope.
|
||||
Namespace *enclosingNamespace() const;
|
||||
|
||||
/// Returns the eclosing template scope.
|
||||
Template *enclosingTemplate() const;
|
||||
|
||||
/// Returns the enclosing class scope.
|
||||
Class *enclosingClass() const;
|
||||
|
||||
/// Returns the enclosing enum scope.
|
||||
Enum *enclosingEnum() const;
|
||||
|
||||
/// Returns the enclosing prototype scope.
|
||||
Function *enclosingFunction() const;
|
||||
|
||||
/// Returns the enclosing Block scope.
|
||||
Block *enclosingBlock() const;
|
||||
|
||||
void setScope(Scope *enclosingScope); // ### make me private
|
||||
void setSourceLocation(unsigned sourceLocation, TranslationUnit *translationUnit); // ### make me private
|
||||
|
||||
void visitSymbol(SymbolVisitor *visitor);
|
||||
static void visitSymbol(Symbol *symbol, SymbolVisitor *visitor);
|
||||
|
||||
virtual void copy(Symbol *other);
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor) = 0;
|
||||
|
||||
private:
|
||||
const Name *_name;
|
||||
Scope *_scope;
|
||||
Symbol *_next;
|
||||
const StringLiteral *_fileId;
|
||||
unsigned _sourceLocation;
|
||||
unsigned _hashCode;
|
||||
int _storage;
|
||||
int _visibility;
|
||||
unsigned _index;
|
||||
unsigned _line;
|
||||
unsigned _column;
|
||||
|
||||
bool _isGenerated: 1;
|
||||
bool _isDeprecated: 1;
|
||||
bool _isUnavailable: 1;
|
||||
|
||||
class HashCode;
|
||||
|
||||
friend class SymbolTable;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_SYMBOL_H
|
65
src/libs/3rdparty/cplusplus/SymbolVisitor.cpp
vendored
Normal file
65
src/libs/3rdparty/cplusplus/SymbolVisitor.cpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "SymbolVisitor.h"
|
||||
#include "Symbol.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
SymbolVisitor::SymbolVisitor()
|
||||
{ }
|
||||
|
||||
SymbolVisitor::~SymbolVisitor()
|
||||
{ }
|
||||
|
||||
void SymbolVisitor::accept(Symbol *symbol)
|
||||
{ Symbol::visitSymbol(symbol, this); }
|
||||
|
107
src/libs/3rdparty/cplusplus/SymbolVisitor.h
vendored
Normal file
107
src/libs/3rdparty/cplusplus/SymbolVisitor.h
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef SYMBOLVISITOR_H
|
||||
#define SYMBOLVISITOR_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT SymbolVisitor
|
||||
{
|
||||
SymbolVisitor(const SymbolVisitor &other);
|
||||
void operator =(const SymbolVisitor &other);
|
||||
|
||||
public:
|
||||
SymbolVisitor();
|
||||
virtual ~SymbolVisitor();
|
||||
|
||||
void accept(Symbol *symbol);
|
||||
|
||||
virtual bool preVisit(Symbol *) { return true; }
|
||||
virtual void postVisit(Symbol *) {}
|
||||
|
||||
virtual bool visit(UsingNamespaceDirective *) { return true; }
|
||||
virtual bool visit(UsingDeclaration *) { return true; }
|
||||
virtual bool visit(NamespaceAlias *) { return true; }
|
||||
virtual bool visit(Declaration *) { return true; }
|
||||
virtual bool visit(Argument *) { return true; }
|
||||
virtual bool visit(TypenameArgument *) { return true; }
|
||||
virtual bool visit(BaseClass *) { return true; }
|
||||
virtual bool visit(Enum *) { return true; }
|
||||
virtual bool visit(Function *) { return true; }
|
||||
virtual bool visit(Namespace *) { return true; }
|
||||
virtual bool visit(Template *) { return true; }
|
||||
virtual bool visit(Class *) { return true; }
|
||||
virtual bool visit(Block *) { return true; }
|
||||
virtual bool visit(ForwardClassDeclaration *) { return true; }
|
||||
|
||||
// Qt
|
||||
virtual bool visit(QtPropertyDeclaration *) { return true; }
|
||||
virtual bool visit(QtEnum *) { return true; }
|
||||
|
||||
// Objective-C
|
||||
virtual bool visit(ObjCBaseClass *) { return true; }
|
||||
virtual bool visit(ObjCBaseProtocol *) { return true; }
|
||||
virtual bool visit(ObjCClass *) { return true; }
|
||||
virtual bool visit(ObjCForwardClassDeclaration *) { return true; }
|
||||
virtual bool visit(ObjCProtocol *) { return true; }
|
||||
virtual bool visit(ObjCForwardProtocolDeclaration *) { return true; }
|
||||
virtual bool visit(ObjCMethod *) { return true; }
|
||||
virtual bool visit(ObjCPropertyDeclaration *) { return true; }
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // SYMBOLVISITOR_H
|
1119
src/libs/3rdparty/cplusplus/Symbols.cpp
vendored
Normal file
1119
src/libs/3rdparty/cplusplus/Symbols.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
910
src/libs/3rdparty/cplusplus/Symbols.h
vendored
Normal file
910
src/libs/3rdparty/cplusplus/Symbols.h
vendored
Normal file
@@ -0,0 +1,910 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_SYMBOLS_H
|
||||
#define CPLUSPLUS_SYMBOLS_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "Symbol.h"
|
||||
#include "Type.h"
|
||||
#include "FullySpecifiedType.h"
|
||||
#include "Scope.h"
|
||||
#include <vector>
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol
|
||||
{
|
||||
public:
|
||||
UsingNamespaceDirective(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~UsingNamespaceDirective();
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const UsingNamespaceDirective *asUsingNamespaceDirective() const
|
||||
{ return this; }
|
||||
|
||||
virtual UsingNamespaceDirective *asUsingNamespaceDirective()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT UsingDeclaration: public Symbol
|
||||
{
|
||||
public:
|
||||
UsingDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~UsingDeclaration();
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const UsingDeclaration *asUsingDeclaration() const
|
||||
{ return this; }
|
||||
|
||||
virtual UsingDeclaration *asUsingDeclaration()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT NamespaceAlias: public Symbol
|
||||
{
|
||||
public:
|
||||
NamespaceAlias(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~NamespaceAlias();
|
||||
|
||||
const Name *namespaceName() const;
|
||||
void setNamespaceName(const Name *namespaceName);
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const NamespaceAlias *asNamespaceAlias() const
|
||||
{ return this; }
|
||||
|
||||
virtual NamespaceAlias *asNamespaceAlias()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
|
||||
private:
|
||||
const Name *_namespaceName;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Declaration: public Symbol
|
||||
{
|
||||
public:
|
||||
Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~Declaration();
|
||||
|
||||
void setType(const FullySpecifiedType &type);
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const Declaration *asDeclaration() const
|
||||
{ return this; }
|
||||
|
||||
virtual Declaration *asDeclaration()
|
||||
{ return this; }
|
||||
|
||||
virtual EnumeratorDeclaration *asEnumeratorDeclarator()
|
||||
{ return 0; }
|
||||
|
||||
virtual const EnumeratorDeclaration *asEnumeratorDeclarator() const
|
||||
{ return 0; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
|
||||
private:
|
||||
FullySpecifiedType _type;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT EnumeratorDeclaration: public Declaration
|
||||
{
|
||||
public:
|
||||
EnumeratorDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~EnumeratorDeclaration();
|
||||
|
||||
const StringLiteral *constantValue() const;
|
||||
void setConstantValue(const StringLiteral *constantValue);
|
||||
|
||||
virtual EnumeratorDeclaration *asEnumeratorDeclarator()
|
||||
{ return this; }
|
||||
|
||||
virtual const EnumeratorDeclaration *asEnumeratorDeclarator() const
|
||||
{ return this; }
|
||||
|
||||
private:
|
||||
const StringLiteral *_constantValue;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Argument: public Symbol
|
||||
{
|
||||
public:
|
||||
Argument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~Argument();
|
||||
|
||||
void setType(const FullySpecifiedType &type);
|
||||
|
||||
bool hasInitializer() const;
|
||||
|
||||
const StringLiteral *initializer() const;
|
||||
void setInitializer(const StringLiteral *initializer);
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const Argument *asArgument() const
|
||||
{ return this; }
|
||||
|
||||
virtual Argument *asArgument()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
|
||||
private:
|
||||
const StringLiteral *_initializer;
|
||||
FullySpecifiedType _type;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT TypenameArgument: public Symbol
|
||||
{
|
||||
public:
|
||||
TypenameArgument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~TypenameArgument();
|
||||
|
||||
void setType(const FullySpecifiedType &type);
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const TypenameArgument *asTypenameArgument() const
|
||||
{ return this; }
|
||||
|
||||
virtual TypenameArgument *asTypenameArgument()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
|
||||
private:
|
||||
FullySpecifiedType _type;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Block: public Scope
|
||||
{
|
||||
public:
|
||||
Block(TranslationUnit *translationUnit, unsigned sourceLocation);
|
||||
virtual ~Block();
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const Block *asBlock() const
|
||||
{ return this; }
|
||||
|
||||
virtual Block *asBlock()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ForwardClassDeclaration: public Symbol, public Type
|
||||
{
|
||||
public:
|
||||
ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~ForwardClassDeclaration();
|
||||
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const ForwardClassDeclaration *asForwardClassDeclaration() const
|
||||
{ return this; }
|
||||
|
||||
virtual ForwardClassDeclaration *asForwardClassDeclaration()
|
||||
{ return this; }
|
||||
|
||||
virtual const ForwardClassDeclaration *asForwardClassDeclarationType() const
|
||||
{ return this; }
|
||||
|
||||
virtual ForwardClassDeclaration *asForwardClassDeclarationType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Enum: public Scope, public Type
|
||||
{
|
||||
public:
|
||||
Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~Enum();
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
// Type's interface
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const Enum *asEnum() const
|
||||
{ return this; }
|
||||
|
||||
virtual Enum *asEnum()
|
||||
{ return this; }
|
||||
|
||||
virtual const Enum *asEnumType() const
|
||||
{ return this; }
|
||||
|
||||
virtual Enum *asEnumType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Function: public Scope, public Type
|
||||
{
|
||||
public:
|
||||
enum MethodKey {
|
||||
NormalMethod,
|
||||
SlotMethod,
|
||||
SignalMethod,
|
||||
InvokableMethod
|
||||
};
|
||||
|
||||
public:
|
||||
Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~Function();
|
||||
|
||||
bool isNormal() const;
|
||||
bool isSignal() const;
|
||||
bool isSlot() const;
|
||||
bool isInvokable() const;
|
||||
int methodKey() const;
|
||||
void setMethodKey(int key);
|
||||
|
||||
FullySpecifiedType returnType() const;
|
||||
void setReturnType(const FullySpecifiedType &returnType);
|
||||
|
||||
/** Convenience function that returns whether the function returns something (including void). */
|
||||
bool hasReturnType() const;
|
||||
|
||||
unsigned argumentCount() const;
|
||||
Symbol *argumentAt(unsigned index) const;
|
||||
|
||||
/** Convenience function that returns whether the function receives any arguments. */
|
||||
bool hasArguments() const;
|
||||
unsigned minimumArgumentCount() const;
|
||||
|
||||
bool isVirtual() const;
|
||||
void setVirtual(bool isVirtual);
|
||||
|
||||
bool isVariadic() const;
|
||||
void setVariadic(bool isVariadic);
|
||||
|
||||
bool isConst() const;
|
||||
void setConst(bool isConst);
|
||||
|
||||
bool isVolatile() const;
|
||||
void setVolatile(bool isVolatile);
|
||||
|
||||
bool isPureVirtual() const;
|
||||
void setPureVirtual(bool isPureVirtual);
|
||||
|
||||
#ifdef ICHECK_BUILD
|
||||
bool isEqualTo(const Function* fct, bool ignoreName = false) const;
|
||||
#endif
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
// Type's interface
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const Function *asFunction() const
|
||||
{ return this; }
|
||||
|
||||
virtual Function *asFunction()
|
||||
{ return this; }
|
||||
|
||||
virtual const Function *asFunctionType() const
|
||||
{ return this; }
|
||||
|
||||
virtual Function *asFunctionType()
|
||||
{ return this; }
|
||||
|
||||
bool isAmbiguous() const; // internal
|
||||
void setAmbiguous(bool isAmbiguous); // internal
|
||||
|
||||
bool maybeValidPrototype(unsigned actualArgumentCount) const;
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
FullySpecifiedType _returnType;
|
||||
struct Flags {
|
||||
unsigned _isVirtual: 1;
|
||||
unsigned _isVariadic: 1;
|
||||
unsigned _isPureVirtual: 1;
|
||||
unsigned _isConst: 1;
|
||||
unsigned _isVolatile: 1;
|
||||
unsigned _isAmbiguous: 1;
|
||||
unsigned _methodKey: 3;
|
||||
};
|
||||
union {
|
||||
unsigned _flags;
|
||||
Flags f;
|
||||
};
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Template: public Scope, public Type
|
||||
{
|
||||
public:
|
||||
Template(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~Template();
|
||||
|
||||
unsigned templateParameterCount() const;
|
||||
Symbol *templateParameterAt(unsigned index) const;
|
||||
Symbol *declaration() const;
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
// Type's interface
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const Template *asTemplate() const
|
||||
{ return this; }
|
||||
|
||||
virtual Template *asTemplate()
|
||||
{ return this; }
|
||||
|
||||
virtual const Template *asTemplateType() const
|
||||
{ return this; }
|
||||
|
||||
virtual Template *asTemplateType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
};
|
||||
|
||||
|
||||
class CPLUSPLUS_EXPORT Namespace: public Scope, public Type
|
||||
{
|
||||
public:
|
||||
Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~Namespace();
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
// Type's interface
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const Namespace *asNamespace() const
|
||||
{ return this; }
|
||||
|
||||
virtual Namespace *asNamespace()
|
||||
{ return this; }
|
||||
|
||||
virtual const Namespace *asNamespaceType() const
|
||||
{ return this; }
|
||||
|
||||
virtual Namespace *asNamespaceType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT BaseClass: public Symbol
|
||||
{
|
||||
public:
|
||||
BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~BaseClass();
|
||||
|
||||
bool isVirtual() const;
|
||||
void setVirtual(bool isVirtual);
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
void setType(const FullySpecifiedType &type);
|
||||
|
||||
virtual const BaseClass *asBaseClass() const
|
||||
{ return this; }
|
||||
|
||||
virtual BaseClass *asBaseClass()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
|
||||
private:
|
||||
bool _isVirtual;
|
||||
FullySpecifiedType _type;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Class: public Scope, public Type
|
||||
{
|
||||
public:
|
||||
Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~Class();
|
||||
|
||||
enum Key {
|
||||
ClassKey,
|
||||
StructKey,
|
||||
UnionKey
|
||||
};
|
||||
|
||||
bool isClass() const;
|
||||
bool isStruct() const;
|
||||
bool isUnion() const;
|
||||
Key classKey() const;
|
||||
void setClassKey(Key key);
|
||||
|
||||
unsigned baseClassCount() const;
|
||||
BaseClass *baseClassAt(unsigned index) const;
|
||||
void addBaseClass(BaseClass *baseClass);
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
// Type's interface
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const Class *asClass() const
|
||||
{ return this; }
|
||||
|
||||
virtual Class *asClass()
|
||||
{ return this; }
|
||||
|
||||
virtual const Class *asClassType() const
|
||||
{ return this; }
|
||||
|
||||
virtual Class *asClassType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
Key _key;
|
||||
std::vector<BaseClass *> _baseClasses;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT QtPropertyDeclaration: public Symbol
|
||||
{
|
||||
public:
|
||||
enum Flag {
|
||||
NoFlags = 0,
|
||||
ReadFunction = 1 << 0,
|
||||
WriteFunction = 1 << 1,
|
||||
ResetFunction = 1 << 2,
|
||||
NotifyFunction = 1 << 3,
|
||||
DesignableFlag = 1 << 4,
|
||||
DesignableFunction = 1 << 5,
|
||||
ScriptableFlag = 1 << 6,
|
||||
ScriptableFunction = 1 << 7,
|
||||
StoredFlag = 1 << 8,
|
||||
StoredFunction = 1 << 9,
|
||||
UserFlag = 1 << 10,
|
||||
UserFunction = 1 << 11,
|
||||
ConstantFlag = 1 << 12,
|
||||
FinalFlag = 1 << 13,
|
||||
};
|
||||
|
||||
public:
|
||||
QtPropertyDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~QtPropertyDeclaration();
|
||||
|
||||
void setType(const FullySpecifiedType &type);
|
||||
|
||||
void setFlags(int flags);
|
||||
int flags() const;
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const QtPropertyDeclaration *asQtPropertyDeclaration() const
|
||||
{ return this; }
|
||||
|
||||
virtual QtPropertyDeclaration *asQtPropertyDeclaration()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
|
||||
private:
|
||||
FullySpecifiedType _type;
|
||||
int _flags;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT QtEnum: public Symbol
|
||||
{
|
||||
public:
|
||||
QtEnum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~QtEnum();
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const QtEnum *asQtEnum() const
|
||||
{ return this; }
|
||||
|
||||
virtual QtEnum *asQtEnum()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ObjCBaseClass: public Symbol
|
||||
{
|
||||
public:
|
||||
ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~ObjCBaseClass();
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const ObjCBaseClass *asObjCBaseClass() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCBaseClass *asObjCBaseClass()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ObjCBaseProtocol: public Symbol
|
||||
{
|
||||
public:
|
||||
ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~ObjCBaseProtocol();
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const ObjCBaseProtocol *asObjCBaseProtocol() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCBaseProtocol *asObjCBaseProtocol()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol, public Type
|
||||
{
|
||||
public:
|
||||
ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~ObjCForwardProtocolDeclaration();
|
||||
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclaration()
|
||||
{ return this; }
|
||||
|
||||
virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ObjCProtocol: public Scope, public Type
|
||||
{
|
||||
public:
|
||||
ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~ObjCProtocol();
|
||||
|
||||
unsigned protocolCount() const;
|
||||
ObjCBaseProtocol *protocolAt(unsigned index) const;
|
||||
void addProtocol(ObjCBaseProtocol *protocol);
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
// Type's interface
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const ObjCProtocol *asObjCProtocol() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCProtocol *asObjCProtocol()
|
||||
{ return this; }
|
||||
|
||||
virtual const ObjCProtocol *asObjCProtocolType() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCProtocol *asObjCProtocolType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
std::vector<ObjCBaseProtocol *> _protocols;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol, public Type
|
||||
{
|
||||
public:
|
||||
ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~ObjCForwardClassDeclaration();
|
||||
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclaration() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclaration()
|
||||
{ return this; }
|
||||
|
||||
virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ObjCClass: public Scope, public Type
|
||||
{
|
||||
public:
|
||||
ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~ObjCClass();
|
||||
|
||||
bool isInterface() const;
|
||||
void setInterface(bool isInterface);
|
||||
|
||||
bool isCategory() const;
|
||||
const Name *categoryName() const;
|
||||
void setCategoryName(const Name *categoryName);
|
||||
|
||||
ObjCBaseClass *baseClass() const;
|
||||
void setBaseClass(ObjCBaseClass *baseClass);
|
||||
|
||||
unsigned protocolCount() const;
|
||||
ObjCBaseProtocol *protocolAt(unsigned index) const;
|
||||
void addProtocol(ObjCBaseProtocol *protocol);
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
// Type's interface
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const ObjCClass *asObjCClass() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCClass *asObjCClass()
|
||||
{ return this; }
|
||||
|
||||
virtual const ObjCClass *asObjCClassType() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCClass *asObjCClassType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
const Name *_categoryName;
|
||||
ObjCBaseClass * _baseClass;
|
||||
std::vector<ObjCBaseProtocol *> _protocols;
|
||||
bool _isInterface;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ObjCMethod: public Scope, public Type
|
||||
{
|
||||
public:
|
||||
ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
|
||||
virtual ~ObjCMethod();
|
||||
|
||||
FullySpecifiedType returnType() const;
|
||||
void setReturnType(const FullySpecifiedType &returnType);
|
||||
|
||||
/** Convenience function that returns whether the function returns something (including void). */
|
||||
bool hasReturnType() const;
|
||||
|
||||
unsigned argumentCount() const;
|
||||
Symbol *argumentAt(unsigned index) const;
|
||||
|
||||
/** Convenience function that returns whether the function receives any arguments. */
|
||||
bool hasArguments() const;
|
||||
|
||||
bool isVariadic() const;
|
||||
void setVariadic(bool isVariadic);
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
// Type's interface
|
||||
virtual bool isEqualTo(const Type *other) const;
|
||||
|
||||
virtual const ObjCMethod *asObjCMethod() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCMethod *asObjCMethod()
|
||||
{ return this; }
|
||||
|
||||
virtual const ObjCMethod *asObjCMethodType() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCMethod *asObjCMethodType()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
virtual void accept0(TypeVisitor *visitor);
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
private:
|
||||
FullySpecifiedType _returnType;
|
||||
struct Flags {
|
||||
unsigned _isVariadic: 1;
|
||||
};
|
||||
union {
|
||||
unsigned _flags;
|
||||
Flags f;
|
||||
};
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT ObjCPropertyDeclaration: public Symbol
|
||||
{
|
||||
public:
|
||||
enum PropertyAttributes {
|
||||
None = 0,
|
||||
Assign = 1 << 0,
|
||||
Retain = 1 << 1,
|
||||
Copy = 1 << 2,
|
||||
ReadOnly = 1 << 3,
|
||||
ReadWrite = 1 << 4,
|
||||
Getter = 1 << 5,
|
||||
Setter = 1 << 6,
|
||||
NonAtomic = 1 << 7,
|
||||
|
||||
WritabilityMask = ReadOnly | ReadWrite,
|
||||
SetterSemanticsMask = Assign | Retain | Copy
|
||||
};
|
||||
|
||||
public:
|
||||
ObjCPropertyDeclaration(TranslationUnit *translationUnit,
|
||||
unsigned sourceLocation,
|
||||
const Name *name);
|
||||
virtual ~ObjCPropertyDeclaration();
|
||||
|
||||
bool hasAttribute(int attribute) const;
|
||||
void setAttributes(int attributes);
|
||||
|
||||
bool hasGetter() const;
|
||||
bool hasSetter() const;
|
||||
|
||||
const Name *getterName() const;
|
||||
|
||||
void setGetterName(const Name *getterName);
|
||||
|
||||
const Name *setterName() const;
|
||||
void setSetterName(const Name *setterName);
|
||||
|
||||
void setType(const FullySpecifiedType &type);
|
||||
|
||||
// Symbol's interface
|
||||
virtual FullySpecifiedType type() const;
|
||||
|
||||
virtual const ObjCPropertyDeclaration *asObjCPropertyDeclaration() const
|
||||
{ return this; }
|
||||
|
||||
virtual ObjCPropertyDeclaration *asObjCPropertyDeclaration()
|
||||
{ return this; }
|
||||
|
||||
protected:
|
||||
virtual void visitSymbol0(SymbolVisitor *visitor);
|
||||
|
||||
private:
|
||||
const Name *_getterName;
|
||||
const Name *_setterName;
|
||||
FullySpecifiedType _type;
|
||||
int _propertyAttributes;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_SYMBOLS_H
|
144
src/libs/3rdparty/cplusplus/Token.cpp
vendored
Normal file
144
src/libs/3rdparty/cplusplus/Token.cpp
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Token.h"
|
||||
#include "Literals.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
static const char *token_names[] = {
|
||||
(""), ("<error>"),
|
||||
|
||||
("<C++ comment>"), ("<C++ doxy comment>"),
|
||||
("<comment>"), ("<doxy comment>"),
|
||||
|
||||
("<identifier>"), ("<numeric literal>"), ("<char literal>"),
|
||||
("<wide char literal>"), ("<string literal>"), ("<wide char literal>"),
|
||||
("<@string literal>"), ("<angle string literal>"),
|
||||
|
||||
("&"), ("&&"), ("&="), ("->"), ("->*"), ("^"), ("^="), (":"), ("::"),
|
||||
(","), ("/"), ("/="), ("."), ("..."), (".*"), ("="), ("=="), ("!"),
|
||||
("!="), (">"), (">="), (">>"), (">>="), ("{"), ("["), ("<"), ("<="),
|
||||
("<<"), ("<<="), ("("), ("-"), ("-="), ("--"), ("%"), ("%="), ("|"),
|
||||
("|="), ("||"), ("+"), ("+="), ("++"), ("#"), ("##"), ("?"), ("}"),
|
||||
("]"), (")"), (";"), ("*"), ("*="), ("~"), ("~="),
|
||||
|
||||
("asm"), ("auto"), ("bool"), ("break"), ("case"), ("catch"), ("char"),
|
||||
("class"), ("const"), ("const_cast"), ("continue"), ("default"),
|
||||
("delete"), ("do"), ("double"), ("dynamic_cast"), ("else"), ("enum"),
|
||||
("explicit"), ("export"), ("extern"), ("false"), ("float"), ("for"),
|
||||
("friend"), ("goto"), ("if"), ("inline"), ("int"), ("long"),
|
||||
("mutable"), ("namespace"), ("new"), ("operator"), ("private"),
|
||||
("protected"), ("public"), ("register"), ("reinterpret_cast"),
|
||||
("return"), ("short"), ("signed"), ("sizeof"), ("static"),
|
||||
("static_cast"), ("struct"), ("switch"), ("template"), ("this"),
|
||||
("throw"), ("true"), ("try"), ("typedef"), ("typeid"), ("typename"),
|
||||
("union"), ("unsigned"), ("using"), ("virtual"), ("void"),
|
||||
("volatile"), ("wchar_t"), ("while"),
|
||||
|
||||
// gnu
|
||||
("__attribute__"), ("__typeof__"),
|
||||
|
||||
// objc @keywords
|
||||
("@catch"), ("@class"), ("@compatibility_alias"), ("@defs"), ("@dynamic"),
|
||||
("@encode"), ("@end"), ("@finally"), ("@implementation"), ("@interface"),
|
||||
("@not_keyword"), ("@optional"), ("@package"), ("@private"), ("@property"),
|
||||
("@protected"), ("@protocol"), ("@public"), ("@required"), ("@selector"),
|
||||
("@synchronized"), ("@synthesize"), ("@throw"), ("@try"),
|
||||
|
||||
// Qt keywords
|
||||
("SIGNAL"), ("SLOT"), ("Q_SIGNAL"), ("Q_SLOT"), ("signals"), ("slots"),
|
||||
("Q_FOREACH"), ("Q_D"), ("Q_Q"),
|
||||
("Q_INVOKABLE"), ("Q_PROPERTY"), ("Q_INTERFACES"), ("Q_ENUMS"), ("Q_FLAGS"),
|
||||
("Q_PRIVATE_SLOT"), ("Q_DECLARE_INTERFACE"), ("Q_OBJECT"), ("Q_GADGET"),
|
||||
|
||||
};
|
||||
|
||||
Token::Token() :
|
||||
flags(0), offset(0), ptr(0)
|
||||
{
|
||||
}
|
||||
|
||||
Token::~Token()
|
||||
{
|
||||
}
|
||||
|
||||
void Token::reset()
|
||||
{
|
||||
flags = 0;
|
||||
offset = 0;
|
||||
ptr = 0;
|
||||
}
|
||||
|
||||
const char *Token::name(int kind)
|
||||
{ return token_names[kind]; }
|
||||
|
||||
const char *Token::spell() const
|
||||
{
|
||||
switch (f.kind) {
|
||||
case T_IDENTIFIER:
|
||||
return identifier->chars();
|
||||
|
||||
case T_NUMERIC_LITERAL:
|
||||
case T_CHAR_LITERAL:
|
||||
case T_STRING_LITERAL:
|
||||
case T_AT_STRING_LITERAL:
|
||||
case T_ANGLE_STRING_LITERAL:
|
||||
case T_WIDE_CHAR_LITERAL:
|
||||
case T_WIDE_STRING_LITERAL:
|
||||
return literal->chars();
|
||||
|
||||
default:
|
||||
return token_names[f.kind];
|
||||
} // switch
|
||||
}
|
||||
|
||||
|
362
src/libs/3rdparty/cplusplus/Token.h
vendored
Normal file
362
src/libs/3rdparty/cplusplus/Token.h
vendored
Normal file
@@ -0,0 +1,362 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_TOKEN_H
|
||||
#define CPLUSPLUS_TOKEN_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
enum Kind {
|
||||
T_EOF_SYMBOL = 0,
|
||||
T_ERROR,
|
||||
|
||||
T_CPP_COMMENT,
|
||||
T_CPP_DOXY_COMMENT,
|
||||
T_COMMENT,
|
||||
T_DOXY_COMMENT,
|
||||
T_IDENTIFIER,
|
||||
|
||||
T_FIRST_LITERAL,
|
||||
T_NUMERIC_LITERAL = T_FIRST_LITERAL,
|
||||
T_CHAR_LITERAL,
|
||||
T_WIDE_CHAR_LITERAL,
|
||||
T_STRING_LITERAL,
|
||||
T_WIDE_STRING_LITERAL,
|
||||
T_AT_STRING_LITERAL,
|
||||
T_ANGLE_STRING_LITERAL,
|
||||
T_LAST_LITERAL = T_ANGLE_STRING_LITERAL,
|
||||
|
||||
T_FIRST_OPERATOR,
|
||||
T_AMPER = T_FIRST_OPERATOR,
|
||||
T_AMPER_AMPER,
|
||||
T_AMPER_EQUAL,
|
||||
T_ARROW,
|
||||
T_ARROW_STAR,
|
||||
T_CARET,
|
||||
T_CARET_EQUAL,
|
||||
T_COLON,
|
||||
T_COLON_COLON,
|
||||
T_COMMA,
|
||||
T_SLASH,
|
||||
T_SLASH_EQUAL,
|
||||
T_DOT,
|
||||
T_DOT_DOT_DOT,
|
||||
T_DOT_STAR,
|
||||
T_EQUAL,
|
||||
T_EQUAL_EQUAL,
|
||||
T_EXCLAIM,
|
||||
T_EXCLAIM_EQUAL,
|
||||
T_GREATER,
|
||||
T_GREATER_EQUAL,
|
||||
T_GREATER_GREATER,
|
||||
T_GREATER_GREATER_EQUAL,
|
||||
T_LBRACE,
|
||||
T_LBRACKET,
|
||||
T_LESS,
|
||||
T_LESS_EQUAL,
|
||||
T_LESS_LESS,
|
||||
T_LESS_LESS_EQUAL,
|
||||
T_LPAREN,
|
||||
T_MINUS,
|
||||
T_MINUS_EQUAL,
|
||||
T_MINUS_MINUS,
|
||||
T_PERCENT,
|
||||
T_PERCENT_EQUAL,
|
||||
T_PIPE,
|
||||
T_PIPE_EQUAL,
|
||||
T_PIPE_PIPE,
|
||||
T_PLUS,
|
||||
T_PLUS_EQUAL,
|
||||
T_PLUS_PLUS,
|
||||
T_POUND,
|
||||
T_POUND_POUND,
|
||||
T_QUESTION,
|
||||
T_RBRACE,
|
||||
T_RBRACKET,
|
||||
T_RPAREN,
|
||||
T_SEMICOLON,
|
||||
T_STAR,
|
||||
T_STAR_EQUAL,
|
||||
T_TILDE,
|
||||
T_TILDE_EQUAL,
|
||||
T_LAST_OPERATOR = T_TILDE_EQUAL,
|
||||
|
||||
T_FIRST_KEYWORD,
|
||||
T_ASM = T_FIRST_KEYWORD,
|
||||
T_AUTO,
|
||||
T_BOOL,
|
||||
T_BREAK,
|
||||
T_CASE,
|
||||
T_CATCH,
|
||||
T_CHAR,
|
||||
T_CLASS,
|
||||
T_CONST,
|
||||
T_CONST_CAST,
|
||||
T_CONTINUE,
|
||||
T_DEFAULT,
|
||||
T_DELETE,
|
||||
T_DO,
|
||||
T_DOUBLE,
|
||||
T_DYNAMIC_CAST,
|
||||
T_ELSE,
|
||||
T_ENUM,
|
||||
T_EXPLICIT,
|
||||
T_EXPORT,
|
||||
T_EXTERN,
|
||||
T_FALSE,
|
||||
T_FLOAT,
|
||||
T_FOR,
|
||||
T_FRIEND,
|
||||
T_GOTO,
|
||||
T_IF,
|
||||
T_INLINE,
|
||||
T_INT,
|
||||
T_LONG,
|
||||
T_MUTABLE,
|
||||
T_NAMESPACE,
|
||||
T_NEW,
|
||||
T_OPERATOR,
|
||||
T_PRIVATE,
|
||||
T_PROTECTED,
|
||||
T_PUBLIC,
|
||||
T_REGISTER,
|
||||
T_REINTERPRET_CAST,
|
||||
T_RETURN,
|
||||
T_SHORT,
|
||||
T_SIGNED,
|
||||
T_SIZEOF,
|
||||
T_STATIC,
|
||||
T_STATIC_CAST,
|
||||
T_STRUCT,
|
||||
T_SWITCH,
|
||||
T_TEMPLATE,
|
||||
T_THIS,
|
||||
T_THROW,
|
||||
T_TRUE,
|
||||
T_TRY,
|
||||
T_TYPEDEF,
|
||||
T_TYPEID,
|
||||
T_TYPENAME,
|
||||
T_UNION,
|
||||
T_UNSIGNED,
|
||||
T_USING,
|
||||
T_VIRTUAL,
|
||||
T_VOID,
|
||||
T_VOLATILE,
|
||||
T_WCHAR_T,
|
||||
T_WHILE,
|
||||
|
||||
T___ATTRIBUTE__,
|
||||
T___TYPEOF__,
|
||||
|
||||
// obj c++ @ keywords
|
||||
T_FIRST_OBJC_AT_KEYWORD,
|
||||
|
||||
T_AT_CATCH = T_FIRST_OBJC_AT_KEYWORD,
|
||||
T_AT_CLASS,
|
||||
T_AT_COMPATIBILITY_ALIAS,
|
||||
T_AT_DEFS,
|
||||
T_AT_DYNAMIC,
|
||||
T_AT_ENCODE,
|
||||
T_AT_END,
|
||||
T_AT_FINALLY,
|
||||
T_AT_IMPLEMENTATION,
|
||||
T_AT_INTERFACE,
|
||||
T_AT_NOT_KEYWORD,
|
||||
T_AT_OPTIONAL,
|
||||
T_AT_PACKAGE,
|
||||
T_AT_PRIVATE,
|
||||
T_AT_PROPERTY,
|
||||
T_AT_PROTECTED,
|
||||
T_AT_PROTOCOL,
|
||||
T_AT_PUBLIC,
|
||||
T_AT_REQUIRED,
|
||||
T_AT_SELECTOR,
|
||||
T_AT_SYNCHRONIZED,
|
||||
T_AT_SYNTHESIZE,
|
||||
T_AT_THROW,
|
||||
T_AT_TRY,
|
||||
|
||||
T_LAST_OBJC_AT_KEYWORD = T_AT_TRY,
|
||||
|
||||
T_FIRST_QT_KEYWORD,
|
||||
|
||||
// Qt keywords
|
||||
T_SIGNAL = T_FIRST_QT_KEYWORD,
|
||||
T_SLOT,
|
||||
T_Q_SIGNAL,
|
||||
T_Q_SLOT,
|
||||
T_Q_SIGNALS,
|
||||
T_Q_SLOTS,
|
||||
T_Q_FOREACH,
|
||||
T_Q_D,
|
||||
T_Q_Q,
|
||||
T_Q_INVOKABLE,
|
||||
T_Q_PROPERTY,
|
||||
T_Q_PRIVATE_PROPERTY,
|
||||
T_Q_INTERFACES,
|
||||
T_Q_ENUMS,
|
||||
T_Q_FLAGS,
|
||||
T_Q_PRIVATE_SLOT,
|
||||
T_Q_DECLARE_INTERFACE,
|
||||
T_Q_OBJECT,
|
||||
T_Q_GADGET,
|
||||
T_LAST_KEYWORD = T_Q_GADGET,
|
||||
|
||||
// aliases
|
||||
T_OR = T_PIPE_PIPE,
|
||||
T_AND = T_AMPER_AMPER,
|
||||
T_NOT = T_EXCLAIM,
|
||||
T_XOR = T_CARET,
|
||||
T_BITOR = T_PIPE,
|
||||
T_COMPL = T_TILDE,
|
||||
T_OR_EQ = T_PIPE_EQUAL,
|
||||
T_AND_EQ = T_AMPER_EQUAL,
|
||||
T_BITAND = T_AMPER,
|
||||
T_NOT_EQ = T_EXCLAIM_EQUAL,
|
||||
T_XOR_EQ = T_CARET_EQUAL,
|
||||
|
||||
T___ASM = T_ASM,
|
||||
T___ASM__ = T_ASM,
|
||||
|
||||
T_TYPEOF = T___TYPEOF__,
|
||||
T___TYPEOF = T___TYPEOF__,
|
||||
|
||||
T___INLINE = T_INLINE,
|
||||
T___INLINE__ = T_INLINE,
|
||||
|
||||
T___CONST = T_CONST,
|
||||
T___CONST__ = T_CONST,
|
||||
|
||||
T___VOLATILE = T_VOLATILE,
|
||||
T___VOLATILE__ = T_VOLATILE,
|
||||
|
||||
T___ATTRIBUTE = T___ATTRIBUTE__
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT Token
|
||||
{
|
||||
public:
|
||||
Token();
|
||||
~Token();
|
||||
|
||||
inline bool is(unsigned k) const { return f.kind == k; }
|
||||
inline bool isNot(unsigned k) const { return f.kind != k; }
|
||||
const char *spell() const;
|
||||
void reset();
|
||||
|
||||
inline unsigned kind() const { return f.kind; }
|
||||
inline bool newline() const { return f.newline; }
|
||||
inline bool whitespace() const { return f.whitespace; }
|
||||
inline bool joined() const { return f.joined; }
|
||||
inline bool expanded() const { return f.expanded; }
|
||||
inline bool generated() const { return f.generated; }
|
||||
inline unsigned length() const { return f.length; }
|
||||
|
||||
inline unsigned begin() const
|
||||
{ return offset; }
|
||||
|
||||
inline unsigned end() const
|
||||
{ return offset + f.length; }
|
||||
|
||||
inline bool isLiteral() const
|
||||
{ return f.kind >= T_FIRST_LITERAL && f.kind <= T_LAST_LITERAL; }
|
||||
|
||||
inline bool isOperator() const
|
||||
{ return f.kind >= T_FIRST_OPERATOR && f.kind <= T_LAST_OPERATOR; }
|
||||
|
||||
inline bool isKeyword() const
|
||||
{ return f.kind >= T_FIRST_KEYWORD && f.kind < T_FIRST_QT_KEYWORD; }
|
||||
|
||||
inline bool isComment() const
|
||||
{ return f.kind == T_COMMENT || f.kind == T_DOXY_COMMENT ||
|
||||
f.kind == T_CPP_COMMENT || f.kind == T_CPP_DOXY_COMMENT; }
|
||||
|
||||
inline bool isObjCAtKeyword() const
|
||||
{ return f.kind >= T_FIRST_OBJC_AT_KEYWORD && f.kind <= T_LAST_OBJC_AT_KEYWORD; }
|
||||
|
||||
static const char *name(int kind);
|
||||
|
||||
public:
|
||||
struct Flags {
|
||||
unsigned kind : 8;
|
||||
unsigned newline : 1;
|
||||
unsigned whitespace : 1;
|
||||
unsigned joined : 1;
|
||||
unsigned expanded : 1;
|
||||
unsigned generated : 1;
|
||||
unsigned pad : 3;
|
||||
unsigned length : 16;
|
||||
};
|
||||
union {
|
||||
unsigned flags;
|
||||
Flags f;
|
||||
};
|
||||
|
||||
unsigned offset;
|
||||
|
||||
union {
|
||||
void *ptr;
|
||||
const Literal *literal;
|
||||
const NumericLiteral *number;
|
||||
const StringLiteral *string;
|
||||
const Identifier *identifier;
|
||||
unsigned close_brace;
|
||||
unsigned lineno;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_TOKEN_H
|
511
src/libs/3rdparty/cplusplus/TranslationUnit.cpp
vendored
Normal file
511
src/libs/3rdparty/cplusplus/TranslationUnit.cpp
vendored
Normal file
@@ -0,0 +1,511 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "TranslationUnit.h"
|
||||
#include "Control.h"
|
||||
#include "Parser.h"
|
||||
#include "Lexer.h"
|
||||
#include "MemoryPool.h"
|
||||
#include "AST.h"
|
||||
#include "Literals.h"
|
||||
#include "DiagnosticClient.h"
|
||||
#include <stack>
|
||||
#include <cstdarg>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define va_copy(dst, src) ((dst) = (src))
|
||||
#elif defined(__INTEL_COMPILER) && !defined(va_copy)
|
||||
# define va_copy __va_copy
|
||||
#endif
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
TranslationUnit::TranslationUnit(Control *control, const StringLiteral *fileId)
|
||||
: _control(control),
|
||||
_fileId(fileId),
|
||||
_firstSourceChar(0),
|
||||
_lastSourceChar(0),
|
||||
_pool(0),
|
||||
_ast(0),
|
||||
_flags(0)
|
||||
{
|
||||
_tokens = new std::vector<Token>();
|
||||
_previousTranslationUnit = control->switchTranslationUnit(this);
|
||||
_pool = new MemoryPool();
|
||||
}
|
||||
|
||||
TranslationUnit::~TranslationUnit()
|
||||
{
|
||||
(void) _control->switchTranslationUnit(_previousTranslationUnit);
|
||||
delete _tokens;
|
||||
delete _pool;
|
||||
}
|
||||
|
||||
bool TranslationUnit::qtMocRunEnabled() const
|
||||
{ return f._qtMocRunEnabled; }
|
||||
|
||||
void TranslationUnit::setQtMocRunEnabled(bool onoff)
|
||||
{ f._qtMocRunEnabled = onoff; }
|
||||
|
||||
bool TranslationUnit::cxx0xEnabled() const
|
||||
{ return f._cxx0xEnabled; }
|
||||
|
||||
void TranslationUnit::setCxxOxEnabled(bool onoff)
|
||||
{ f._cxx0xEnabled = onoff; }
|
||||
|
||||
bool TranslationUnit::objCEnabled() const
|
||||
{ return f._objCEnabled; }
|
||||
|
||||
void TranslationUnit::setObjCEnabled(bool onoff)
|
||||
{ f._objCEnabled = onoff; }
|
||||
|
||||
Control *TranslationUnit::control() const
|
||||
{ return _control; }
|
||||
|
||||
const StringLiteral *TranslationUnit::fileId() const
|
||||
{ return _fileId; }
|
||||
|
||||
const char *TranslationUnit::fileName() const
|
||||
{ return _fileId->chars(); }
|
||||
|
||||
unsigned TranslationUnit::fileNameLength() const
|
||||
{ return _fileId->size(); }
|
||||
|
||||
const char *TranslationUnit::firstSourceChar() const
|
||||
{ return _firstSourceChar; }
|
||||
|
||||
const char *TranslationUnit::lastSourceChar() const
|
||||
{ return _lastSourceChar; }
|
||||
|
||||
unsigned TranslationUnit::sourceLength() const
|
||||
{ return _lastSourceChar - _firstSourceChar; }
|
||||
|
||||
void TranslationUnit::setSource(const char *source, unsigned size)
|
||||
{
|
||||
_firstSourceChar = source;
|
||||
_lastSourceChar = source + size;
|
||||
}
|
||||
|
||||
unsigned TranslationUnit::tokenCount() const
|
||||
{ return _tokens->size(); }
|
||||
|
||||
const Token &TranslationUnit::tokenAt(unsigned index) const
|
||||
{ return _tokens->at(index); }
|
||||
|
||||
int TranslationUnit::tokenKind(unsigned index) const
|
||||
{ return _tokens->at(index).f.kind; }
|
||||
|
||||
const char *TranslationUnit::spell(unsigned index) const
|
||||
{
|
||||
if (! index)
|
||||
return 0;
|
||||
|
||||
return _tokens->at(index).spell();
|
||||
}
|
||||
|
||||
const Identifier *TranslationUnit::identifier(unsigned index) const
|
||||
{ return _tokens->at(index).identifier; }
|
||||
|
||||
const Literal *TranslationUnit::literal(unsigned index) const
|
||||
{ return _tokens->at(index).literal; }
|
||||
|
||||
const StringLiteral *TranslationUnit::stringLiteral(unsigned index) const
|
||||
{ return _tokens->at(index).string; }
|
||||
|
||||
const NumericLiteral *TranslationUnit::numericLiteral(unsigned index) const
|
||||
{ return _tokens->at(index).number; }
|
||||
|
||||
unsigned TranslationUnit::matchingBrace(unsigned index) const
|
||||
{ return _tokens->at(index).close_brace; }
|
||||
|
||||
MemoryPool *TranslationUnit::memoryPool() const
|
||||
{ return _pool; }
|
||||
|
||||
AST *TranslationUnit::ast() const
|
||||
{ return _ast; }
|
||||
|
||||
bool TranslationUnit::isTokenized() const
|
||||
{ return f._tokenized; }
|
||||
|
||||
bool TranslationUnit::isParsed() const
|
||||
{ return f._parsed; }
|
||||
|
||||
void TranslationUnit::tokenize()
|
||||
{
|
||||
if (isTokenized())
|
||||
return;
|
||||
|
||||
f._tokenized = true;
|
||||
|
||||
Lexer lex(this);
|
||||
lex.setQtMocRunEnabled(f._qtMocRunEnabled);
|
||||
lex.setCxxOxEnabled(f._cxx0xEnabled);
|
||||
lex.setObjCEnabled(f._objCEnabled);
|
||||
|
||||
std::stack<unsigned> braces;
|
||||
_tokens->push_back(Token()); // the first token needs to be invalid!
|
||||
|
||||
pushLineOffset(0);
|
||||
pushPreprocessorLine(0, 1, fileId());
|
||||
|
||||
const Identifier *lineId = control()->identifier("line");
|
||||
const Identifier *genId = control()->identifier("gen");
|
||||
|
||||
bool generated = false;
|
||||
Token tk;
|
||||
do {
|
||||
lex(&tk);
|
||||
|
||||
_Lrecognize:
|
||||
if (tk.is(T_POUND) && tk.newline()) {
|
||||
unsigned offset = tk.offset;
|
||||
lex(&tk);
|
||||
|
||||
if (! tk.f.newline && tk.is(T_IDENTIFIER) && tk.identifier == genId) {
|
||||
// it's a gen directive.
|
||||
lex(&tk);
|
||||
|
||||
if (! tk.f.newline && tk.is(T_TRUE)) {
|
||||
lex(&tk);
|
||||
generated = true;
|
||||
} else {
|
||||
generated = false;
|
||||
}
|
||||
} else {
|
||||
if (! tk.f.newline && tk.is(T_IDENTIFIER) && tk.identifier == lineId)
|
||||
lex(&tk);
|
||||
if (! tk.f.newline && tk.is(T_NUMERIC_LITERAL)) {
|
||||
unsigned line = (unsigned) strtoul(tk.spell(), 0, 0);
|
||||
lex(&tk);
|
||||
if (! tk.f.newline && tk.is(T_STRING_LITERAL)) {
|
||||
const StringLiteral *fileName = control()->stringLiteral(tk.string->chars(),
|
||||
tk.string->size());
|
||||
pushPreprocessorLine(offset, line, fileName);
|
||||
lex(&tk);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (tk.isNot(T_EOF_SYMBOL) && ! tk.f.newline)
|
||||
lex(&tk);
|
||||
goto _Lrecognize;
|
||||
} else if (tk.f.kind == T_LBRACE) {
|
||||
braces.push(_tokens->size());
|
||||
} else if (tk.f.kind == T_RBRACE && ! braces.empty()) {
|
||||
const unsigned open_brace_index = braces.top();
|
||||
braces.pop();
|
||||
(*_tokens)[open_brace_index].close_brace = _tokens->size();
|
||||
}
|
||||
tk.f.generated = generated;
|
||||
_tokens->push_back(tk);
|
||||
} while (tk.f.kind);
|
||||
|
||||
for (; ! braces.empty(); braces.pop()) {
|
||||
unsigned open_brace_index = braces.top();
|
||||
(*_tokens)[open_brace_index].close_brace = _tokens->size();
|
||||
}
|
||||
}
|
||||
|
||||
bool TranslationUnit::skipFunctionBody() const
|
||||
{ return f._skipFunctionBody; }
|
||||
|
||||
void TranslationUnit::setSkipFunctionBody(bool skipFunctionBody)
|
||||
{ f._skipFunctionBody = skipFunctionBody; }
|
||||
|
||||
bool TranslationUnit::parse(ParseMode mode)
|
||||
{
|
||||
if (isParsed())
|
||||
return false;
|
||||
|
||||
if (! isTokenized())
|
||||
tokenize();
|
||||
|
||||
f._parsed = true;
|
||||
|
||||
Parser parser(this);
|
||||
parser.setQtMocRunEnabled(f._qtMocRunEnabled);
|
||||
parser.setCxxOxEnabled(f._cxx0xEnabled);
|
||||
parser.setObjCEnabled(f._objCEnabled);
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
switch (mode) {
|
||||
case ParseTranlationUnit: {
|
||||
TranslationUnitAST *node = 0;
|
||||
parsed = parser.parseTranslationUnit(node);
|
||||
_ast = node;
|
||||
} break;
|
||||
|
||||
case ParseDeclaration: {
|
||||
DeclarationAST *node = 0;
|
||||
parsed = parser.parseDeclaration(node);
|
||||
_ast = node;
|
||||
} break;
|
||||
|
||||
case ParseExpression: {
|
||||
ExpressionAST *node = 0;
|
||||
parsed = parser.parseExpression(node);
|
||||
_ast = node;
|
||||
} break;
|
||||
|
||||
case ParseDeclarator: {
|
||||
DeclaratorAST *node = 0;
|
||||
parsed = parser.parseDeclarator(node, /*decl_specifier_list =*/ 0);
|
||||
_ast = node;
|
||||
} break;
|
||||
|
||||
case ParseStatement: {
|
||||
StatementAST *node = 0;
|
||||
parsed = parser.parseStatement(node);
|
||||
_ast = node;
|
||||
} break;
|
||||
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
void TranslationUnit::pushLineOffset(unsigned offset)
|
||||
{ _lineOffsets.push_back(offset); }
|
||||
|
||||
void TranslationUnit::pushPreprocessorLine(unsigned offset,
|
||||
unsigned line,
|
||||
const StringLiteral *fileName)
|
||||
{ _ppLines.push_back(PPLine(offset, line, fileName)); }
|
||||
|
||||
unsigned TranslationUnit::findLineNumber(unsigned offset) const
|
||||
{
|
||||
std::vector<unsigned>::const_iterator it =
|
||||
std::lower_bound(_lineOffsets.begin(), _lineOffsets.end(), offset);
|
||||
|
||||
if (it != _lineOffsets.begin())
|
||||
--it;
|
||||
|
||||
return it - _lineOffsets.begin();
|
||||
}
|
||||
|
||||
TranslationUnit::PPLine TranslationUnit::findPreprocessorLine(unsigned offset) const
|
||||
{
|
||||
std::vector<PPLine>::const_iterator it =
|
||||
std::lower_bound(_ppLines.begin(), _ppLines.end(), PPLine(offset));
|
||||
|
||||
if (it != _ppLines.begin())
|
||||
--it;
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
unsigned TranslationUnit::findColumnNumber(unsigned offset, unsigned lineNumber) const
|
||||
{
|
||||
if (! offset)
|
||||
return 0;
|
||||
|
||||
return offset - _lineOffsets[lineNumber];
|
||||
}
|
||||
|
||||
void TranslationUnit::getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
const StringLiteral **fileName) const
|
||||
{ return getPosition(tokenAt(index).offset, line, column, fileName); }
|
||||
|
||||
void TranslationUnit::getTokenStartPosition(unsigned index, unsigned *line,
|
||||
unsigned *column,
|
||||
const StringLiteral **fileName) const
|
||||
{ return getPosition(tokenAt(index).begin(), line, column, fileName); }
|
||||
|
||||
void TranslationUnit::getTokenEndPosition(unsigned index, unsigned *line,
|
||||
unsigned *column,
|
||||
const StringLiteral **fileName) const
|
||||
{ return getPosition(tokenAt(index).end(), line, column, fileName); }
|
||||
|
||||
void TranslationUnit::getPosition(unsigned tokenOffset,
|
||||
unsigned *line,
|
||||
unsigned *column,
|
||||
const StringLiteral **fileName) const
|
||||
{
|
||||
unsigned lineNumber = findLineNumber(tokenOffset);
|
||||
unsigned columnNumber = findColumnNumber(tokenOffset, lineNumber);
|
||||
const PPLine ppLine = findPreprocessorLine(tokenOffset);
|
||||
|
||||
lineNumber -= findLineNumber(ppLine.offset) + 1;
|
||||
lineNumber += ppLine.line;
|
||||
|
||||
if (line)
|
||||
*line = lineNumber;
|
||||
|
||||
if (column)
|
||||
*column = columnNumber;
|
||||
|
||||
if (fileName)
|
||||
*fileName = ppLine.fileName;
|
||||
}
|
||||
|
||||
bool TranslationUnit::blockErrors(bool block)
|
||||
{
|
||||
bool previous = f._blockErrors;
|
||||
f._blockErrors = block;
|
||||
return previous;
|
||||
}
|
||||
|
||||
void TranslationUnit::message(DiagnosticClient::Level level, unsigned index, const char *format, va_list args)
|
||||
{
|
||||
if (f._blockErrors)
|
||||
return;
|
||||
|
||||
index = std::min(index, tokenCount() - 1);
|
||||
|
||||
unsigned line = 0, column = 0;
|
||||
const StringLiteral *fileName = 0;
|
||||
getTokenPosition(index, &line, &column, &fileName);
|
||||
|
||||
if (DiagnosticClient *client = control()->diagnosticClient()) {
|
||||
client->report(level, fileName, line, column, format, args);
|
||||
} else {
|
||||
fprintf(stderr, "%s:%d: ", fileName->chars(), line);
|
||||
const char *l = "error";
|
||||
if (level == DiagnosticClient::Warning)
|
||||
l = "warning";
|
||||
else if (level == DiagnosticClient::Fatal)
|
||||
l = "fatal";
|
||||
fprintf(stderr, "%s: ", l);
|
||||
|
||||
vfprintf(stderr, format, args);
|
||||
fputc('\n', stderr);
|
||||
|
||||
showErrorLine(index, column, stderr);
|
||||
}
|
||||
|
||||
if (level == DiagnosticClient::Fatal)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void TranslationUnit::warning(unsigned index, const char *format, ...)
|
||||
{
|
||||
if (f._blockErrors)
|
||||
return;
|
||||
|
||||
va_list args, ap;
|
||||
va_start(args, format);
|
||||
va_copy(ap, args);
|
||||
message(DiagnosticClient::Warning, index, format, args);
|
||||
va_end(ap);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void TranslationUnit::error(unsigned index, const char *format, ...)
|
||||
{
|
||||
if (f._blockErrors)
|
||||
return;
|
||||
|
||||
va_list args, ap;
|
||||
va_start(args, format);
|
||||
va_copy(ap, args);
|
||||
message(DiagnosticClient::Error, index, format, args);
|
||||
va_end(ap);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void TranslationUnit::fatal(unsigned index, const char *format, ...)
|
||||
{
|
||||
if (f._blockErrors)
|
||||
return;
|
||||
|
||||
va_list args, ap;
|
||||
va_start(args, format);
|
||||
va_copy(ap, args);
|
||||
message(DiagnosticClient::Fatal, index, format, args);
|
||||
va_end(ap);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
unsigned TranslationUnit::findPreviousLineOffset(unsigned tokenIndex) const
|
||||
{
|
||||
unsigned lineOffset = _lineOffsets[findLineNumber(_tokens->at(tokenIndex).offset)];
|
||||
return lineOffset;
|
||||
}
|
||||
|
||||
void TranslationUnit::showErrorLine(unsigned index, unsigned column, FILE *out)
|
||||
{
|
||||
unsigned lineOffset = _lineOffsets[findLineNumber(_tokens->at(index).offset)];
|
||||
for (const char *cp = _firstSourceChar + lineOffset + 1; *cp && *cp != '\n'; ++cp) {
|
||||
fputc(*cp, out);
|
||||
}
|
||||
fputc('\n', out);
|
||||
|
||||
const char *end = _firstSourceChar + lineOffset + 1 + column - 1;
|
||||
for (const char *cp = _firstSourceChar + lineOffset + 1; cp != end; ++cp) {
|
||||
if (*cp != '\t')
|
||||
fputc(' ', out);
|
||||
else
|
||||
fputc('\t', out);
|
||||
}
|
||||
fputc('^', out);
|
||||
fputc('\n', out);
|
||||
}
|
||||
|
||||
void TranslationUnit::resetAST()
|
||||
{
|
||||
delete _pool;
|
||||
_pool = 0;
|
||||
_ast = 0;
|
||||
}
|
||||
|
||||
void TranslationUnit::release()
|
||||
{
|
||||
resetAST();
|
||||
delete _tokens;
|
||||
_tokens = 0;
|
||||
}
|
||||
|
||||
|
221
src/libs/3rdparty/cplusplus/TranslationUnit.h
vendored
Normal file
221
src/libs/3rdparty/cplusplus/TranslationUnit.h
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_TRANSLATIONUNIT_H
|
||||
#define CPLUSPLUS_TRANSLATIONUNIT_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include "ASTfwd.h"
|
||||
#include "Token.h"
|
||||
#include "DiagnosticClient.h"
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT TranslationUnit
|
||||
{
|
||||
TranslationUnit(const TranslationUnit &other);
|
||||
void operator =(const TranslationUnit &other);
|
||||
|
||||
public:
|
||||
TranslationUnit(Control *control, const StringLiteral *fileId);
|
||||
~TranslationUnit();
|
||||
|
||||
Control *control() const;
|
||||
|
||||
const StringLiteral *fileId() const;
|
||||
const char *fileName() const;
|
||||
unsigned fileNameLength() const;
|
||||
|
||||
const char *firstSourceChar() const;
|
||||
const char *lastSourceChar() const;
|
||||
unsigned sourceLength() const;
|
||||
|
||||
void setSource(const char *source, unsigned size);
|
||||
|
||||
unsigned tokenCount() const;
|
||||
const Token &tokenAt(unsigned index) const;
|
||||
int tokenKind(unsigned index) const;
|
||||
const char *spell(unsigned index) const;
|
||||
|
||||
unsigned matchingBrace(unsigned index) const;
|
||||
const Identifier *identifier(unsigned index) const;
|
||||
const Literal *literal(unsigned index) const;
|
||||
const StringLiteral *stringLiteral(unsigned index) const;
|
||||
const NumericLiteral *numericLiteral(unsigned index) const;
|
||||
|
||||
MemoryPool *memoryPool() const;
|
||||
AST *ast() const;
|
||||
|
||||
bool blockErrors() const { return f._blockErrors; }
|
||||
bool blockErrors(bool block);
|
||||
|
||||
bool qtMocRunEnabled() const;
|
||||
void setQtMocRunEnabled(bool onoff);
|
||||
|
||||
bool cxx0xEnabled() const;
|
||||
void setCxxOxEnabled(bool onoff);
|
||||
|
||||
bool objCEnabled() const;
|
||||
void setObjCEnabled(bool onoff);
|
||||
|
||||
void warning(unsigned index, const char *fmt, ...);
|
||||
void error(unsigned index, const char *fmt, ...);
|
||||
void fatal(unsigned index, const char *fmt, ...);
|
||||
|
||||
void message(DiagnosticClient::Level level, unsigned index,
|
||||
const char *format, va_list ap);
|
||||
|
||||
bool isTokenized() const;
|
||||
void tokenize();
|
||||
|
||||
bool skipFunctionBody() const;
|
||||
void setSkipFunctionBody(bool skipFunctionBody);
|
||||
|
||||
bool isParsed() const;
|
||||
|
||||
enum ParseMode {
|
||||
ParseTranlationUnit,
|
||||
ParseDeclaration,
|
||||
ParseExpression,
|
||||
ParseDeclarator,
|
||||
ParseStatement
|
||||
};
|
||||
|
||||
bool parse(ParseMode mode = ParseTranlationUnit);
|
||||
|
||||
void resetAST();
|
||||
void release();
|
||||
|
||||
void getTokenStartPosition(unsigned index, unsigned *line,
|
||||
unsigned *column = 0,
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenEndPosition(unsigned index, unsigned *line,
|
||||
unsigned *column = 0,
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getPosition(unsigned offset,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void getTokenPosition(unsigned index,
|
||||
unsigned *line,
|
||||
unsigned *column = 0,
|
||||
const StringLiteral **fileName = 0) const;
|
||||
|
||||
void pushLineOffset(unsigned offset);
|
||||
void pushPreprocessorLine(unsigned offset,
|
||||
unsigned line,
|
||||
const StringLiteral *fileName);
|
||||
|
||||
unsigned findPreviousLineOffset(unsigned tokenIndex) const;
|
||||
|
||||
public:
|
||||
struct PPLine {
|
||||
unsigned offset;
|
||||
unsigned line;
|
||||
const StringLiteral *fileName;
|
||||
|
||||
PPLine(unsigned offset = 0,
|
||||
unsigned line = 0,
|
||||
const StringLiteral *fileName = 0)
|
||||
: offset(offset), line(line), fileName(fileName)
|
||||
{ }
|
||||
|
||||
bool operator == (const PPLine &other) const
|
||||
{ return offset == other.offset; }
|
||||
|
||||
bool operator != (const PPLine &other) const
|
||||
{ return offset != other.offset; }
|
||||
|
||||
bool operator < (const PPLine &other) const
|
||||
{ return offset < other.offset; }
|
||||
};
|
||||
|
||||
private:
|
||||
unsigned findLineNumber(unsigned offset) const;
|
||||
unsigned findColumnNumber(unsigned offset, unsigned lineNumber) const;
|
||||
PPLine findPreprocessorLine(unsigned offset) const;
|
||||
void showErrorLine(unsigned index, unsigned column, FILE *out);
|
||||
|
||||
Control *_control;
|
||||
const StringLiteral *_fileId;
|
||||
const char *_firstSourceChar;
|
||||
const char *_lastSourceChar;
|
||||
std::vector<Token> *_tokens;
|
||||
std::vector<unsigned> _lineOffsets;
|
||||
std::vector<PPLine> _ppLines;
|
||||
MemoryPool *_pool;
|
||||
AST *_ast;
|
||||
TranslationUnit *_previousTranslationUnit;
|
||||
struct Flags {
|
||||
unsigned _tokenized: 1;
|
||||
unsigned _parsed: 1;
|
||||
unsigned _blockErrors: 1;
|
||||
unsigned _skipFunctionBody: 1;
|
||||
unsigned _qtMocRunEnabled: 1;
|
||||
unsigned _cxx0xEnabled: 1;
|
||||
unsigned _objCEnabled: 1;
|
||||
};
|
||||
union {
|
||||
unsigned _flags;
|
||||
Flags f;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_TRANSLATIONUNIT_H
|
144
src/libs/3rdparty/cplusplus/Type.cpp
vendored
Normal file
144
src/libs/3rdparty/cplusplus/Type.cpp
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "Type.h"
|
||||
#include "TypeVisitor.h"
|
||||
#include "CoreTypes.h"
|
||||
#include "Symbols.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
Type::Type()
|
||||
{ }
|
||||
|
||||
Type::~Type()
|
||||
{ }
|
||||
|
||||
bool Type::isUndefinedType() const
|
||||
{ return this == UndefinedType::instance(); }
|
||||
|
||||
bool Type::isVoidType() const
|
||||
{ return asVoidType() != 0; }
|
||||
|
||||
bool Type::isIntegerType() const
|
||||
{ return asIntegerType() != 0; }
|
||||
|
||||
bool Type::isFloatType() const
|
||||
{ return asFloatType() != 0; }
|
||||
|
||||
bool Type::isPointerType() const
|
||||
{ return asPointerType() != 0; }
|
||||
|
||||
bool Type::isPointerToMemberType() const
|
||||
{ return asPointerToMemberType() != 0; }
|
||||
|
||||
bool Type::isReferenceType() const
|
||||
{ return asReferenceType() != 0; }
|
||||
|
||||
bool Type::isArrayType() const
|
||||
{ return asArrayType() != 0; }
|
||||
|
||||
bool Type::isNamedType() const
|
||||
{ return asNamedType() != 0; }
|
||||
|
||||
bool Type::isFunctionType() const
|
||||
{ return asFunctionType() != 0; }
|
||||
|
||||
bool Type::isNamespaceType() const
|
||||
{ return asNamespaceType() != 0; }
|
||||
|
||||
bool Type::isTemplateType() const
|
||||
{ return asTemplateType() != 0; }
|
||||
|
||||
bool Type::isClassType() const
|
||||
{ return asClassType() != 0; }
|
||||
|
||||
bool Type::isEnumType() const
|
||||
{ return asEnumType() != 0; }
|
||||
|
||||
bool Type::isForwardClassDeclarationType() const
|
||||
{ return asForwardClassDeclarationType() != 0; }
|
||||
|
||||
bool Type::isObjCClassType() const
|
||||
{ return asObjCClassType() != 0; }
|
||||
|
||||
bool Type::isObjCProtocolType() const
|
||||
{ return asObjCProtocolType() != 0; }
|
||||
|
||||
bool Type::isObjCMethodType() const
|
||||
{ return asObjCMethodType() != 0; }
|
||||
|
||||
bool Type::isObjCForwardClassDeclarationType() const
|
||||
{ return asObjCForwardClassDeclarationType() != 0; }
|
||||
|
||||
bool Type::isObjCForwardProtocolDeclarationType() const
|
||||
{ return asObjCForwardProtocolDeclarationType() != 0; }
|
||||
|
||||
void Type::accept(TypeVisitor *visitor)
|
||||
{
|
||||
if (visitor->preVisit(this))
|
||||
accept0(visitor);
|
||||
visitor->postVisit(this);
|
||||
}
|
||||
|
||||
void Type::accept(Type *type, TypeVisitor *visitor)
|
||||
{
|
||||
if (! type)
|
||||
return;
|
||||
|
||||
type->accept(visitor);
|
||||
}
|
||||
|
||||
bool Type::matchType(const Type *otherType, TypeMatcher *matcher) const
|
||||
{
|
||||
return matchType0(otherType, matcher);
|
||||
}
|
||||
|
151
src/libs/3rdparty/cplusplus/Type.h
vendored
Normal file
151
src/libs/3rdparty/cplusplus/Type.h
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_TYPE_H
|
||||
#define CPLUSPLUS_TYPE_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT Type
|
||||
{
|
||||
public:
|
||||
Type();
|
||||
virtual ~Type();
|
||||
|
||||
bool isUndefinedType() const;
|
||||
bool isVoidType() const;
|
||||
bool isIntegerType() const;
|
||||
bool isFloatType() const;
|
||||
bool isPointerType() const;
|
||||
bool isPointerToMemberType() const;
|
||||
bool isReferenceType() const;
|
||||
bool isArrayType() const;
|
||||
bool isNamedType() const;
|
||||
bool isFunctionType() const;
|
||||
bool isNamespaceType() const;
|
||||
bool isTemplateType() const;
|
||||
bool isClassType() const;
|
||||
bool isEnumType() const;
|
||||
bool isForwardClassDeclarationType() const;
|
||||
bool isObjCClassType() const;
|
||||
bool isObjCProtocolType() const;
|
||||
bool isObjCMethodType() const;
|
||||
bool isObjCForwardClassDeclarationType() const;
|
||||
bool isObjCForwardProtocolDeclarationType() const;
|
||||
|
||||
virtual const UndefinedType *asUndefinedType() const { return 0; }
|
||||
virtual const VoidType *asVoidType() const { return 0; }
|
||||
virtual const IntegerType *asIntegerType() const { return 0; }
|
||||
virtual const FloatType *asFloatType() const { return 0; }
|
||||
virtual const PointerType *asPointerType() const { return 0; }
|
||||
virtual const PointerToMemberType *asPointerToMemberType() const { return 0; }
|
||||
virtual const ReferenceType *asReferenceType() const { return 0; }
|
||||
virtual const ArrayType *asArrayType() const { return 0; }
|
||||
virtual const NamedType *asNamedType() const { return 0; }
|
||||
virtual const Function *asFunctionType() const { return 0; }
|
||||
virtual const Namespace *asNamespaceType() const { return 0; }
|
||||
virtual const Template *asTemplateType() const { return 0; }
|
||||
virtual const Class *asClassType() const { return 0; }
|
||||
virtual const Enum *asEnumType() const { return 0; }
|
||||
virtual const ForwardClassDeclaration *asForwardClassDeclarationType() const { return 0; }
|
||||
virtual const ObjCClass *asObjCClassType() const { return 0; }
|
||||
virtual const ObjCProtocol *asObjCProtocolType() const { return 0; }
|
||||
virtual const ObjCMethod *asObjCMethodType() const { return 0; }
|
||||
virtual const ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() const { return 0; }
|
||||
virtual const ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() const { return 0; }
|
||||
|
||||
virtual UndefinedType *asUndefinedType() { return 0; }
|
||||
virtual VoidType *asVoidType() { return 0; }
|
||||
virtual IntegerType *asIntegerType() { return 0; }
|
||||
virtual FloatType *asFloatType() { return 0; }
|
||||
virtual PointerType *asPointerType() { return 0; }
|
||||
virtual PointerToMemberType *asPointerToMemberType() { return 0; }
|
||||
virtual ReferenceType *asReferenceType() { return 0; }
|
||||
virtual ArrayType *asArrayType() { return 0; }
|
||||
virtual NamedType *asNamedType() { return 0; }
|
||||
virtual Function *asFunctionType() { return 0; }
|
||||
virtual Namespace *asNamespaceType() { return 0; }
|
||||
virtual Template *asTemplateType() { return 0; }
|
||||
virtual Class *asClassType() { return 0; }
|
||||
virtual Enum *asEnumType() { return 0; }
|
||||
virtual ForwardClassDeclaration *asForwardClassDeclarationType() { return 0; }
|
||||
virtual ObjCClass *asObjCClassType() { return 0; }
|
||||
virtual ObjCProtocol *asObjCProtocolType() { return 0; }
|
||||
virtual ObjCMethod *asObjCMethodType() { return 0; }
|
||||
virtual ObjCForwardClassDeclaration *asObjCForwardClassDeclarationType() { return 0; }
|
||||
virtual ObjCForwardProtocolDeclaration *asObjCForwardProtocolDeclarationType() { return 0; }
|
||||
|
||||
void accept(TypeVisitor *visitor);
|
||||
static void accept(Type *type, TypeVisitor *visitor);
|
||||
|
||||
static bool matchType(const Type *type, const Type *otherType, TypeMatcher *matcher)
|
||||
{
|
||||
if (! type)
|
||||
return type == otherType;
|
||||
|
||||
return type->matchType(otherType, matcher);
|
||||
}
|
||||
|
||||
bool matchType(const Type *otherType, TypeMatcher *matcher) const;
|
||||
|
||||
virtual bool isEqualTo(const Type *other) const = 0; // ### remove
|
||||
|
||||
protected:
|
||||
virtual void accept0(TypeVisitor *visitor) = 0;
|
||||
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const = 0;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_TYPE_H
|
242
src/libs/3rdparty/cplusplus/TypeMatcher.cpp
vendored
Normal file
242
src/libs/3rdparty/cplusplus/TypeMatcher.cpp
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "TypeMatcher.h"
|
||||
#include "CoreTypes.h"
|
||||
#include "Symbols.h"
|
||||
#include "Names.h"
|
||||
#include "Literals.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
TypeMatcher::TypeMatcher()
|
||||
{
|
||||
}
|
||||
|
||||
TypeMatcher::~TypeMatcher()
|
||||
{
|
||||
}
|
||||
|
||||
bool TypeMatcher::isEqualTo(const Name *name, const Name *otherName) const
|
||||
{
|
||||
if (name == otherName)
|
||||
return true;
|
||||
|
||||
else if (! name || ! otherName)
|
||||
return false;
|
||||
|
||||
return name->isEqualTo(otherName);
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const UndefinedType *, const UndefinedType *)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const VoidType *, const VoidType *)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const IntegerType *type, const IntegerType *otherType)
|
||||
{
|
||||
if (type == otherType)
|
||||
return true;
|
||||
|
||||
else if (type->kind() != otherType->kind())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const FloatType *type, const FloatType *otherType)
|
||||
{
|
||||
if (type == otherType)
|
||||
return true;
|
||||
|
||||
else if (type->kind() != otherType->kind())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const PointerToMemberType *type, const PointerToMemberType *otherType)
|
||||
{
|
||||
if (type == otherType)
|
||||
return true;
|
||||
|
||||
else if (! isEqualTo(type->memberName(), otherType->memberName()))
|
||||
return false;
|
||||
|
||||
else if (! type->elementType().match(otherType->elementType(), this))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const PointerType *type, const PointerType *otherType)
|
||||
{
|
||||
if (type == otherType)
|
||||
return true;
|
||||
|
||||
else if (! type->elementType().match(otherType->elementType(), this))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const ReferenceType *type, const ReferenceType *otherType)
|
||||
{
|
||||
if (type == otherType)
|
||||
return true;
|
||||
|
||||
else if (type->isRvalueReference() != otherType->isRvalueReference())
|
||||
return false;
|
||||
|
||||
else if (! type->elementType().match(otherType->elementType(), this))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const ArrayType *type, const ArrayType *otherType)
|
||||
{
|
||||
if (type == otherType)
|
||||
return true;
|
||||
|
||||
else if (type->size() != otherType->size())
|
||||
return false;
|
||||
|
||||
else if (! type->elementType().match(otherType->elementType(), this))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const NamedType *type, const NamedType *otherType)
|
||||
{
|
||||
if (type == otherType)
|
||||
return true;
|
||||
|
||||
else if (! isEqualTo(type->name(), otherType->name()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const Function *type, const Function *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const Enum *type, const Enum *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const Namespace *type, const Namespace *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const Template *type, const Template *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const ForwardClassDeclaration *type, const ForwardClassDeclaration *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const Class *type, const Class *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const ObjCClass *type, const ObjCClass *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const ObjCProtocol *type, const ObjCProtocol *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const ObjCForwardClassDeclaration *type, const ObjCForwardClassDeclaration *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const ObjCForwardProtocolDeclaration *type, const ObjCForwardProtocolDeclaration *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TypeMatcher::match(const ObjCMethod *type, const ObjCMethod *otherType)
|
||||
{
|
||||
if (type != otherType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
76
src/libs/3rdparty/cplusplus/TypeMatcher.h
vendored
Normal file
76
src/libs/3rdparty/cplusplus/TypeMatcher.h
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef TYPEMATCHER_H
|
||||
#define TYPEMATCHER_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT TypeMatcher
|
||||
{
|
||||
TypeMatcher(const TypeMatcher &other);
|
||||
void operator = (const TypeMatcher &other);
|
||||
|
||||
public:
|
||||
TypeMatcher();
|
||||
virtual ~TypeMatcher();
|
||||
|
||||
virtual bool match(const UndefinedType *type, const UndefinedType *otherType);
|
||||
virtual bool match(const VoidType *type, const VoidType *otherType);
|
||||
virtual bool match(const IntegerType *type, const IntegerType *otherType);
|
||||
virtual bool match(const FloatType *type, const FloatType *otherType);
|
||||
virtual bool match(const PointerToMemberType *type, const PointerToMemberType *otherType);
|
||||
virtual bool match(const PointerType *type, const PointerType *otherType);
|
||||
virtual bool match(const ReferenceType *type, const ReferenceType *otherType);
|
||||
virtual bool match(const ArrayType *type, const ArrayType *otherType);
|
||||
virtual bool match(const NamedType *type, const NamedType *otherType);
|
||||
|
||||
virtual bool match(const Function *type, const Function *otherType);
|
||||
virtual bool match(const Enum *type, const Enum *otherType);
|
||||
virtual bool match(const Namespace *type, const Namespace *otherType);
|
||||
virtual bool match(const Template *type, const Template *otherType);
|
||||
virtual bool match(const ForwardClassDeclaration *type, const ForwardClassDeclaration *otherType);
|
||||
virtual bool match(const Class *type, const Class *otherType);
|
||||
virtual bool match(const ObjCClass *type, const ObjCClass *otherType);
|
||||
virtual bool match(const ObjCProtocol *type, const ObjCProtocol *otherType);
|
||||
virtual bool match(const ObjCForwardClassDeclaration *type, const ObjCForwardClassDeclaration *otherType);
|
||||
virtual bool match(const ObjCForwardProtocolDeclaration *type, const ObjCForwardProtocolDeclaration *otherType);
|
||||
virtual bool match(const ObjCMethod *type, const ObjCMethod *otherType);
|
||||
|
||||
bool isEqualTo(const Name *name, const Name *otherName) const;
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
#endif // TYPEMATCHER_H
|
66
src/libs/3rdparty/cplusplus/TypeVisitor.cpp
vendored
Normal file
66
src/libs/3rdparty/cplusplus/TypeVisitor.cpp
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "TypeVisitor.h"
|
||||
#include "Type.h"
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
TypeVisitor::TypeVisitor()
|
||||
{ }
|
||||
|
||||
TypeVisitor::~TypeVisitor()
|
||||
{ }
|
||||
|
||||
void TypeVisitor::accept(Type *type)
|
||||
{ Type::accept(type, this); }
|
||||
|
||||
|
98
src/libs/3rdparty/cplusplus/TypeVisitor.h
vendored
Normal file
98
src/libs/3rdparty/cplusplus/TypeVisitor.h
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#ifndef CPLUSPLUS_TYPEVISITOR_H
|
||||
#define CPLUSPLUS_TYPEVISITOR_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
|
||||
namespace CPlusPlus {
|
||||
|
||||
class CPLUSPLUS_EXPORT TypeVisitor
|
||||
{
|
||||
TypeVisitor(const TypeVisitor &other);
|
||||
void operator =(const TypeVisitor &other);
|
||||
|
||||
public:
|
||||
TypeVisitor();
|
||||
virtual ~TypeVisitor();
|
||||
|
||||
void accept(Type *type);
|
||||
|
||||
virtual bool preVisit(Type *) { return true; }
|
||||
virtual void postVisit(Type *) {}
|
||||
|
||||
virtual void visit(UndefinedType *) {}
|
||||
virtual void visit(VoidType *) {}
|
||||
virtual void visit(IntegerType *) {}
|
||||
virtual void visit(FloatType *) {}
|
||||
virtual void visit(PointerToMemberType *) {}
|
||||
virtual void visit(PointerType *) {}
|
||||
virtual void visit(ReferenceType *) {}
|
||||
virtual void visit(ArrayType *) {}
|
||||
virtual void visit(NamedType *) {}
|
||||
virtual void visit(Function *) {}
|
||||
virtual void visit(Namespace *) {}
|
||||
virtual void visit(Template *) {}
|
||||
virtual void visit(Class *) {}
|
||||
virtual void visit(Enum *) {}
|
||||
virtual void visit(ForwardClassDeclaration *) {}
|
||||
virtual void visit(ObjCClass *) {}
|
||||
virtual void visit(ObjCProtocol *) {}
|
||||
virtual void visit(ObjCMethod *) {}
|
||||
virtual void visit(ObjCForwardClassDeclaration *) {}
|
||||
virtual void visit(ObjCForwardProtocolDeclaration*) {}
|
||||
};
|
||||
|
||||
} // namespace CPlusPlus
|
||||
|
||||
|
||||
#endif // CPLUSPLUS_TYPEVISITOR_H
|
71
src/libs/3rdparty/cplusplus/cplusplus.pri
vendored
Normal file
71
src/libs/3rdparty/cplusplus/cplusplus.pri
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
DEPENDPATH += $$PWD
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/CPlusPlus.h \
|
||||
$$PWD/AST.h \
|
||||
$$PWD/ASTVisitor.h \
|
||||
$$PWD/ASTMatcher.h \
|
||||
$$PWD/ASTPatternBuilder.h \
|
||||
$$PWD/ASTfwd.h \
|
||||
$$PWD/TypeMatcher.h \
|
||||
$$PWD/CPlusPlusForwardDeclarations.h \
|
||||
$$PWD/Control.h \
|
||||
$$PWD/CoreTypes.h \
|
||||
$$PWD/DiagnosticClient.h \
|
||||
$$PWD/FullySpecifiedType.h \
|
||||
$$PWD/Lexer.h \
|
||||
$$PWD/LiteralTable.h \
|
||||
$$PWD/Literals.h \
|
||||
$$PWD/MemoryPool.h \
|
||||
$$PWD/Name.h \
|
||||
$$PWD/NameVisitor.h \
|
||||
$$PWD/Names.h \
|
||||
$$PWD/Parser.h \
|
||||
$$PWD/Scope.h \
|
||||
$$PWD/Bind.h \
|
||||
$$PWD/Symbol.h \
|
||||
$$PWD/Symbols.h \
|
||||
$$PWD/SymbolVisitor.h \
|
||||
$$PWD/Token.h \
|
||||
$$PWD/TranslationUnit.h \
|
||||
$$PWD/Type.h \
|
||||
$$PWD/TypeVisitor.h \
|
||||
$$PWD/ObjectiveCTypeQualifiers.h \
|
||||
$$PWD/QtContextKeywords.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/AST.cpp \
|
||||
$$PWD/ASTVisit.cpp \
|
||||
$$PWD/ASTMatch0.cpp \
|
||||
$$PWD/ASTVisitor.cpp \
|
||||
$$PWD/ASTClone.cpp \
|
||||
$$PWD/ASTPatternBuilder.cpp \
|
||||
$$PWD/ASTMatcher.cpp \
|
||||
$$PWD/TypeMatcher.cpp \
|
||||
$$PWD/Control.cpp \
|
||||
$$PWD/CoreTypes.cpp \
|
||||
$$PWD/DiagnosticClient.cpp \
|
||||
$$PWD/FullySpecifiedType.cpp \
|
||||
$$PWD/Keywords.cpp \
|
||||
$$PWD/ObjectiveCAtKeywords.cpp \
|
||||
$$PWD/ObjectiveCTypeQualifiers.cpp \
|
||||
$$PWD/Lexer.cpp \
|
||||
$$PWD/LiteralTable.cpp \
|
||||
$$PWD/Literals.cpp \
|
||||
$$PWD/MemoryPool.cpp \
|
||||
$$PWD/Name.cpp \
|
||||
$$PWD/NameVisitor.cpp \
|
||||
$$PWD/Names.cpp \
|
||||
$$PWD/Parser.cpp \
|
||||
$$PWD/Scope.cpp \
|
||||
$$PWD/Bind.cpp \
|
||||
$$PWD/Symbol.cpp \
|
||||
$$PWD/Symbols.cpp \
|
||||
$$PWD/SymbolVisitor.cpp \
|
||||
$$PWD/Token.cpp \
|
||||
$$PWD/TranslationUnit.cpp \
|
||||
$$PWD/Type.cpp \
|
||||
$$PWD/TypeVisitor.cpp \
|
||||
$$PWD/QtContextKeywords.cpp
|
Reference in New Issue
Block a user