moved messages to Json, some refactoring
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "../Distribution/Arrays.h"
|
||||
#include "../DynamicAnalysis/gcov_info.h"
|
||||
#include "../ParallelizationRegions/ParRegions.h"
|
||||
#include "json.hpp"
|
||||
|
||||
#if __SPF
|
||||
#include "acc_analyzer.h"
|
||||
@@ -42,6 +43,7 @@ using std::set;
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::wstring;
|
||||
using json = nlohmann::json;
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
#include <filesystem>
|
||||
@@ -427,7 +429,7 @@ static map<string, vector<Messages>> removeCopies(map<string, vector<Messages>>
|
||||
map<tuple<typeMessage, int, int, wstring>, const Messages*> uniq;
|
||||
for (auto& message : byFile.second)
|
||||
{
|
||||
auto key = make_tuple(message.type, message.group, message.line, message.value);
|
||||
auto key = message.getUniqKey();
|
||||
/*string tmp = "";
|
||||
for (auto& s : message.toString())
|
||||
tmp += (char)s;
|
||||
@@ -460,7 +462,7 @@ static void convertGlobalMessagesBuffer(short *&result, int *&resultSize)
|
||||
bool waschanged = false;
|
||||
for (auto &message : byFile.second)
|
||||
{
|
||||
if (message.line > 0)
|
||||
if (message.getLine() > 0)
|
||||
newVal.push_back(message);
|
||||
else
|
||||
waschanged = true;
|
||||
@@ -470,22 +472,30 @@ static void convertGlobalMessagesBuffer(short *&result, int *&resultSize)
|
||||
byFile.second = newVal;
|
||||
}
|
||||
|
||||
wstring val = L"";
|
||||
val += std::to_wstring(copySPF_messages.size());
|
||||
for (auto it = copySPF_messages.begin(); it != copySPF_messages.end(); ++it)
|
||||
json allMessages = json::array();
|
||||
for (auto& byFile : copySPF_messages)
|
||||
{
|
||||
val += L"|" + to_wstring(it->first.c_str()) + L"|" + std::to_wstring(it->second.size());
|
||||
for (int k = 0; k < it->second.size(); ++k)
|
||||
val += it->second[k].toString();
|
||||
json inFile;
|
||||
inFile["file"] = byFile.first;
|
||||
|
||||
json array = json::array();
|
||||
for (auto& message : byFile.second)
|
||||
{
|
||||
json msg = message.toJson();
|
||||
array.push_back(msg);
|
||||
}
|
||||
inFile["messages"] = array;
|
||||
allMessages.push_back(inFile);
|
||||
}
|
||||
|
||||
const unsigned len = (unsigned)val.size();
|
||||
result = new short[len + 1];
|
||||
allocated.insert(result);
|
||||
json all;
|
||||
all["allMessages"] = allMessages;
|
||||
|
||||
result[len] = '\0';
|
||||
for (unsigned i = 0; i < len; ++i)
|
||||
result[i] = val[i];
|
||||
const string str = all.dump();
|
||||
const unsigned len = (unsigned)str.size();
|
||||
|
||||
copyStringToShort(result, str);
|
||||
allocated.insert(result);
|
||||
|
||||
resultSize = new int[1];
|
||||
resultSize[0] = (int)len;
|
||||
@@ -1686,4 +1696,16 @@ set<string> fillDistributedArrays(const DataDirective& dataDirectives,
|
||||
for (auto& elem : ret)
|
||||
distrArrays.insert(shortName ? elem->GetShortName() : elem->GetName());
|
||||
return distrArrays;
|
||||
}
|
||||
|
||||
void copyStringToShort(short*& result, const string& resVal, bool withEnd)
|
||||
{
|
||||
result = new short[resVal.size() + 1];
|
||||
allocated.insert(result);
|
||||
|
||||
for (int i = 0; i < resVal.size(); ++i)
|
||||
result[i] = resVal[i];
|
||||
|
||||
if (withEnd)
|
||||
result[resVal.size()] = (short)'\0';
|
||||
}
|
||||
Reference in New Issue
Block a user