CPlusPlus: Inline some Scope related simple functions

Change-Id: I23486fdfa749fe864c04d5c1a7cede21fb16005b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2022-06-24 16:37:14 +02:00
parent 6b32f58225
commit 27d51e9804
4 changed files with 15 additions and 47 deletions

View File

@@ -19,7 +19,6 @@
// THE SOFTWARE.
#include "Scope.h"
#include "Symbols.h"
#include "Names.h"
#include "Literals.h"
#include "Templates.h"
@@ -55,19 +54,19 @@ public:
void enterSymbol(Symbol *symbol);
/// 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.
int symbolCount() const;
int symbolCount() const { return _symbolCount + 1; }
/// Returns the Symbol at the given position.
Symbol *symbolAt(int index) const;
/// Returns the first Symbol in the scope.
iterator firstSymbol() const;
iterator firstSymbol() const { return _symbols; }
/// 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(OperatorNameId::Kind operatorId) const;
@@ -225,12 +224,6 @@ unsigned SymbolTable::hashValue(Symbol *symbol) const
return symbol->hashCode() % _hashSize;
}
bool SymbolTable::isEmpty() const
{ return _symbolCount == -1; }
int SymbolTable::symbolCount() const
{ return _symbolCount + 1; }
Symbol *SymbolTable::symbolAt(int index) const
{
if (! _symbols)
@@ -238,12 +231,6 @@ Symbol *SymbolTable::symbolAt(int index) const
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)
: Symbol(translationUnit, sourceLocation, name),
_members(nullptr),
@@ -302,18 +289,4 @@ Symbol *Scope::find(OperatorNameId::Kind operatorId) const
Symbol *Scope::find(const ConversionNameId *conv) const
{ 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

View File

@@ -26,7 +26,7 @@
namespace CPlusPlus {
class CPLUSPLUS_EXPORT Scope: public Symbol
class CPLUSPLUS_EXPORT Scope : public Symbol
{
public:
Scope(TranslationUnit *translationUnit, int sourceLocation, const Name *name);
@@ -58,18 +58,17 @@ public:
Symbol *find(const ConversionNameId *conv) const;
/// Set the start offset of the scope
int startOffset() const;
void setStartOffset(int offset);
int startOffset() const { return _startOffset; }
/// Set the start offset of the scope
void setStartOffset(int offset) { _startOffset = offset; }
/// Set the end offset of the scope
int endOffset() const;
void setEndOffset(int offset);
int endOffset() const { return _endOffset; }
/// Set the end offset of the scope
void setEndOffset(int offset) { _endOffset = offset; }
const Scope *asScope() const override
{ return this; }
Scope *asScope() override
{ return this; }
const Scope *asScope() const override { return this; }
Scope *asScope() override { return this; }
private:
SymbolTable *_members;

View File

@@ -201,7 +201,6 @@ EnumeratorDeclaration::EnumeratorDeclaration(TranslationUnit *translationUnit, i
{}
Argument::Argument(TranslationUnit *translationUnit, int sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name),
_initializer(nullptr)

View File

@@ -195,11 +195,8 @@ public:
// Symbol's interface
FullySpecifiedType type() const override;
const Block *asBlock() const override
{ return this; }
Block *asBlock() override
{ return this; }
const Block *asBlock() const override { return this; }
Block *asBlock() override { return this; }
protected:
void visitSymbol0(SymbolVisitor *visitor) override;