From a9a1c5026865a7badbca8e3dec6a26b9911afb2a Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Mon, 16 Sep 2013 20:59:36 -0700 Subject: [PATCH] Support "this" for calling task methods. --- design_dump.cc | 9 +++++++++ elaborate.cc | 4 ++++ netlist.h | 6 ++++++ parse.y | 9 +++++++-- symbol_search.cc | 6 ++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/design_dump.cc b/design_dump.cc index fb88272cd..7bf168973 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -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] = { diff --git a/elaborate.cc b/elaborate.cc index 169952d84..9c67f5be0 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -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); diff --git a/netlist.h b/netlist.h index d2cbc15d0..2670c19b8 100644 --- a/netlist.h +++ b/netlist.h @@ -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. diff --git a/parse.y b/parse.y index 94f88ddc4..cb773627c 100644 --- a/parse.y +++ b/parse.y @@ -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; diff --git a/symbol_search.cc b/symbol_search.cc index 1b26bb22a..5bf69af84 100644 --- a/symbol_search.cc +++ b/symbol_search.cc @@ -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;