Support "this" for calling task methods.

This commit is contained in:
Stephen Williams
2013-09-20 20:44:57 -07:00
parent 5084a23417
commit a9a1c50268
5 changed files with 32 additions and 2 deletions
+9
View File
@@ -183,6 +183,15 @@ ostream& operator <<(ostream&o, struct __ScopePathManip marg)
return o; 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 void NetBranch::dump(ostream&o, unsigned ind) const
{ {
static const char*pin_names[2] = { static const char*pin_names[2] = {
+4
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. // There is no signal to search for so this cannot be a method.
if (use_path.empty()) return 0; 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, symbol_search(this, des, scope, use_path,
net, par, eve, ex1, ex2); net, par, eve, ex1, ex2);
+6
View File
@@ -4600,6 +4600,12 @@ inline __ScopePathManip scope_path(const NetScope*scope)
extern ostream& operator << (ostream&o, __ScopePathManip); 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 * If this link has a nexus_ pointer, then it is the last Link in the
* list. next_nlink() returns 0 for the last Link. * list. next_nlink() returns 0 for the last Link.
+7 -2
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 ')' ';' | implicit_class_handle '.' hierarchy_identifier '(' expression_list_with_nuls ')' ';'
{ PCallTask*tmp = new PCallTask(*$3, *$5); { pform_name_t*nam = $1;
yyerror(@1, "sorry: Implicit class handle not supported in front of task names."); while (! $3->empty()) {
nam->push_back($3->front());
$3->pop_front();
}
PCallTask*tmp = new PCallTask(*nam, *$5);
FILE_NAME(tmp, @1); FILE_NAME(tmp, @1);
delete $1;
delete $3; delete $3;
delete $5; delete $5;
$$ = tmp; $$ = tmp;
+6
View File
@@ -104,6 +104,12 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
} }
while (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)) { if (NetNet*net = scope->find_signal(path_tail.name)) {
res->scope = scope; res->scope = scope;
res->net = net; res->net = net;