本文整理汇总了C++中SgScopeStatement::lookup_function_symbol方法的典型用法代码示例。如果您正苦于以下问题:C++ SgScopeStatement::lookup_function_symbol方法的具体用法?C++ SgScopeStatement::lookup_function_symbol怎么用?C++ SgScopeStatement::lookup_function_symbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgScopeStatement
的用法示例。
在下文中一共展示了SgScopeStatement::lookup_function_symbol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
void SimpleInstrumentation::visit ( SgNode* astNode )
{
switch(astNode->variantT())
{
case V_SgFunctionCallExp:
{
SgFunctionCallExp *functionCallExp = isSgFunctionCallExp(astNode);
SgExpression *function = functionCallExp->get_function();
ROSE_ASSERT(function);
switch (function->variantT())
{
case V_SgFunctionRefExp:
{
SgFunctionRefExp *functionRefExp = isSgFunctionRefExp(function);
SgFunctionSymbol *symbol = functionRefExp->get_symbol();
ROSE_ASSERT(symbol != NULL);
SgFunctionDeclaration *functionDeclaration = symbol->get_declaration();
ROSE_ASSERT(functionDeclaration != NULL);
if (symbol == functionSymbol)
{
// Now we know that we have found the correct function call
// (even in the presence of overloading or other forms of hidding)
// Now fixup the symbol and type of the SgFunctionRefExp object to
// reflect the new function to be called (after this we still have to
// fixup the argument list in the SgFunctionCallExp.
// We only want to build the decalration once (and insert it into the global scope)
// after that we save the symbol and reuse it.
if (newFunctionSymbol == NULL)
{
SgFunctionType* originalFunctionType = isSgFunctionType(functionSymbol->get_type());
ROSE_ASSERT(originalFunctionType != NULL);
newFunctionSymbol = buildNewFunctionDeclaration (TransformationSupport::getStatement(astNode),originalFunctionType);
}
ROSE_ASSERT(newFunctionSymbol != NULL);
ROSE_ASSERT(newFunctionSymbol->get_type() != NULL);
functionRefExp->set_symbol(newFunctionSymbol);
}
break;
}
default:
cerr<<"warning: unrecognized variant: "<<function->class_name();
}
break;
}
case V_SgFunctionDeclaration:
{
SgFunctionDeclaration* functionDeclaration = isSgFunctionDeclaration(astNode);
string functionName = functionDeclaration->get_name().str();
if (functionName == "send")
{
SgFunctionType *functionType = functionDeclaration->get_type();
ROSE_ASSERT(functionType != NULL);
bool foundFunction = false;
if (functionType->get_return_type()->unparseToString() == "ssize_t")
{
SgTypePtrList & argumentList = functionType->get_arguments();
SgTypePtrList::iterator i = argumentList.begin();
if ( (*i++)->unparseToString() == "int" )
if ( (*i++)->unparseToString() == "const void *" )
if ( (*i++)->unparseToString() == "size_t" )
if ( (*i++)->unparseToString() == "int" )
foundFunction = true;
}
if (foundFunction == true)
{
// Now get the sysmbol using functionType
SgScopeStatement *scope = functionDeclaration->get_scope();
ROSE_ASSERT(scope != NULL);
functionSymbol = scope->lookup_function_symbol (functionName,functionType);
}
}
break;
}
default:
{
// No other special cases
}
}
}