int main(int argc, char** argv){ NProgram program(argc, argv); NPLParser parser; nvar code = parser.parseFile("kernel.npl"); //cout << "code is: " << code << endl; typedef NVector<Cell*> CellVec; CellVec cellVec; typedef NVector<CellFunc*> FuncVec; FuncVec funcVec; for(size_t i = 0; i < 10; ++i){ cellVec.push_back(new Cell); funcVec.push_back(new CellFunc); } NPLModule module; if(!module.compile(code)){ cerr << "failed to compile" << endl; NProgram::exit(1); } CellFunc* f = funcVec[0]; module.getFunc({"Cell", "run", 1}, f); NPQueue queue; for(size_t i = 0; i < funcVec.size(); ++i){ funcVec[i]->fp = f->fp; funcVec[i]->y = 10; funcVec[i]->o = cellVec[i]; queue.add(funcVec[i]); } queue.run(); for(size_t i = 0; i < cellVec.size(); ++i){ cout << "x is: " << cellVec[i]->x << endl; } nvar x; return 0; }
/** * @brief Tries to find functions that can be called by indirect calls. * * @par Preconditions * - @a callInsts are a calls that calls some function indirectly. * * @param[in] call We try to find functions for this indirect calls. * @param[in] funcsToCheck We are finding functions that can be indirectly called * only in this functions. * * @return Found functions that can be called indirectly. */ FuncSet IndirectlyCalledFuncsAnalysis::getFuncsForIndirectCalls( const CallInstSet &call, Module::FunctionListType &funcsToCheck) { FuncVec funcVec; for (Function &func : funcsToCheck) { funcVec.push_back(&func); } FuncSet indirectlyCalledFuncs; for (CallInst *callInst : call) { addToSet(getFuncsForIndirectCall(*callInst, funcVec), indirectlyCalledFuncs); } return indirectlyCalledFuncs; }