diff --git a/sapfor/experts/Sapfor_2017/_src/ProjectParameters/projectParameters.cpp b/sapfor/experts/Sapfor_2017/_src/ProjectParameters/projectParameters.cpp index 524f67d..30b83b0 100644 --- a/sapfor/experts/Sapfor_2017/_src/ProjectParameters/projectParameters.cpp +++ b/sapfor/experts/Sapfor_2017/_src/ProjectParameters/projectParameters.cpp @@ -99,14 +99,14 @@ vector FindLoopsWithFilename(string filename, const map> found, int block_num, SAPFOR::Instruction* instr){ -// for(pair p: found){ -// if(p.first == block_num && p.second == instr){ -// return true; -// } -// } -// return -// } +bool CheckIfInstructionIsFound(vector> found, int block_num, SAPFOR::Instruction* instr){ + for(pair p: found){ + if(p.first == block_num && p.second == instr){ + return true; + } + } + return false; +} map< pair, set> findParameters(const map> &defUseByFunctions, @@ -157,6 +157,7 @@ map< pair, set> } } } + */ cout << "\n\nLoopGraph" << endl; for(const pair>& p: loopGraph){ cout << "file name = " << p.first << endl; @@ -180,7 +181,7 @@ map< pair, set> } } } - */ + // Находим для каждой функции блоки, с которых начинаются циклы @@ -207,7 +208,7 @@ map< pair, set> } } - map> finalInstructions; + map>> finalInstructions; for(const auto lookedFunc: mapFuncLoops){ for(const auto& v: lookedFunc.second){ // cout << "NEW LOOP SEARCH" << endl; @@ -219,6 +220,9 @@ map< pair, set> int block_ind = 0; // for(auto pr: argumentsForLook){cout << "FIRST ARGUMENT TO FIND: " << pr->getValue() << endl;} while(block_ind < blocks.size()){ + if(argumentsForLook.empty()){ + break; + } vector blockInstructions = blocks[block_ind]->getInstructions(); int vec_size = blockInstructions.size(); // cout << "NUMBER OF INSTRUCTIONS IN BLOCK " << blocks[block_ind]->getNumber() << " IS: " << vec_size << endl; @@ -231,7 +235,7 @@ map< pair, set> // cout << "Instruction Operation (type): " << SAPFOR::CFG_OP_S[(int)cur->getOperation()] << endl; if(cur->getOperation() == SAPFOR::CFG_OP::F_CALL){ if(cur->getArg1()->getValue() == "_READ"){ - cout << "READ OPERATION FOUND" << endl; + // cout << "READ OPERATION FOUND" << endl; int numParams = std::stoi(cur->getArg2()->getValue()); bool flag = false; for(int j=i-1; j>i-numParams-1; j--){ @@ -241,12 +245,12 @@ map< pair, set> flag = true; } } - if(flag && find(finalInstructions[lookedFunc.first].begin(), finalInstructions[lookedFunc.first].end(), cur) == finalInstructions[lookedFunc.first].end()){ - finalInstructions[lookedFunc.first].push_back(cur); - } - // if(flag && CheckIfInstructionIsFound(finalInstructions[lookedFunc.first], blocks[block_ind]->getNumber(), cur)){ - // finalInstructions[lookedFunc.first].push_back({blocks[block_ind]->getNumber(), cur}); + // if(flag && find(finalInstructions[lookedFunc.first].begin(), finalInstructions[lookedFunc.first].end(), cur) == finalInstructions[lookedFunc.first].end()){ + // finalInstructions[lookedFunc.first].push_back(cur); // } + if(flag && !CheckIfInstructionIsFound(finalInstructions[lookedFunc.first], blocks[block_ind]->getNumber(), cur)){ + finalInstructions[lookedFunc.first].push_back({blocks[block_ind]->getNumber(), cur}); + } i = i-numParams; continue; } @@ -314,9 +318,10 @@ map< pair, set> for(auto m: finalInstructions){ cout << "func: " << m.first->funcName << endl; for(auto v: m.second){ - cout << "instruction num: " << v->getNumber() << endl; - cout << v->dump() << endl; - cout << v->getOperator()->sunparse() << endl; + cout << "Block num: " << v.first << endl; + cout << "Istruction num in block: " << v.second->getNumber() << endl; + cout << "Instruction dump: " << v.second->dump() << endl; + cout << "Operator" << v.second->getOperator()->sunparse() << endl; } }