forked from qt-creator/qt-creator
CPlusPlus: Inline some Scope related simple functions
Change-Id: I23486fdfa749fe864c04d5c1a7cede21fb16005b Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
35
src/libs/3rdparty/cplusplus/Scope.cpp
vendored
35
src/libs/3rdparty/cplusplus/Scope.cpp
vendored
@@ -19,7 +19,6 @@
|
|||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include "Scope.h"
|
#include "Scope.h"
|
||||||
#include "Symbols.h"
|
|
||||||
#include "Names.h"
|
#include "Names.h"
|
||||||
#include "Literals.h"
|
#include "Literals.h"
|
||||||
#include "Templates.h"
|
#include "Templates.h"
|
||||||
@@ -55,19 +54,19 @@ public:
|
|||||||
void enterSymbol(Symbol *symbol);
|
void enterSymbol(Symbol *symbol);
|
||||||
|
|
||||||
/// Returns true if this Scope is empty; otherwise returns false.
|
/// Returns true if this Scope is empty; otherwise returns false.
|
||||||
bool isEmpty() const;
|
bool isEmpty() const { return _symbolCount == -1; }
|
||||||
|
|
||||||
/// Returns the number of symbols is in the scope.
|
/// Returns the number of symbols is in the scope.
|
||||||
int symbolCount() const;
|
int symbolCount() const { return _symbolCount + 1; }
|
||||||
|
|
||||||
/// Returns the Symbol at the given position.
|
/// Returns the Symbol at the given position.
|
||||||
Symbol *symbolAt(int index) const;
|
Symbol *symbolAt(int index) const;
|
||||||
|
|
||||||
/// Returns the first Symbol in the scope.
|
/// Returns the first Symbol in the scope.
|
||||||
iterator firstSymbol() const;
|
iterator firstSymbol() const { return _symbols; }
|
||||||
|
|
||||||
/// Returns the last Symbol in the scope.
|
/// Returns the last Symbol in the scope.
|
||||||
iterator lastSymbol() const;
|
iterator lastSymbol() const { return _symbols + _symbolCount + 1; }
|
||||||
|
|
||||||
Symbol *lookat(const Identifier *id) const;
|
Symbol *lookat(const Identifier *id) const;
|
||||||
Symbol *lookat(OperatorNameId::Kind operatorId) const;
|
Symbol *lookat(OperatorNameId::Kind operatorId) const;
|
||||||
@@ -225,12 +224,6 @@ unsigned SymbolTable::hashValue(Symbol *symbol) const
|
|||||||
return symbol->hashCode() % _hashSize;
|
return symbol->hashCode() % _hashSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SymbolTable::isEmpty() const
|
|
||||||
{ return _symbolCount == -1; }
|
|
||||||
|
|
||||||
int SymbolTable::symbolCount() const
|
|
||||||
{ return _symbolCount + 1; }
|
|
||||||
|
|
||||||
Symbol *SymbolTable::symbolAt(int index) const
|
Symbol *SymbolTable::symbolAt(int index) const
|
||||||
{
|
{
|
||||||
if (! _symbols)
|
if (! _symbols)
|
||||||
@@ -238,12 +231,6 @@ Symbol *SymbolTable::symbolAt(int index) const
|
|||||||
return _symbols[index];
|
return _symbols[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolTable::iterator SymbolTable::firstSymbol() const
|
|
||||||
{ return _symbols; }
|
|
||||||
|
|
||||||
SymbolTable::iterator SymbolTable::lastSymbol() const
|
|
||||||
{ return _symbols + _symbolCount + 1; }
|
|
||||||
|
|
||||||
Scope::Scope(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
Scope::Scope(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
||||||
: Symbol(translationUnit, sourceLocation, name),
|
: Symbol(translationUnit, sourceLocation, name),
|
||||||
_members(nullptr),
|
_members(nullptr),
|
||||||
@@ -302,18 +289,4 @@ Symbol *Scope::find(OperatorNameId::Kind operatorId) const
|
|||||||
Symbol *Scope::find(const ConversionNameId *conv) const
|
Symbol *Scope::find(const ConversionNameId *conv) const
|
||||||
{ return _members ? _members->lookat(conv) : nullptr; }
|
{ return _members ? _members->lookat(conv) : nullptr; }
|
||||||
|
|
||||||
/// Set the start offset of the scope
|
|
||||||
int Scope::startOffset() const
|
|
||||||
{ return _startOffset; }
|
|
||||||
|
|
||||||
void Scope::setStartOffset(int offset)
|
|
||||||
{ _startOffset = offset; }
|
|
||||||
|
|
||||||
/// Set the end offset of the scope
|
|
||||||
int Scope::endOffset() const
|
|
||||||
{ return _endOffset; }
|
|
||||||
|
|
||||||
void Scope::setEndOffset(int offset)
|
|
||||||
{ _endOffset = offset; }
|
|
||||||
|
|
||||||
} // namespace CPlusPlus
|
} // namespace CPlusPlus
|
||||||
|
19
src/libs/3rdparty/cplusplus/Scope.h
vendored
19
src/libs/3rdparty/cplusplus/Scope.h
vendored
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
namespace CPlusPlus {
|
namespace CPlusPlus {
|
||||||
|
|
||||||
class CPLUSPLUS_EXPORT Scope: public Symbol
|
class CPLUSPLUS_EXPORT Scope : public Symbol
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Scope(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
|
Scope(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
|
||||||
@@ -58,18 +58,17 @@ public:
|
|||||||
Symbol *find(const ConversionNameId *conv) const;
|
Symbol *find(const ConversionNameId *conv) const;
|
||||||
|
|
||||||
/// Set the start offset of the scope
|
/// Set the start offset of the scope
|
||||||
int startOffset() const;
|
int startOffset() const { return _startOffset; }
|
||||||
void setStartOffset(int offset);
|
/// Set the start offset of the scope
|
||||||
|
void setStartOffset(int offset) { _startOffset = offset; }
|
||||||
|
|
||||||
/// Set the end offset of the scope
|
/// Set the end offset of the scope
|
||||||
int endOffset() const;
|
int endOffset() const { return _endOffset; }
|
||||||
void setEndOffset(int offset);
|
/// Set the end offset of the scope
|
||||||
|
void setEndOffset(int offset) { _endOffset = offset; }
|
||||||
|
|
||||||
const Scope *asScope() const override
|
const Scope *asScope() const override { return this; }
|
||||||
{ return this; }
|
Scope *asScope() override { return this; }
|
||||||
|
|
||||||
Scope *asScope() override
|
|
||||||
{ return this; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SymbolTable *_members;
|
SymbolTable *_members;
|
||||||
|
1
src/libs/3rdparty/cplusplus/Symbols.cpp
vendored
1
src/libs/3rdparty/cplusplus/Symbols.cpp
vendored
@@ -201,7 +201,6 @@ EnumeratorDeclaration::EnumeratorDeclaration(TranslationUnit *translationUnit, i
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Argument::Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
Argument::Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
|
||||||
: Symbol(translationUnit, sourceLocation, name),
|
: Symbol(translationUnit, sourceLocation, name),
|
||||||
_initializer(nullptr)
|
_initializer(nullptr)
|
||||||
|
7
src/libs/3rdparty/cplusplus/Symbols.h
vendored
7
src/libs/3rdparty/cplusplus/Symbols.h
vendored
@@ -195,11 +195,8 @@ public:
|
|||||||
// Symbol's interface
|
// Symbol's interface
|
||||||
FullySpecifiedType type() const override;
|
FullySpecifiedType type() const override;
|
||||||
|
|
||||||
const Block *asBlock() const override
|
const Block *asBlock() const override { return this; }
|
||||||
{ return this; }
|
Block *asBlock() override { return this; }
|
||||||
|
|
||||||
Block *asBlock() override
|
|
||||||
{ return this; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void visitSymbol0(SymbolVisitor *visitor) override;
|
void visitSymbol0(SymbolVisitor *visitor) override;
|
||||||
|
Reference in New Issue
Block a user