source: icGREP/icgrep-devel/icgrep/re/re_cc.cpp @ 5934

Last change on this file since 5934 was 5847, checked in by cameron, 18 months ago

Unify Parabix CC compiler and Direct CC compiler with a common superclass

File size: 2.0 KB
RevLine 
[3850]1/*
[5847]2 *  Copyright (c) 2018 International Characters.
[3850]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#include "re_cc.h"
[4286]8#include <llvm/Support/Compiler.h>
[4339]9#include <sstream>
[3850]10
[4194]11namespace re {
[3850]12
[5847]13std::string CC::canonicalName() const {
[4339]14    std::stringstream name;
[5847]15    name << mAlphabet->getName();
[4614]16    name << std::hex;
[4519]17    char separator = '_';
[4829]18    for (const interval_t i : *this) {
[4339]19        name << separator;
[4614]20        if (lo_codepoint(i) == hi_codepoint(i)) {
21            name << lo_codepoint(i);
[4287]22        }
23        else {
[4614]24            name << lo_codepoint(i) << '_' << hi_codepoint(i);
[4287]25        }
[4612]26        separator = ',';
[3914]27    }
[4339]28    return name.str();
[3850]29}
[4319]30   
[5795]31CC::CC(const cc::Alphabet * alphabet)
[5748]32: RE(ClassTypeId::CC)
[5795]33, UnicodeSet()
34, mAlphabet(alphabet) {}
[5742]35
36
37CC::CC(const CC & cc)
38: RE(ClassTypeId::CC)
[5795]39, UCD::UnicodeSet(cc)
40, mAlphabet(cc.getAlphabet()) {}
[5742]41
42
[5795]43CC::CC(const codepoint_t codepoint, const cc::Alphabet * alphabet)
[5742]44: RE(ClassTypeId::CC)
[5795]45, UCD::UnicodeSet(codepoint)
46, mAlphabet(alphabet) {}
[5742]47
48
[5795]49CC::CC(const codepoint_t lo_codepoint, const codepoint_t hi_codepoint, const cc::Alphabet * alphabet)
[5742]50: RE(ClassTypeId::CC)
[5795]51, UCD::UnicodeSet(lo_codepoint, hi_codepoint)
52, mAlphabet(alphabet) {}
[5742]53
54
55CC::CC(const CC * cc1, const CC * cc2)
56: RE(ClassTypeId::CC)
[5795]57, UCD::UnicodeSet(std::move(*cc1 + *cc2))
58, mAlphabet(cc1->getAlphabet()) {
59    assert (cc1->getAlphabet() == cc2->getAlphabet());
[5742]60}
61
[5795]62
63CC::CC(const UCD::UnicodeSet && set, const cc::Alphabet * alphabet)
[5742]64: RE(ClassTypeId::CC)
[5795]65, UCD::UnicodeSet(std::move(set))
66, mAlphabet(alphabet) {}
[5742]67
68
[5795]69CC::CC(std::initializer_list<interval_t>::iterator begin, std::initializer_list<interval_t>::iterator end, const cc::Alphabet * alphabet)
[5742]70: RE(ClassTypeId::CC)
[5748]71, UCD::UnicodeSet(begin, end)
[5795]72, mAlphabet(alphabet) {}
[5742]73
74
[5795]75CC::CC(const std::vector<interval_t>::iterator begin, const std::vector<interval_t>::iterator end, const cc::Alphabet * alphabet)
[5742]76: RE(ClassTypeId::CC)
[5748]77, UCD::UnicodeSet(begin, end)
[5795]78, mAlphabet(alphabet) {}
[5742]79
80}
Note: See TracBrowser for help on using the repository browser.