From 79f772200acec4852562f2e9a2c415128691cecc Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 12 Mar 2000 04:35:22 +0000 Subject: [PATCH] Allow parameter identifiers in parameter expressions. --- PExpr.h | 6 +++++- elab_pexpr.cc | 26 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/PExpr.h b/PExpr.h index 6600bc7bd..32489d205 100644 --- a/PExpr.h +++ b/PExpr.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: PExpr.h,v 1.30 2000/03/08 04:36:53 steve Exp $" +#ident "$Id: PExpr.h,v 1.31 2000/03/12 04:35:22 steve Exp $" #endif # include @@ -148,6 +148,7 @@ class PEIdent : public PExpr { unsigned long decay) const; virtual NetExpr*elaborate_expr(Design*des, NetScope*) const; + virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const; virtual bool is_constant(Module*) const; verinum* eval_const(const Design*des, const string&path) const; @@ -336,6 +337,9 @@ class PECallFunction : public PExpr { /* * $Log: PExpr.h,v $ + * Revision 1.31 2000/03/12 04:35:22 steve + * Allow parameter identifiers in parameter expressions. + * * Revision 1.30 2000/03/08 04:36:53 steve * Redesign the implementation of scopes and parameters. * I now generate the scopes and notice the parameters diff --git a/elab_pexpr.cc b/elab_pexpr.cc index a1f89e19b..3652fd2a2 100644 --- a/elab_pexpr.cc +++ b/elab_pexpr.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: elab_pexpr.cc,v 1.1 2000/03/08 04:36:53 steve Exp $" +#ident "$Id: elab_pexpr.cc,v 1.2 2000/03/12 04:35:22 steve Exp $" #endif # include "PExpr.h" @@ -31,6 +31,27 @@ NetExpr*PExpr::elaborate_pexpr(Design*des, NetScope*sc) const return 0; } +/* + * Parameter expressions may reference other parameters, but only in + * the current scope. Preserve the parameter reference in the + * parameter expression I'm generating, instead of evaluating it now, + * because the referenced parameter may yet be overridden. + */ +NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const +{ + const NetExpr*ex = scope->get_parameter(text_); + if (ex == 0) { + cerr << get_line() << ": error: identifier ``" << text_ << + "'' is not a parameter in " << scope->name() << "." << endl; + des->errors += 1; + return 0; + } + + NetExpr*res = new NetEParam(des, scope, text_); + assert(res); + return res; +} + /* * Simple numbers can be elaborated by the elaborate_expr method. */ @@ -42,6 +63,9 @@ NetExpr*PENumber::elaborate_pexpr(Design*des, NetScope*sc) const /* * $Log: elab_pexpr.cc,v $ + * Revision 1.2 2000/03/12 04:35:22 steve + * Allow parameter identifiers in parameter expressions. + * * Revision 1.1 2000/03/08 04:36:53 steve * Redesign the implementation of scopes and parameters. * I now generate the scopes and notice the parameters