当前位置: 首页>>代码示例>>C++>>正文


C++ FunctionSet::begin方法代码示例

本文整理汇总了C++中FunctionSet::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionSet::begin方法的具体用法?C++ FunctionSet::begin怎么用?C++ FunctionSet::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FunctionSet的用法示例。


在下文中一共展示了FunctionSet::begin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addCalledFunctions

/// Add the functions called by a function to the function set
/// \param func
///   The function for which all called functions will be added
/// \param funcSet
///   The set of currently called functions
/// \param funcList
///   The list of all functions
/// \return
///   True if all functions are found in the funcList, false otherwise.
bool HlslLinker::addCalledFunctions( GlslFunction *func, FunctionSet& funcSet, std::vector<GlslFunction*> &funcList )
{
	const std::set<std::string> &cf = func->getCalledFunctions();

	for (std::set<std::string>::const_iterator cit=cf.begin(); cit != cf.end(); cit++)
	{
		std::vector<GlslFunction*>::iterator it = funcList.begin();

		//This might be better as a more efficient search
		while (it != funcList.end())
		{
			if ( *cit == (*it)->getMangledName())
				break;
			it++;
		}

		//check to see if it really exists
		if ( it == funcList.end())
		{
			infoSink.info << "Failed to find function '" << *cit <<"'\n";
			return false;
		}

		//add the function (if it's not there already) and recurse
		if (std::find (funcSet.begin(), funcSet.end(), *it) == funcSet.end())
			funcSet.push_back (*it);
		addCalledFunctions( *it, funcSet, funcList); 
	}

	return true;
}
开发者ID:asmboom,项目名称:hlsl2glslfork,代码行数:40,代码来源:hlslLinker.cpp

示例2: destroy_functions_in_set

void FunctionManager::destroy_functions_in_set(FunctionSet &function_set)
{
    // We iterate over the set like this because destroy_function() will erase
    // the function from function_set, thereby invalidating any iterator we are
    // holding on to.
    while (!function_set.empty())
    {
        destroy_function(*function_set.begin());
    }
}
开发者ID:ZornsLemma,项目名称:lib6502-jit,代码行数:10,代码来源:FunctionManager.cpp

示例3:

// Free the function_entries map, the Function objects in the map, the
// excluded_function_entries set and cbranges intervals.
//
void
function_entries_reinit(void)
{
    FunctionSet::iterator it;

    for (it = function_entries.begin(); it != function_entries.end(); it++) {
        Function *f = it->second;
        delete f->comment;
        delete f;
    }
    function_entries.clear();
    excluded_function_entries.clear();
    cbranges.clear();
    num_entries_total = 0;
}
开发者ID:HPCToolkit,项目名称:hpctoolkit,代码行数:18,代码来源:function-entries.cpp

示例4: sprintf

void
dump_reachable_functions()
{
    char buffer[1024];
    FunctionSet::iterator i = function_entries.begin();

    for (; i != function_entries.end();) {
        Function *f = (*i).second;
        ++i;

        const char *name;
        if (!f->isvisible && !(f->call_count > 1) && !is_possible_fn(f->address)) continue;
        if (f->comment) {
            name = f->comment->c_str();
        }
        else {
            // inferred functions must be at least 16 bytes long
            if (i != function_entries.end()) {
                Function *nextf = (*i).second;
                if (f->call_count == 0 &&
                        (((unsigned long) nextf->address) -
                         ((unsigned long) f->address)) < 16)  {
                    long offset = offset_for_fn(f->address);
                    if (offset == 0) {
                        // if f->address lies within a valid code range, its
                        // offset will be non-zero. if offset is zero, the
                        // address cannot be a valid function start.
                        continue;
                    }
                    if (!range_contains_control_flow((char *) f->address + offset,
                                                     ((char *) nextf->address +
                                                      offset)))
                        continue;
                }
            }
            sprintf(buffer,"stripped_%p", f->address);
            name = buffer;
        }
        dump_function_entry(f->address, name);
    }
}
开发者ID:HPCToolkit,项目名称:hpctoolkit,代码行数:41,代码来源:function-entries.cpp

示例5: buildUniformsAndLibFunctions

void HlslLinker::buildUniformsAndLibFunctions(const FunctionSet& calledFunctions, std::vector<GlslSymbol*>& constants, std::set<TOperator>& libFunctions)
{
	for (FunctionSet::const_iterator it = calledFunctions.begin(); it != calledFunctions.end(); ++it) {
		const std::vector<GlslSymbol*> &symbols = (*it)->getSymbols();
		
		unsigned n_symbols = symbols.size();
		for (unsigned i = 0; i != n_symbols; ++i) {
			GlslSymbol* s = symbols[i];
			if (s->getQualifier() == EqtUniform || s->getQualifier() == EqtMutableUniform)
				constants.push_back(s);
		}
		
		//take each referenced library function, and add it to the set
		const std::set<TOperator> &referencedFunctions = (*it)->getLibFunctions();
		libFunctions.insert( referencedFunctions.begin(), referencedFunctions.end());
	}
	
    // std::unique only removes contiguous duplicates, so vector must be sorted to remove them all
    std::sort(constants.begin(), constants.end(), GlslSymbolSorter());

	// Remove duplicates
	constants.resize(std::unique(constants.begin(), constants.end()) - constants.begin());
}
开发者ID:KonajuGames,项目名称:hlsl2glslfork,代码行数:23,代码来源:hlslLinker.cpp

示例6: link

bool HlslLinker::link(HlslCrossCompiler* compiler, const char* entryFunc, bool usePrecision)
{
	std::vector<GlslFunction*> globalList;
	std::vector<GlslFunction*> functionList;
	std::string entryPoint;
	GlslFunction* funcMain = NULL;
	FunctionSet calledFunctions;
	std::set<TOperator> libFunctions;
	std::map<std::string,GlslSymbol*> globalSymMap;
	std::map<std::string,GlslStruct*> structMap;

	if (!compiler)
	{
		infoSink.info << "No shader compiler provided\n";
		return false;
	}

	EShLanguage lang = compiler->getLanguage();

	if (!entryFunc)
	{
		infoSink.info << "No shader entry function provided\n";
		return false;
	}

	entryPoint = GetEntryName (entryFunc);

	//build the list of functions
	HlslCrossCompiler *comp = static_cast<HlslCrossCompiler*>(compiler);

	std::vector<GlslFunction*> &fl = comp->functionList;

	for ( std::vector<GlslFunction*>::iterator fit = fl.begin(); fit < fl.end(); fit++)
	{
		if ( (*fit)->getName() == "__global__")
			globalList.push_back( *fit);
		else
			functionList.push_back( *fit);

		if ((*fit)->getName() == entryPoint)
		{
			if (funcMain)
			{
				infoSink.info << kShaderTypeNames[lang] << " entry function cannot be overloaded\n";
				return false;
			}
			funcMain = *fit;
		}
	}

	// check to ensure that we found the entry function
	if (!funcMain)
	{
		infoSink.info << "Failed to find entry function: '" << entryPoint <<"'\n";
		return false;
	}

	//add all the called functions to the list
	calledFunctions.push_back (funcMain);
	if (!addCalledFunctions (funcMain, calledFunctions, functionList))
	{
		infoSink.info << "Failed to resolve all called functions in the " << kShaderTypeNames[lang] << " shader\n";
	}

	//iterate over the functions, building a global list of structure declaractions and symbols
	// assume a single compilation unit for expediency (eliminates name clashes, as type checking
	// withing a single compilation unit has been performed)
	for (FunctionSet::iterator it=calledFunctions.begin(); it != calledFunctions.end(); it++)
	{
		//get each symbol and each structure, and add them to the map
		// checking that any previous entries are equivalent
		const std::vector<GlslSymbol*> &symList = (*it)->getSymbols();

		for (std::vector<GlslSymbol*>::const_iterator cit = symList.begin(); cit < symList.end(); cit++)
		{
			if ( (*cit)->getIsGlobal())
			{
				//should check for already added ones here
				globalSymMap[(*cit)->getName()] = *cit;
			}
		}

		//take each referenced library function, and add it to the set
		const std::set<TOperator> &libSet = (*it)->getLibFunctions();

		libFunctions.insert( libSet.begin(), libSet.end());
	}


	// The following code is what is used to generate the actual shader and "main"
	// function. The process is to take all the components collected above, and
	// write them to the appropriate code stream. Finally, a main function is
	// generated that calls the specified entrypoint. That main function uses
	// semantics on the arguments and return values to connect items appropriately.

	//
	// Write Library Functions & required extensions
	std::string shaderExtensions, shaderLibFunctions;
	if (!libFunctions.empty())
	{
//.........这里部分代码省略.........
开发者ID:asmboom,项目名称:hlsl2glslfork,代码行数:101,代码来源:hlslLinker.cpp


注:本文中的FunctionSet::begin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。