Skip to content

Commit e8f261b

Browse files
committed
Implement sorted term -> pattern
1 parent 8824613 commit e8f261b

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

bindings/core/src/core.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ std::shared_ptr<KOREPattern> evaluate_function(
7878
}
7979

8080
auto tag = getTagForSymbolName(label.c_str());
81+
auto return_sort = getReturnSortForTag(tag);
8182
auto result = evaluateFunctionSymbol(tag, term_args.data());
8283

83-
return term_to_pattern(static_cast<block *>(result));
84+
return sortedTermToKorePattern(static_cast<block *>(result), return_sort);
8485
}
8586

8687
bool is_sort_kitem(std::shared_ptr<KORESort> const &sort) {

include/runtime/header.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ void printConfigurationInternal(
310310
// you can use the C bindings, which wrap the return value of this method in
311311
// a POD struct.
312312
std::shared_ptr<kllvm::KOREPattern> termToKorePattern(block *);
313+
std::shared_ptr<kllvm::KOREPattern>
314+
sortedTermToKorePattern(block *, const char *);
313315

314316
// This function injects its argument into KItem before printing, using the sort
315317
// argument as the source sort. Doing so allows the term to be pretty-printed

runtime/util/ConfigurationSerializer.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,18 @@ void serializeRawTermToFile(
464464
fclose(file);
465465
}
466466

467-
std::shared_ptr<kllvm::KOREPattern> termToKorePattern(block *subject) {
467+
std::shared_ptr<kllvm::KOREPattern>
468+
sortedTermToKorePattern(block *subject, const char *sort) {
469+
auto is_kitem = (std::string(sort) == "SortKItem{}");
470+
block *term = is_kitem ? subject : constructRawTerm(subject, sort);
471+
468472
char *data_out;
469473
size_t size_out;
470474

471-
serializeConfiguration(subject, "SortKItem{}", &data_out, &size_out, true);
472-
return deserialize_pattern(data_out, data_out + size_out);
475+
serializeConfiguration(term, "SortKItem{}", &data_out, &size_out, true);
476+
return deserialize_pattern(data_out, data_out + size_out, true);
477+
}
478+
479+
std::shared_ptr<kllvm::KOREPattern> termToKorePattern(block *subject) {
480+
return sortedTermToKorePattern(subject, "SortKItem{}");
473481
}

0 commit comments

Comments
 (0)