diff --git a/src/Distribution/Distribution.cpp b/src/Distribution/Distribution.cpp index 1ff6149..64b56d5 100644 --- a/src/Distribution/Distribution.cpp +++ b/src/Distribution/Distribution.cpp @@ -455,15 +455,7 @@ namespace Distribution } if (needPrint) - { -#if _WIN32 - wstring treeM = L"разрешение конфликтов, обработка группы " + std::to_wstring(k + 1) + L"/" + std::to_wstring(AllCycles.size()); -#else - wstring treeM = L"conflict resolution, processing group " + std::to_wstring(k + 1) + L"/" + std::to_wstring(AllCycles.size()); -#endif - sendMessage_2lvl(treeM); - - } + sendMessage_2lvl(4, k, (int)AllCycles.size()); auto timeR = steady_clock::now(); if (countConflicts != 0) @@ -516,7 +508,7 @@ namespace Distribution } if (needPrint) - sendMessage_2lvl(L""); + sendMessage_2lvl(2); return make_pair(allOnlySecondType, globalSum); } @@ -572,13 +564,7 @@ namespace Distribution for (int z = 0; z < arraysV.size(); ++z) { const DIST::Array *array = arraysV[z]; - -#ifdef _WIN32 - wstring treeM = L"разрешение конфликтов, обработка массива " + std::to_wstring(z + 1) + L"/" + std::to_wstring(arrays.size()); -#else - wstring treeM = L"conflict resolution, processing array " + std::to_wstring(z + 1) + L"/" + std::to_wstring(arrays.size()); -#endif - sendMessage_2lvl(treeM); + sendMessage_2lvl(5, z, (int)arrays.size()); vector verts; @@ -605,7 +591,7 @@ namespace Distribution } } } - sendMessage_2lvl(L""); + sendMessage_2lvl(2); } else { diff --git a/src/Distribution/GraphCSR.cpp b/src/Distribution/GraphCSR.cpp index 1890479..9d17db0 100644 --- a/src/Distribution/GraphCSR.cpp +++ b/src/Distribution/GraphCSR.cpp @@ -830,13 +830,13 @@ namespace Distribution color[k] = WHITE; findFrom = currentV; -#ifdef _WIN32 +/*#ifdef _WIN32 if (needPrint) { wstring vertexM = std::to_wstring(k + 1) + L"/" + std::to_wstring(vertByTrees[t].size()); sendMessage_2lvl(wstring(L"поиск простых циклов в графе, обработка дерева ") + wstring(treeM.begin(), treeM.end()) + L" вершины " + wstring(vertexM.begin(), vertexM.end())); } -#endif +#endif*/ __spf_print(PRINT_TIMES && needPrint, "v (tree %d) = %d (with neighb %d) ", t, i, neighbors[i + 1] - neighbors[i]); activeV[activeCounter++] = currentV; FindLoop(cyclesTmp[t], currentV, currentV, numbers); @@ -847,8 +847,8 @@ namespace Distribution maxLoopDim = wasMaxLoopDim; } - if (needPrint) - sendMessage_2lvl(L""); + /*if (needPrint) + sendMessage_2lvl(2);*/ } catch (int code) { diff --git a/src/LoopAnalyzer/loop_analyzer.cpp b/src/LoopAnalyzer/loop_analyzer.cpp index cdbbc7d..dd312bf 100644 --- a/src/LoopAnalyzer/loop_analyzer.cpp +++ b/src/LoopAnalyzer/loop_analyzer.cpp @@ -1633,17 +1633,7 @@ void loopAnalyzer(SgFile *file, vector ®ions, mapfunctions(i)->symbol()->identifier(); -#if _WIN32 - if (file->functions(i)->variant() != MODULE_STMT) - sendMessage_2lvl(wstring(L"обработка функции '") + wstring(fName.begin(), fName.end()) + L"'"); - else - sendMessage_2lvl(wstring(L"обработка модуля '") + wstring(fName.begin(), fName.end()) + L"'"); -#else - if (file->functions(i)->variant() != MODULE_STMT) - sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'"); - else - sendMessage_2lvl(wstring(L"processing module '") + wstring(fName.begin(), fName.end()) + L"'"); -#endif + sendMessage_2lvl(0, (file->functions(i)->variant() != MODULE_STMT), fName); set delcsSymbViewed; set delcsStatViewed; @@ -2188,11 +2178,8 @@ void loopAnalyzer(SgFile *file, vector ®ions, mapfunctions(i)->symbol()->identifier(); -#ifdef _WIN32 - sendMessage_2lvl(wstring(L"обработка цикла ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); -#else - sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(convertedLoopInfo.size())); -#endif + sendMessage_2lvl(1, idx, (int)convertedLoopInfo.size()); + tryToFindDependencies(loop.first, allLoops, funcWasInit, file, regions, currMessages, collection, funcByName, defUseByPlace); } } @@ -2340,7 +2327,7 @@ void loopAnalyzer(SgFile *file, vector ®ions, map parseList(vector& listOfProject, } } -#ifdef _WIN32 - sendMessage_2lvl(L" обработка файла '" + to_wstring(file) + L"'"); -#else - sendMessage_2lvl(L" processing file '" + to_wstring(file) + L"'"); -#endif + sendMessage_2lvl(3, file); + StdCapture::Init(); string errorMessage = ""; try @@ -578,11 +575,8 @@ static void parseFiles(int& iters, vector& errors, vector& lis do { -#ifdef _WIN32 - sendMessage_1lvl(L"выполняется " + std::to_wstring((iters + 1)) + L" итерация синтаксического анализа"); -#else - sendMessage_1lvl(L"running " + std::to_wstring((iters + 1)) + L" iteration of syntax analisys"); -#endif + sendMessage_1lvl(0, iters + 1); + errors = parseList(listOfProject, iters != 0, parseForInlining, mapModuleDeps, moduleDelc, modDirectOrder, isFromConsole); changed = createMapOfUse(errors, listOfProject, mapModuleDeps); if (iters != 0) diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 961964f..24f4a77 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -398,11 +398,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne __spf_print(DEBUG_LVL1, "RUN PASS with name %s\n", passNames[curr_regime]); auto toSendStrMessage = string(passNames[curr_regime]); -#ifdef _WIN32 - sendMessage_1lvl(wstring(L"выполняется РїСЂРѕС…РѕРґ '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'"); -#else - sendMessage_1lvl(wstring(L"running pass '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'"); -#endif + sendMessage_1lvl(1, toSendStrMessage); const int n = project.numberOfFiles(); bool verifyOK = true; @@ -450,11 +446,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne SgFile *file = &(project.file(i)); toSendStrMessage = file->filename(); -#ifdef _WIN32 - sendMessage_2lvl(wstring(L"обработка файла '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'"); -#else - sendMessage_2lvl(wstring(L"processing file '") + wstring(toSendStrMessage.begin(), toSendStrMessage.end()) + L"'"); -#endif + sendMessage_2lvl(3, toSendStrMessage); sendMessage_progress(std::to_wstring((int)(((double)(n - i) / n) * 100))); const char *file_name = file->filename(); @@ -1057,7 +1049,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne throw -11; } - sendMessage_2lvl(wstring(L"")); + sendMessage_2lvl(2); // ********************************** /// /// SECOND AGGREGATION STEP /// // ********************************** /// @@ -1928,7 +1920,7 @@ static bool runAnalysis(SgProject &project, const int curr_regime, const bool ne const float elapsedGlobal = duration_cast(high_resolution_clock::now() - globalTime).count() / 1000.; __spf_print(1, "PROFILE: time for this pass = %f sec (total %f sec)\n", elapsed, elapsedGlobal); - sendMessage_2lvl(wstring(L"")); + sendMessage_2lvl(2); if (internalExit != 0) throw -1; diff --git a/src/Transformations/FunctionInlining/inliner.cpp b/src/Transformations/FunctionInlining/inliner.cpp index 209cffd..bb3231d 100644 --- a/src/Transformations/FunctionInlining/inliner.cpp +++ b/src/Transformations/FunctionInlining/inliner.cpp @@ -1776,11 +1776,8 @@ static bool inliner(const string& fileName_in, const string& funcName, const int point.currCall = func->funcName; __spf_print(1, " INLINE %s - ", func->funcName.c_str()); -#ifdef _WIN32 - sendMessage_2lvl(wstring(L"подстановка функции '") + wstring(func->funcName.begin(), func->funcName.end()) + L"'"); -#else - sendMessage_2lvl(wstring(L"inlinig of function '") + wstring(func->funcName.begin(), func->funcName.end()) + L"'"); -#endif + sendMessage_2lvl(6, func->funcName); + //1 level bool isInlined = run_inliner(funcMap, toInsert, SPF_messages, fileName, func, newSymbsToDeclare, point, commonBlocks); __spf_print(1, "%s\n", isInlined ? "done" : "fault"); diff --git a/src/VisualizerCalls/SendMessage.cpp b/src/VisualizerCalls/SendMessage.cpp index 0997195..068e9fe 100644 --- a/src/VisualizerCalls/SendMessage.cpp +++ b/src/VisualizerCalls/SendMessage.cpp @@ -144,10 +144,116 @@ static int decodeMessage(const string& message, vector& pars, int &winH, return 0; } -void sendMessage_1lvl(const wstring& toSend) { MessageManager::sendFirstLvl (toSend); } -void sendMessage_2lvl(const wstring& toSend) { MessageManager::sendSecondLvl(toSend); } +static void sendMessage_1lvl(const wstring& toSend) { MessageManager::sendFirstLvl (toSend); } +static void sendMessage_2lvl(const wstring& toSend) { MessageManager::sendSecondLvl(toSend); } void sendMessage_progress(const wstring& toSend) { MessageManager::sendProgress (toSend); } +void sendMessage_1lvl(int kind, ...) +{ + va_list list; + va_start(list, kind); + + if (kind == 0) + { + int iters = va_arg(list, int); +#ifdef _WIN32 + sendMessage_1lvl(L"выполняется " + std::to_wstring(iters) + L" итерация синтаксического анализа"); +#else + sendMessage_1lvl(L"running " + std::to_wstring(iters) + L" iteration of syntax analisys"); +#endif + } + else if (kind == 1) + { + string str = va_arg(list, string); +#ifdef _WIN32 + sendMessage_1lvl(wstring(L"выполняется проход '") + wstring(str.begin(), str.end()) + L"'"); +#else + sendMessage_1lvl(wstring(L"running pass '") + wstring(str.begin(), str.end()) + L"'"); +#endif + } + + va_end(list); +} + +void sendMessage_2lvl(int kind, ...) +{ + va_list list; + va_start(list, kind); + + if (kind == 0) + { + bool isFunction = va_arg(list, int); + string fName = va_arg(list, string); +#if _WIN32 + if (isFunction) + sendMessage_2lvl(wstring(L"обработка функции '") + to_wstring(fName) + L"'"); + else + sendMessage_2lvl(wstring(L"обработка модуля '") + to_wstring(fName) + L"'"); +#else + if (isFunction) + sendMessage_2lvl(wstring(L"processing function '") + wstring(fName.begin(), fName.end()) + L"'"); + else + sendMessage_2lvl(wstring(L"processing module '") + wstring(fName.begin(), fName.end()) + L"'"); +#endif + } + else if (kind == 1) + { + int idx = va_arg(list, int); + int all = va_arg(list, int); +#ifdef _WIN32 + sendMessage_2lvl(wstring(L"обработка цикла ") + std::to_wstring(idx) + L"/" + std::to_wstring(all)); +#else + sendMessage_2lvl(wstring(L"processing loop ") + std::to_wstring(idx) + L"/" + std::to_wstring(all)); +#endif + } + else if (kind == 2) + { + sendMessage_2lvl(L""); + } + else if (kind == 3) + { + string file = va_arg(list, string); +#ifdef _WIN32 + sendMessage_2lvl(L" обработка файла '" + to_wstring(file) + L"'"); +#else + sendMessage_2lvl(L" processing file '" + to_wstring(file) + L"'"); +#endif + } + else if (kind == 4) + { + int k = va_arg(list, int); + int all = va_arg(list, int); +#if _WIN32 + wstring treeM = L"разрешение конфликтов, обработка группы " + std::to_wstring(k + 1) + L"/" + std::to_wstring(all); +#else + wstring treeM = L"conflict resolution, processing group " + std::to_wstring(k + 1) + L"/" + std::to_wstring(all); +#endif + sendMessage_2lvl(treeM); + } + else if (kind == 5) + { + int z = va_arg(list, int); + int all = va_arg(list, int); +#ifdef _WIN32 + wstring treeM = L"разрешение конфликтов, обработка массива " + std::to_wstring(z + 1) + L"/" + std::to_wstring(all); +#else + wstring treeM = L"conflict resolution, processing array " + std::to_wstring(z + 1) + L"/" + std::to_wstring(all); +#endif + sendMessage_2lvl(treeM); + } + else if (kind == 6) + { + string funcName = va_arg(list, string); +#ifdef _WIN32 + sendMessage_2lvl(wstring(L"подстановка функции '") + to_wstring(funcName) + L"'"); +#else + sendMessage_2lvl(wstring(L"inlinig of function '") + to_wstring(funcName) + L"'"); +#endif + } + + va_end(list); +} + static string utf8_encode(const wstring& wstr) { if (wstr.empty()) diff --git a/src/VisualizerCalls/SendMessage.h b/src/VisualizerCalls/SendMessage.h index aa3bbba..eeb583b 100644 --- a/src/VisualizerCalls/SendMessage.h +++ b/src/VisualizerCalls/SendMessage.h @@ -32,7 +32,8 @@ public: static int init(); }; -void sendMessage_1lvl(const std::wstring& toSend); -void sendMessage_2lvl(const std::wstring& toSend); +void sendMessage_1lvl(int kind, ...); +void sendMessage_2lvl(int kind, ...); void sendMessage_progress(const std::wstring& toSend); + unsigned int GetPid();