Ignore:
Timestamp:
May 10, 2016, 12:12:41 AM (3 years ago)
Author:
nmedfort
Message:

UnicodeSet? bug fix and compile warning clean-up.

Location:
icGREP/icgrep-devel/icgrep/UCD
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/resolve_properties.cpp

    r4829 r5037  
    161161    }
    162162    assert (functionName.length() > 0);
    163     return std::move(functionName);
     163    return functionName;
    164164}
    165165
  • icGREP/icgrep-devel/icgrep/UCD/unicode_set.cpp

    r4982 r5037  
    4242
    4343
    44 UnicodeSet::Allocator UnicodeSet::mAllocator;
     44UnicodeSet::RunAllocator UnicodeSet::mRunAllocator;
     45UnicodeSet::QuadAllocator UnicodeSet::mQuadAllocator;
    4546
    4647const size_t QUAD_BITS = (8 * sizeof(bitquad_t));
     
    478479    }
    479480
     481    //this->dump(llvm::errs()); llvm::errs() << " + [" << lo << ',' << hi << "]\n"; llvm::errs().flush();
     482
    480483    // Create a temporary run and quad set for the given range
    481484    std::vector<run_t> runs;
     
    490493    length_t length = 0;
    491494    run_type_t type = Empty;
     495
    492496    // Advance past any full runs prior to the lo_index
    493497    for (;;) {
     498        assert (ri != mRuns.cend());
    494499        std::tie(type, length) = *ri;
     500        //llvm::errs() << std::distance(mRuns.cbegin(), ri) << ") type=" << (int)(type) << ", length=" << length << ", lo_index=" << lo_index << ", hi_index=" << hi_index << "\n"; llvm::errs().flush();
    495501        if (lo_index < length) {
    496502            break;
    497503        }
    498504        if (type == Mixed) {
     505            assert (std::distance(qi, mQuads.cend()) >= length);
    499506            qi += length;
    500507        }
     
    504511    }
    505512
     513    //llvm::errs() << "* " << std::distance(mRuns.cbegin(), ri) << ") type=" << (int)(type) << ", length=" << length << ", lo_index=" << lo_index << ", hi_index=" << hi_index << "\n"; llvm::errs().flush();
     514
    506515    // Now record the runs and any quads prior to lo_index
    507     runs.assign(mRuns.cbegin(), ri);
     516    runs.assign(mRuns.cbegin(), ri++);
    508517    if (lo_index) {
    509518        runs.push_back(std::make_pair(type, lo_index));
    510519        if (type == Mixed) {
     520            assert (std::distance(qi, mQuads.cend()) >= lo_index);
    511521            qi += lo_index;
    512522        }
     
    528538        }
    529539        if (type == Mixed) {
     540            assert (std::distance(qi, mQuads.cend()) > 0);
    530541            lo_quad |= *qi++;
    531542        }
     
    533544    }
    534545    --length;
     546
     547    //llvm::errs() << "* " << std::distance(mRuns.cbegin(), ri) << ") type=" << (int)(type) << ", length=" << length << ", lo_index=" << lo_index << ", hi_index=" << hi_index << "\n"; llvm::errs().flush();
    535548
    536549    // Now check if we need to write out any Full blocks between the lo and hi code points; adjust our position
     
    540553        append_run(Full, hi_index - 1, runs);
    541554        // Advance past original quads that were filled in
    542         for (;;) {
     555        while (ri != mRuns.cend()) {
    543556            if (type == Mixed) {
     557                assert (std::distance(qi, mQuads.cend()) >= length);
    544558                qi += length;
    545559            }
    546             std::tie(type, length) = *++ri;
     560            std::tie(type, length) = *ri++;
     561            //llvm::errs() << std::distance(mRuns.cbegin(), ri) << ") type=" << (int)(type) << ", length=" << length << ", lo_index=" << lo_index << ", hi_index=" << hi_index << "\n"; llvm::errs().flush();
    547562            if (hi_index < length) {
    548563                break;
     
    556571        } else {
    557572            if (type == Mixed) {
     573                assert (std::distance(qi, mQuads.cend()) > hi_index);
    558574                qi += hi_index;
    559575                hi_quad |= *qi++;
     
    563579    }
    564580
     581    //llvm::errs() << "* " << std::distance(mRuns.cbegin(), ri) << ") type=" << (int)(type) << ", length=" << length << ", lo_index=" << lo_index << ", hi_index=" << hi_index << "\n";
     582
     583    //llvm::errs() << "* remaining=" << std::distance(ri, mRuns.cend()) << "\n";
     584
     585    //llvm::errs().flush();
     586
    565587    // And append any remaining values from the original data
    566588    append_run(type, length - hi_index, runs);
    567     runs.insert(runs.end(), ++ri, mRuns.cend());
     589    assert ("We wrote all the runs but still have remaining quads?" && (ri != mRuns.cend() || qi == mQuads.cend()));
     590    runs.insert(runs.end(), ri, mRuns.cend());
    568591    quads.insert(quads.end(), qi, mQuads.cend());
    569 
    570592    assert (verify(runs, quads));
    571593
     
    751773 ** ------------------------------------------------------------------------------------------------------------- */
    752774UnicodeSet::UnicodeSet()
    753 : mRuns(reinterpret_cast<RunAllocator &>(mAllocator))
    754 , mQuads(reinterpret_cast<QuadAllocator &>(mAllocator))
     775: mRuns(mRunAllocator)
     776, mQuads(mQuadAllocator)
    755777{
    756778    append_run(Empty, UNICODE_QUAD_COUNT, mRuns);
     
    762784 ** ------------------------------------------------------------------------------------------------------------- */
    763785UnicodeSet::UnicodeSet(const codepoint_t codepoint)
    764 : mRuns(reinterpret_cast<RunAllocator &>(mAllocator))
    765 , mQuads(reinterpret_cast<QuadAllocator &>(mAllocator))
     786: mRuns(mRunAllocator)
     787, mQuads(mQuadAllocator)
    766788{
    767789    const codepoint_t quad_no = codepoint / QUAD_BITS;
     
    776798 ** ------------------------------------------------------------------------------------------------------------- */
    777799UnicodeSet::UnicodeSet(const codepoint_t lo, const codepoint_t hi)
    778 : mRuns(reinterpret_cast<RunAllocator &>(mAllocator))
    779 , mQuads(reinterpret_cast<QuadAllocator &>(mAllocator))
     800: mRuns(mRunAllocator)
     801, mQuads(mQuadAllocator)
    780802{
    781803    const codepoint_t lo_index = lo / QUAD_BITS;
     
    857879 ** ------------------------------------------------------------------------------------------------------------- */
    858880UnicodeSet::UnicodeSet(std::initializer_list<interval_t>::iterator begin, std::initializer_list<interval_t>::iterator end)
    859 : mRuns(0, {Empty, 0}, reinterpret_cast<RunAllocator &>(mAllocator))
    860 , mQuads(0, 0, reinterpret_cast<QuadAllocator &>(mAllocator))
     881: mRuns(0, {Empty, 0}, mRunAllocator)
     882, mQuads(0, 0, mQuadAllocator)
    861883{
    862884    convertIntervalRangesToSparseSet(begin, end, mRuns, mQuads);
     
    867889 ** ------------------------------------------------------------------------------------------------------------- */
    868890UnicodeSet::UnicodeSet(const std::vector<interval_t>::iterator begin, const std::vector<interval_t>::iterator end)
    869 : mRuns(0, {Empty, 0}, reinterpret_cast<RunAllocator &>(mAllocator))
    870 , mQuads(0, 0, reinterpret_cast<QuadAllocator &>(mAllocator))
     891: mRuns(0, {Empty, 0}, mRunAllocator)
     892, mQuads(0, 0, mQuadAllocator)
    871893{
    872894    convertIntervalRangesToSparseSet(begin, end, mRuns, mQuads);
     
    877899 ** ------------------------------------------------------------------------------------------------------------- */
    878900UnicodeSet::UnicodeSet(const UnicodeSet & other)
    879 : mRuns(other.mRuns, reinterpret_cast<RunAllocator &>(mAllocator))
    880 , mQuads(other.mQuads, reinterpret_cast<QuadAllocator &>(mAllocator))
     901: mRuns(other.mRuns, mRunAllocator)
     902, mQuads(other.mQuads, mQuadAllocator)
    881903{
    882904    assert (verify(mRuns, mQuads));
     
    887909 ** ------------------------------------------------------------------------------------------------------------- */
    888910UnicodeSet::UnicodeSet(std::initializer_list<run_t> r, std::initializer_list<bitquad_t> q)
    889 : mRuns(r.begin(), r.end(), reinterpret_cast<RunAllocator &>(mAllocator))
    890 , mQuads(q.begin(), q.end(), reinterpret_cast<QuadAllocator &>(mAllocator))
     911: mRuns(r.begin(), r.end(), mRunAllocator)
     912, mQuads(q.begin(), q.end(), mQuadAllocator)
    891913{
    892914    assert (verify(mRuns, mQuads));
     
    897919 ** ------------------------------------------------------------------------------------------------------------- */
    898920inline UnicodeSet::UnicodeSet(std::vector<run_t> && r, std::vector<bitquad_t> && q)
    899 : mRuns(r.begin(), r.end(), reinterpret_cast<RunAllocator &>(mAllocator))
    900 , mQuads(q.begin(), q.end(), reinterpret_cast<QuadAllocator &>(mAllocator))
     921: mRuns(r.begin(), r.end(), mRunAllocator)
     922, mQuads(q.begin(), q.end(), mQuadAllocator)
    901923{
    902924    assert (verify(mRuns, mQuads));
  • icGREP/icgrep-devel/icgrep/UCD/unicode_set.h

    r4983 r5037  
    4949    using interval_t = std::pair<codepoint_t, codepoint_t>;
    5050
    51     using Allocator = SlabAllocator<uint32_t>;
    52     using RunAllocator = Allocator::rebind<run_t>::other;
    53     using QuadAllocator = Allocator::rebind<bitquad_t>::other;
     51    using RunAllocator = SlabAllocator<run_t>;
     52    using QuadAllocator = SlabAllocator<bitquad_t>;
    5453
    5554    using RunVector = std::vector<run_t, RunAllocator>;
     
    196195private:
    197196
    198     RunVector           mRuns;
    199     QuadVector          mQuads;
    200     static Allocator    mAllocator;
     197    RunVector               mRuns;
     198    QuadVector              mQuads;
     199    static RunAllocator     mRunAllocator;
     200    static QuadAllocator    mQuadAllocator;
    201201};
    202202
Note: See TracChangeset for help on using the changeset viewer.