Support "this" for calling task methods.

This commit is contained in:
Stephen Williams 2013-09-16 20:59:36 -07:00
parent 5084a23417
commit a9a1c50268
5 changed files with 32 additions and 2 deletions

View File

@ -183,6 +183,15 @@ ostream& operator <<(ostream&o, struct __ScopePathManip marg)
return o;
}
ostream& operator <<(ostream&o, struct __ObjectPathManip marg)
{
if (marg.obj != 0) {
dump_scope_path(o, marg.obj->scope());
o << "." << marg.obj->name();
}
return o;
}
void NetBranch::dump(ostream&o, unsigned ind) const
{
static const char*pin_names[2] = {

View File

@ -3309,6 +3309,10 @@ NetProc* PCallTask::elaborate_method_(Design*des, NetScope*scope) const
// There is no signal to search for so this cannot be a method.
if (use_path.empty()) return 0;
// Search for an object using the use_path. This should
// resolve to a class object. Note that the "this" symbol
// (internally represented as "@") is handled by there being a
// "this" object in the instance scope.
symbol_search(this, des, scope, use_path,
net, par, eve, ex1, ex2);

View File

@ -4600,6 +4600,12 @@ inline __ScopePathManip scope_path(const NetScope*scope)
extern ostream& operator << (ostream&o, __ScopePathManip);
struct __ObjectPathManip { const NetObj*obj; };
inline __ObjectPathManip scope_path(const NetObj*obj)
{ __ObjectPathManip tmp; tmp.obj = obj; return tmp; }
extern ostream& operator << (ostream&o, __ObjectPathManip);
/*
* If this link has a nexus_ pointer, then it is the last Link in the
* list. next_nlink() returns 0 for the last Link.

View File

@ -5816,9 +5816,14 @@ statement_item /* This is roughly statement_item in the LRM */
}
| implicit_class_handle '.' hierarchy_identifier '(' expression_list_with_nuls ')' ';'
{ PCallTask*tmp = new PCallTask(*$3, *$5);
yyerror(@1, "sorry: Implicit class handle not supported in front of task names.");
{ pform_name_t*nam = $1;
while (! $3->empty()) {
nam->push_back($3->front());
$3->pop_front();
}
PCallTask*tmp = new PCallTask(*nam, *$5);
FILE_NAME(tmp, @1);
delete $1;
delete $3;
delete $5;
$$ = tmp;

View File

@ -104,6 +104,12 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
}
while (scope) {
if (path_tail.name == "#") {
cerr << li->get_fileline() << ": sorry: "
<< "Implicit class handle \"super\" not supported." << endl;
return false;
}
if (NetNet*net = scope->find_signal(path_tail.name)) {
res->scope = scope;
res->net = net;