vhdlpp: Added ScopeBase::transfer_from() method.

This commit is contained in:
Maciej Suminski 2014-09-29 11:38:54 +02:00
parent 7b5470c8a7
commit 747e656a0e
2 changed files with 25 additions and 1 deletions

View File

@ -203,6 +203,27 @@ void ScopeBase::do_use_from(const ScopeBase*that)
}
}
void ScopeBase::transfer_from(ScopeBase&ref)
{
std::copy(ref.new_signals_.begin(), ref.new_signals_.end(),
insert_iterator<map<perm_string, Signal*> >(
new_signals_, new_signals_.end())
);
ref.new_signals_.clear();
std::copy(ref.new_variables_.begin(), ref.new_variables_.end(),
insert_iterator<map<perm_string, Variable*> >(
new_variables_, new_variables_.end())
);
ref.new_variables_.clear();
std::copy(ref.new_components_.begin(), ref.new_components_.end(),
insert_iterator<map<perm_string, ComponentBase*> >(
new_components_, new_components_.end())
);
ref.new_components_.clear();
}
void ActiveScope::set_package_header(Package*pkg)
{
assert(package_header_ == 0);

View File

@ -57,6 +57,9 @@ class ScopeBase {
Signal* find_signal(perm_string by_name) const;
Variable* find_variable(perm_string by_name) const;
Subprogram* find_subprogram(perm_string by_name) const;
// Moves all signals, variables and components from another scope to
// this one. After the transfer new_* maps are emptied in the another scope.
void transfer_from(ScopeBase&ref);
protected:
void cleanup();
@ -202,7 +205,7 @@ class ActiveScope : public ScopeBase {
{ map<perm_string, Subprogram*>::iterator it;
if((it = use_subprograms_.find(name)) != use_subprograms_.end() )
use_subprograms_.erase(it);
cur_subprograms_[name] = obj;;
cur_subprograms_[name] = obj;
}
void bind(Entity*ent)