本文整理汇总了C++中SgInitializedName::get_initptr方法的典型用法代码示例。如果您正苦于以下问题:C++ SgInitializedName::get_initptr方法的具体用法?C++ SgInitializedName::get_initptr怎么用?C++ SgInitializedName::get_initptr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgInitializedName
的用法示例。
在下文中一共展示了SgInitializedName::get_initptr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stencil_rhs
StencilEvaluation_SynthesizedAttribute
StencilEvaluationTraversal::evaluateSynthesizedAttribute (SgNode* astNode, StencilEvaluation_InheritedAttribute inheritedAttribute, SubTreeSynthesizedAttributes synthesizedAttributeList )
{
StencilEvaluation_SynthesizedAttribute return_synthesizedAttribute;
#if 0
printf ("In StencilEvaluationTraversal::evaluateSynthesizedAttribute(): astNode = %p = %s \n",astNode,astNode->class_name().c_str());
#endif
bool foundStencilOffsetFSM = false;
SgConstructorInitializer* constructorInitializer = isSgConstructorInitializer(astNode);
if (constructorInitializer != NULL && inheritedAttribute.stencilOffsetFSM != NULL)
{
#if 0
printf ("Found pair<Shift,double>(x,y): set then in the synthesizedAttribute: astNode = %p = %s \n",astNode,astNode->class_name().c_str());
#endif
return_synthesizedAttribute.stencilOffsetFSM = inheritedAttribute.stencilOffsetFSM;
return_synthesizedAttribute.stencilCoeficientValue = inheritedAttribute.stencilCoeficientValue;
#if 0
printf ("return_synthesizedAttribute.stencilCoeficientValue = %f \n",return_synthesizedAttribute.stencilCoeficientValue);
#endif
foundStencilOffsetFSM = true;
}
// There should only be a single child set with a pair<Shift,double>(x,y) object.
for (size_t i = 0; i < synthesizedAttributeList.size(); i++)
{
if (synthesizedAttributeList[i].stencilOffsetFSM != NULL)
{
// Check that the return_synthesizedAttribute.stencilOffsetFSM has not already been set.
// This could happend if we allows nesting of pair<Shift,double>(x,y) within itself (not allowed).
#if 0
printf ("synthesizedAttributeList[i].stencilOffsetFSM != NULL \n");
#endif
// ROSE_ASSERT(foundStencilOffsetFSM == false);
if (foundStencilOffsetFSM == false)
{
#if 0
printf ("foundStencilOffsetFSM == false \n");
#endif
// ROSE_ASSERT(return_synthesizedAttribute.stencilOffsetFSM == NULL);
if (return_synthesizedAttribute.stencilOffsetFSM == NULL)
{
#if 0
printf ("return_synthesizedAttribute.stencilOffsetFSM != NULL \n");
#endif
return_synthesizedAttribute.stencilOffsetFSM = synthesizedAttributeList[i].stencilOffsetFSM;
return_synthesizedAttribute.stencilCoeficientValue = synthesizedAttributeList[i].stencilCoeficientValue;
}
foundStencilOffsetFSM = true;
}
}
}
// This allows us to find the variables of type vector<Point> and vector<double> used as an alternative way
// to specify a stencil (using the Stencil constructor that takes these variables as input arguments).
// It relies upon a previous traversal to have identified the inputs to Stencil constructor.
// This support is incomplete while I focus on the alternative approach to the specification of the stencil
// using intremental union of a stencil with a pair<Shift,double>() template instantiation.
SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(astNode);
if (variableDeclaration != NULL)
{
// Get the SgInitializedName from the SgVariableDeclaration.
SgInitializedName* initializedName = SageInterface::getFirstInitializedName(variableDeclaration);
#if 0
printf ("In evaluateInheritedAttribute(): case SgInitializedName from variable declaration: initializedName = %p name = %s \n",initializedName,initializedName->get_name().str());
#endif
bool foundStencilDeclaration = false;
if (find(stencilInputInitializedNameList.begin(),stencilInputInitializedNameList.end(),initializedName) != stencilInputInitializedNameList.end())
{
#if 0
printf ("Found declaration associated with stencil input: initializedName = %p = %s name = %s \n",initializedName,initializedName->class_name().c_str(),initializedName->get_name().str());
#endif
// Build the finite state machine for the stencil and add it to the map using the name (in SgInitializedName) as a key.
// For now we assume that the stencil specification is using the default construction.
if (initializedName->get_initptr() != NULL)
{
printf ("FIXME: This declaration of a stencil appears to have constrcutor arguments (this not the default constuctor as interprest below). \n");
#if 0
ROSE_ASSERT(false);
#endif
}
foundStencilDeclaration = true;
}
else
{
// Verify that this is a Stencil declaration.
SgClassType* classType = isSgClassType(initializedName->get_type());
if (classType != NULL)
{
// Check if this is associated with a template instantiation.
SgTemplateInstantiationDecl* templateInstantiationDecl = isSgTemplateInstantiationDecl(classType->get_declaration());
if (templateInstantiationDecl != NULL)
{
#if 0
printf ("case SgTemplateInstaiationDecl: class name = %s \n",classType->get_name().str());
printf ("case SgTemplateInstaiationDecl: templateInstantiationDecl->get_templateName() = %s \n",templateInstantiationDecl->get_templateName().str());
#endif
//.........这里部分代码省略.........
示例2: StencilEvaluation_InheritedAttribute
StencilEvaluation_InheritedAttribute
StencilEvaluationTraversal::evaluateInheritedAttribute (SgNode* astNode, StencilEvaluation_InheritedAttribute inheritedAttribute )
{
#if 0
printf ("In evaluateInheritedAttribute(): astNode = %p = %s \n",astNode,astNode->class_name().c_str());
#endif
bool foundPairShiftDoubleConstructor = false;
// This is for stencil specifications using vectors of points to represent offsets (not finished).
// bool foundVariableDeclarationForStencilInput = false;
double stencilCoeficientValue = 0.0;
// StencilOffsetFSM offset;
StencilOffsetFSM* stencilOffsetFSM = NULL;
// We want to interogate the SgAssignInitializer, but we need to generality in the refactored function to use any SgInitializer (e.g. SgConstructorInitializer, etc.).
SgInitializedName* initializedName = detectVariableDeclarationOfSpecificType (astNode,"Point");
if (initializedName != NULL)
{
// This is the code that is specific to the DSL (e.g. the semantics of getZeros() and getUnitv() functions).
// So this may be the limit of what can be refactored to common DSL support code.
// Or I can maybe do a second pass at atempting to refactor more code later.
string name = initializedName->get_name();
SgInitializer* initializer = initializedName->get_initptr();
SgAssignInitializer* assignInitializer = isSgAssignInitializer(initializer);
if (assignInitializer != NULL)
{
SgExpression* exp = assignInitializer->get_operand();
ROSE_ASSERT(exp != NULL);
SgFunctionCallExp* functionCallExp = isSgFunctionCallExp(exp);
if (functionCallExp != NULL)
{
SgFunctionRefExp* functionRefExp = isSgFunctionRefExp(functionCallExp->get_function());
if (functionRefExp != NULL)
{
SgFunctionSymbol* functionSymbol = functionRefExp->get_symbol();
ROSE_ASSERT(functionSymbol != NULL);
string functionName = functionSymbol->get_name();
#if 0
printf ("functionName = %s \n",functionName.c_str());
#endif
if (functionName == "getZeros")
{
// We leverage the semantics of known functions used to initialize "Point" objects ("getZeros" initialized the Point object to be all zeros).
// In a stencil this will be the center point from which all other points will have non-zero offsets.
// For a common centered difference discretization this will be the center point of the stencil.
#if 0
printf ("Identified and interpreting the semantics of getZeros() function \n");
#endif
stencilOffsetFSM = new StencilOffsetFSM(0,0,0);
ROSE_ASSERT(stencilOffsetFSM != NULL);
}
if (functionName == "getUnitv")
{
// We leverage the semantics of known functions used to initialize "Point" objects
// ("getUnitv" initializes the Point object to be a unit vector for a specific input dimention).
// In a stencil this will be an ofset from the center point.
#if 0
printf ("Identified and interpreting the semantics of getUnitv() function \n");
#endif
// Need to get the dimention argument.
SgExprListExp* argumentList = functionCallExp->get_args();
ROSE_ASSERT(argumentList != NULL);
// This function has a single argument.
ROSE_ASSERT(argumentList->get_expressions().size() == 1);
SgExpression* functionArg = argumentList->get_expressions()[0];
ROSE_ASSERT(functionArg != NULL);
SgIntVal* intVal = isSgIntVal(functionArg);
// ROSE_ASSERT(intVal != NULL);
if (intVal != NULL)
{
int value = intVal->get_value();
#if 0
printf ("value = %d \n",value);
#endif
switch(value)
{
case 0: stencilOffsetFSM = new StencilOffsetFSM(1,0,0); break;
case 1: stencilOffsetFSM = new StencilOffsetFSM(0,1,0); break;
case 2: stencilOffsetFSM = new StencilOffsetFSM(0,0,1); break;
default:
{
printf ("Error: default reached in switch: value = %d (for be value of 0, 1, or 2) \n",value);
ROSE_ASSERT(false);
}
}
ROSE_ASSERT(stencilOffsetFSM != NULL);
// End of test for intVal != NULL
}
else
//.........这里部分代码省略.........