Skip to content

Commit

Permalink
Addressing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Robertorosmaninho committed Apr 26, 2024
1 parent 790103f commit 169a356
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
15 changes: 12 additions & 3 deletions include/kllvm/ast/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,8 @@ class kore_definition {

kore_symbol *inj_symbol_{};

SubsortMap *subsorts_ = nullptr;
SubsortMap *subsorts_inverted_ = nullptr;
std::optional<SubsortMap> subsorts_;
std::optional<SubsortMap> subsorts_inverted_;

/*
* Insert symbols into this definition that have knowable labels, but cannot
Expand Down Expand Up @@ -967,7 +967,16 @@ class kore_definition {
* S |-> {T . S is a subsort of T}
*/
[[nodiscard]] SubsortMap get_subsorts();
[[nodiscard]] SubsortMap get_inverted_subsorts();

/*
* Build this definition's inverted subsort relation from axioms that have the
* `subsort` attribute.
*
* The returned map is as follows:
*
* S |-> {T . S is a direct supersort of T}
*/
[[nodiscard]] SubsortMap get_supersort();

/*
* Build this definition's overload relation from axioms that have the
Expand Down
11 changes: 6 additions & 5 deletions lib/ast/definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void kore_definition::insert_reserved_symbols() {

SubsortMap kore_definition::get_subsorts() {

if (subsorts_ != nullptr) {
if (subsorts_.has_value()) {
return *subsorts_;
}

Expand All @@ -123,13 +123,14 @@ SubsortMap kore_definition::get_subsorts() {
}
}

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

SubsortMap kore_definition::get_inverted_subsorts() {
SubsortMap kore_definition::get_supersort() {

if (subsorts_inverted_ != nullptr) {
if (subsorts_inverted_.has_value()) {
return *subsorts_inverted_;
}

Expand All @@ -141,7 +142,7 @@ SubsortMap kore_definition::get_inverted_subsorts() {
}
}

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

Expand Down
2 changes: 1 addition & 1 deletion lib/codegen/CreateTerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ std::pair<llvm::Value *, bool> create_term::create_allocation(
= dynamic_cast<kore_composite_sort *>(symbol->get_arguments()[0].get());
symbol_decl->attributes().contains(attribute_set::key::SortInjection)
&& (sort->get_category(definition_).cat == sort_category::Symbol)
&& definition_->get_inverted_subsorts()[sort].empty()) {
&& definition_->get_supersort()[sort].empty()) {
std::pair<llvm::Value *, bool> val = create_allocation(
constructor->get_arguments()[0].get(), location_stack);
if (val.second) {
Expand Down

0 comments on commit 169a356

Please sign in to comment.