vhdlpp: Support for implicit initalizers and finalizers.
This commit is contained in:
parent
e4ba4b5acd
commit
83f01a5fc4
|
|
@ -59,6 +59,14 @@ int Architecture::elaborate(Entity*entity)
|
|||
cur->second->elaborate_init_expr(entity, this);
|
||||
}
|
||||
|
||||
// Create 'initial' and 'final' blocks for implicit
|
||||
// initalization and clean-up actions
|
||||
if(!initializers_.empty())
|
||||
statements_.push_front(new InitialStatement(&initializers_));
|
||||
|
||||
if(!finalizers_.empty())
|
||||
statements_.push_front(new FinalStatement(&finalizers_));
|
||||
|
||||
for (list<Architecture::Statement*>::iterator cur = statements_.begin()
|
||||
; cur != statements_.end() ; ++cur) {
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ ScopeBase::ScopeBase(const ActiveScope&ref)
|
|||
|
||||
use_enums_ = ref.use_enums_;
|
||||
|
||||
initializers_ = ref.initializers_;
|
||||
finalizers_ = ref.finalizers_;
|
||||
|
||||
// This constructor is invoked when the parser is finished with
|
||||
// an active scope and is making the actual scope. At this point
|
||||
// we know that "this" is the parent scope for the subprograms,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class ComponentBase;
|
|||
class Package;
|
||||
class SubprogramHeader;
|
||||
class VType;
|
||||
class SequentialStmt;
|
||||
|
||||
template<typename T>
|
||||
struct delete_object{
|
||||
|
|
@ -75,6 +76,20 @@ class ScopeBase {
|
|||
cur_subprograms_[name] = obj;
|
||||
}
|
||||
|
||||
// Adds a statement to implicit initializers list
|
||||
// (emitted in a 'initial block).
|
||||
void add_initializer(SequentialStmt* s)
|
||||
{
|
||||
initializers_.push_back(s);
|
||||
}
|
||||
|
||||
// Adds a statement to implicit finalizers list
|
||||
// (emitted in a 'final' block).
|
||||
void add_finalizer(SequentialStmt* s)
|
||||
{
|
||||
finalizers_.push_back(s);
|
||||
}
|
||||
|
||||
protected:
|
||||
void cleanup();
|
||||
|
||||
|
|
@ -122,6 +137,12 @@ class ScopeBase {
|
|||
|
||||
std::list<const VTypeEnum*> use_enums_;
|
||||
|
||||
// List of statements that should be emitted in a 'initial' block
|
||||
std::list<SequentialStmt*> initializers_;
|
||||
|
||||
// List of statements that should be emitted in a 'final' block
|
||||
std::list<SequentialStmt*> finalizers_;
|
||||
|
||||
void do_use_from(const ScopeBase*that);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue