source: icGREP/icgrep-devel/icgrep/re/re_re.h @ 5202

Last change on this file since 5202 was 5091, checked in by xuedongx, 3 years ago

delete GCB as a separate type.

File size: 1.8 KB
Line 
1/*
2 *  Copyright (c) 2014 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#ifndef RE_H
8#define RE_H
9
10#include <vector>
11#include <assert.h>
12#include <llvm/Support/Casting.h>
13#include <util/slab_allocator.h>
14
15using namespace llvm;
16
17namespace re {
18
19class Vector;
20class Pair;
21
22class Alt;
23class Any;
24class Assertion;
25class CC;
26class Diff;
27class End;
28class Intersect;
29class Name;
30class Permute;
31class Rep;
32class Seq;
33class Start;
34class SymDiff;
35class Union;
36
37class RE {
38public:
39    using Allocator = SlabAllocator<u_int8_t>;
40    using VectorAllocator = SlabAllocator<RE *>;
41    enum class ClassTypeId : unsigned {
42        Alt
43        , Any
44        , Assertion
45        , CC
46        , Diff
47        , End
48        , Intersect
49        , Name
50        , Permute
51        , Rep
52        , Seq
53        , Start
54        , SymDiff
55        , Union
56    };
57    inline ClassTypeId getClassTypeId() const {
58        return mClassTypeId;
59    }
60    typedef std::initializer_list<RE *> InitializerList;
61protected:
62    inline RE(const ClassTypeId id)
63    : mClassTypeId(id) {
64
65    }
66    void* operator new (std::size_t size) noexcept {
67        return mAllocator.allocate(size);
68    }
69    const ClassTypeId mClassTypeId;
70
71    static Allocator mAllocator;
72    static VectorAllocator mVectorAllocator;
73};
74
75class Vector : public RE, public std::vector<RE*, RE::VectorAllocator> {
76public:
77
78    virtual ~Vector() {
79    }
80protected:
81    inline Vector(const ClassTypeId id)
82    : RE(id)
83    , std::vector<RE*, RE::VectorAllocator>(mVectorAllocator)
84    {
85
86    }
87    inline Vector(const ClassTypeId id, const iterator begin, const iterator end)
88    : RE(id)
89    , std::vector<RE*, RE::VectorAllocator>(begin, end, mVectorAllocator) {
90
91    }
92};
93
94}
95
96#endif // RE_H
97
98
Note: See TracBrowser for help on using the repository browser.