void PatchMgr::getFuncs(Scope &scope, Functions &funcs) { if (scope.wholeProgram) { AddrSpace::ObjMap &objs = as()->objMap(); for (AddrSpace::ObjMap::iterator iter = objs.begin(); iter != objs.end(); ++iter) { iter->second->funcs(std::back_inserter(funcs)); } } else if (scope.obj) { scope.obj->funcs(std::back_inserter(funcs)); } else if (scope.func) { funcs.push_back(scope.func); } }
ScriptingService::Functions ScriptingService::loadFunctions( const string& code, const string& filename, bool mrethrow ) { Logger::In in("ScriptingService::loadFunctions"); Parser p; Functions exec; Functions ret; try { Logger::log() << Logger::Info << "Parsing file "<<filename << Logger::endl; ret = p.parseFunction(code, mowner, filename); } catch( const file_parse_exception& exc ) { #ifndef ORO_EMBEDDED Logger::log() << Logger::Error << filename<<" :"<< exc.what() << Logger::endl; if ( mrethrow ) throw; #endif return Functions(); } if ( ret.empty() ) { Logger::log() << Logger::Debug << "No Functions executed from "<< filename << Logger::endl; Logger::log() << Logger::Info << filename <<" : Successfully parsed." << Logger::endl; return Functions(); } else { // Load all listed functions in the TaskContext's Processor: for( Parser::ParsedFunctions::iterator it = ret.begin(); it != ret.end(); ++it) { Logger::log() << "Queueing Function "<< (*it)->getName() << Logger::endl; if ( mowner->engine()->runFunction( it->get() ) == false) { Logger::log() << Logger::Error << "Could not run Function '"<< (*it)->getName() <<"' :" << Logger::nl; Logger::log() << "Processor not accepting or function queue is full." << Logger::endl; } else exec.push_back( *it ); // is being executed. } } return exec; }