Permalink
Browse files

Parse parameters within nested scopes.

  • Loading branch information...
1 parent 4e7a5d5 commit 02fc59fbdf55476904b784841bd8359efd760255 steve committed Jan 13, 2001
Showing with 144 additions and 79 deletions.
  1. +19 −3 PFunction.cc
  2. +20 −3 PTask.cc
  3. +11 −3 PTask.h
  4. +10 −6 design_dump.cc
  5. +17 −4 elab_expr.cc
  6. +28 −23 elab_sig.cc
  7. +29 −31 parse.y
  8. +10 −6 pform_dump.cc
View
@@ -17,20 +17,33 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: PFunction.cc,v 1.3 2000/02/23 02:56:53 steve Exp $"
+#ident "$Id: PFunction.cc,v 1.4 2001/01/13 22:20:08 steve Exp $"
#endif
#include "PTask.h"
-PFunction::PFunction(svector<PWire*>*p, Statement*s)
-: out_(0), ports_(p), statement_(s)
+PFunction::PFunction()
+: out_(0), ports_(0), statement_(0)
{
}
PFunction::~PFunction()
{
}
+void PFunction::set_ports(svector<PWire *>*p)
+{
+ assert(ports_ == 0);
+ ports_ = p;
+}
+
+void PFunction::set_statement(Statement*s)
+{
+ assert(s != 0);
+ assert(statement_ == 0);
+ statement_ = s;
+}
+
void PFunction::set_output(PWire*o)
{
assert(out_ == 0);
@@ -39,6 +52,9 @@ void PFunction::set_output(PWire*o)
/*
* $Log: PFunction.cc,v $
+ * Revision 1.4 2001/01/13 22:20:08 steve
+ * Parse parameters within nested scopes.
+ *
* Revision 1.3 2000/02/23 02:56:53 steve
* Macintosh compilers do not support ident.
*
View
@@ -17,22 +17,39 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: PTask.cc,v 1.3 2000/02/23 02:56:53 steve Exp $"
+#ident "$Id: PTask.cc,v 1.4 2001/01/13 22:20:08 steve Exp $"
#endif
# include "PTask.h"
-PTask::PTask(svector<PWire*>*p, Statement*s)
-: ports_(p), statement_(s)
+PTask::PTask()
+: ports_(0), statement_(0)
{
}
PTask::~PTask()
{
}
+void PTask::set_ports(svector<PWire*>*p)
+{
+ assert(ports_ == 0);
+ ports_ = p;
+}
+
+void PTask::set_statement(Statement*s)
+{
+ assert(statement_ == 0);
+ assert(s != 0);
+ statement_ = s;
+}
+
+
/*
* $Log: PTask.cc,v $
+ * Revision 1.4 2001/01/13 22:20:08 steve
+ * Parse parameters within nested scopes.
+ *
* Revision 1.3 2000/02/23 02:56:53 steve
* Macintosh compilers do not support ident.
*
View
14 PTask.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: PTask.h,v 1.9 2000/07/30 18:25:43 steve Exp $"
+#ident "$Id: PTask.h,v 1.10 2001/01/13 22:20:08 steve Exp $"
#endif
# include "LineInfo.h"
@@ -36,9 +36,12 @@ class Statement;
class PTask : public LineInfo {
public:
- explicit PTask(svector<PWire*>*p, Statement*s);
+ explicit PTask();
~PTask();
+ void set_ports(svector<PWire *>*p);
+ void set_statement(Statement *s);
+
// Tasks introduce scope, to need to be handled during the
// scope elaboration pass. The scope passed is my scope,
// created by the containing scope. I fill it in with stuff if
@@ -70,9 +73,11 @@ class PTask : public LineInfo {
class PFunction : public LineInfo {
public:
- explicit PFunction(svector<PWire *>*p, Statement *s);
+ explicit PFunction();
~PFunction();
+ void set_ports(svector<PWire *>*p);
+ void set_statement(Statement *s);
void set_output(PWire*);
void elaborate_scope(Design*des, NetScope*scope) const;
@@ -93,6 +98,9 @@ class PFunction : public LineInfo {
/*
* $Log: PTask.h,v $
+ * Revision 1.10 2001/01/13 22:20:08 steve
+ * Parse parameters within nested scopes.
+ *
* Revision 1.9 2000/07/30 18:25:43 steve
* Rearrange task and function elaboration so that the
* NetTaskDef and NetFuncDef functions are created during
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: design_dump.cc,v 1.108 2000/12/16 01:45:47 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.109 2001/01/13 22:20:08 steve Exp $"
#endif
/*
@@ -947,11 +947,12 @@ void NetETernary::dump(ostream&o) const
void NetEUFunc::dump(ostream&o) const
{
o << name() << "(";
- assert(parms_.count() > 0);
- parms_[0]->dump(o);
- for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) {
- o << ", ";
- parms_[idx]->dump(o);
+ if (parms_.count() > 0) {
+ parms_[0]->dump(o);
+ for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) {
+ o << ", ";
+ parms_[idx]->dump(o);
+ }
}
o << ")";
}
@@ -998,6 +999,9 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.109 2001/01/13 22:20:08 steve
+ * Parse parameters within nested scopes.
+ *
* Revision 1.108 2000/12/16 01:45:47 steve
* Detect recursive instantiations (PR#2)
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: elab_expr.cc,v 1.32 2001/01/02 04:21:13 steve Exp $"
+#ident "$Id: elab_expr.cc,v 1.33 2001/01/13 22:20:08 steve Exp $"
#endif
@@ -179,16 +179,26 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope) const
NetScope*dscope = des->find_scope(def->name());
assert(dscope);
- svector<NetExpr*> parms (parms_.count());
+ /* How many parameters have I got? Normally the size of the
+ list is correct, but there is the special case of a list of
+ 1 nil pointer. This is how the parser tells me of no
+ parameter. In other words, ``func()'' is 1 nil parameter. */
+
+ unsigned parms_count = parms_.count();
+ if ((parms_count == 1) && (parms_[0] == 0))
+ parms_count = 0;
+
+ svector<NetExpr*> parms (parms_count);
/* Elaborate the input expressions for the function. This is
done in the scope of the function call, and not the scope
of the function being called. The scope of the called
function is elaborated when the definition is elaborated. */
for (unsigned idx = 0 ; idx < parms.count() ; idx += 1) {
- NetExpr*tmp = parms_[idx]->elaborate_expr(des, scope);
- parms[idx] = tmp;
+ PExpr*tmp = parms_[idx];
+ assert(tmp);
+ parms[idx] = tmp->elaborate_expr(des, scope);
}
@@ -529,6 +539,9 @@ NetEUnary* PEUnary::elaborate_expr(Design*des, NetScope*scope) const
/*
* $Log: elab_expr.cc,v $
+ * Revision 1.33 2001/01/13 22:20:08 steve
+ * Parse parameters within nested scopes.
+ *
* Revision 1.32 2001/01/02 04:21:13 steve
* Support a bunch of unary operators in parameter expressions.
*
View
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
-#ident "$Id: elab_sig.cc,v 1.9 2001/01/07 07:00:31 steve Exp $"
+#ident "$Id: elab_sig.cc,v 1.10 2001/01/13 22:20:08 steve Exp $"
#endif
# include "Module.h"
@@ -182,34 +182,36 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const
return;
}
- for (unsigned idx = 0 ; idx < ports_->count() ; idx += 1) {
+ if (ports_)
+ for (unsigned idx = 0 ; idx < ports_->count() ; idx += 1) {
- /* Parse the port name into the task name and the reg
- name. We know by design that the port name is given
- as two components: <func>.<port>. */
+ /* Parse the port name into the task name and the reg
+ name. We know by design that the port name is given
+ as two components: <func>.<port>. */
- string pname = (*ports_)[idx]->name();
- string ppath = parse_first_name(pname);
+ string pname = (*ports_)[idx]->name();
+ string ppath = parse_first_name(pname);
- if (ppath != scope->basename()) {
- cerr << get_line() << ": internal error: function "
- << "port " << (*ports_)[idx]->name()
- << " has wrong name for function "
- << scope->name() << "." << endl;
- des->errors += 1;
- }
+ if (ppath != scope->basename()) {
+ cerr << get_line() << ": internal error: function "
+ << "port " << (*ports_)[idx]->name()
+ << " has wrong name for function "
+ << scope->name() << "." << endl;
+ des->errors += 1;
+ }
- NetNet*tmp = scope->find_signal(pname);
- if (tmp == 0) {
- cerr << get_line() << ": internal error: function "
- << scope->name() << " is missing port "
- << pname << "." << endl;
- scope->dump(cerr);
- des->errors += 1;
+ NetNet*tmp = scope->find_signal(pname);
+ if (tmp == 0) {
+ cerr << get_line() << ": internal error: function "
+ << scope->name() << " is missing port "
+ << pname << "." << endl;
+ scope->dump(cerr);
+ des->errors += 1;
+ }
+
+ ports[idx+1] = tmp;
}
- ports[idx+1] = tmp;
- }
NetFuncDef*def = new NetFuncDef(scope, ports);
scope->set_func_def(def);
@@ -402,6 +404,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
/*
* $Log: elab_sig.cc,v $
+ * Revision 1.10 2001/01/13 22:20:08 steve
+ * Parse parameters within nested scopes.
+ *
* Revision 1.9 2001/01/07 07:00:31 steve
* Detect port direction attached to non-ports.
*
Oops, something went wrong.

0 comments on commit 02fc59f

Please sign in to comment.