Skip to content

Commit

Permalink
Adding the transitive_closure to get_supersort
Browse files Browse the repository at this point in the history
Caching the non-transitive closure of `subsorts_`.
  • Loading branch information
Robertorosmaninho committed Apr 26, 2024
1 parent 169a356 commit 6a6ff3d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/ast/definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void kore_definition::insert_reserved_symbols() {
SubsortMap kore_definition::get_subsorts() {

if (subsorts_.has_value()) {
return *subsorts_;
return transitive_closure(*subsorts_);
}

auto subsorts = SubsortMap{};
Expand All @@ -123,9 +123,8 @@ SubsortMap kore_definition::get_subsorts() {
}
}

subsorts_
= std::optional<SubsortMap>(SubsortMap(transitive_closure(subsorts)));
return *subsorts_;
subsorts_ = std::optional<SubsortMap>(SubsortMap(subsorts));
return transitive_closure(subsorts);
}

SubsortMap kore_definition::get_supersort() {
Expand All @@ -142,8 +141,9 @@ SubsortMap kore_definition::get_supersort() {
}
}

subsorts_inverted_ = std::optional<SubsortMap>(SubsortMap(inverted_subsorts));
return inverted_subsorts;
subsorts_inverted_ = std::optional<SubsortMap>(
SubsortMap(transitive_closure(inverted_subsorts)));
return *subsorts_inverted_;
}

SymbolMap kore_definition::get_overloads() const {
Expand Down

0 comments on commit 6a6ff3d

Please sign in to comment.