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

sourceAlphabet and transformCC

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.