data: compare signatures when storing overloaded functions and methods

Function and method nodes are now distincted by their signature when added to the graph. A different node for each
overloaded declaration is created with the signature as member field.

fortune cookie message = Deine harte Arbeit wird schnell belohnt werden.
This commit is contained in:
Eberhard Graether
2014-07-10 16:08:59 +02:00
parent cdeece6231
commit e2ec5ffee2
11 changed files with 283 additions and 106 deletions
+106
View File
@@ -1,5 +1,111 @@
#include "data/parser/ParserClient.h"
#include <sstream>
#include "data/parser/ParseLocation.h"
#include "data/parser/ParseVariable.h"
#include "data/type/DataType.h"
std::string ParserClient::addAccessPrefix(const std::string& str, AccessType access)
{
switch (access)
{
case ACCESS_PUBLIC:
return "public " + str;
case ACCESS_PROTECTED:
return "protected " + str;
case ACCESS_PRIVATE:
return "private " + str;
case ACCESS_NONE:
return str;
}
}
std::string ParserClient::addAbstractionPrefix(const std::string& str, AbstractionType abstraction)
{
switch (abstraction)
{
case ABSTRACTION_VIRTUAL:
return "virtual " + str;
case ABSTRACTION_PURE_VIRTUAL:
return "pure virtual " + str;
case ABSTRACTION_NONE:
return str;
}
}
std::string ParserClient::addStaticPrefix(const std::string& str, bool isStatic)
{
if (isStatic)
{
return "static " + str;
}
return str;
}
std::string ParserClient::addConstPrefix(const std::string& str, bool isConst, bool atFront)
{
if (isConst)
{
return atFront ? "const " + str : str + " const";
}
return str;
}
std::string ParserClient::addLocationSuffix(const std::string& str, const ParseLocation& location)
{
std::stringstream ss;
ss << str << " <" << location.startLineNumber << ":" << location.startColumnNumber << " ";
ss << location.endLineNumber << ":" << location.endColumnNumber << ">";
return ss.str();
}
std::string ParserClient::variableStr(const ParseVariable& variable, bool withName)
{
std::string str = variable.type.getFullTypeName();
if (withName)
{
str += " " + variable.fullName;
}
return addStaticPrefix(str, variable.isStatic);
}
std::string ParserClient::parameterStr(const std::vector<ParseVariable> parameters, bool withName)
{
std::string str = "(";
for (size_t i = 0; i < parameters.size(); i++)
{
str += variableStr(parameters[i], withName);
if (i < parameters.size() - 1)
{
str += ", ";
}
}
return str + ")";
}
std::string ParserClient::functionStr(
const DataType& returnType,
const std::string& fullName,
const std::vector<ParseVariable>& parameters,
bool isConst
){
return addConstPrefix(
returnType.getFullTypeName() + " " + fullName + parameterStr(parameters),
isConst,
false
);
}
std::string ParserClient::functionSignatureStr(
const DataType& returnType,
const std::string& fullName,
const std::vector<ParseVariable>& parameters,
bool isConst
){
return addConstPrefix(fullName + parameterStr(parameters, false), isConst, false);
}
ParserClient::ParserClient()
{
}
+20
View File
@@ -24,6 +24,26 @@ public:
ABSTRACTION_NONE
};
static std::string addAccessPrefix(const std::string& str, AccessType access);
static std::string addAbstractionPrefix(const std::string& str, AbstractionType abstraction);
static std::string addStaticPrefix(const std::string& str, bool isStatic);
static std::string addConstPrefix(const std::string& str, bool isConst, bool atFront);
static std::string addLocationSuffix(const std::string& str, const ParseLocation& location);
static std::string variableStr(const ParseVariable& variable, bool withName = true);
static std::string parameterStr(const std::vector<ParseVariable> parameters, bool withName = true);
static std::string functionStr(
const DataType& returnType,
const std::string& fullName,
const std::vector<ParseVariable>& parameters,
bool isConst
);
static std::string functionSignatureStr(
const DataType& returnType,
const std::string& fullName,
const std::vector<ParseVariable>& parameters,
bool isConst
);
ParserClient();
virtual ~ParserClient();