logic: add storage transformation to merge anonymous types and the respective typedef
* moved storage related classes to data/storage folder * implemented recording c++ unions as NODE_UNION instead of just using NODE_TYPE * added transformation to merge anonymous classes/structs/enums/unions and typedef nodes * added tests for this transformation * added setting for enabling/disabling this transformation
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
#include "data/storage/StorageProvider.h"
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
int StorageProvider::getStorageCount() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
||||
return m_storages.size();
|
||||
}
|
||||
|
||||
void StorageProvider::insert(std::shared_ptr<IntermediateStorage> storage)
|
||||
{
|
||||
const std::size_t storageSize = storage->getSourceLocationCount();
|
||||
std::list<std::shared_ptr<IntermediateStorage>>::iterator it;
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
||||
for (it = m_storages.begin(); it != m_storages.end(); it++)
|
||||
{
|
||||
if ((*it)->getSourceLocationCount() < storageSize)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_storages.insert(it, storage);
|
||||
}
|
||||
|
||||
std::shared_ptr<IntermediateStorage> StorageProvider::consumeSecondLargestStorage()
|
||||
{
|
||||
std::shared_ptr<IntermediateStorage> ret;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
||||
if (m_storages.size() > 1)
|
||||
{
|
||||
std::list<std::shared_ptr<IntermediateStorage>>::iterator it = m_storages.begin();
|
||||
it++;
|
||||
ret = *it;
|
||||
m_storages.erase(it);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::shared_ptr<IntermediateStorage> StorageProvider::consumeLargestStorage()
|
||||
{
|
||||
std::shared_ptr<IntermediateStorage> ret;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
||||
if (!m_storages.empty())
|
||||
{
|
||||
ret = m_storages.front();
|
||||
m_storages.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void StorageProvider::logCurrentState() const
|
||||
{
|
||||
std::string logString = "Storages waiting for injection:";
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_storagesMutex);
|
||||
for (std::shared_ptr<IntermediateStorage> storage: m_storages)
|
||||
{
|
||||
logString += " " + std::to_string(storage->getSourceLocationCount()) + ";";
|
||||
}
|
||||
}
|
||||
LOG_INFO(logString);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user