Пример #1
0
bool MatchOpSkipChildOnForward::performOperation(MatchStatus& status, RoseAst::iterator& i, SingleMatchResult& smr) {
  if(status.debug)
    std::cout << "skip_child_on_forward";
  SgNode* node=*i;
  if(status.debug)
    std::cout << "-OK1-";
  i.skipChildrenOnForward();
  ++i;
  if(status.debug)
    std::cout << "-OK2-";
  if(status.debug) {
    std::cout << "("<<node<<"->";
    if(!i.is_past_the_end())
      std::cout<<*i<<")";
    else
      std::cout<<"past-the-end."<<")";
  }
  return true;
}
Пример #2
0
//Searches through the expression for variables of the given type then links them with the key node provided
void Analysis::linkVariables(SgNode* key, SgType* type, SgExpression* expression){
  RoseAst ast(expression);
  for(RoseAst::iterator i = ast.begin(); i!=ast.end(); i++){
    if(SgExpression* exp = isSgExpression(*i)){
      if(sameType(exp->get_type(), type)){
        if(SgFunctionCallExp* funCall = isSgFunctionCallExp(exp)){
          SgFunctionDeclaration* funDec = funCall->getAssociatedFunctionDeclaration();
          SgFunctionDefinition* funDef = SgNodeHelper::determineFunctionDefinition(funCall);
          if(!funDef) continue;
          funDec = funDef->get_declaration();
          addToMap(key, funDec);
          i.skipChildrenOnForward();
        }
        else if(SgPntrArrRefExp* refExp = isSgPntrArrRefExp(exp)){
          linkVariables(key, refExp->get_lhs_operand()->get_type(), refExp->get_lhs_operand());
          i.skipChildrenOnForward();
        }
        else if(SgPointerDerefExp* refExp = isSgPointerDerefExp(exp)){
          linkVariables(key, refExp->get_operand()->get_type(), refExp->get_operand());
          i.skipChildrenOnForward();
        }
        else if(SgVarRefExp* varRef = isSgVarRefExp(exp)){
          SgVariableSymbol* varSym = varRef->get_symbol();
          if(varSym){  
            SgInitializedName* refInitName = varSym->get_declaration();
            SgNode* target = refInitName;
            if(!SgNodeHelper::isFunctionParameterVariableSymbol(varSym)) target = refInitName->get_declaration();
            if(target){
              addToMap(key, target);
            }
          }
        }
      }
    }
  }
}