data: revised indexing
* increased performance. coati is now 1.55 times as fast as at version 0.4 * integrated sourceweb parsing code * removed astbodyvisitor * NameHierarchy now store signatures in a new format * storage does not allow to re-set the type of a node, once it is marked as "defined". * made onTemplateRecordSpecParsed just create the edge, not the node. * removed distinction between template specialitzations for functions and classes
This commit is contained in:
@@ -1,12 +1,61 @@
|
||||
#include "data/name/NameElement.h"
|
||||
|
||||
NameElement::NameElement(const std::string& name)
|
||||
: m_name(name)
|
||||
, m_signature("")
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
std::string NameElement::Signature::serialize(Signature signature)
|
||||
{
|
||||
return signature.m_prefix + "\r" + signature.m_postfix;
|
||||
}
|
||||
|
||||
NameElement::Signature NameElement::Signature::deserialize(const std::string& serialized)
|
||||
{
|
||||
std::vector<std::string> serializedElements = utility::splitToVector(serialized, "\r");
|
||||
if (serializedElements.size() != 2)
|
||||
{
|
||||
LOG_ERROR("unable to deserialize name signature: " + serialized); // todo: obfuscate serialized!
|
||||
}
|
||||
return Signature(serializedElements[0], serializedElements[1]);
|
||||
}
|
||||
|
||||
NameElement::Signature::Signature()
|
||||
{
|
||||
}
|
||||
|
||||
NameElement::NameElement(const std::string& name, const std::string& signature)
|
||||
NameElement::Signature::Signature(std::string prefix, std::string postfix)
|
||||
: m_prefix(prefix)
|
||||
, m_postfix(postfix)
|
||||
{
|
||||
}
|
||||
|
||||
std::string NameElement::Signature::qualifyName(const std::string& name) const
|
||||
{
|
||||
if (!isValid())
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string qualifiedName = m_prefix;
|
||||
if (name.size() > 0)
|
||||
{
|
||||
qualifiedName += " " + name;
|
||||
}
|
||||
qualifiedName += m_postfix;
|
||||
|
||||
return qualifiedName;
|
||||
}
|
||||
|
||||
bool NameElement::Signature::isValid() const
|
||||
{
|
||||
return ((m_prefix + m_postfix).size() > 0);
|
||||
}
|
||||
|
||||
NameElement::NameElement(const std::string& name)
|
||||
: m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
NameElement::NameElement(const std::string& name, const Signature& signature)
|
||||
: m_name(name)
|
||||
, m_signature(signature)
|
||||
{
|
||||
@@ -16,12 +65,22 @@ NameElement::~NameElement()
|
||||
{
|
||||
}
|
||||
|
||||
std::string NameElement::getFullName() const
|
||||
std::string NameElement::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
std::string NameElement::getFullSignature() const
|
||||
std::string NameElement::getNameWithSignature() const
|
||||
{
|
||||
return m_signature.qualifyName(m_name);
|
||||
}
|
||||
|
||||
bool NameElement::hasSignature() const
|
||||
{
|
||||
return m_signature.isValid();
|
||||
}
|
||||
|
||||
NameElement::Signature NameElement::getSignature()
|
||||
{
|
||||
return m_signature;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,43 @@
|
||||
#ifndef NAME_ELEMENT_H
|
||||
#define NAME_ELEMENT_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class DataType;
|
||||
|
||||
class NameElement
|
||||
{
|
||||
public:
|
||||
class Signature
|
||||
{
|
||||
public:
|
||||
static std::string serialize(Signature signature);
|
||||
static Signature deserialize(const std::string& serialized);
|
||||
|
||||
Signature();
|
||||
Signature(std::string prefix, std::string postfix);
|
||||
std::string qualifyName(const std::string& name) const;
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
std::string m_prefix;
|
||||
std::string m_postfix;
|
||||
};
|
||||
|
||||
NameElement(const std::string& name);
|
||||
NameElement(const std::string& name, const std::string& signature);
|
||||
NameElement(const std::string& name, const Signature& signature);
|
||||
~NameElement();
|
||||
|
||||
std::string getFullName() const;
|
||||
std::string getFullSignature() const;
|
||||
std::string getName() const;
|
||||
std::string getNameWithSignature() const;
|
||||
bool hasSignature() const;
|
||||
Signature getSignature();
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
std::string m_signature;
|
||||
Signature m_signature;
|
||||
};
|
||||
|
||||
#endif // NAME_ELEMENT_H
|
||||
|
||||
@@ -8,10 +8,12 @@ std::string NameHierarchy::serialize(NameHierarchy nameHierarchy)
|
||||
std::string serializedName = "";
|
||||
for (size_t i = 0; i < nameHierarchy.size(); i++)
|
||||
{
|
||||
serializedName += nameHierarchy[i]->getFullName() + "\t";
|
||||
serializedName += nameHierarchy[i]->getFullSignature();
|
||||
if (i + 1 < nameHierarchy.size())
|
||||
if (i > 0)
|
||||
{
|
||||
serializedName += "\n";
|
||||
}
|
||||
serializedName += nameHierarchy[i]->getName() + "\t";
|
||||
serializedName += NameElement::Signature::serialize(nameHierarchy[i]->getSignature());
|
||||
}
|
||||
return serializedName;
|
||||
}
|
||||
@@ -29,7 +31,7 @@ NameHierarchy NameHierarchy::deserialize(const std::string& serializedName)
|
||||
LOG_ERROR("unable to deserialize name hierarchy: " + serializedName); // todo: obfuscate serializedName!
|
||||
return NameHierarchy();
|
||||
}
|
||||
nameHierarchy.push(std::make_shared<NameElement>(nameParts[0], nameParts[1]));
|
||||
nameHierarchy.push(std::make_shared<NameElement>(nameParts[0], NameElement::Signature::deserialize(nameParts[1])));
|
||||
}
|
||||
|
||||
return nameHierarchy;
|
||||
@@ -77,26 +79,44 @@ size_t NameHierarchy::size() const
|
||||
return m_elements.size();
|
||||
}
|
||||
|
||||
std::string NameHierarchy::getFullName() const
|
||||
std::string NameHierarchy::getQualifiedName() const
|
||||
{
|
||||
std::string name;
|
||||
for (size_t i = 0; i < m_elements.size(); i++)
|
||||
{
|
||||
name += m_elements[i]->getFullName();
|
||||
if (i + 1 < m_elements.size())
|
||||
if (i > 0)
|
||||
{
|
||||
name += "::";
|
||||
}
|
||||
name += m_elements[i]->getName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string NameHierarchy::getName() const
|
||||
std::string NameHierarchy::getQualifiedNameWithSignature() const
|
||||
{
|
||||
std::string name = getQualifiedName();
|
||||
if (m_elements.size())
|
||||
{
|
||||
name = m_elements.back()->getSignature().qualifyName(name);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string NameHierarchy::getRawName() const
|
||||
{
|
||||
if (m_elements.size())
|
||||
{
|
||||
return m_elements.back()->getFullName();
|
||||
return m_elements.back()->getName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string NameHierarchy::getRawNameWithSignature() const
|
||||
{
|
||||
if (m_elements.size())
|
||||
{
|
||||
return m_elements.back()->getNameWithSignature();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ public:
|
||||
std::shared_ptr<NameElement> operator[](size_t pos) const;
|
||||
size_t size() const;
|
||||
|
||||
std::string getFullName() const;
|
||||
std::string getName() const;
|
||||
std::string getQualifiedName() const;
|
||||
std::string getQualifiedNameWithSignature() const;
|
||||
std::string getRawName() const;
|
||||
std::string getRawNameWithSignature() const;
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<NameElement>> m_elements;
|
||||
|
||||
Reference in New Issue
Block a user