Ignore:
Timestamp:
Oct 4, 2015, 4:59:28 PM (3 years ago)
Author:
nmedfort
Message:

First stage of CC_NameMap removal

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_name.h

    r4818 r4819  
    55#include <re/re_cc.h>
    66#include <string>
    7 #include <re/printer_re.h>
    87
    98namespace pablo {
     
    4342        mCompiled = var;
    4443    }
     44    bool operator<(const Name & other) const;
     45    bool operator<(const CC & other) const;
    4546    void setDefinition(RE * definition);
    4647    virtual ~Name() {}
    4748protected:
    4849    friend Name * makeName(const std::string &, RE *);
    49     friend Name * makeByteName(const std::string &, RE *);
    5050    friend Name * makeName(const std::string &, const Type);
    5151    friend Name * makeName(const std::string &, const std::string &, const Type);
     
    106106}
    107107
     108inline bool Name::operator < (const Name & other) const {
     109    if (mDefinition && other.mDefinition && isa<CC>(mDefinition) && isa<CC>(other.mDefinition)) {
     110        return *cast<CC>(mDefinition) < *cast<CC>(other.mDefinition);
     111    } else if (mNamespaceLength < other.mNamespaceLength) {
     112        return true;
     113    } else if (mNamespaceLength > other.mNamespaceLength) {
     114        return false;
     115    } else if (mNameLength < other.mNameLength) {
     116        return true;
     117    } else if (mNameLength > other.mNameLength) {
     118        return false;
     119    }
     120    const auto diff = std::memcmp(mNamespace, other.mNamespace, mNamespaceLength);
     121    if (diff < 0) {
     122        return true;
     123    } else if (diff > 0) {
     124        return false;
     125    }
     126    return (std::memcmp(mName, other.mName, mNameLength) < 0);
     127}
     128
     129inline bool Name::operator < (const CC & other) const {
     130    if (mDefinition && isa<CC>(mDefinition)) {
     131        return *cast<CC>(mDefinition) < other;
     132    }
     133    return false;
     134}
     135
    108136inline Name * makeName(const std::string & name, const Name::Type type) {
    109137    return new Name(nullptr, 0, name.c_str(), name.length(), type, nullptr);
     
    125153}
    126154
    127 inline Name * makeByteName(const std::string & name, RE * cc) {
    128     if (isa<Name>(cc)) {
    129         return cast<Name>(cc);
    130     }
    131     else {
    132         return new Name(nullptr, 0, name.c_str(), name.length(), Name::Type::Byte, cc);
    133     }
    134 }
    135 
    136155}
    137156
Note: See TracChangeset for help on using the changeset viewer.