Ignore:
Timestamp:
Oct 5, 2017, 7:56:16 AM (23 months ago)
Author:
cameron
Message:

Fix Mac OS compile bugs and some property object issues

File:
1 edited

Legend:

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

    r5663 r5667  
    2424using namespace llvm;
    2525
    26 inline int GetPropertyValueEnumCode(const UCD::property_t type, const std::string & value) {
    27     return property_object_table[type]->GetPropertyValueEnumCode(value);
    28 }
    29 
    3026namespace UCD {
    3127   
     
    119115}
    120116
    121 std::string resolvePropertyFunction(Name * const property) {
    122     const std::string value = property->getName();
    123     std::string functionName;
    124     if (property->hasNamespace()) {
    125         auto propit = alias_map.find(property->getNamespace());
    126         if (propit == alias_map.end()) {
    127             UnicodePropertyExpressionError("Expected a property name but '" + property->getNamespace() + "' was found instead");
    128         }
    129         auto theprop = propit->second;
    130         if (EnumeratedPropertyObject * p = dyn_cast<EnumeratedPropertyObject>(property_object_table[theprop])){
    131             int valcode = p->GetPropertyValueEnumCode(value);
    132             if (valcode < 0) {
    133                 UnicodePropertyExpressionError("Erroneous property value '" + value + "' for " + property_full_name[theprop] + " property");
    134             }
    135             functionName = "__get_" + property_enum_name[theprop] + "_" + p->GetValueEnumName(valcode);
    136         }
    137         else if (theprop == scx) {
    138             // Script extension property identified
    139             int valcode = GetPropertyValueEnumCode(sc, value);
    140             if (valcode < 0) {
    141                 UnicodePropertyExpressionError("Erroneous property value for script_extension property");
    142             }
    143             functionName = "__get_scx_" + SC_ns::enum_names[valcode];
    144         }
    145         else if (isa<BinaryPropertyObject>(property_object_table[theprop])){
    146             auto valit = Binary_ns::aliases_only_map.find(value);
    147             if (valit == Binary_ns::aliases_only_map.end()) {
    148                 UnicodePropertyExpressionError("Erroneous property value for binary property " + property_full_name[theprop]);
    149             }
    150             if (valit->second == Binary_ns::Y) {
    151                 functionName = "__get_" + property_enum_name[theprop] + "_Y";
    152             } else {
    153                 UnicodePropertyExpressionError("Unexpected property value for binary property " + property_full_name[theprop]);
    154             }
    155         }
    156         else {
    157             UnicodePropertyExpressionError("Property " + property_full_name[theprop] + " recognized but not supported in icgrep 1.0");
    158         }
    159     } else { // No namespace (property) name.
    160         // Try as a general category, script or binary property.
    161         int valcode;
    162         if ((valcode = GetPropertyValueEnumCode(gc, value)) >= 0) {
    163             functionName = "__get_gc_" + GC_ns::enum_names[valcode];
    164         }
    165         else if ((valcode = GetPropertyValueEnumCode(sc, value)) >= 0) {
    166             functionName = "__get_sc_" + SC_ns::enum_names[valcode];
    167         }
    168         else { // Try as a binary property.
    169             auto propit = alias_map.find(value);
    170             if (propit != alias_map.end()) {
    171                 auto theprop = propit->second;
    172                 if (isa<BinaryPropertyObject>(property_object_table[theprop])) {
    173                     functionName = "__get_" + property_enum_name[theprop] + "_Y";
    174                 }
    175                 else {
    176                     UnicodePropertyExpressionError("Error: property " + property_full_name[theprop] + " specified without a value");
    177                 }
    178             }
    179             else {
    180                 UnicodePropertyExpressionError("Expected a general category, script or binary property name but '" + value + "' was found instead");
    181             }
    182         }
    183     }
    184     assert (functionName.length() > 0);
    185     return functionName;
    186 }
    187 
    188117const std::string & getPropertyValueGrepString(const std::string & prop) {
    189118    auto propit = alias_map.find(canonicalize_value_name(prop));
     
    216145        else {
    217146            // No namespace (property) name.   Try as a general category.
    218             int valcode = GetPropertyValueEnumCode(gc, value);
     147            const auto & gcobj = cast<EnumeratedPropertyObject>(property_object_table[gc]);
     148            int valcode = gcobj->GetPropertyValueEnumCode(value);
    219149            if (valcode >= 0) {
    220                 return cast<EnumeratedPropertyObject>(property_object_table[gc])->GetCodepointSet(valcode);
    221             }
    222             valcode = GetPropertyValueEnumCode(sc, value);
     150                return gcobj->GetCodepointSet(valcode);
     151            }
     152            const auto & scObj = cast<EnumeratedPropertyObject>(property_object_table[sc]);
     153            valcode = scObj->GetPropertyValueEnumCode(value);
    223154            if (valcode >= 0) {
    224                 return cast<EnumeratedPropertyObject>(property_object_table[sc])->GetCodepointSet(valcode);
     155                return scObj->GetCodepointSet(valcode);
    225156            }
    226157            // Try as a binary property.
Note: See TracChangeset for help on using the changeset viewer.