source: icGREP/icgrep-devel/icgrep/cc/cc_namemap.hpp @ 4602

Last change on this file since 4602 was 4602, checked in by nmedfort, 4 years ago

Fixed PabloBuilder? and intergrated it into CC Compiler.

File size: 1.3 KB
Line 
1#ifndef CC_NAMER_HPP
2#define CC_NAMER_HPP
3
4#include <unordered_map>
5#include <vector>
6#include <string>
7#include "re/re_name.h"
8#include "re/re_cc.h"
9#include <pablo/expression_map.hpp>
10
11namespace re {
12    class CC;
13    class RE;
14}
15
16namespace cc {
17
18class CC_NameMap {
19public:
20
21    typedef std::unordered_map<std::string, re::Name*>          NameMap;
22    typedef std::vector<re::Name*>                              NameVector;
23    typedef NameVector::const_iterator                          iterator;
24
25    CC_NameMap() {}
26
27    re::RE * process(re::RE * re, const re::CC_type t);
28
29    inline const re::Name * operator[](const std::string & name) const {
30        auto f = mNameMap.find(name);
31        if (f == mNameMap.end()) {
32            return nullptr;
33        }
34        return f->second;
35    }
36
37    inline iterator begin() const {
38        return mNameVector.begin();
39    }
40
41    inline iterator end() const {
42        return mNameVector.end();
43    }
44
45    std::string printMap();
46   
47private:
48
49    inline re::Name * insert(std::string && name, re::Name * re) {
50        mNameMap.insert(std::make_pair(std::move(name), re));
51        mNameVector.push_back(re);
52        return re;
53    }
54
55private:
56    NameMap                 mNameMap;
57    NameVector              mNameVector;
58};
59
60}
61
62#endif // CC_NAMER_HPP
Note: See TracBrowser for help on using the repository browser.