diff --git a/src/Distribution/Array.h b/src/Distribution/Array.h index 4d56db1..17365a0 100644 --- a/src/Distribution/Array.h +++ b/src/Distribution/Array.h @@ -9,6 +9,7 @@ #include "DvmhDirectiveBase.h" #include "../Utils/utils.h" #include "../Utils/errors.h" +#include "../Utils/json.hpp" class Symbol; class Expression; @@ -20,6 +21,7 @@ struct FuncInfo; #define MAP std::map #define SET std::set #define TO_STR std::to_string +#define JSON nlohmann::json #if __SPF extern int sharedMemoryParallelization; @@ -424,6 +426,7 @@ namespace Distribution void ClearShadowSpecs() { allShadowSpecs.clear(); } + //TODO: to remove STRING toString() { STRING retVal = ""; @@ -466,6 +469,63 @@ namespace Distribution return retVal; } + JSON toJson() + { + JSON retVal; + + retVal["id"] = (int64_t)id; + retVal["name"] = name; + retVal["shortName"] = shortName; + + retVal["dimSize"] = dimSize; + retVal["typeSize"] = typeSize; + retVal["state"] = (int)isNonDistribute; + retVal["location"] = (int)locationPos.first; + retVal["locName"] = locationPos.second; + + retVal["isTemplFlag"] = (int)isTemplFlag; + retVal["isLoopArrayFlag"] = (int)isLoopArrayFlag; + + JSON deprToDist = nlohmann::json::array(); + for (int i = 0; i < depracateToDistribute.size(); ++i) + deprToDist.push_back((int)depracateToDistribute[i]); + retVal["depracateToDist"] = deprToDist; + + JSON mappedDimsJ = nlohmann::json::array(); + for (int i = 0; i < mappedDims.size(); ++i) + mappedDimsJ.push_back((int)mappedDims[i]); + retVal["mappedDims"] = mappedDimsJ; + + JSON sizesJ = nlohmann::json::array(); + for (int i = 0; i < sizes.size(); ++i) + { + JSON pair; + pair["key"] = sizes[i].first; + pair["value"] = sizes[i].second; + sizesJ.push_back(pair); + } + retVal["sizes"] = sizesJ; + + JSON regions = nlohmann::json::array(); + for (auto& reg : containsInRegions) + regions.push_back(reg); + retVal["regions"] = regions; + + + JSON declPlacesJ = nlohmann::json::array(); + for (auto& place : declPlaces) + { + JSON elem; + elem["array_name"] = place.first; + elem["array_loc"] = place.second; + + declPlacesJ.push_back(elem); + } + retVal["declPlaces"] = declPlacesJ; + + return retVal; + } + Array* GetTemplateArray(const uint64_t regionId, bool withCheck = true) { TemplateLink *currLink = getTemlateInfo(regionId, withCheck); diff --git a/src/Utils/version.h b/src/Utils/version.h index 2633120..ed408b9 100644 --- a/src/Utils/version.h +++ b/src/Utils/version.h @@ -1,3 +1,3 @@ #pragma once -#define VERSION_SPF "2416" +#define VERSION_SPF "2417" diff --git a/src/VisualizerCalls/get_information.cpp b/src/VisualizerCalls/get_information.cpp index 698d970..058108f 100644 --- a/src/VisualizerCalls/get_information.cpp +++ b/src/VisualizerCalls/get_information.cpp @@ -1416,14 +1416,17 @@ int SPF_GetAllDeclaratedArrays(void*& context, int winHandler, short *options, s { runPassesForVisualizer(projName, { GET_ALL_ARRAY_DECL }); - string resVal = ""; - for (auto f = declaredArrays.begin(); f != declaredArrays.end(); ++f) + json arrays = json::array(); + for (const auto& [_, array] : declaredArrays) { - if (f != declaredArrays.begin()) - resVal += "@"; - resVal += f->second.first->toString(); + json jArray = array.first->toJson(); + arrays.push_back(jArray); } + json allArrays; + allArrays["allArrays"] = arrays; + string resVal = allArrays.dump(); + copyStringToShort(result, resVal); retSize = (int)resVal.size() + 1; }