forked from jasder/antlr
Compare contents in SemanticContext::*::operator==
This commit is contained in:
parent
739bf3a756
commit
198da78c98
|
@ -65,14 +65,10 @@ size_t SemanticContext::Predicate::hashCode() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SemanticContext::Predicate::operator == (const SemanticContext &other) const {
|
bool SemanticContext::Predicate::operator == (const SemanticContext &other) const {
|
||||||
const Predicate *p = dynamic_cast<const Predicate*>(&other);
|
if (this == &other)
|
||||||
if (p == nullptr)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (this == p) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
|
const Predicate *p = dynamic_cast<const Predicate*>(&other);
|
||||||
if (p == nullptr)
|
if (p == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -116,14 +112,13 @@ size_t SemanticContext::PrecedencePredicate::hashCode() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SemanticContext::PrecedencePredicate::operator == (const SemanticContext &other) const {
|
bool SemanticContext::PrecedencePredicate::operator == (const SemanticContext &other) const {
|
||||||
|
if (this == &other)
|
||||||
|
return true;
|
||||||
|
|
||||||
const PrecedencePredicate *predicate = dynamic_cast<const PrecedencePredicate *>(&other);
|
const PrecedencePredicate *predicate = dynamic_cast<const PrecedencePredicate *>(&other);
|
||||||
if (predicate == nullptr)
|
if (predicate == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (this == predicate) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return precedence == predicate->precedence;
|
return precedence == predicate->precedence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,15 +167,21 @@ std::vector<Ref<SemanticContext>> SemanticContext::AND::getOperands() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SemanticContext::AND::operator == (const SemanticContext &other) const {
|
bool SemanticContext::AND::operator == (const SemanticContext &other) const {
|
||||||
|
if (this == &other)
|
||||||
|
return true;
|
||||||
|
|
||||||
const AND *context = dynamic_cast<const AND *>(&other);
|
const AND *context = dynamic_cast<const AND *>(&other);
|
||||||
if (context == nullptr)
|
if (context == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (this == context) {
|
if (opnds == context->opnds)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return opnds == context->opnds;
|
for (auto opndIt = opnds.begin(), otherIt = context->opnds.begin(); opndIt < opnds.end(), otherIt < context->opnds.end(); ++opndIt, ++otherIt) {
|
||||||
|
if (*opndIt != *otherIt)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SemanticContext::AND::hashCode() const {
|
size_t SemanticContext::AND::hashCode() const {
|
||||||
|
@ -275,15 +276,21 @@ std::vector<Ref<SemanticContext>> SemanticContext::OR::getOperands() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SemanticContext::OR::operator == (const SemanticContext &other) const {
|
bool SemanticContext::OR::operator == (const SemanticContext &other) const {
|
||||||
|
if (this == &other)
|
||||||
|
return true;
|
||||||
|
|
||||||
const OR *context = dynamic_cast<const OR *>(&other);
|
const OR *context = dynamic_cast<const OR *>(&other);
|
||||||
if (context == nullptr)
|
if (context == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (this == context) {
|
if (opnds == context->opnds)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return opnds == context->opnds;
|
for (auto opndIt = opnds.begin(), otherIt = context->opnds.begin(); opndIt < opnds.end(), otherIt < context->opnds.end(); ++opndIt, ++otherIt ) {
|
||||||
|
if (*opndIt != *otherIt)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SemanticContext::OR::hashCode() const {
|
size_t SemanticContext::OR::hashCode() const {
|
||||||
|
|
Loading…
Reference in New Issue