Changeset 5781


Ignore:
Timestamp:
Dec 15, 2017, 9:19:27 AM (9 months ago)
Author:
cameron
Message:

Small fixes

Location:
icGREP/icgrep-devel/icgrep
Files:
11 edited

Legend:

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

    r5770 r5781  
    2727}
    2828
    29 void caseInsensitiveInsertRange(UnicodeSet * const cc, const codepoint_t lo, const codepoint_t hi) {
    30     cc->insert_range(lo, hi);
     29void caseInsensitiveInsertRange(UnicodeSet & cc, const codepoint_t lo, const codepoint_t hi) {
     30    cc.insert_range(lo, hi);
    3131    // Find the first foldTable entry overlapping the (lo, hi) range.
    3232    int e = findFoldEntry(lo);
     
    5050            if ((lo1 <= negative_subrange_hi) && (hi1 >= negative_subrange_lo)) {
    5151                // negative offsets apply
    52                 cc->insert_range(std::max(negative_subrange_lo,lo1) - fe.fold_offset, std::min(negative_subrange_hi, hi1) - fe.fold_offset);
     52                cc.insert_range(std::max(negative_subrange_lo,lo1) - fe.fold_offset, std::min(negative_subrange_hi, hi1) - fe.fold_offset);
    5353            }
    5454            // Now the positive offset subrange.
     
    5656            codepoint_t positive_subrange_hi = positive_subrange_lo + fe.fold_offset - 1;
    5757            if ((lo1 <= positive_subrange_hi) && (hi1 >= positive_subrange_lo)) {
    58                 cc->insert_range(std::max(positive_subrange_lo, lo1) + fe.fold_offset, std::min(positive_subrange_hi, hi1) + fe.fold_offset);
     58                cc.insert_range(std::max(positive_subrange_lo, lo1) + fe.fold_offset, std::min(positive_subrange_hi, hi1) + fe.fold_offset);
    5959            }
    6060        }
     
    6262            // We have either a positive or negative offset, and all offsets for
    6363            // this entry have the same sign.
    64             cc->insert_range(lo1 + fe.fold_offset, hi1 + fe.fold_offset);
     64            cc.insert_range(lo1 + fe.fold_offset, hi1 + fe.fold_offset);
    6565        }
    6666        // Now pick up any individual fold entries.
     
    6868            if (fe.fold_pairs[i].first < lo) continue;  // Only possible for first fold_entry.
    6969            if (fe.fold_pairs[i].first > hi) break;     // Only possible for last fold_entry.
    70             cc->insert(fe.fold_pairs[i].second);
     70            cc.insert(fe.fold_pairs[i].second);
    7171        }
    7272        // Move on to the next fold_entry.
     
    8282}
    8383
    84 UnicodeSet * caseInsensitize(UnicodeSet * const cc) {
    85     UnicodeSet * cci = new UnicodeSet();
    86     for (const interval_t i : *cc) {
     84UnicodeSet caseInsensitize(UnicodeSet & cc) {
     85    UnicodeSet cci;
     86    for (const interval_t i : cc) {
    8787        caseInsensitiveInsertRange(cci, lo_codepoint(i), hi_codepoint(i));
    8888    }
  • icGREP/icgrep-devel/icgrep/UCD/CaseFolding.h

    r5770 r5781  
    2121};
    2222
    23 UCD::UnicodeSet * caseInsensitize(UCD::UnicodeSet * const cc);
     23UCD::UnicodeSet caseInsensitize(UCD::UnicodeSet & cc);
    2424
    2525
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.h

    r5620 r5781  
    7474
    7575inline pablo::PabloAST * CC_Compiler::compileCC(const re::CC *cc, pablo::PabloBlock & block) {
    76     return compileCC(cc->canonicalName(re::ByteClass), cc, block);
     76    return compileCC(cc->canonicalName(re::CC_type::ByteClass), cc, block);
    7777}
    7878
    7979inline pablo::PabloAST *CC_Compiler::compileCC(const re::CC *cc, pablo::PabloBuilder & builder) {
    80     return compileCC(cc->canonicalName(re::ByteClass), cc, builder);
     80    return compileCC(cc->canonicalName(re::CC_type::ByteClass), cc, builder);
    8181}
    8282
  • icGREP/icgrep-devel/icgrep/kernels/cc_kernel.cpp

    r5440 r5781  
    7575, mCharClasses(charClasses) {
    7676    for (CC * cc : mCharClasses) {
    77         addOutput(cc->canonicalName(re::ByteClass), b->getStreamTy());
     77        addOutput(cc->canonicalName(re::CC_type::ByteClass), b->getStreamTy());
    7878    }
    7979}
  • icGREP/icgrep-devel/icgrep/re/casing.cpp

    r5770 r5781  
    2525    if (isa<CC>(re)) {
    2626        if (inCaseInsensitiveMode) {
    27             UCD::UnicodeSet * cased = caseInsensitize(cast<CC>(re));
    28             return makeCC(std::move(*cased));
     27            UCD::UnicodeSet cased = caseInsensitize(*cast<CC>(re));
     28            return makeCC(std::move(cased));
    2929        }
    3030        else return re;
  • icGREP/icgrep-devel/icgrep/re/printer_re.cpp

    r5765 r5781  
    4444    } else if (const CC* re_cc = dyn_cast<const CC>(re)) {
    4545        retVal = "CC \"";
    46         retVal += re_cc->canonicalName(UnicodeClass);
     46        retVal += re_cc->canonicalName(CC_type::UnicodeClass);
    4747        retVal += "\" ";
    4848
     
    6262        retVal += re_name->getName();
    6363        retVal += "\" ";
    64         if (re_name->getType() == Name::Type::Capture) {
    6564            retVal += "=(" + PrintRE(re_name->getDefinition()) + ")";
    66         }
    6765    } else if (const Range* rg = dyn_cast<const Range>(re)) {
    6866        retVal = "Range (";
  • icGREP/icgrep-devel/icgrep/re/re_cc.cpp

    r5770 r5781  
    1414    std::stringstream name;
    1515    name << std::hex;
    16     if ((type == ByteClass) && (max_codepoint() >= 0x80)) {
     16    if ((type == CC_type::ByteClass) && (max_codepoint() >= 0x80)) {
    1717        name << "BC";
    1818    } else {
  • icGREP/icgrep-devel/icgrep/re/re_cc.h

    r5770 r5781  
    1616using interval_t = UCD::interval_t;
    1717
    18 enum CC_type {UnicodeClass, ByteClass};
     18enum class CC_type {UnicodeClass, ByteClass};
    1919
    2020class CC : public RE, public UCD::UnicodeSet {
  • icGREP/icgrep-devel/icgrep/re/re_multiplex.cpp

    r5765 r5781  
    9292                        name << n->getName();
    9393                    } else if (isa<CC>(re)) {
    94                         name << cast<CC>(re)->canonicalName(UnicodeClass);
     94                        name << cast<CC>(re)->canonicalName(CC_type::UnicodeClass);
    9595                    }
    9696                    ai = alt->erase(ai);
  • icGREP/icgrep-devel/icgrep/re/re_name.h

    r5634 r5781  
    6060    }
    6161    inline const char * replicateString(const char * string, const length_t length) {
    62         if (string) {
     62        if (string && (length > 0)) {
    6363            char * allocated = reinterpret_cast<char*>(mAllocator.allocate(length));
    6464            std::memcpy(allocated, string, length);
    65             string = allocated;
     65            return allocated;
    6666        }
    67         return string;
     67        return nullptr;
    6868    }
    6969
  • icGREP/icgrep-devel/icgrep/re/re_name_resolve.cpp

    r5769 r5781  
    7373                        name << n->getName();
    7474                    } else if (isa<CC>(item)) {
    75                         name << cast<CC>(item)->canonicalName(UnicodeClass);
     75                        name << cast<CC>(item)->canonicalName(CC_type::UnicodeClass);
    7676                    }
    7777                    ai = alt->erase(ai);
Note: See TracChangeset for help on using the changeset viewer.