From dd5fb47c6cff3b2200dec9c67be2d89b2aa14a3e Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sun, 24 Feb 2013 10:57:37 -0800 Subject: [PATCH] pform dump class methods. --- PScope.h | 2 ++ pform_dump.cc | 52 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/PScope.h b/PScope.h index fe2d3a711..e554d7d67 100644 --- a/PScope.h +++ b/PScope.h @@ -178,6 +178,8 @@ class PScopeExtra : public PScope { protected: void dump_classes_(ostream&out, unsigned indent) const; + void dump_tasks_(ostream&out, unsigned indent) const; + void dump_funcs_(ostream&out, unsigned indent) const; }; #endif diff --git a/pform_dump.cc b/pform_dump.cc index b87b9c3ea..3c6238292 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -345,7 +345,10 @@ void PEBinary::dump(ostream&out) const return; } - out << "(" << *left_ << ")"; + if (left_) + out << "(" << *left_ << ")"; + else + out << "()"; switch (op_) { case 'a': out << "&&"; @@ -381,7 +384,10 @@ void PEBinary::dump(ostream&out) const out << op_; break; } - out << "(" << *right_ << ")"; + if (right_) + out << "(" << *right_ << ")"; + else + out << "()"; } @@ -1285,10 +1291,36 @@ void PScopeExtra::dump_classes_(ostream&out, unsigned indent) const } } +void PScopeExtra::dump_tasks_(ostream&out, unsigned indent) const +{ + // Dump the task definitions. + typedef map::const_iterator task_iter_t; + for (task_iter_t cur = tasks.begin() + ; cur != tasks.end() ; ++ cur ) { + out << setw(indent) << "" << "task " << (*cur).first << ";" << endl; + (*cur).second->dump(out, indent+2); + out << setw(indent) << "" << "endtask;" << endl; + } +} + +void PScopeExtra::dump_funcs_(ostream&out, unsigned indent) const +{ + // Dump the task definitions. + typedef map::const_iterator task_iter_t; + for (task_iter_t cur = funcs.begin() + ; cur != funcs.end() ; ++ cur ) { + out << setw(indent) << "" << "function " << (*cur).first << ";" << endl; + (*cur).second->dump(out, indent+2); + out << setw(indent) << "" << "endfunction;" << endl; + } +} + void PClass::dump(ostream&out, unsigned indent) const { out << setw(indent) << "" << "class " << type->name << ";" << endl; type->pform_dump(out, indent+2); + dump_tasks_(out, indent+2); + dump_funcs_(out, indent+2); out << setw(indent) << "" << "endclass" << endl; } @@ -1391,22 +1423,10 @@ void Module::dump(ostream&out) const dump_wires_(out, 4); // Dump the task definitions. - typedef map::const_iterator task_iter_t; - for (task_iter_t cur = tasks.begin() - ; cur != tasks.end() ; ++ cur ) { - out << " task " << (*cur).first << ";" << endl; - (*cur).second->dump(out, 6); - out << " endtask;" << endl; - } + dump_tasks_(out, 4); // Dump the function definitions. - typedef map::const_iterator func_iter_t; - for (func_iter_t cur = funcs.begin() - ; cur != funcs.end() ; ++ cur ) { - out << " function " << (*cur).first << ";" << endl; - (*cur).second->dump(out, 6); - out << " endfunction;" << endl; - } + dump_funcs_(out, 4); // Iterate through and display all the gates