Cope with errors during ternary operator elaboration.

This commit is contained in:
steve 1999-09-30 00:48:49 +00:00
parent 076cecb6cd
commit 6e486e9bcf
3 changed files with 53 additions and 17 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: elab_expr.cc,v 1.4 1999/09/29 22:57:10 steve Exp $" #ident "$Id: elab_expr.cc,v 1.5 1999/09/30 00:48:49 steve Exp $"
#endif #endif
@ -282,8 +282,43 @@ NetExpr* PEIdent::elaborate_expr(Design*des, const string&path) const
return 0; return 0;
} }
/*
* Elaborate the Ternary operator. I know that the expressions were
* parsed so I can presume that they exist, and call elaboration
* methods. If any elaboration fails, then give up and return 0.
*/
NetExpr*PETernary::elaborate_expr(Design*des, const string&path) const
{
assert(expr_);
assert(tru_);
assert(fal_);
NetExpr*con = expr_->elaborate_expr(des, path);
if (con == 0)
return 0;
NetExpr*tru = tru_->elaborate_expr(des, path);
if (tru == 0) {
delete con;
return 0;
}
NetExpr*fal = fal_->elaborate_expr(des, path);
if (fal == 0) {
delete con;
delete tru;
return 0;
}
NetETernary*res = new NetETernary(con, tru, fal);
return res;
}
/* /*
* $Log: elab_expr.cc,v $ * $Log: elab_expr.cc,v $
* Revision 1.5 1999/09/30 00:48:49 steve
* Cope with errors during ternary operator elaboration.
*
* Revision 1.4 1999/09/29 22:57:10 steve * Revision 1.4 1999/09/29 22:57:10 steve
* Move code to elab_expr.cc * Move code to elab_expr.cc
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: elaborate.cc,v 1.103 1999/09/29 22:57:10 steve Exp $" #ident "$Id: elaborate.cc,v 1.104 1999/09/30 00:48:50 steve Exp $"
#endif #endif
/* /*
@ -1157,16 +1157,6 @@ NetNet* PETernary::elaborate_net(Design*des, const string&path,
return sig; return sig;
} }
NetExpr*PETernary::elaborate_expr(Design*des, const string&path) const
{
NetExpr*con = expr_->elaborate_expr(des, path);
NetExpr*tru = tru_->elaborate_expr(des, path);
NetExpr*fal = fal_->elaborate_expr(des, path);
NetETernary*res = new NetETernary(con, tru, fal);
return res;
}
NetNet* PEUnary::elaborate_net(Design*des, const string&path, NetNet* PEUnary::elaborate_net(Design*des, const string&path,
unsigned long rise, unsigned long rise,
unsigned long fall, unsigned long fall,
@ -1401,8 +1391,9 @@ NetNet* PAssign_::elaborate_lval(Design*des, const string&path,
NetNet*reg = des->find_signal(path, id->name()); NetNet*reg = des->find_signal(path, id->name());
if (reg == 0) { if (reg == 0) {
cerr << get_line() << ": Could not match signal ``" << cerr << get_line() << ": error: Could not match signal ``" <<
id->name() << "'' in ``" << path << "''" << endl; id->name() << "'' in ``" << path << "''" << endl;
des->errors += 1;
return 0; return 0;
} }
assert(reg); assert(reg);
@ -1416,8 +1407,9 @@ NetNet* PAssign_::elaborate_lval(Design*des, const string&path,
if (id->msb_ && id->lsb_) { if (id->msb_ && id->lsb_) {
verinum*vl = id->lsb_->eval_const(des, path); verinum*vl = id->lsb_->eval_const(des, path);
if (vl == 0) { if (vl == 0) {
cerr << id->lsb_->get_line() << ": Expression must be" cerr << id->lsb_->get_line() << ": error: "
" constant in this context: " << *id->lsb_; "Expression must be constant in this context: "
<< *id->lsb_;
des->errors += 1; des->errors += 1;
return 0; return 0;
} }
@ -2508,6 +2500,9 @@ Design* elaborate(const map<string,Module*>&modules,
/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.104 1999/09/30 00:48:50 steve
* Cope with errors during ternary operator elaboration.
*
* Revision 1.103 1999/09/29 22:57:10 steve * Revision 1.103 1999/09/29 22:57:10 steve
* Move code to elab_expr.cc * Move code to elab_expr.cc
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: pform_dump.cc,v 1.42 1999/09/29 21:15:58 steve Exp $" #ident "$Id: pform_dump.cc,v 1.43 1999/09/30 00:48:50 steve Exp $"
#endif #endif
/* /*
@ -474,7 +474,10 @@ void PFunction::dump(ostream&out, unsigned ind) const
out << (*ports_)[idx]->name() << ";" << endl; out << (*ports_)[idx]->name() << ";" << endl;
} }
statement_->dump(out, ind); if (statement_)
statement_->dump(out, ind);
else
out << setw(ind) << "" << "/* NOOP */" << endl;
} }
void PRepeat::dump(ostream&out, unsigned ind) const void PRepeat::dump(ostream&out, unsigned ind) const
@ -663,6 +666,9 @@ void PUdp::dump(ostream&out) const
/* /*
* $Log: pform_dump.cc,v $ * $Log: pform_dump.cc,v $
* Revision 1.43 1999/09/30 00:48:50 steve
* Cope with errors during ternary operator elaboration.
*
* Revision 1.42 1999/09/29 21:15:58 steve * Revision 1.42 1999/09/29 21:15:58 steve
* Handle some mor missing names. * Handle some mor missing names.
* *