Changeset 5800


Ignore:
Timestamp:
Dec 23, 2017, 7:59:51 AM (12 months ago)
Author:
cameron
Message:

isa and dyn_cast for Alphabets

Location:
icGREP/icgrep-devel/icgrep/cc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/cc/alphabet.cpp

    r5797 r5800  
    1414                                                 unsigned unicodeCommon,
    1515                                                 std::vector <UCD::codepoint_t> aboveCommon) :
    16     Alphabet(alphabetName), mUnicodeCommon(unicodeCommon), mAboveCommon(aboveCommon) {}
     16    Alphabet(alphabetName, ClassTypeId::UnicodeMappableAlphabet),
     17    mUnicodeCommon(unicodeCommon),
     18    mAboveCommon(aboveCommon) {}
    1719
    1820UCD::codepoint_t UnicodeMappableAlphabet::toUnicode(const unsigned n) const {
     
    3335
    3436CodeUnitAlphabet::CodeUnitAlphabet(std::string alphabetName, uint8_t bits) :
    35     Alphabet(alphabetName), mCodeUnitBits(bits) {}
     37    Alphabet(alphabetName, ClassTypeId::CodeUnitAlphabet), mCodeUnitBits(bits) {}
    3638
    3739const UnicodeMappableAlphabet Unicode("Unicode", UCD::UNICODE_MAX, {});
  • icGREP/icgrep-devel/icgrep/cc/alphabet.h

    r5797 r5800  
    2222public:
    2323    const std::string & getName() const { return mAlphabetName;}
     24    enum class ClassTypeId : unsigned {UnicodeMappableAlphabet, CodeUnitAlphabet, MultiplexedAlphabet};
     25    inline ClassTypeId getClassTypeId() const {
     26        return mClassTypeId;
     27    }
     28
    2429protected:
    25     Alphabet(std::string alphabetName) : mAlphabetName(alphabetName) {}
     30    Alphabet(std::string name, ClassTypeId k) : mAlphabetName(name), mClassTypeId(k) {}
    2631private:
    27     std::string mAlphabetName;
     32    const std::string mAlphabetName;
     33    const ClassTypeId mClassTypeId;
    2834};
    2935
     
    4147                            std::vector <UCD::codepoint_t> aboveCommon);
    4248   
     49    static inline bool classof(const Alphabet * a) {
     50        return a->getClassTypeId() == ClassTypeId::UnicodeMappableAlphabet;
     51    }
     52    static inline bool classof(const void *) {return false;}
    4353    //  The Unicode codepoint of the nth character (the character whose alphabet code is n).
    4454    UCD::codepoint_t toUnicode(const unsigned n) const;
     
    5666public:
    5767    CodeUnitAlphabet(std::string alphabetName, uint8_t codeUnitBits);
     68    static inline bool classof(const Alphabet * a) {
     69        return a->getClassTypeId() == ClassTypeId::CodeUnitAlphabet;
     70    }
     71    static inline bool classof(const void *) {return false;}
    5872    uint8_t getCodeUnitBitWidth() { return mCodeUnitBits;}
    5973   
  • icGREP/icgrep-devel/icgrep/cc/multiplex_CCs.cpp

    r5799 r5800  
    4949    return breakpoints;
    5050}
    51 
    5251
    5352void doMultiplexCCs(const std::vector<const re::CC *> & CCs,
     
    113112
    114113MultiplexedAlphabet::MultiplexedAlphabet(std::string alphabetName, const std::vector<const re::CC *> CCs)
    115     : Alphabet(alphabetName), mUnicodeSets(CCs) {
     114    : Alphabet(alphabetName, ClassTypeId::MultiplexedAlphabet), mUnicodeSets(CCs) {
    116115        if (CCs.size() > 0) {
    117116            mSourceAlphabet = CCs[0]->getAlphabet();
     
    123122}
    124123
    125 const Alphabet * MultiplexedAlphabet::getSourceAlphabet() {
     124const Alphabet * MultiplexedAlphabet::getSourceAlphabet() const {
    126125    return mSourceAlphabet;
    127126}
  • icGREP/icgrep-devel/icgrep/cc/multiplex_CCs.h

    r5799 r5800  
    1616public:
    1717    MultiplexedAlphabet(std::string alphabetName, const std::vector<const re::CC *> CCs);
    18    
    19     const Alphabet * getSourceAlphabet();
     18    static inline bool classof(const Alphabet * a) {
     19        return a->getClassTypeId() == ClassTypeId::MultiplexedAlphabet;
     20    }
     21    static inline bool classof(const void *) {return false;}
     22
     23    const Alphabet * getSourceAlphabet() const;
    2024   
    2125    std::vector<std::vector<unsigned>> getExclusiveSetIDs();
Note: See TracChangeset for help on using the changeset viewer.