Changeset 6158


Ignore:
Timestamp:
Sep 5, 2018, 1:31:19 PM (3 weeks ago)
Author:
cameron
Message:

EnumeratedPropertyObject::GetEnumerationValue?

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

Legend:

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

    r6134 r6158  
    99#include "PropertyObjectTable.h"
    1010#include <llvm/Support/Casting.h>
     11#include <llvm/Support/raw_ostream.h>
    1112#include <sstream>
    1213#include <llvm/Support/ErrorHandling.h>
     
    130131            enumeration_basis_sets.push_back(UnicodeSet());
    131132            for (unsigned e = 0; e < independent_enum_count; e++) {
    132                 if (((e >> i) & 1UL) == 0) {
     133                if (((e >> i) & 1UL) == 1UL) {
    133134                    enumeration_basis_sets[i] = enumeration_basis_sets[i] + *property_value_sets[e];
    134135                }
     
    137138    }
    138139    return enumeration_basis_sets;
     140}
     141
     142unsigned EnumeratedPropertyObject::GetEnumerationValue(codepoint_t cp) {
     143    unsigned enum_value = 0;
     144    if (LLVM_UNLIKELY(enumeration_basis_sets.empty())) {
     145        GetEnumerationBasisSets();
     146    }
     147    unsigned basis_count = enumeration_basis_sets.size();
     148    for (unsigned i = 0; i < basis_count; i++) {
     149        if (enumeration_basis_sets[i].contains(cp)) {
     150            enum_value += 1 << i;
     151        }
     152    }
     153    return enum_value;
    139154}
    140155
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.h

    r6138 r6158  
    108108    const UnicodeSet & GetCodepointSet(const int property_enum_val) const;
    109109    std::vector<UnicodeSet> & GetEnumerationBasisSets();
     110    unsigned GetEnumerationValue(codepoint_t cp);
    110111    const std::string & GetValueEnumName(const int property_enum_val) const {return property_value_enum_names[property_enum_val]; }
    111112    const std::string & GetValueFullName(const int property_enum_val) const {return property_value_full_names[property_enum_val]; }
Note: See TracChangeset for help on using the changeset viewer.