Changeset 5799


Ignore:
Timestamp:
Dec 22, 2017, 8:49:48 PM (9 months ago)
Author:
cameron
Message:

sourceAlphabet and transformCC

Location:
icGREP/icgrep-devel/icgrep/cc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/cc/multiplex_CCs.cpp

    r5795 r5799  
    99#include "boost/dynamic_bitset.hpp"
    1010#include <cc/multiplex_CCs.h>
     11#include <llvm/Support/Casting.h>
     12#include <llvm/Support/ErrorHandling.h>
    1113
    1214namespace cc {
     
    111113
    112114MultiplexedAlphabet::MultiplexedAlphabet(std::string alphabetName, const std::vector<const re::CC *> CCs)
    113     : Alphabet(alphabetName) {
     115    : Alphabet(alphabetName), mUnicodeSets(CCs) {
     116        if (CCs.size() > 0) {
     117            mSourceAlphabet = CCs[0]->getAlphabet();
     118            for (unsigned i = 1; i < CCs.size(); i++) {
     119                if (CCs[i]->getAlphabet() != mSourceAlphabet) llvm::report_fatal_error("Mismatched source alphabets for Multiplexed Alphabet");
     120            }
     121        }
    114122        cc::doMultiplexCCs(CCs, mExclusiveSetIDs, mMultiplexedCCs);
     123}
     124
     125const Alphabet * MultiplexedAlphabet::getSourceAlphabet() {
     126    return mSourceAlphabet;
    115127}
    116128
     
    122134    return mMultiplexedCCs;
    123135}
     136   
     137re::CC * MultiplexedAlphabet::transformCC(re::CC * sourceCC) {
     138    if (sourceCC->getAlphabet() != mSourceAlphabet) llvm::report_fatal_error("Mismatched source alphabets for transformCC");
     139   
     140    const auto index = find(mUnicodeSets.begin(), mUnicodeSets.end(), sourceCC) - mUnicodeSets.begin();
     141    const auto exclusive_IDs = mExclusiveSetIDs[index];
     142    re::CC * CC_union = re::makeCC(this);
     143    for (auto i : exclusive_IDs) {
     144        CC_union = re::makeCC(CC_union, re::makeCC(i, this));
     145    }
     146    return CC_union;
     147}
    124148}
    125149
  • icGREP/icgrep-devel/icgrep/cc/multiplex_CCs.h

    r5795 r5799  
    1717    MultiplexedAlphabet(std::string alphabetName, const std::vector<const re::CC *> CCs);
    1818   
     19    const Alphabet * getSourceAlphabet();
     20   
    1921    std::vector<std::vector<unsigned>> getExclusiveSetIDs();
    2022   
    2123    std::vector<re::CC *> getMultiplexedCCs();
     24   
     25    re::CC * transformCC(re::CC * sourceCC);
    2226private:
     27    const Alphabet * mSourceAlphabet;
     28    const std::vector<const re::CC *> mUnicodeSets;
    2329    std::vector<std::vector<unsigned>> mExclusiveSetIDs;
    2430    std::vector<re::CC *> mMultiplexedCCs;
Note: See TracChangeset for help on using the changeset viewer.