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


C++ SgScopeStatement类代码示例

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


在下文中一共展示了SgScopeStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: isSgStatement

void visitorTraversal::visit(SgNode* n)
   {
  // There are three types ir IR nodes that can be queried for scope:
  //   - SgStatement, and 
  //   - SgInitializedName
     SgStatement* statement = isSgStatement(n);
     if (statement != NULL)
        {
          SgScopeStatement* scope = statement->get_scope();
          ROSE_ASSERT(scope != NULL);
          printf ("SgStatement       = %12p = %30s has scope = %12p = %s (total number = %d) \n",
               statement,statement->class_name().c_str(),
               scope,scope->class_name().c_str(),(int)scope->numberOfNodes());
        }

     SgInitializedName* initializedName = isSgInitializedName(n);
     if (initializedName != NULL)
        {
          SgScopeStatement* scope = initializedName->get_scope();
          ROSE_ASSERT(scope != NULL);
          printf ("SgInitializedName = %12p = %30s has scope = %12p = %s (total number = %d)\n",
               initializedName,initializedName->get_name().str(),
               scope,scope->class_name().c_str(),(int)scope->numberOfNodes());
        }
   }
开发者ID:matzke1,项目名称:rose-develop,代码行数:25,代码来源:scopeInformation.C

示例3: fortran_error_handler

/**
 *  handling error occured due to failed assertion
 * this error handler only works during parser phase since it uses
 * Token_t to know the line number

 * TODO: we need to make this function more general
 **/
void 
fortran_error_handler(int signum)
{
  // get the current filename 
  std::string sFilename = getCurrentFilename();
  if (sFilename.size()==0) {
     fprintf(stderr, "ERROR while parsing the source code\n");
  } else {
    
    SgScopeStatement* scope = astScopeStack.front();
    SgStatement* lastStatement = scope;
    SgStatementPtrList statementList = scope->generateStatementList();
    if (statementList.empty() == false)
       {
         lastStatement = statementList.back();
       }
    int lineNumberOfLastStatement = (astScopeStack.empty() == false) ? lastStatement->get_file_info()->get_line() : 0;
    // get the latest token parsed
    if (lineNumberOfLastStatement > 0)
      std::cerr <<"FATAL ERROR in file "<<sFilename<<":"<<lineNumberOfLastStatement<<std::endl;
    else
     std::cerr <<"FATAL ERROR while parsing "<<sFilename<<std::endl;
  }
  fflush(NULL); // flush all stdio
  fortran_error_handler_end();
  exit(-1);
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:34,代码来源:fortran_error_handler.C

示例4: findScopes

/*
 *  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

示例5: requiresParentIsBasicBlock

void
RtedTransformation::changeReturnStmt(ReturnInfo rinfo)
{
  SgReturnStmt* const   rstmt = rinfo.stmt;
  SgExpression* const   returnExpr = rstmt->get_expression();

  requiresParentIsBasicBlock(*rstmt);

  if (!returnExpr)
  {
    // function returns a value but return statement has no expression
    insertErrorReport(*rstmt, "return statement is expected to return a value");
    return;
  }

  // We need to build a new variable of type returnExpr
  // \pp why do we have to do that?
  //     most likely b/c exitScope clears all local pointers ...
  SgScopeStatement*      scope = rstmt->get_scope();
  SgType* const          typeRet = returnExpr->get_type();
  std::string            name = "rstmt";

  ROSE_ASSERT(scope);
  name.append(scope->get_qualified_name().str());

  SgName                 rName( name );
  SgAssignInitializer*   init = SB::buildAssignInitializer(returnExpr);
  SgVariableDeclaration* resDecl = SB::buildVariableDeclaration( rName, typeRet, init, scope );
  SgInitializedName&     resVar = SI::getFirstVariable(*resDecl);

  SgVarRefExp* const     vexp = SB::buildVarRefExp(rName, scope);
  SgStatement* const     newRtnStmt = SB::buildReturnStmt( vexp );

  SI::replaceStatement( rstmt, newRtnStmt );
  SI::insertStatementBefore( newRtnStmt, resDecl );

  Sg_File_Info* const    fileinfo = scope->get_endOfConstruct();

  // handle C++ only if the function returns a pointer
  if (rinfo.filetype != ftCxx)
  {
    SgStatement* const   exitStmt = (rinfo.expected_return == ReturnInfo::rtValue)
                                          ? buildExitBlockStmt(rinfo.open_blocks, *scope, fileinfo)
                                          : buildDelayedLeakCheckExitStmt(rinfo.filetype, rinfo.open_blocks, *scope, resVar, fileinfo)
                                          ;

    SI::insertStatementBefore( newRtnStmt, exitStmt );
  }
  else if (rinfo.expected_return == ReturnInfo::rtIndirection)
  {
    SgStatement* const   exitStmt = buildDelayedLeakCheckExitStmt(rinfo.filetype, rinfo.open_blocks, *scope, resVar, fileinfo);

    SI::insertStatementBefore( newRtnStmt, exitStmt );
  }
}
开发者ID:jacob-lidman,项目名称:rose,代码行数:55,代码来源:RtedTransf_returnStmt.cpp

示例6: initAstFromString

void initAstFromString(std::ifstream & in_file) {
  SgScopeStatement * scope = SageBuilder::buildBasicBlock();

  AstFromString::c_sgnode = scope;
  SageBuilder::pushScopeStack(scope);

  SgName pow_name("pow");
  SgFunctionDeclaration * pow_decl = SageBuilder::buildNondefiningFunctionDeclaration(
                                       pow_name,
                                       SageBuilder::buildDoubleType(),
                                       SageBuilder::buildFunctionParameterList(
                                         SageBuilder::buildInitializedName("base", SageBuilder::buildDoubleType()),
                                         SageBuilder::buildInitializedName("exp", SageBuilder::buildDoubleType())
                                       ),
                                       scope,
                                       NULL
                                     );
  scope->insert_symbol(pow_name, new SgFunctionSymbol(pow_decl));

  SgName sqrt_name("sqrt");
  SgFunctionDeclaration * sqrt_decl = SageBuilder::buildNondefiningFunctionDeclaration(
                                       sqrt_name,
                                       SageBuilder::buildDoubleType(),
                                       SageBuilder::buildFunctionParameterList(
                                         SageBuilder::buildInitializedName("v", SageBuilder::buildDoubleType())
                                       ),
                                       scope,
                                       NULL
                                     );
  scope->insert_symbol(sqrt_name, new SgFunctionSymbol(sqrt_decl));

  SgName abs_name("fabs");
  SgFunctionDeclaration * abs_decl = SageBuilder::buildNondefiningFunctionDeclaration(
                                       abs_name,
                                       SageBuilder::buildDoubleType(),
                                       SageBuilder::buildFunctionParameterList(
                                         SageBuilder::buildInitializedName("v", SageBuilder::buildDoubleType())
                                       ),
                                       scope,
                                       NULL
                                     );
  scope->insert_symbol(abs_name, new SgFunctionSymbol(abs_decl));

  in_file.seekg (0, in_file.end);
  int length = in_file.tellg();
  in_file.seekg (0, in_file.beg);

  char * tmp_char_str = new char [length + 1];
  in_file.read(tmp_char_str, length);
  tmp_char_str[length] = 0;

  AstFromString::c_char = tmp_char_str;
  AstFromString::afs_skip_whitespace();
}
开发者ID:Sciumo,项目名称:rose,代码行数:54,代码来源:utils.cpp

示例7: createPackExpr

/*!
 *  \brief Creates an assignment to "pack" a local variable back into
 *  an outlined-function parameter that has been passed as a pointer
 *  value.
 *
 *  This routine takes the original "unpack" definition, of the form
 *
 *    TYPE local_unpack_var = *outlined_func_arg;
 *    int i = *(int *)(__out_argv[1]); // parameter wrapping case
 *
 *  and creates the "re-pack" assignment expression,
 *
 *    *outlined_func_arg = local_unpack_var
 *    *(int *)(__out_argv[1]) =i; // parameter wrapping case
 *
 *  C++ variables of reference types do not need this step.
 */
static
SgAssignOp *
createPackExpr (SgInitializedName* local_unpack_def)
{
  if (!Outliner::temp_variable)
  {
    if (is_C_language()) //skip for pointer dereferencing used in C language
      return NULL;
  }
  // reference types do not need copy the value back in any cases
  if (isSgReferenceType (local_unpack_def->get_type ()))  
    return NULL;

  if (local_unpack_def
      && !isReadOnlyType (local_unpack_def->get_type ()))
//      && !isSgReferenceType (local_unpack_def->get_type ()))
    {
      SgName local_var_name (local_unpack_def->get_name ());

      SgAssignInitializer* local_var_init =
        isSgAssignInitializer (local_unpack_def->get_initializer ());
      ROSE_ASSERT (local_var_init);

      // Create the LHS, which derefs the function argument, by
      // copying the original dereference expression.
      // 
      SgPointerDerefExp* param_deref_unpack =
        isSgPointerDerefExp (local_var_init->get_operand_i ());
      if (param_deref_unpack == NULL)  
      {
        cout<<"packing statement is:"<<local_unpack_def->get_declaration()->unparseToString()<<endl;
        cout<<"local unpacking stmt's initializer's operand has non-pointer deferencing type:"<<local_var_init->get_operand_i ()->class_name()<<endl;
        ROSE_ASSERT (param_deref_unpack);
      }

      SgPointerDerefExp* param_deref_pack = isSgPointerDerefExp (ASTtools::deepCopy (param_deref_unpack));
      ROSE_ASSERT (param_deref_pack);
              
      // Create the RHS, which references the local variable.
      SgScopeStatement* scope = local_unpack_def->get_scope ();
      ROSE_ASSERT (scope);
      SgVariableSymbol* local_var_sym =
        scope->lookup_var_symbol (local_var_name);
      ROSE_ASSERT (local_var_sym);
      SgVarRefExp* local_var_ref = SageBuilder::buildVarRefExp (local_var_sym);
      ROSE_ASSERT (local_var_ref);

      // Assemble the final assignment expression.
      return SageBuilder::buildAssignOp (param_deref_pack, local_var_ref);
    }
  return 0;
}
开发者ID:8l,项目名称:rose,代码行数:69,代码来源:CudaOutliner.C

示例8: translateProgramHeaderStatement

void Jovial_to_C::translateProgramHeaderStatement(SgProgramHeaderStatement* programHeaderStatement)
{
// Get scopeStatement from SgProgramHeaderStatement
   SgScopeStatement* scopeStatement = programHeaderStatement->get_scope();
   ROSE_ASSERT(scopeStatement);
  
// Get ParameterList and DecoratorList
   SgFunctionParameterList* functionParameterList = buildFunctionParameterList(); 
   SgExprListExp* decoratorList = deepCopy(programHeaderStatement->get_decoratorList());
  
// Reuse FunctionDefinition from Fortran programHeaderStatement
   SgFunctionDefinition* functionDefinition = programHeaderStatement->get_definition();
  
// Get basicBlock from SgProgramHeaderStatement
   SgBasicBlock* basicBlock = functionDefinition->get_body();
   ROSE_ASSERT(basicBlock);

   SgSymbolTable* symbolTable = basicBlock->get_symbol_table();
   ROSE_ASSERT(symbolTable);
  
// The main function return type is int
   SgType* mainType = SgTypeInt::createType();
  
// Remove original function symbol.  Keep the new function symbol with name of "main"
   SgFunctionSymbol* functionSymbol = isSgFunctionSymbol(scopeStatement->lookup_symbol(programHeaderStatement->get_name()));
   SgSymbolTable* globalSymbolTable = isSgSymbolTable(functionSymbol->get_parent());
   globalSymbolTable->remove(functionSymbol);
   functionSymbol->set_parent(NULL);
   delete(functionSymbol);
  
// Create SgFunctionDeclaration for C main function. Name must be "main".
   SgFunctionDeclaration* cFunctionDeclaration = buildDefiningFunctionDeclaration("main",
                                                                                  mainType,
                                                                                  functionParameterList,
                                                                                  scopeStatement);
  
// Setup the C function declaration.
   removeList.push_back(cFunctionDeclaration->get_definition());
   functionDefinition->set_parent(cFunctionDeclaration);
   cFunctionDeclaration->set_definition(functionDefinition);
   programHeaderStatement->set_definition(NULL);
 
// Replace the SgProgramHeaderStatement with SgFunctionDeclaration.
   replaceStatement(programHeaderStatement,cFunctionDeclaration,true);
   cFunctionDeclaration->set_decoratorList(decoratorList);
// cFunctionDeclaration->set_startOfConstruct(functionDefinition->get_startOfConstruct());
// cFunctionDeclaration->set_endOfConstruct(functionDefinition->get_endOfConstruct());
// cFunctionDeclaration->get_file_info()->set_physical_filename(cFunctionDeclaration->get_file_info()->get_filenameString()); 
  
   programHeaderStatement->set_parent(NULL);
}  // End of Jovial_to_C::translateProgramHeaderStatement
开发者ID:matzke1,项目名称:rose-develop,代码行数:51,代码来源:j2cStatement.C

示例9: printf

void
SgScopeStatement::fixupCopy_symbols(SgNode* copy, SgCopyHelp & help) const
   {
#if DEBUG_FIXUP_COPY
     printf ("Inside of SgScopeStatement::fixupCopy_symbols() for %p = %s copy = %p \n",this,this->class_name().c_str(),copy);
#endif
#if 0
     printf ("Inside of SgScopeStatement::fixupCopy_symbols() for %p = %s copy = %p (calling SgStatement::fixupCopy_symbols()) \n",this,this->class_name().c_str(),copy);
#endif

  // Call the base class fixupCopy member function
     SgStatement::fixupCopy_symbols(copy,help);

#if 0
     printf ("DONE: Inside of SgScopeStatement::fixupCopy_symbols() for %p = %s copy = %p (calling SgStatement::fixupCopy_symbols()) \n",this,this->class_name().c_str(),copy);
#endif

     SgScopeStatement* copyScopeStatement = isSgScopeStatement(copy);
     ROSE_ASSERT(copyScopeStatement != NULL);

  // The symbol table should not have been setup yet!
  // ROSE_ASSERT(copyScopeStatement->get_symbol_table()->size() == 0);
     ROSE_ASSERT(copyScopeStatement->symbol_table_size() == 0);

#if 0
     printf ("Inside of SgScopeStatement::fixupCopy_symbols() for %p = %s copy = %p (calling SageInterface::rebuildSymbolTable()) \n",this,this->class_name().c_str(),copy);
#endif

     SageInterface::rebuildSymbolTable(copyScopeStatement);

#if 0
     printf ("DONE: Inside of SgScopeStatement::fixupCopy_symbols() for %p = %s copy = %p (calling SageInterface::rebuildSymbolTable()) \n",this,this->class_name().c_str(),copy);
     printf ("Inside of SgScopeStatement::fixupCopy_symbols() for %p = %s copy = %p (calling SageInterface::fixupReferencesToSymbols()) \n",this,this->class_name().c_str(),copy);
#endif

  // DQ (3/1/2009): After rebuilding the symbol table, we have to reset references 
  // to old symbols (from the original symbol table) to the new symbols just built.
     SageInterface::fixupReferencesToSymbols(this,copyScopeStatement,help);

#if 0
     printf ("DONE: Inside of SgScopeStatement::fixupCopy_symbols() for %p = %s copy = %p (calling SageInterface::fixupReferencesToSymbols()) \n",this,this->class_name().c_str(),copy);
#endif

  // printf ("\nLeaving SgScopeStatement::fixupCopy_symbols() for %p = %s copy = %p \n\n",this,this->class_name().c_str(),copy);
   }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:45,代码来源:fixupCopy_symbols.C

示例10: getDeclStmtName

string
Doxygen::getProtoName(SgDeclarationStatement *st)
{
    SgScopeStatement *scope;
    if (SgVariableDeclaration* varDeclSt = isSgVariableDeclaration(st))
    {
        // TODO: uncomment SgVariableDeclaration::get_scope removing need for this code
        scope = varDeclSt->get_variables().front()->get_scope();
    }
    else
    {
        scope = st->get_scope();
    }
    if (isSgGlobal(scope))
    {
        return getDeclStmtName(st);
    }
    else
    {
        SgUnparse_Info info;
        info.set_SkipSemiColon();
        info.set_SkipFunctionDefinition();
        info.set_forceQualifiedNames();
        info.set_skipCheckAccess();
        info.set_SkipInitializer();
        info.set_SkipClassSpecifier();
        //AS(091507) In the new version of ROSE global qualifiers are paret of the qualified name of
        //a scope statement. For the documentation work we do not want that and we therefore use string::substr()
        //to trim of  "::" from the front of the qualified name.

        if( scope->get_qualified_name().getString().length() > 2 )
        {
            return scope->get_qualified_name().getString().substr(2)+("::"+getDeclStmtName(st));
        } else {
            return getDeclStmtName(st);

        }

        //return scope->get_qualified_name().str()+("::"+getDeclStmtName(st));
    }
}
开发者ID:rose-compiler,项目名称:rose-edg3,代码行数:41,代码来源:sageDoxygen.C

示例11: ATgetAnnotation

SgScopeStatement*
AtermSupport::getAtermScopeNodeAttribute (ATerm term, const std::string & annotationName )
   {
     SgScopeStatement* returnNode = NULL;

     ATerm idannot = ATgetAnnotation(term, ATmake(annotationName.c_str()));
     if (idannot)
        {
#if 1
          printf ("In getAtermScopeNodeAttribute(): Found an annotation: annotationName = %s \n",annotationName.c_str());
#endif
          char* id = NULL;
       // Get the associated annotation string.
          if (ATmatch(idannot, "<str>", &id))
             {
#if 1
                printf ("In getAtermScopeNodeAttribute(): Found an string in the annotation: annotationName = %s id = %s \n",annotationName.c_str(),id);
#endif
               if (translationScopeMap.find(id) != translationScopeMap.end())
                  {
                    returnNode = translationScopeMap[id];
                    ROSE_ASSERT(returnNode != NULL);
#if 1
                    printf ("In getAtermScopeNodeAttribute translationScopeMap: id = %s returnNode = %p = %s \n",id,returnNode,returnNode->class_name().c_str());
#endif
                  }
                 else
                  {
#if 1
                    printf ("In getAtermScopeNodeAttribute(): Node not found in translationNodeMap: returing NULL pointer \n");
#endif
                  }
             }
            else
             {
               printf ("Error: The nested aterm associated with the annotation must be available on the aterm: annotationName = %s \n",annotationName.c_str());
               ROSE_ASSERT(false);
             }
        }
       else
        {
          printf ("Error: The annotation not found on the aterm: annotationName = %s \n",annotationName.c_str());
          ROSE_ASSERT(false);
        }

#if 0
     printf ("In AtermSupport::getAtermScopeNodeAttribute(): not yet implemented \n");
     ROSE_ASSERT(false);
#endif

     return returnNode;
   }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:52,代码来源:atermSupport.C

示例12: findRootFunc

const SgFunctionDefinition*
findRootFunc (const SgScopeStatement* scope)
   {
  // DQ (12/13/2011): This function is being called recursively (infinite recursion) for test2011_187.C (added support for SgTemplateFunctionDefinition).

  // printf ("Inside of findRootFunc(scope = %p) \n",scope);

     if (scope != NULL)
        {
          if (scope->variantT () == V_SgFunctionDefinition)
             {
               return isSgFunctionDefinition (scope);
             }
            else
             {
               if (scope->variantT () == V_SgTemplateFunctionDefinition)
                  {
                    return isSgTemplateFunctionDefinition (scope);
                  }
                 else
                  {
                 // DQ (12/13/2011): Adding test for improperly set scope.
                 // printf ("In findRootFunc(): scope = %p = %s \n",scope,scope->class_name().c_str());

                    SgScopeStatement* nextOuterScope = scope->get_scope();
                    ROSE_ASSERT(nextOuterScope != NULL);
#if 0
                    printf ("nextOuterScope = %p = %s \n",nextOuterScope,nextOuterScope->class_name().c_str());
#endif
                    ROSE_ASSERT(nextOuterScope != scope);

                    return findRootFunc(scope->get_scope());
                  }
             }
        }

  // Not found.
     return NULL;
   }
开发者ID:InstRO,项目名称:InstRO-ROSE-Develop,代码行数:39,代码来源:manglingSupport.C

示例13: ROSE_ASSERT


//.........这里部分代码省略.........
            // it is still not meaningful since we don't generate a unique name for the SgBasicBlock
            // so it will never be shared.
            // case V_SgBasicBlock:

               case V_SgClassDefinition:
               case V_SgTemplateInstantiationDefn:
               case V_SgFunctionDefinition:
               case V_SgVariableDefinition:
#endif
#if 1
            // DQ (5/29/2006): Added support for types
               case V_SgFunctionType:
               case V_SgMemberFunctionType:
               case V_SgModifierType:
               case V_SgPointerType:

            // DQ (5/29/2006): Added support for types
               case V_SgClassType:
               case V_SgEnumType:
               case V_SgTypedefType:

            // DQ (2/10/2007): Add this case
               case V_SgTemplateArgument:

            // DQ (3/17/2007): These should be shared, I think!
               case V_SgPragma:
            // DQ (5/20/2006): Initialized names are held in SgVariableDeclaration IR
            // nodes or other sharable structures so we don't have to share these.
            // But we have to permit them all to be shared because all pointers to 
            // them need to be reset they all need to be reset.
               case V_SgInitializedName:
#endif
#if 1
                  {
                 // DQ (7/4/2010): To improve the performance avoid regenerating the unique name for the same IR nodes when it is revisited!

                 // Make the use of false in generateUniqueName() more clear.  We need to 
                 // distinguish between defining and non-defining declarations in the generation 
                 // of unique names for the AST merge.
                 // string key = generateUniqueName(node,false);
                    bool ignoreDifferenceBetweenDefiningAndNondefiningDeclarations = false;
                    string key = SageInterface::generateUniqueName(node,ignoreDifferenceBetweenDefiningAndNondefiningDeclarations);
                    ROSE_ASSERT(key.empty() == false);
#if 1
                    SgDeclarationStatement* declaration = isSgDeclarationStatement(node);
                    if (declaration != NULL)
                       {
                      // ROSE_ASSERT(declaration->get_symbol_from_symbol_table() != NULL);

                      // DQ (7/4/2007): Some SgDeclarationStatement IR nodes don't have a representation 
                      // in the symbol table (the list of SgInitializedName object have them instead).
                         if (isSgVariableDeclaration(declaration) == NULL && 
                             isSgVariableDefinition(declaration) == NULL && 
                             isSgUsingDeclarationStatement(declaration) == NULL && 
                             isSgUsingDirectiveStatement(declaration) == NULL && 
                             isSgTemplateInstantiationDirectiveStatement(declaration) == NULL && 
                             isSgPragmaDeclaration(declaration) == NULL)
                            {
                           // DQ (6/8/2010): Only do this test for non compiler generated variable...(e.g. __default_member_function_pointer_name 
                           // is compiler generated to handle function pointers where no member function id specified).
                              if (declaration->get_startOfConstruct()->isCompilerGenerated() == false)
                                 {
                                   SgSymbol* symbol = declaration->search_for_symbol_from_symbol_table();
                                   if (symbol == NULL)
                                      {
                                     // Output more information to support debugging!
                                        printf ("declaration = %p = %s = %s \n",declaration,declaration->class_name().c_str(),SageInterface::get_name(declaration).c_str());
                                        SgScopeStatement* scope = declaration->get_scope();
                                        ROSE_ASSERT(scope != NULL);
                                        printf ("     scope = %p = %s = %s \n",scope,scope->class_name().c_str(),SageInterface::get_name(scope).c_str());
                                        declaration->get_startOfConstruct()->display("declaration->search_for_symbol_from_symbol_table() == NULL");
                                      }
                                   ROSE_ASSERT(symbol != NULL);
                                 }
                            }
#if 0
                      // DQ (6/23/2010): Added the base type of the typedef
                         SgTypedefDeclaration* typedefDeclaration = isSgTypedefDeclaration(declaration);
                         if (typedefDeclaration != NULL)
                            {
                            }
#endif 
                       }
#endif

                    addToMap(key,node);

                 // Keep track of the number of IR nodes that were evaluated for mangled name matching
                    numberOfNodesEvaluated++;
                    break;
                  }
#endif
               default:
                  {
                 // Nothing to do here
                  }
             }
        }
#endif
   }
开发者ID:billhoffman,项目名称:rose-develop,代码行数:101,代码来源:buildMangledNameMap.C

示例14: insert

void
MidLevelRewrite<MidLevelInterfaceNodeCollection>::
insert (
   SgStatement* target,
   const string & transformationString,
   ScopeIdentifierEnum inputRelativeScope,
   PlacementPositionEnum locationInScope )
   {
     ROSE_ASSERT (target != NULL);

#if 0
     printf ("MidLevelRewrite<MidLevelInterfaceNodeCollection>::insert(): inputRelativeScope = %s \n",
          MidLevelCollectionTypedefs::getRelativeScopeString(inputRelativeScope).c_str());
#endif

  // Error Reporting
  // Test to see if this is a supported statement (a few are not supported in the rewrite mechanism)
     if ( insertSupported(target,inputRelativeScope) == false )
        {
          printf ("ERROR (MidLevelRewrite<MidLevelInterfaceNodeCollection>::insert): \n");
          printf ("     This %s statement is not currently supported (or not supported \n",target->sage_class_name());
          printf ("     in its position relative to other statements) within the AST Rewrite Mechanism. \n");
          printf ("Work Around: \n");
          printf ("     Use the parent node as a target instead (and specify corresponding appropriate (longer) string. \n");
          printf ("     exiting ... \n");
          ROSE_ABORT();
        }

  // Use a more general interface to allow relative strings to be used in the high level interface 
  // even though they are not required mid level interface.
     MidLevelInterfaceNodeCollection stringAndNodeCollection;

  // DQ (1/15/2003): Needed to add handling of StatementScope insert handling.
  // The specification for scope can be either surrounding scope of statement scope
  // If it is statement scope then the target must contain a list of statements.
     ScopeIdentifierEnum scope = inputRelativeScope;

     if (scope == MidLevelCollectionTypedefs::StatementScope)
        {
       // Not clear if this is a sufficent test
          ROSE_ASSERT (isSgScopeStatement(target) != NULL);

       // Now specify a new target (use any statement inside the scope pointer to by target)
       // printf ("Before resetting target is a: %s \n",target->sage_class_name());

       // Not clear if this works for ALL scope statements!          
          SgScopeStatement* scope = isSgScopeStatement(target);
          ROSE_ASSERT (scope != NULL);
          SgStatementPtrList statementList = scope->generateStatementList();
          resetTargetStatementAndLocation (target,statementList,locationInScope);

       // Reset the target to a statement in the scope pointed to by the target
          ROSE_ASSERT (target != NULL);

       // printf ("Reset target is a: %s \n",target->sage_class_name());
       // printf ("Reset target location is: %s \n",MidLevelCollectionTypedefs::getRelativeLocationString(locationInScope).c_str());
        }

     bool buildInNewScope = false;
     TransformationStringTemplatedType<MidLevelCollectionTypedefs> 
          transformation (target,transformationString,scope,locationInScope,buildInNewScope);

#if 0
     transformation.display("In mid level insert");
#endif
#if 0
     printf ("After display ... exiting ... \n");
     ROSE_ASSERT (false);
#endif

     stringAndNodeCollection.addString(target,transformation);

#if 0
  // PreamblePositionInScope = 1 /*!< Source code to be placed at the top of a specified scope */ ,
  // TopOfCurrentScope       = 2 /*!< Top of scope (current location must be a scope)  */ ,
  // BeforeCurrentPosition   = 3 /*!< Before  */ ,
  // ReplaceCurrentPosition  = 4 /*!< Replace */ ,
  // AfterCurrentPosition    = 5 /*!< After   */ ,
  // BottomOfCurrentScope    = 6 /*!< Bottom of scope (current location must be a scope)  */ ,
#endif

  // Be careful to include/exclude the current statement when generating the prefix!
     bool prefixIncludesCurrentStatement = true;
     switch(locationInScope)
        {
          case MidLevelCollectionTypedefs::TopOfCurrentScope:
          case MidLevelCollectionTypedefs::BeforeCurrentPosition:
          case MidLevelCollectionTypedefs::ReplaceCurrentPosition:
               prefixIncludesCurrentStatement = false;
               break;

          case MidLevelCollectionTypedefs::AfterCurrentPosition:
          case MidLevelCollectionTypedefs::BottomOfCurrentScope:
               prefixIncludesCurrentStatement = true;
               break;

          default:
               printf ("Error, default reached in MidLevelRewrite<MidLevelInterfaceNodeCollection>::insert() \n");
               ROSE_ASSERT (false);
        }
//.........这里部分代码省略.........
开发者ID:Root-nix,项目名称:rose,代码行数:101,代码来源:rewriteMidLevelInterface.C

示例15: printf


//.........这里部分代码省略.........

#error "DEAD CODE"

#if ALIAS_SYMBOL_DEBUGGING
               printf ("namespaceMap.size() = %" PRIuPTR " \n",namespaceMap.size());
#endif
             }
        }

#error "DEAD CODE"

#else
  // DQ (5/23/2013): Commented out since we now have a newer and better namespace support for symbol handling.
  // printf ("NOTE:: COMMENTED OUT old support for namespace declarations in FixupAstSymbolTablesToSupportAliasedSymbols traversal \n");
#endif

     SgUseStatement* useDeclaration = isSgUseStatement(node);
     if (useDeclaration != NULL)
        {
       // This must be done in the Fortran AST construction since aliased symbols must be inserted
       // before they are looked up as part of name resolution of variable, functions, and types.
       // For C++ we can be more flexible and support the construction of symbol aliases within 
       // post-processing.
        }

  // DQ (4/14/2010): Added this C++ specific support.
  // In the future we may want to support the injection of alias symbols for C++ "using" directives and "using" declarations.
     SgUsingDeclarationStatement* usingDeclarationStatement = isSgUsingDeclarationStatement(node);
     if (usingDeclarationStatement != NULL)
        {
#if ALIAS_SYMBOL_DEBUGGING
          printf ("Found the SgUsingDeclarationStatement \n");
#endif
          SgScopeStatement* currentScope = usingDeclarationStatement->get_scope();
          ROSE_ASSERT(currentScope != NULL);

          SgDeclarationStatement* declaration     = usingDeclarationStatement->get_declaration();
          SgInitializedName*      initializedName = usingDeclarationStatement->get_initializedName();

       // Only one of these can be non-null.
          ROSE_ASSERT(initializedName != NULL || declaration != NULL);
          ROSE_ASSERT( (initializedName != NULL && declaration != NULL) == false);

          if (declaration != NULL)
             {
#if ALIAS_SYMBOL_DEBUGGING
               printf ("In FixupAstSymbolTablesToSupportAliasedSymbols::visit(): declaration = %p = %s \n",declaration,declaration->class_name().c_str());
#endif
             }
            else
             {
               if (initializedName != NULL)
                  {
#if ALIAS_SYMBOL_DEBUGGING
                    printf ("In FixupAstSymbolTablesToSupportAliasedSymbols::visit(): initializedName = %s \n",initializedName->get_name().str());
#endif
                  }
                 else
                  {
                    printf ("Error: both declaration and initializedName in SgUsingDeclarationStatement are NULL \n");
                    ROSE_ASSERT(false);
                  }
             }

#if 0
          printf ("Exiting at the base of FixupAstSymbolTablesToSupportAliasedSymbols::visit() \n");
开发者ID:matzke1,项目名称:rose-develop,代码行数:67,代码来源:fixupCxxSymbolTablesToSupportAliasingSymbols.C


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