Some additional changes for removal of the == operator override.

This commit is contained in:
Mike Lischke 2016-08-04 15:41:35 +02:00
parent a41774ef0d
commit 07ceea1245
5 changed files with 9 additions and 11 deletions

View File

@ -104,7 +104,7 @@ void ATNConfig::setPrecedenceFilterSuppressed(bool value) {
bool ATNConfig::operator == (const ATNConfig &other) const {
return state->stateNumber == other.state->stateNumber && alt == other.alt &&
(context == other.context || (context != nullptr && *context == *(other.context))) &&
(semanticContext == other.semanticContext || (semanticContext != nullptr && *semanticContext == *(other.semanticContext))) &&
*semanticContext == *(other.semanticContext) &&
isPrecedenceFilterSuppressed() == other.isPrecedenceFilterSuppressed();
}

View File

@ -33,7 +33,8 @@
#include "atn/ATNConfig.h"
#include "atn/ATNSimulator.h"
#include "Exceptions.h"
#include "SemanticContext.h"
#include "atn/SemanticContext.h"
#include "support/Arrays.h"
#include "atn/ATNConfigSet.h"
@ -169,12 +170,7 @@ bool ATNConfigSet::operator == (const ATNConfigSet &other) {
dipsIntoOuterContext != other.dipsIntoOuterContext) // includes stack context
return false;
for (size_t i = 0; i < configs.size(); i++) {
if (configs[i] != other.configs[i] && *(configs[i]) != *(other.configs[i]))
return false;
}
return true;
return Arrays::equals(configs, other.configs);
}
size_t ATNConfigSet::hashCode() {

View File

@ -95,7 +95,9 @@ bool LexerATNConfig::operator == (const LexerATNConfig& other) const
if (_passedThroughNonGreedyDecision != other._passedThroughNonGreedyDecision)
return false;
if (_lexerActionExecutor != other._lexerActionExecutor && (_lexerActionExecutor != nullptr && *_lexerActionExecutor != *(other._lexerActionExecutor))) {
if (_lexerActionExecutor == nullptr)
return other._lexerActionExecutor == nullptr;
if (*_lexerActionExecutor != *(other._lexerActionExecutor)) {
return false;
}

View File

@ -645,7 +645,7 @@ std::unique_ptr<ATNConfigSet> ParserATNSimulator::applyPrecedenceFilter(ATNConfi
* (basically a graph subtraction algorithm).
*/
auto iterator = statesFromAlt1.find(config->state->stateNumber);
if (iterator != statesFromAlt1.end() && iterator->second == config->context) {
if (iterator != statesFromAlt1.end() && *iterator->second == *config->context) {
// eliminated
continue;
}

View File

@ -61,7 +61,7 @@ struct AltAndContextConfigComparer {
if (a == b) {
return true;
}
return a->state->stateNumber == b->state->stateNumber && a->context == b->context;
return a->state->stateNumber == b->state->stateNumber && *a->context == *b->context;
}
};