Program Listing for File booleanQuery.h

Program Listing for File booleanQuery.h#

Return to documentation for file (src/midend/astQuery/booleanQuery.h)

#ifndef ROSE_BOOLEAN_QUERY
#define ROSE_BOOLEAN_QUERY

#include "AstProcessing.h"

// *************************************
// Prototypes for Variable Boolean Query
// *************************************

// forward declaration
class BooleanQueryInheritedAttributeType;

typedef bool BooleanQuerySynthesizedAttributeType;

class BooleanQuery
   : public SgTopDownBottomUpProcessing<BooleanQueryInheritedAttributeType,BooleanQuerySynthesizedAttributeType>
   {
     public:

          enum TypeOfQueryType
             {
               UnknownListElementType        =  0,
               VariableDeclaration           =  1,
               Type                          =  2,
               FunctionDeclaration           =  3,
               MemberFunctionDeclaration     =  4,
               ClassDeclaration              =  5,
               Argument                      =  6,
               Field                         =  7,
               UnionedField                  =  8,
               Struct                        =  9,
               ContainedInSubtreeOfType      = 10,
               END_OF_BOOLEAN_QUERY_TYPE
             };

         ~BooleanQuery();
          BooleanQuery();

          BooleanQuery( const BooleanQuery & X );
          BooleanQuery & operator= ( const BooleanQuery & X );
          static bool isStruct ( SgNode* astNode );
          static bool isUnion  ( SgNode* astNode );

          static bool isContainedInSubtreeOfType ( SgNode* astNode, VariantT targetNodeVariant );

#if 0
          static nodeListType isTypeQuery                ( SgNode* astNode );
          static nodeListType isClassDeclarationQuery    ( SgNode* astNode );
          static nodeListType isFunctionDeclarationQuery ( SgNode* astNode );
          static nodeListType isFunctionReferenceQuery   ( SgNode* astNode );
          static nodeListType isMemberFunctionDeclarationQuery
             ( SgNode* astNode );
#endif
     private:
          static bool internalBooleanQuery (
               SgNode* astNode,
               TypeOfQueryType elementReturnType );

          BooleanQueryInheritedAttributeType
          evaluateInheritedAttribute (
             SgNode* astNode,
             BooleanQueryInheritedAttributeType inheritedValue );

          BooleanQuerySynthesizedAttributeType
          evaluateSynthesizedAttribute (
             SgNode* astNode,
             BooleanQueryInheritedAttributeType inheritedValue,
             SubTreeSynthesizedAttributes attributList );
   };




// *************************************************************
//       Boolean Traversal using TraverseToRoot mechanism
// *************************************************************

// Inherited Attribute
class BooleanQueryReverseTraversalInheritedAttribute
   {
     public:
       // Save the input parameter (the enum value for what we are checking the parent list to find).
          VariantT targetVariant;

          BooleanQueryReverseTraversalInheritedAttribute() : targetVariant(VariantT(0)) {}
   };

// Synthesized Attribute
class BooleanQueryReverseTraversalSynthesizedAttribute
   {
     public:
       // If found in the chain of parents to the AST root then we the synthesized attribute will be
       // used to carry the boolean value back to the location from which the traversal begain!
          bool value;

          BooleanQueryReverseTraversalSynthesizedAttribute() : value(false) {}
   };

#if 0
// BooleanQueryReverseTraversal is derived from ReverseTraversal
class BooleanQueryReverseTraversal : public TraverseToRoot<BooleanQueryReverseTraversalInheritedAttribute,
                                                           BooleanQueryReverseTraversalSynthesizedAttribute >
   {
     public:
          BooleanQueryReverseTraversalInheritedAttribute evaluateInheritedAttribute (
               SgNode* node,
               BooleanQueryReverseTraversalInheritedAttribute inputInheritedAttribute );

          BooleanQueryReverseTraversalSynthesizedAttribute evaluateSynthesizedAttribute (
               SgNode* node,
               BooleanQueryReverseTraversalInheritedAttribute inputInheritedAttribute,
               BooleanQueryReverseTraversalSynthesizedAttribute inputSynthesizedAttribute );
   };
#endif

// endif for ROSE_BOOLEAN_QUERY
#endif