Skip to content

Commit 063b1f0

Browse files
committed
Implement sorted term -> pattern
1 parent 452cecf commit 063b1f0

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

bindings/core/src/core.cpp

+2-1
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

+2
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

+11-3
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,18 @@ void serializeRawTermToFile(
452452
fclose(file);
453453
}
454454

455-
std::shared_ptr<kllvm::KOREPattern> termToKorePattern(block *subject) {
455+
std::shared_ptr<kllvm::KOREPattern>
456+
sortedTermToKorePattern(block *subject, const char *sort) {
457+
auto is_kitem = (std::string(sort) == "SortKItem{}");
458+
block *term = is_kitem ? subject : constructRawTerm(subject, sort);
459+
456460
char *data_out;
457461
size_t size_out;
458462

459-
serializeConfiguration(subject, "SortKItem{}", &data_out, &size_out, true);
460-
return deserialize_pattern(data_out, data_out + size_out);
463+
serializeConfiguration(term, "SortKItem{}", &data_out, &size_out, true);
464+
return deserialize_pattern(data_out, data_out + size_out, true);
465+
}
466+
467+
std::shared_ptr<kllvm::KOREPattern> termToKorePattern(block *subject) {
468+
return sortedTermToKorePattern(subject, "SortKItem{}");
461469
}

0 commit comments

Comments
 (0)