From 056a3f72200c9b9033497ce866ecea0bbb56debd Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 30 Jun 2000 15:50:20 +0000 Subject: [PATCH] Allow unary operators in constant expressions. --- PExpr.cc | 19 ++++++++++++++++++- PExpr.h | 11 ++++++++--- parse.y | 7 ++++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/PExpr.cc b/PExpr.cc index 8d932ad53..e0a235399 100644 --- a/PExpr.cc +++ b/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: PExpr.cc,v 1.18 2000/05/07 04:37:55 steve Exp $" +#ident "$Id: PExpr.cc,v 1.19 2000/06/30 15:50:20 steve Exp $" #endif # include "PExpr.h" @@ -212,8 +212,25 @@ bool PETernary::is_constant(Module*) const return false; } +PEUnary::PEUnary(char op, PExpr*ex) +: op_(op), expr_(ex) +{ +} + +PEUnary::~PEUnary() +{ +} + +bool PEUnary::is_constant(Module*m) const +{ + return expr_->is_constant(m); +} + /* * $Log: PExpr.cc,v $ + * Revision 1.19 2000/06/30 15:50:20 steve + * Allow unary operators in constant expressions. + * * Revision 1.18 2000/05/07 04:37:55 steve * Carry strength values from Verilog source to the * pform and netlist for gates. diff --git a/PExpr.h b/PExpr.h index 1dded8802..78b02e955 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.40 2000/06/13 05:22:16 steve Exp $" +#ident "$Id: PExpr.h,v 1.41 2000/06/30 15:50:20 steve Exp $" #endif # include @@ -247,8 +247,8 @@ class PEString : public PExpr { class PEUnary : public PExpr { public: - explicit PEUnary(char op, PExpr*ex) - : op_(op), expr_(ex) { } + explicit PEUnary(char op, PExpr*ex); + ~PEUnary(); virtual void dump(ostream&out) const; virtual NetNet* elaborate_net(Design*des, const string&path, @@ -261,6 +261,8 @@ class PEUnary : public PExpr { virtual NetEUnary*elaborate_expr(Design*des, NetScope*) const; virtual NetExpr*elaborate_pexpr(Design*des, NetScope*sc) const; + virtual bool is_constant(Module*) const; + private: char op_; PExpr*expr_; @@ -381,6 +383,9 @@ class PECallFunction : public PExpr { /* * $Log: PExpr.h,v $ + * Revision 1.41 2000/06/30 15:50:20 steve + * Allow unary operators in constant expressions. + * * Revision 1.40 2000/06/13 05:22:16 steve * Support concatenation in parameter expressions. * diff --git a/parse.y b/parse.y index 991818cbb..393e479e5 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: parse.y,v 1.100 2000/06/27 16:00:40 steve Exp $" +#ident "$Id: parse.y,v 1.101 2000/06/30 15:50:20 steve Exp $" #endif # include "parse_misc.h" @@ -1369,11 +1369,12 @@ parameter_assign { PExpr*tmp = $3; if (!pform_expression_is_constant(tmp)) { yyerror(@3, "error: parameter value " - "must be constant."); + "must be a constant expression."); delete tmp; tmp = 0; + } else { + pform_set_parameter($1, tmp); } - pform_set_parameter($1, tmp); delete $1; } ;