smtr: Structs have local scope

Also unique_name can take field_name directly.
This commit is contained in:
Krystine Sherwin 2024-09-03 22:23:41 +12:00 committed by Emily (aiju)
parent a2abbcb33f
commit d6c5e13bf3
1 changed files with 5 additions and 4 deletions

View File

@ -75,15 +75,16 @@ class SmtrStruct {
};
idict<IdString> field_names;
vector<Field> fields;
SmtrScope &scope;
SmtrScope &global_scope;
SmtrScope local_scope;
public:
std::string name;
SmtrStruct(std::string name, SmtrScope &scope) : scope(scope), name(name) {}
SmtrStruct(std::string name, SmtrScope &scope) : global_scope(scope), local_scope(), name(name) {}
void insert(IdString field_name, SmtrSort sort) {
field_names(field_name);
auto base_name = scope.unique_name("\\" + RTLIL::unescape_id(field_name));
auto base_name = local_scope.unique_name(field_name);
auto accessor = name + "-" + base_name;
scope.reserve(accessor);
global_scope.reserve(accessor);
fields.emplace_back(Field{sort, accessor, base_name});
}
void write_definition(SExprWriter &w) {