smtr: Refactor write back into _eval and _initial

Easier for comparisons, and the structure still works.  (I don't remember why I moved away from it in the first place.)
This commit is contained in:
Krystine Sherwin 2025-02-07 13:58:09 +13:00
parent d73c58fad1
commit fa2d45a922
No known key found for this signature in database
1 changed files with 17 additions and 8 deletions

View File

@ -210,14 +210,8 @@ struct SmtrModule {
state_struct.insert(state->name, state->sort);
}
void write(std::ostream &out)
{
SExprWriter w(out);
input_struct.write_definition(w);
output_struct.write_definition(w);
state_struct.write_definition(w);
void write_eval(SExprWriter &w)
{
w.push();
w.open(list("define", list(name, "inputs", "state")));
auto inlined = [&](Functional::Node n) {
@ -240,7 +234,10 @@ struct SmtrModule {
output_struct.write_value(w, [&](IdString name) { return node_to_sexpr(ir.output(name).value()); });
state_struct.write_value(w, [&](IdString name) { return node_to_sexpr(ir.state(name).next_value()); });
w.pop();
}
void write_initial(SExprWriter &w)
{
w.push();
auto initial = name + "_initial";
w.open(list("define", initial));
@ -259,6 +256,18 @@ struct SmtrModule {
}
w.pop();
}
void write(std::ostream &out)
{
SExprWriter w(out);
input_struct.write_definition(w);
output_struct.write_definition(w);
state_struct.write_definition(w);
write_eval(w);
write_initial(w);
}
};
struct FunctionalSmtrBackend : public Backend {