source: icGREP/icgrep-devel/icgrep/re/re_collect_unicodesets.cpp @ 5585

Last change on this file since 5585 was 5565, checked in by xuedongx, 2 years ago

Separate name resolve and gather for future use. Add re_colloect_unicodesets and re_multiplex.

File size: 1.9 KB
Line 
1#include "re_collect_unicodesets.h"
2#include <re/re_name.h>
3#include <re/re_alt.h>
4#include <re/re_cc.h>
5#include <re/re_seq.h>
6#include <re/re_rep.h>
7#include <re/re_diff.h>
8#include <re/re_intersect.h>
9#include <re/re_assertion.h>
10#include <re/re_analysis.h>
11#include <re/re_memoizer.hpp>
12#include <UCD/ucd_compiler.hpp>
13#include <UCD/resolve_properties.h>
14#include <boost/container/flat_set.hpp>
15#include <cc/multiplex_CCs.h>
16#include <sstream>
17#include <iostream>
18
19using namespace boost::container;
20using namespace llvm;
21
22namespace re {
23
24flat_set<Name *>        mVisited;
25
26void collect_UnicodeSets(RE * re, std::vector<UCD::UnicodeSet> & UnicodeSets) {
27    assert ("RE object cannot be null!" && re);
28    if (isa<Name>(re)) {
29        if (mVisited.insert(cast<Name>(re)).second) {
30            if (CC * cc = dyn_cast<CC>(cast<Name>(re)->getDefinition())) {
31                UnicodeSets.push_back(* cast<UCD::UnicodeSet>(cc));
32            } else {
33                collect_UnicodeSets(cast<Name>(re)->getDefinition(), UnicodeSets);
34            }
35        }
36    } else if (isa<Seq>(re)) {
37        for (RE * item : *cast<Seq>(re)) {
38            collect_UnicodeSets(item, UnicodeSets);
39        }
40    } else if (isa<Alt>(re)) {
41        for (RE * item : *cast<Alt>(re)) {
42            collect_UnicodeSets(item, UnicodeSets);
43        }
44    } else if (isa<Rep>(re)) {
45        collect_UnicodeSets(cast<Rep>(re)->getRE(), UnicodeSets);
46    } else if (isa<Assertion>(re)) {
47        collect_UnicodeSets(cast<Assertion>(re)->getAsserted(), UnicodeSets);
48    } else if (isa<Diff>(re)) {
49        collect_UnicodeSets(cast<Diff>(re)->getLH(), UnicodeSets);
50        collect_UnicodeSets(cast<Diff>(re)->getRH(), UnicodeSets);
51    } else if (isa<Intersect>(re)) {
52        collect_UnicodeSets(cast<Intersect>(re)->getLH(), UnicodeSets);
53        collect_UnicodeSets(cast<Intersect>(re)->getRH(), UnicodeSets);
54    }
55}
56
57}
Note: See TracBrowser for help on using the repository browser.