AstDisplayInfo.cpp

Go to the documentation of this file.
00001 #include "rose.h"
00002 
00003 
00004 #include "AstDisplayInfo.h"
00005 #include <string>
00006 namespace AstDisplayInfo
00007 {
00008     NodeType getType(SgNode* node)
00009     {
00010         SgClassDefinition *    sgClassDefinition    = isSgClassDefinition(node);
00011         SgFunctionDefinition * sgFunctionDefinition = isSgFunctionDefinition(node);
00012         SgFunctionDeclaration *sgFunctionDecl       = isSgFunctionDeclaration(node);
00013 
00014         SgNamespaceDefinitionStatement * sgNSDef    = isSgNamespaceDefinitionStatement(node);
00015 
00016         //Assembler Nodes
00017         SgAsmFunctionDeclaration * sgAsmFunctionDecl= isSgAsmFunctionDeclaration(node);
00018 
00019         if(sgClassDefinition)          return CLASS;
00020         else if (sgFunctionDefinition) return FUNCTION;
00021         else if (sgFunctionDecl)       return FUNCTION;
00022         else if (sgNSDef)              return NAMESPACE;
00023         else if (sgAsmFunctionDecl)    return FUNCTION;
00024         else                           return UNKNOWN;
00025     }
00026 
00027 
00028     QString getShortNodeNameDesc(SgNode * node)
00029     {
00030         SgClassDefinition * sgClassDefinition        = isSgClassDefinition(node);
00031         SgClassDeclaration* sgClassDeclaration       = isSgClassDeclaration(node);
00032         SgFunctionDefinition * sgFunctionDefinition  = isSgFunctionDefinition(node);
00033         SgFunctionDeclaration * sgFunctionDecl       = isSgFunctionDeclaration(node);
00034         SgNamespaceDefinitionStatement * sgNSDef     = isSgNamespaceDefinitionStatement(node);
00035         SgNamespaceDeclarationStatement * sgNsDecl   = isSgNamespaceDeclarationStatement(node);
00036 
00037 
00038         SgFile * sgFile                              = isSgFile(node);
00039         SgProject * sgProject                        = isSgProject(node);
00040 
00041         SgVariableDeclaration * sgVarDecl            = isSgVariableDeclaration(node);
00042         SgInitializedName * sgInitName               = isSgInitializedName(node);
00043 
00044         SgTypedefDeclaration * sgTypeDefDecl         = isSgTypedefDeclaration(node);
00045         SgEnumDeclaration *   sgEnumDecl             = isSgEnumDeclaration(node);
00046         SgPragmaDeclaration * sgPragmaDecl           = isSgPragmaDeclaration(node);
00047 
00048         //Assembler Nodes
00049         SgAsmFunctionDeclaration * sgAsmFunctionDecl  = isSgAsmFunctionDeclaration(node);
00050 
00051         std::string s;
00052 
00053         if(sgClassDefinition)          s = sgClassDefinition->get_declaration()->get_name().getString();
00054         else if (sgClassDeclaration)   s = sgClassDeclaration->get_name().getString();
00055         else if (sgFunctionDefinition) s = sgFunctionDefinition->get_declaration()->get_name().getString();
00056         else if (sgNSDef)              s = sgNSDef->get_namespaceDeclaration()->get_name().getString();
00057         else if (sgNsDecl)             s = "namespace " + sgNsDecl->get_name().getString();
00058         else if (sgFunctionDecl)       s = sgFunctionDecl->get_name().getString();
00059         else if (sgAsmFunctionDecl)    s = StringUtility::demangledName( sgAsmFunctionDecl->get_name());
00060         else if (sgTypeDefDecl)        s = "typedef " + sgTypeDefDecl->get_name().getString();
00061         else if (sgEnumDecl)           s = "enum " + sgEnumDecl->get_name().getString();
00062         else if (sgPragmaDecl)         s = "pragma " + sgPragmaDecl->get_pragma()->get_name();
00063         else if (sgVarDecl)            s = "Variable Declaration";
00064         else if (sgInitName)           s = sgInitName->get_name().getString();
00065         else if (sgFile)               s = sgFile->get_sourceFileNameWithoutPath();
00066         else if (sgProject)            s = "Project";
00067         else                           return getShortNodeTypeDesc(node);
00068 
00069 
00070         return QString(s.c_str());
00071     }
00072 
00073     QString getShortNodeTypeDesc(SgNode * node)
00074     {
00075         SgClassDefinition * sgClassDefinition       = isSgClassDefinition(node);
00076 
00077         SgFunctionDefinition * sgFunctionDefinition = isSgFunctionDefinition(node);
00078         SgFunctionDeclaration * sgFunctionDecl      = isSgFunctionDeclaration(node);
00079         SgNamespaceDefinitionStatement * sgNSDef    = isSgNamespaceDefinitionStatement(node);
00080         SgForStatement * sgForStatement             = isSgForStatement(node);
00081         SgWhileStmt * sgWhileStatement              = isSgWhileStmt(node);
00082 
00083         //Assembler Nodes
00084         SgAsmFunctionDeclaration * sgAsmFunctionDecl= isSgAsmFunctionDeclaration(node);
00085 
00086 
00087         if      (sgClassDefinition)     return QObject::tr("Class");
00088         else if (sgFunctionDefinition)  return QObject::tr("Function");
00089         else if (sgFunctionDecl)        return QObject::tr("Function");
00090         else if (sgNSDef)               return QObject::tr("Namespace");
00091         else if (sgForStatement)        return QObject::tr("For-Loop");
00092         else if (sgWhileStatement)      return QObject::tr("While-Loop");
00093         else if (sgAsmFunctionDecl)     return QObject::tr("Asm-Function");
00094         else                            return QString();
00095     }
00096 
00097 
00098     QIcon nodeIcon(SgNode * node)
00099     {
00100         SgClassDefinition * sgClassDefinition       = isSgClassDefinition(node);
00101         SgClassDeclaration* sgClassDeclaration      = isSgClassDeclaration(node);
00102 
00103         SgFunctionDefinition * sgFunctionDefinition = isSgFunctionDefinition(node);
00104         SgFunctionDeclaration * sgFunctionDecl      = isSgFunctionDeclaration(node);
00105         SgNamespaceDefinitionStatement * sgNSDef    = isSgNamespaceDefinitionStatement(node);
00106         SgNamespaceDeclarationStatement * sgNsDecl  = isSgNamespaceDeclarationStatement(node);
00107 
00108         SgForStatement * sgForStatement             = isSgForStatement(node);
00109         SgWhileStmt * sgWhileStatement              = isSgWhileStmt(node);
00110 
00111         SgTypedefDeclaration * sgTypeDefDecl        = isSgTypedefDeclaration(node);
00112         SgEnumDeclaration *   sgEnumDecl            = isSgEnumDeclaration(node);
00113         SgPragmaDeclaration * sgPragmaDecl          = isSgPragmaDeclaration(node);
00114 
00115         SgVariableDeclaration * sgVarDecl           = isSgVariableDeclaration(node);
00116         SgInitializedName * sgInitName              = isSgInitializedName(node);
00117 
00118 
00119         SgSourceFile * sgSrcFile                    = isSgSourceFile(node);
00120         SgBinaryFile * sgBinFile                    = isSgBinaryFile(node);
00121         SgProject * sgProject                       = isSgProject(node);
00122 
00123 
00124         //Assembler Nodes
00125         SgAsmFunctionDeclaration * sgAsmFunctionDecl= isSgAsmFunctionDeclaration(node);
00126 
00127         if      (sgClassDefinition)     return QIcon(":/util/NodeIcons/class.gif");
00128         else if (sgClassDeclaration)    return QIcon(":/util/NodeIcons/class.gif");
00129         else if (sgFunctionDefinition)  return QIcon(":/util/NodeIcons/function.gif");
00130         else if (sgFunctionDecl)        return QIcon(":/util/NodeIcons/function.gif");
00131         else if (sgNSDef)               return QIcon(":/util/NodeIcons/namespace.gif");
00132         else if (sgNsDecl)              return QIcon(":/util/NodeIcons/namespace.gif");
00133         else if (sgForStatement)        return QIcon(":/util/NodeIcons/loop.png");
00134         else if (sgWhileStatement)      return QIcon(":/util/NodeIcons/loop.png");
00135         else if (sgAsmFunctionDecl)     return QIcon(":/util/NodeIcons/function.gif");
00136         else if (sgSrcFile)             return QIcon(":/util/NodeIcons/sourcefile.gif");
00137         else if (sgBinFile)             return QIcon(":/util/NodeIcons/binaryfiles.gif");
00138         else if (sgProject)             return QIcon(":/util/NodeIcons/project.gif");
00139         else if (sgTypeDefDecl)         return QIcon(":/util/NodeIcons/typedef.gif");
00140         else if (sgEnumDecl)            return QIcon(":/util/NodeIcons/enum.gif");
00141         else if (sgPragmaDecl)          return QIcon(":/util/NodeIcons/pragma.gif");
00142         else if (sgVarDecl)             return QIcon(":/util/NodeIcons/variable.gif");
00143         else if (sgInitName)            return QIcon(":/util/NodeIcons/variable.gif");
00144         else                            return QIcon();
00145     }
00146 
00147     QIcon includedFilesIcon()
00148     {
00149         return QIcon(":/util/NodeIcons/includes.gif");
00150     }
00151 
00152     QIcon includeFileIcon()
00153     {
00154         return QIcon(":/util/NodeIcons/include.gif");
00155     }
00156 
00157     QIcon sourceFileIcon()
00158     {
00159         return QIcon(":/util/NodeIcons/sourcefile.gif");
00160     }
00161 
00162 }
00163 
00164 

Generated on Tue Sep 15 14:48:47 2009 for RoseQtWidgets by  doxygen 1.4.7