Ignore:
Timestamp:
Sep 27, 2014, 11:12:13 PM (5 years ago)
Author:
nmedfort
Message:

Modified RE module to use a LLVM-like dyn_cast system; added 'make' functions to hide RE constructors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_seq.h

    r4187 r4194  
    55 */
    66
    7 #ifndef JOIN_H
    8 #define JOIN_H
     7#ifndef RE_SEQ_H
     8#define RE_SEQ_H
    99
    1010#include "re_re.h"
    11 #include "re_cc.h"
    12 #include "re_name.h"
    13 #include <list>
    14 #include <sstream>
    15 #include <utility>
     11#include <string>
    1612
    17 class Seq : public RE, public RE::Vector {
     13namespace re {
     14
     15class Seq : public Vector {
    1816public:
    19     typedef RE::Vector Vector;
    20     typedef enum {
    21         Normal,
    22         Byte
    23     } Type;
    24     Seq();
    25     Seq(const Type type);
    26     Seq(const Type type, iterator begin, iterator end);
    27     virtual ~Seq();
     17    static inline bool classof(const RE * re) {
     18        return re->getClassTypeId() == ClassTypeId::Seq;
     19    }
     20    static inline bool classof(const void *) {
     21        return false;
     22    }
     23    virtual RE * clone() const {
     24        return new Seq(*this);
     25    }
     26    enum class Type {
     27        Normal
     28        , Byte
     29    };
    2830    std::string getName() const;
    29     Type getType() const;
    30     void setType(Type type);
     31    inline Type getType() const {
     32        return mType;
     33    }
     34    inline void setType(const Type type) {
     35        mType = type;
     36    }
     37    virtual ~Seq() {}
     38protected:
     39    friend Seq * makeSeq(const Seq::Type);
     40    friend Seq * makeSeq(const Seq::Type, Seq::iterator, Seq::iterator);
     41    Seq(const Type type)
     42    : Vector(ClassTypeId::Seq)
     43    , mType(type) {
     44
     45    }
     46    Seq(const Seq & seq)
     47    : Vector(ClassTypeId::Seq, seq.cbegin(), seq.cend(), true)
     48    , mType(seq.mType) {
     49
     50    }
     51    Seq(const Type type, iterator begin, iterator end)
     52    : Vector(ClassTypeId::Seq, begin, end)
     53    , mType(type)
     54    {
     55
     56    }
    3157private:
    3258    Type    mType;
    3359};
     60
     61inline Seq * makeSeq(const Seq::Type type = Seq::Type::Normal) {
     62    return new Seq(type);
     63}
     64
     65inline Seq * makeSeq(const Seq::Type type, Seq::iterator begin, Seq::iterator end) {
     66    return new Seq(type, begin, end);
     67}
     68
     69}
    3470
    3571#endif // JOIN_H
Note: See TracChangeset for help on using the changeset viewer.