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


C++ AstInterface::IsVariableDecl方法代码示例

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


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

示例1: Traverse

  virtual bool Traverse( AstInterface &fa, const AstNodePtr& s,
                               AstInterface::TraversalVisitType t)
   {
       HasValueMapReplace valrepl( fa, valmap, false);
       if (ValueAnnotation::get_inst()->is_value_restrict_op( fa, s, &append, &valrepl, &astcodegen)) 
             return true;
       AstNodePtr lhs, rhs;
       AstInterface::AstNodeList vars, args;
       HasValueDescriptor desc;
       if (fa.IsAssignment(s, &lhs, &rhs)) {
          if (append.has_value( rhs, &desc) ) {
             append( lhs, desc);
          }
       }
       else if (fa.IsVariableDecl( s, &vars, &args)) {
          AstInterface::AstNodeList::iterator pv = vars.begin();
          AstInterface::AstNodeList::iterator pa = args.begin();
          while (pv != vars.end()) {
            lhs = *pv;
            rhs = *pa;
            if (append.has_value( rhs, &desc) ) {
                append( lhs, desc );
            }
            ++pv;
            ++pa;
          }
       }

       return true;
   } 
开发者ID:faizurahman,项目名称:rose,代码行数:30,代码来源:ValuePropagate.C

示例2: if

bool PtrAnal::
ProcessTree( AstInterface &fa, const AstNodePtr& s, AstInterface::TraversalVisitType t)
{
 if (t == AstInterface::PreVisit) {
    AstNodePtr lhs, rhs;
    AstInterface::AstNodeList vars, args;
    if (fa.IsStatement(s)) {
       if (DebugAliasAnal()) 
           std::cerr << "pre visiting " << AstToString(s) << "\n";
      stmt_active.push_back(stmts.size());
    }

    if (fa.IsReturn(s,&rhs)) {
       // size_t stmt_firstIndex = stmts.size();
       std::string fname = fdefined.back(); 
       if (rhs != AST_NULL) {
          std::string rhsname = Get_VarName(fa, rhs);
          Stmt stmt_last = x_eq_y(func_return_name(fname), rhsname);
          stmts_pushback(stmts,stmt_last);
          namemap[rhs.get_ptr()] = VarRef(stmt_last, rhsname);
       }
       Stmt stmt_last = funcexit_x(fname);
       stmts_pushback(stmts,stmt_last);
       Skip(s);
    }
    else if (fa.IsVariableDecl( s, &vars, &args)) {
       // size_t stmt_firstIndex = stmts.size();
       AstInterface::AstNodeList::const_iterator pv = vars.begin();
       AstInterface::AstNodeList::const_iterator pa = args.begin();
       while (pv != vars.end()) {
         AstNodePtr v = *pv;
         AstNodePtr a = *pa;
         if (a != AST_NULL) {
           ProcessAssign(fa, v, a);
         }
         ++pv;
         ++pa;
      }
       Skip(s);
   }
   else if ( (lhs = fa.IsExpression(s)) != AST_NULL) {
       ProcessExpression(fa, "", lhs);
       Skip(s);
   }
 }
 else {
   if (DebugAliasAnal()) 
      std::cerr << "post visiting " << AstToString(s) << "\n";
   if (fa.IsStatement(s)) {
       size_t stmt_firstIndex = stmt_active.back();
       stmt_active.pop_back();
       if (stmt_firstIndex < stmts.size()) {
          if (DebugAliasAnal()) 
              std::cerr << "setting stmt mapping \n";
          stmtmap[s.get_ptr()] = pair<size_t,size_t>(stmt_firstIndex, stmts.size()-1);
       }
       else
          if (DebugAliasAnal()) 
             std::cerr << "no translation: " << AstToString(s) << "\n"; 
  }
 }
 return true;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:63,代码来源:PtrAnal.C


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