Clean up pseudo-private member usage in `passes/cmds/design.cc`.

This commit is contained in:
Alberto Gonzalez 2020-03-28 04:45:50 +00:00
parent 1bf2bdf05b
commit 4681f02a6e
No known key found for this signature in database
GPG Key ID: 8395A8BA109708B2
1 changed files with 33 additions and 31 deletions

View File

@ -194,13 +194,13 @@ struct DesignPass : public Pass {
argidx = args.size(); argidx = args.size();
} }
for (auto &it : copy_from_design->modules_) { for (auto mod : copy_from_design->modules()) {
if (sel.selected_whole_module(it.first)) { if (sel.selected_whole_module(mod->name)) {
copy_src_modules.push_back(it.second); copy_src_modules.push_back(mod);
continue; continue;
} }
if (sel.selected_module(it.first)) if (sel.selected_module(mod->name))
log_cmd_error("Module %s is only partly selected.\n", RTLIL::id2cstr(it.first)); log_cmd_error("Module %s is only partly selected.\n", RTLIL::id2cstr(mod->name));
} }
if (import_mode) { if (import_mode) {
@ -230,8 +230,8 @@ struct DesignPass : public Pass {
pool<Module*> queue; pool<Module*> queue;
dict<IdString, IdString> done; dict<IdString, IdString> done;
if (copy_to_design->modules_.count(prefix)) if (copy_to_design->module(prefix) != nullptr)
delete copy_to_design->modules_.at(prefix); copy_to_design->remove(copy_to_design->module(prefix));
if (GetSize(copy_src_modules) != 1) if (GetSize(copy_src_modules) != 1)
log_cmd_error("No top module found in source design.\n"); log_cmd_error("No top module found in source design.\n");
@ -240,12 +240,13 @@ struct DesignPass : public Pass {
{ {
log("Importing %s as %s.\n", log_id(mod), log_id(prefix)); log("Importing %s as %s.\n", log_id(mod), log_id(prefix));
copy_to_design->modules_[prefix] = mod->clone(); RTLIL::Module *t = mod->clone();
copy_to_design->modules_[prefix]->name = prefix; t->name = prefix;
copy_to_design->modules_[prefix]->design = copy_to_design; t->design = copy_to_design;
copy_to_design->modules_[prefix]->attributes.erase("\\top"); t->attributes.erase("\\top");
copy_to_design->add(t);
queue.insert(copy_to_design->modules_[prefix]); queue.insert(t);
done[mod->name] = prefix; done[mod->name] = prefix;
} }
@ -268,15 +269,16 @@ struct DesignPass : public Pass {
log("Importing %s as %s.\n", log_id(fmod), log_id(trg_name)); log("Importing %s as %s.\n", log_id(fmod), log_id(trg_name));
if (copy_to_design->modules_.count(trg_name)) if (copy_to_design->module(trg_name) != nullptr)
delete copy_to_design->modules_.at(trg_name); copy_to_design->remove(copy_to_design->module(trg_name));
copy_to_design->modules_[trg_name] = fmod->clone(); RTLIL::Module *t = fmod->clone();
copy_to_design->modules_[trg_name]->name = trg_name; t->name = trg_name;
copy_to_design->modules_[trg_name]->design = copy_to_design; t->design = copy_to_design;
copy_to_design->modules_[trg_name]->attributes.erase("\\top"); t->attributes.erase("\\top");
copy_to_design->add(t);
queue.insert(copy_to_design->modules_[trg_name]); queue.insert(t);
done[cell->type] = trg_name; done[cell->type] = trg_name;
} }
@ -294,12 +296,13 @@ struct DesignPass : public Pass {
{ {
std::string trg_name = as_name.empty() ? mod->name.str() : RTLIL::escape_id(as_name); std::string trg_name = as_name.empty() ? mod->name.str() : RTLIL::escape_id(as_name);
if (copy_to_design->modules_.count(trg_name)) if (copy_to_design->module(trg_name) != nullptr)
delete copy_to_design->modules_.at(trg_name); copy_to_design->remove(copy_to_design->module(trg_name));
copy_to_design->modules_[trg_name] = mod->clone(); RTLIL::Module *t = mod->clone();
copy_to_design->modules_[trg_name]->name = trg_name; t->name = trg_name;
copy_to_design->modules_[trg_name]->design = copy_to_design; t->design = copy_to_design;
copy_to_design->add(t);
} }
} }
@ -307,8 +310,8 @@ struct DesignPass : public Pass {
{ {
RTLIL::Design *design_copy = new RTLIL::Design; RTLIL::Design *design_copy = new RTLIL::Design;
for (auto &it : design->modules_) for (auto mod : design->modules())
design_copy->add(it.second->clone()); design_copy->add(mod->clone());
design_copy->selection_stack = design->selection_stack; design_copy->selection_stack = design->selection_stack;
design_copy->selection_vars = design->selection_vars; design_copy->selection_vars = design->selection_vars;
@ -325,9 +328,8 @@ struct DesignPass : public Pass {
if (reset_mode || !load_name.empty() || push_mode || pop_mode) if (reset_mode || !load_name.empty() || push_mode || pop_mode)
{ {
for (auto &it : design->modules_) for (auto mod : design->modules())
delete it.second; design->remove(mod);
design->modules_.clear();
design->selection_stack.clear(); design->selection_stack.clear();
design->selection_vars.clear(); design->selection_vars.clear();
@ -353,8 +355,8 @@ struct DesignPass : public Pass {
{ {
RTLIL::Design *saved_design = pop_mode ? pushed_designs.back() : saved_designs.at(load_name); RTLIL::Design *saved_design = pop_mode ? pushed_designs.back() : saved_designs.at(load_name);
for (auto &it : saved_design->modules_) for (auto mod : saved_design->modules())
design->add(it.second->clone()); design->add(mod->clone());
design->selection_stack = saved_design->selection_stack; design->selection_stack = saved_design->selection_stack;
design->selection_vars = saved_design->selection_vars; design->selection_vars = saved_design->selection_vars;