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


C++ SgScopeStatement::variantT方法代码示例

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


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

示例1: while

// SgScopeStatement*
SgNode*
SourceLocationInheritedAttribute::getParentScope() const
   {
     SgScopeStatement* scope = NULL;
     int numberOfScopes = scopeList.size();
  // ROSE_ASSERT (numberOfScopes > 0);
  // printf ("In SourceLocationInheritedAttribute::getParentScope(): numberOfScopes = %d \n",numberOfScopes);
     if (numberOfScopes > 1)
        {
          scope = scopeList[numberOfScopes-2];

       // We don't want to return a for loop statement as a parent scope statement since insert_statement
       // is not well defined for such scope statements.

       // if (scope->variantT() == V_SgForStatement)
          int i = 1;
          while (scope->variantT() == V_SgForStatement)
             {
               ROSE_ASSERT (numberOfScopes-(2+i) >= 0);
               scope = scopeList[numberOfScopes-(2+i)];
               i++;
             }
        }
       else
        {
          scope = isSgGlobal( getGlobalScope() );
        }

     printf ("In SourceLocationInheritedAttribute::getParentScope(): parent scope is %s \n",scope->sage_class_name());

     ROSE_ASSERT (scope->variantT() != V_SgForStatement);

     ROSE_ASSERT (scope != NULL);
     return scope;
   }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:36,代码来源:sourceLocationInheritedAttribute.C

示例2: isSgScopeStatement

/*
 *  The function
 *      findScope()
 *  takes as a parameter a SgNode* which is a SgStatement*. It returns a SgNodePtrVector of all
 *  preceding scopes the SgStatement is in.
 *
 */
SgNodePtrVector
findScopes (SgNode * astNode)
{
  ROSE_ASSERT (isSgStatement (astNode));

  SgNodePtrVector returnVector;
  SgScopeStatement *currentScope;

  if (isSgScopeStatement (astNode))
    {
      currentScope = isSgScopeStatement (astNode);
      ROSE_ASSERT (currentScope != NULL);
      returnVector.push_back (astNode);
    }
  else
    {
      SgStatement *sageStatement = isSgStatement (astNode);
      ROSE_ASSERT (sageStatement != NULL);
      currentScope = sageStatement->get_scope ();
      ROSE_ASSERT (currentScope != NULL);
      returnVector.push_back (currentScope);
    }

  while (currentScope->variantT () != V_SgGlobal)
    {
      currentScope = currentScope->get_scope ();
      ROSE_ASSERT (currentScope != NULL);
      returnVector.push_back (currentScope);
    }

  //Must also include the Global Scopes of the other files in the project
  if (currentScope->variantT () == V_SgGlobal)
    {
      SgFile *sageFile = isSgFile ((currentScope)->get_parent ());
      ROSE_ASSERT (sageFile != NULL);
      SgProject *sageProject = isSgProject (sageFile->get_parent ());
      ROSE_ASSERT (sageProject != NULL);

      //Get a list of all files in the current project
      const SgFilePtrList& sageFilePtrList = sageProject->get_fileList ();

      //Iterate over the list of files to find all Global Scopes
      SgNodePtrVector globalScopes;
      for (unsigned int i = 0; i < sageFilePtrList.size (); i += 1)
	{
	  const SgSourceFile *sageFile = isSgSourceFile (sageFilePtrList[i]);
	  ROSE_ASSERT (sageFile != NULL);
	  SgGlobal *sageGlobal = sageFile->get_globalScope();
	  ROSE_ASSERT (sageGlobal != NULL);

	  returnVector.push_back (sageGlobal);
	}
    }


  return returnVector;
};
开发者ID:8l,项目名称:rose,代码行数:64,代码来源:helpFunctions.C

示例3: isSgStatement


//.........这里部分代码省略.........
                 if ( inForTest.front() )
                   {
                     ROSE_ASSERT ( d->initVarDeclaration );
                     parentScope->insert_statement( stm, d->initVarDeclaration );

                     // set the scope of the initializedName
                     SgInitializedName *initName = isSgVariableDeclaration( d->initVarDeclaration )->get_decl_item( d->name );
                     ROSE_ASSERT ( initName );
                     initName->set_scope( isSgScopeStatement( parentScope ) );
                     ROSE_ASSERT ( initName->get_scope() );
                   }
                 // function call is in loop post increment so add noninitialized variable decls above the loop
                 else
                   {
                     parentScope->insert_statement( stm, d->nonInitVarDeclaration );

                     // set the scope of the initializedName
                     SgInitializedName *initName = isSgVariableDeclaration( d->nonInitVarDeclaration )->get_decl_item( d->name );
                     ROSE_ASSERT ( initName );
                     initName->set_scope( isSgScopeStatement( parentScope ) );
                     ROSE_ASSERT ( initName->get_scope() );
                   }

                 // in a for-loop, always insert assignments at the end of the loop
                 body->get_statements().push_back( d->assignment );
                 d->assignment->set_parent( body );

                 // remove marker
                 inForTest.pop_front();
               }
             else
               {
                 // look at the type of the enclosing scope
                 switch ( scope->variantT() )
                   {

                     // while stmts have to repeat the function calls at the end of the loop;
                     // note there is no "break" statement, since we want to also add initialized
                     // declarations before the while-loop
                   case V_SgWhileStmt:
                     {
                       // assignments need to be inserted at the end of each while loop
                       SgBasicBlock *body = SageInterface::ensureBasicBlockAsBodyOfWhile(isSgWhileStmt( scope ) );
                       ROSE_ASSERT ( body );
                       d->assignment->set_parent( body );
                       body->get_statements().push_back( d->assignment );
                     }

                     // SgForInitStatement has scope SgForStatement, move declarations before the for loop;
                     // same thing if the enclosing scope is an If, or Switch statement
                   case V_SgForStatement:
                   case V_SgIfStmt:
                   case V_SgSwitchStatement:
                     {
                       // adding bindings (initialized variable declarations only, not assignments)
                       // outside the statement, in the parent scope
                       SgStatement *parentScope = isSgStatement( scope->get_parent() );
                       ROSE_ASSERT ( parentScope );
                       parentScope->insert_statement( scope, d->initVarDeclaration, true );\

                       // setting the scope of the initializedName
                       SgInitializedName *initName = isSgVariableDeclaration( d->initVarDeclaration )->get_decl_item( d->name );
                       ROSE_ASSERT ( initName );
                       initName->set_scope( scope->get_scope() );
                       ROSE_ASSERT ( initName->get_scope() );
                     }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:67,代码来源:FunctionNormalization.C

示例4: contains_private_type


//.........这里部分代码省略.........
                  {
#if 0
                    printf ("Symbol for typedef name = %s not found in parent scopes \n",typedefDeclaration->get_name().str());
#endif
                 // ROSE_ASSERT(false);
                  }
             }
#if 0
       // Testing codes because it seems that "BitSet" shuld be visiable and so we need to debug this first.
          if (typedefDeclaration->get_name() == "BitSet")
             {
               printf ("Exiting as a test! \n");
               ROSE_ASSERT(false);
             }
#endif
       // If this is not private, then we are looking at what would be possbile template arguments used in a possible name qualification.
       // if (isPrivate == false)
       // if (isPrivate == false && isVisable == false)
          if (isVisable == false)
             {
               if (isPrivate == true)
                  {
                    return true;
                  }
                 else
                  {

                 // Get the scope and see if it is a template instantiation.
                    SgScopeStatement* scope = typedefDeclaration->get_scope();
#if DEBUG_PRIVATE_TYPE || 0
                    printf ("++++++++++++++ Looking in parent scope for template arguments: scope = %p = %s \n",scope,scope->class_name().c_str());
#endif
                 // Get the associated declaration.
                    switch (scope->variantT())
                       {
                         case V_SgTemplateInstantiationDefn:
                            {
                              SgTemplateInstantiationDefn* templateInstantiationDefinition = isSgTemplateInstantiationDefn(scope);
                              ROSE_ASSERT(templateInstantiationDefinition != NULL);

                              SgTemplateInstantiationDecl* templateInstantiationDeclaration = isSgTemplateInstantiationDecl(templateInstantiationDefinition->get_declaration());
                              ROSE_ASSERT(templateInstantiationDeclaration != NULL);

                              SgTemplateArgumentPtrList & templateArgumentPtrList = templateInstantiationDeclaration->get_templateArguments();
                              for (SgTemplateArgumentPtrList::iterator i = templateArgumentPtrList.begin(); i != templateArgumentPtrList.end(); i++)
                                 {
#if DEBUG_PRIVATE_TYPE
                                   printf ("recursive call to contains_private_type(%p): name = %s = %s \n",*i,(*i)->class_name().c_str(),(*i)->unparseToString().c_str());
#endif
#if DEBUGGING_USING_RECURSIVE_DEPTH
                                   global_depth++;
#endif

                                   bool isPrivateType = contains_private_type(*i,targetScope);

#if DEBUGGING_USING_RECURSIVE_DEPTH
                                   global_depth--;
#endif
                                   returnValue |= isPrivateType;
                                 }
                              break;
                            }

                         default:
                            {
#if DEBUG_PRIVATE_TYPE
开发者ID:matzke1,项目名称:rose-develop,代码行数:67,代码来源:fixupTemplateArguments.C

示例5: isSgDeclarationStatement

string
nodeColor( SgStatement* statement )
   {
  /* color: colorCode:red:on
     color: colorCode:orange:on 
     color: colorCode:yellow:on 
     color: colorCode:blue:on 
     color: colorCode:green:on 
     color: colorCode:violet:on 
     color: colorCode:brown:on 
     color: colorCode:purple:on 
     color: colorCode:lightblue:on 
     color: colorCode:lightgreen:on 
     color: colorCode:lightred:on 
     color: colorCode:black:on 
     color: colorCode:darkblue:on 
     color: colorCode:grey:on 
     color: colorCode:darkgrey:on 
     color: colorCode:olivegreen:on 
     color: colorCode:darkgreen:on 
  */
     string returnString;

     SgDeclarationStatement* declarationStatement = isSgDeclarationStatement(statement);
     if (declarationStatement != NULL)
        {
          switch (declarationStatement->variantT())
             {
               case V_SgFunctionDeclaration:
               case V_SgMemberFunctionDeclaration:
               case V_SgTemplateInstantiationFunctionDecl:
               case V_SgTemplateInstantiationMemberFunctionDecl:
                    returnString = "orange";
                    break;

               case V_SgClassDeclaration:
               case V_SgTemplateInstantiationDecl:
                    returnString = "yellow";
                    break;

               case V_SgAsmStmt:
               case V_SgCtorInitializerList:
               case V_SgEnumDeclaration:
               case V_SgFunctionParameterList:
               case V_SgNamespaceAliasDeclarationStatement:
               case V_SgNamespaceDeclarationStatement:
               case V_SgPragmaDeclaration:
               case V_SgTemplateDeclaration:
               case V_SgTemplateInstantiationDirectiveStatement:
               case V_SgTypedefDeclaration:
               case V_SgUsingDeclarationStatement:
               case V_SgUsingDirectiveStatement:
               case V_SgVariableDeclaration:
               case V_SgVariableDefinition:
                    returnString = "lightred";
                    break;

            // DQ (11/11/2012): Added support for newer IR nodes in edg4x work.
               case V_SgTemplateMemberFunctionDeclaration:
               case V_SgTemplateClassDeclaration:
               case V_SgTemplateFunctionDeclaration:
               case V_SgTemplateVariableDeclaration:
                    returnString = "red";
                    break;

               default:
                    returnString = "ERROR DEFAULT REACHED";
                    printf ("Default reached in nodeColor() exiting ... (%s) \n",declarationStatement->class_name().c_str());
                    ROSE_ASSERT(false);
                    break;
             }
        }

     SgScopeStatement* scopeStatement = isSgScopeStatement(statement);
     if (scopeStatement != NULL)
        {
          switch (scopeStatement->variantT())
             {
               case V_SgBasicBlock:
                    returnString = "lightblue";
                    break;

               case V_SgClassDefinition:
                    returnString = "lightblue";
                    break;

               case V_SgTemplateInstantiationDefn:
               case V_SgFunctionDefinition:
                    returnString = "lightblue";
                    break;

               case V_SgWhileStmt:
               case V_SgDoWhileStmt:
               case V_SgForStatement:
                    returnString = "darkblue";
                    break;

               case V_SgGlobal:
               case V_SgIfStmt:
               case V_SgNamespaceDefinitionStatement:
//.........这里部分代码省略.........
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:101,代码来源:statements.C


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