void
FindVariableDeclarations::visit ( SgNode* astNode )
   {
     SgBasicBlock* block = isSgBasicBlock(astNode);
     if (block != NULL)
        {
          SgStatementPtrList & listOfStatements = block->get_statements();
          for (size_t i = 0; i < listOfStatements.size(); i++)
             {
               SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(listOfStatements[i]);
               if (variableDeclaration != NULL)
                  {
                    printf ("Found a variable decaration in a SgBasicBlock at: \n");
                    variableDeclaration->get_file_info()->display("Found a variable decaration in a SgBasicBlock");
                  }
             }
        }
   }
Exemplo n.º 2
0
        virtual void
        visit(SgNode *n)
        {
            SgVariableDeclaration *vd = isSgVariableDeclaration(n);
            if (!vd)
            {
                return;
            }
            if (isRecognizedDeclaration(vd))
            {
                return;
            }

            AttachedPreprocessingInfoType *info = vd->getAttachedPreprocessingInfo();
            if (info)
            {
                DoxygenFile *f = new DoxygenFile(vd);
                DoxygenGroup *currentGroup = 0;
                DoxygenComment *groupComment = 0;
                (*docsList)[vd->get_file_info()->get_filenameString()] = f;
                for (AttachedPreprocessingInfoType::iterator i = info->begin(); i != info->end(); ++i)
                {
                    PreprocessingInfo *pi = *i;
                    //printf("pass %d: processing comment %s\n", inexact ? 3 : 2, pi->getString().c_str());
                    //printf("processing comment %s\n", pi->getString().c_str());
                    if (DoxygenComment::isDoxygenComment(pi))
                    {
                        DoxygenComment *comm = new DoxygenComment(vd, pi);
                        comm->originalFile = f;
                        if (comm->entry.type() == DoxygenEntry::None)
                        {
                            if (comm->entry.hasName())
                            {
                                // this is a group
                                //printf("name = '%s'\n", comm->entry.name().c_str());
                                if (currentGroup)
                                {
                                    currentGroup->comment = comm;
                                }
                                else
                                {
                                    groupComment = comm;
                                }
                            }
                            else
                            {
                                delete comm;
                                continue;
                            }
                        }
                        commentList->push_back(comm);
#if 0
                        pair<SymTab::iterator, SymTab::iterator> bounds = symTab->equal_range(DoxygenClass::getProtoName(comm->entry.prototype));
                        for (SymTab::iterator i = bounds.first; i != bounds.second; )
                        {
                            if (inexact || comm->entry.prototype == getQualifiedPrototype((*i).second))
                            {
                                DoxygenCommentListAttribute *attr = dynamic_cast<DoxygenCommentListAttribute *>((*i).second->attribute()["DoxygenCommentList"]);
                                ROSE_ASSERT(attr);

                                printf("attaching to node %s\n", (*i).second->unparseToString().c_str());
                                attr->commentList.push_back(comm);
                                SymTab::iterator ii = i;
                                ++i;
                                symTab->erase(ii);
                            }
                            else
                            {
                                ++i;
                            }
                        }
#endif
                    }
                    else if (isGroupStart(pi))
                    {
                        if (currentGroup)
                        {
                            puts("Group already open!");
                        }
                        //puts("opening group");
                        currentGroup = new DoxygenGroup();
                        currentGroup->groupStart = *i;
                        currentGroup->comment = groupComment;
                        groupComment = 0;
                    }
                    else if (isGroupEnd(pi))
                    {
                        //puts("closing group");
                        if (!currentGroup)
                        {
                            puts("Group-end encountered without group begin!");
                        }
                        else
                        {
                            currentGroup->groupEnd = *i;
                            if (currentGroup->comment)
                            {
                                f->groups[currentGroup->comment->entry.name()] = currentGroup;
                            }
                            else
                            {
                                puts("Group wasn't given a name!");
                            }
                            currentGroup = 0;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
void
TypeTransformation::visit ( SgNode* astNode )
{
    SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(astNode);
    if (variableDeclaration != NULL)
    {
#if 0
        // One way to know where you are when your doing a transformation (debugging).
        printf ("Found a variable decaration: \n");
        variableDeclaration->get_file_info()->display("Found a variable decaration");
#endif
        SgInitializedNamePtrList & varList = variableDeclaration->get_variables();
        SgInitializedNamePtrList::iterator i = varList.begin();

        bool transformed = false;

        // Iterate over the SgInitializedName objects.
        while (i != varList.end())
        {
            SgPointerType* pointerType = isSgPointerType((*i)->get_type());
            if (pointerType != NULL)
            {
                // Types are shared, so don't modify the types directly, but point to a new type.
                (*i)->set_type(SageBuilder::buildRestrictType((*i)->get_type()));
#if 1
                printf ("In TypeTransformation::visit(): Calling setTransformation on SgInitializedName: i = %p = %s \n",*i,(*i)->get_name().str());
#endif
                // DQ (4/14/2015): Explicitly set this as containing a transformation (we might want
                // to alternatively fixup the token-based unparsing frontier tests to triggered based
                // on the setting of the isModified flag in each IR node.
                // (*i)->set_containsTransformation(true);
                // (*i)->setTransformation();

                transformed = true;
            }

            i++;
        }

        if (transformed == true)
        {
#if 0
            // DQ (4/16/2015): That this can be commented out means that we have general support in place to
            // interpret transformations from status of the isModified flags that are set by all of the
            // set_* access functions.  This interpretation of the isModified flag status to explicitly
            // mark transformations is handled in the function:
            // SimpleFrontierDetectionForTokenStreamMapping::evaluateInheritedAttribute()
            // in file: simpleFrontierDetection.C

            // DQ (4/14/2015): Mark the SgVariableDeclaration as being a transformation.
            variableDeclaration->setTransformation();

            // Also set to be output in the generated code.
            variableDeclaration->setOutputInCodeGeneration();

            // By definition: for this to be a transformation it cannot also contain a transforamtion.
            ROSE_ASSERT(variableDeclaration->get_containsTransformation() == false);
            ROSE_ASSERT(variableDeclaration->isTransformation() == true);
#endif
        }
    }
}