Home | History | Annotate | Download | only in Script
      1 //===- WildcardPattern.h --------------------------------------------------===//
      2 //
      3 //                     The MCLinker Project
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 #ifndef MCLD_SCRIPT_WILDCARDPATTERN_H_
     10 #define MCLD_SCRIPT_WILDCARDPATTERN_H_
     11 
     12 #include "mcld/Config/Config.h"
     13 #include "mcld/Script/StrToken.h"
     14 #include "mcld/Support/Allocators.h"
     15 
     16 #include <llvm/ADT/StringRef.h>
     17 
     18 namespace mcld {
     19 
     20 /** \class WildcardPattern
     21  *  \brief This class defines the interfaces to Input Section Wildcard Patterns
     22  */
     23 
     24 class WildcardPattern : public StrToken {
     25  public:
     26   enum SortPolicy {
     27     SORT_NONE,
     28     SORT_BY_NAME,
     29     SORT_BY_ALIGNMENT,
     30     SORT_BY_NAME_ALIGNMENT,
     31     SORT_BY_ALIGNMENT_NAME,
     32     SORT_BY_INIT_PRIORITY
     33   };
     34 
     35  private:
     36   friend class Chunk<WildcardPattern, MCLD_SYMBOLS_PER_INPUT>;
     37   WildcardPattern();
     38   WildcardPattern(const std::string& pPattern, SortPolicy pPolicy);
     39 
     40  public:
     41   ~WildcardPattern();
     42 
     43   SortPolicy sortPolicy() const { return m_SortPolicy; }
     44 
     45   bool isPrefix() const { return m_bIsPrefix; }
     46 
     47   llvm::StringRef prefix() const;
     48 
     49   static bool classof(const StrToken* pToken) {
     50     return pToken->kind() == StrToken::Wildcard;
     51   }
     52 
     53   /* factory method */
     54   static WildcardPattern* create(const std::string& pPattern,
     55                                  SortPolicy pPolicy);
     56   static void destroy(WildcardPattern*& pToken);
     57   static void clear();
     58 
     59  private:
     60   SortPolicy m_SortPolicy;
     61   bool m_bIsPrefix;
     62 };
     63 
     64 }  // namespace mcld
     65 
     66 #endif  // MCLD_SCRIPT_WILDCARDPATTERN_H_
     67