vhdlpp: Subprograms are linked to Package instead of generic Scope.
This commit is contained in:
parent
78d6ee26dd
commit
94f7504372
|
|
@ -53,6 +53,7 @@ int Package::elaborate()
|
|||
|
||||
for(SubHeaderList::iterator it = subp_list.begin();
|
||||
it != subp_list.end(); ++it) {
|
||||
(*it)->set_package(this);
|
||||
errors += (*it)->elaborate();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -317,11 +317,8 @@ SubprogramHeader*ScopeBase::match_subprogram(perm_string name,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void ActiveScope::set_package_header(Package*pkg)
|
||||
void ScopeBase::generate_name()
|
||||
{
|
||||
assert(package_header_ == 0);
|
||||
package_header_ = pkg;
|
||||
char buf[64];
|
||||
|
||||
// Generate a name for the scope
|
||||
|
|
|
|||
|
|
@ -101,6 +101,11 @@ class ScopeBase {
|
|||
|
||||
perm_string peek_name() const { return name_; }
|
||||
|
||||
void set_package_header(Package*pkg) {
|
||||
assert(package_header_ == 0);
|
||||
package_header_ = pkg;
|
||||
}
|
||||
|
||||
protected:
|
||||
void cleanup();
|
||||
|
||||
|
|
@ -158,6 +163,10 @@ class ScopeBase {
|
|||
|
||||
void do_use_from(const ScopeBase*that);
|
||||
|
||||
// If this is a package body, then there is a Package header
|
||||
// already declared.
|
||||
Package*package_header_;
|
||||
|
||||
// Generates an unique name for the scope
|
||||
void generate_name();
|
||||
|
||||
|
|
@ -193,8 +202,6 @@ class ActiveScope : public ScopeBase {
|
|||
|
||||
~ActiveScope() { }
|
||||
|
||||
void set_package_header(Package*);
|
||||
|
||||
// Pull items from "that" scope into "this" scope as is
|
||||
// defined by a "use" directive. The parser uses this method
|
||||
// to implement the "use <pkg>::*" directive.
|
||||
|
|
@ -276,10 +283,6 @@ class ActiveScope : public ScopeBase {
|
|||
std::map<perm_string,VTypeDef*> incomplete_types;
|
||||
|
||||
private:
|
||||
// If this is a package body, then there is a Package header
|
||||
// already declared.
|
||||
Package*package_header_;
|
||||
|
||||
Entity*context_entity_;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ void SubprogramBody::write_to_stream(ostream&fd) const
|
|||
|
||||
SubprogramHeader::SubprogramHeader(perm_string nam, list<InterfacePort*>*ports,
|
||||
const VType*return_type)
|
||||
: name_(nam), ports_(ports), return_type_(return_type), body_(NULL), parent_(NULL)
|
||||
: name_(nam), ports_(ports), return_type_(return_type), body_(NULL), package_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -172,12 +172,6 @@ const VType*SubprogramHeader::peek_param_type(int idx) const
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void SubprogramHeader::set_parent(const ScopeBase*par)
|
||||
{
|
||||
ivl_assert(*this, !parent_);
|
||||
parent_ = par;
|
||||
}
|
||||
|
||||
bool SubprogramHeader::unbounded() const {
|
||||
if(return_type_ && return_type_->is_unbounded())
|
||||
return true;
|
||||
|
|
@ -263,7 +257,7 @@ SubprogramHeader*SubprogramHeader::make_instance(std::vector<Expression*> argume
|
|||
}
|
||||
|
||||
body_inst->set_statements(body_->statements_);
|
||||
instance->set_parent(scope);
|
||||
instance->set_package(package_);
|
||||
instance->set_body(body_inst);
|
||||
instance->fix_return_type();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
class InterfacePort;
|
||||
class SequentialStmt;
|
||||
class Package;
|
||||
class VType;
|
||||
|
||||
class SubprogramBody : public LineInfo, public ScopeBase {
|
||||
|
|
@ -78,8 +79,8 @@ class SubprogramHeader : public LineInfo {
|
|||
const VType*peek_param_type(int idx) const;
|
||||
const VType*peek_return_type() const { return return_type_; }
|
||||
|
||||
void set_parent(const ScopeBase*par);
|
||||
inline const ScopeBase*get_parent() const { return parent_; }
|
||||
inline void set_package(const Package*pkg) { assert(!package_); package_ = pkg; }
|
||||
inline const Package*get_package() const { return package_; }
|
||||
|
||||
// Checks if either return type or parameters are unbounded vectors.
|
||||
bool unbounded() const;
|
||||
|
|
@ -138,7 +139,7 @@ class SubprogramHeader : public LineInfo {
|
|||
std::list<InterfacePort*>*ports_;
|
||||
const VType*return_type_;
|
||||
SubprogramBody*body_;
|
||||
const ScopeBase*parent_;
|
||||
const Package*package_;
|
||||
};
|
||||
|
||||
// Class to define functions headers defined in the standard VHDL libraries.
|
||||
|
|
|
|||
|
|
@ -107,10 +107,9 @@ int SubprogramHeader::emit_full_name(const std::vector<Expression*>&argv,
|
|||
// the SV elaborator finds the correct VHDL elaborated
|
||||
// definition. It should not be emitted only if we call another
|
||||
// function from the same package.
|
||||
const Package*pkg = dynamic_cast<const Package*>(parent_);
|
||||
const SubprogramBody*subp = dynamic_cast<const SubprogramBody*>(scope);
|
||||
if (pkg != 0 && (!subp || !subp->header() || subp->header()->get_parent() != pkg))
|
||||
out << "\\" << pkg->name() << " ::";
|
||||
if (package_ && (!subp || !subp->header() || subp->header()->get_package() != package_))
|
||||
out << "\\" << package_->name() << " ::";
|
||||
|
||||
return emit_name(argv, out, ent, scope);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue