Skip to content

Commit

Permalink
fix equal methods
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin committed Mar 4, 2024
1 parent b208798 commit 7623d7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/ast/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ bool Component::equal(const Node& node) const {
equal_targets(relations, other.relations) &&
equal_targets(clauses, other.clauses) &&
equal_targets(directives, other.directives) &&
equal_targets(lattices, other.lattices) &&
overrideRules != other.overrideRules);
// clang-format off
}
Expand All @@ -173,6 +174,7 @@ Component* Component::cloning() const {
res->relations = clone(relations);
res->clauses = clone(clauses);
res->directives = clone(directives);
res->lattices = clone(lattices);
res->overrideRules = overrideRules;
return res;
}
Expand Down
15 changes: 12 additions & 3 deletions src/ast/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,18 @@ bool Program::classof(const Node* n) {
return n->getKind() == NK_Program;
}

bool Program::equal(const Node&) const {
assert("never needed" && false);
throw("not implemented");
bool Program::equal(const Node& node) const {
const auto& other = asAssert<Program>(node);
// strict ordered comparisons of vectors
return equal_targets(types, other.types) &&
equal_targets(lattices, other.lattices) &&
equal_targets(functors, other.functors) &&
equal_targets(components, other.components) &&
equal_targets(instantiations, other.instantiations) &&
equal_targets(pragmas, other.pragmas) &&
equal_targets(getClauses(), other.getClauses()) &&
equal_targets(getRelations(), other.getRelations()) &&
equal_targets(getDirectives(), other.getDirectives());
}

} // namespace souffle::ast

0 comments on commit 7623d7e

Please sign in to comment.