Careful not to lose bits parameter add expression
[iverilog.git] / Statement.cc
blobf6f14fa654a2354534f52da580b699e23ca845c3
1 /*
2 * Copyright (c) 1998-1999 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 #ifdef HAVE_CVS_IDENT
20 #ident "$Id: Statement.cc,v 1.30 2007/05/24 04:07:11 steve Exp $"
21 #endif
23 # include "config.h"
25 # include "Statement.h"
26 # include "PExpr.h"
28 Statement::~Statement()
32 PAssign_::PAssign_(PExpr*lval, PExpr*ex)
33 : event_(0), lval_(lval), rval_(ex)
35 delay_ = 0;
38 PAssign_::PAssign_(PExpr*lval, PExpr*de, PExpr*ex)
39 : event_(0), lval_(lval), rval_(ex)
41 delay_ = de;
44 PAssign_::PAssign_(PExpr*lval, PEventStatement*ev, PExpr*ex)
45 : event_(ev), lval_(lval), rval_(ex)
47 delay_ = 0;
50 PAssign_::~PAssign_()
52 delete lval_;
53 delete rval_;
56 PAssign::PAssign(PExpr*lval, PExpr*ex)
57 : PAssign_(lval, ex)
61 PAssign::PAssign(PExpr*lval, PExpr*d, PExpr*ex)
62 : PAssign_(lval, d, ex)
66 PAssign::PAssign(PExpr*lval, PEventStatement*d, PExpr*ex)
67 : PAssign_(lval, d, ex)
71 PAssign::~PAssign()
75 PAssignNB::PAssignNB(PExpr*lval, PExpr*ex)
76 : PAssign_(lval, ex)
80 PAssignNB::PAssignNB(PExpr*lval, PExpr*d, PExpr*ex)
81 : PAssign_(lval, d, ex)
85 PAssignNB::~PAssignNB()
89 PBlock::PBlock(perm_string n, BL_TYPE t, const svector<Statement*>&st)
90 : name_(n), bl_type_(t), list_(st)
94 PBlock::PBlock(BL_TYPE t, const svector<Statement*>&st)
95 : bl_type_(t), list_(st)
99 PBlock::PBlock(BL_TYPE t)
100 : bl_type_(t)
104 PBlock::~PBlock()
106 for (unsigned idx = 0 ; idx < list_.count() ; idx += 1)
107 delete list_[idx];
110 PCallTask::PCallTask(const pform_name_t&n, const svector<PExpr*>&p)
111 : path_(n), parms_(p)
115 PCallTask::PCallTask(perm_string n, const svector<PExpr*>&p)
116 : parms_(p)
118 path_.push_back(name_component_t(n));
121 PCallTask::~PCallTask()
125 const pform_name_t& PCallTask::path() const
127 return path_;
130 PCase::PCase(NetCase::TYPE t, PExpr*ex, svector<PCase::Item*>*l)
131 : type_(t), expr_(ex), items_(l)
135 PCase::~PCase()
137 delete expr_;
138 for (unsigned idx = 0 ; idx < items_->count() ; idx += 1)
139 if ((*items_)[idx]->stat) delete (*items_)[idx]->stat;
141 delete[]items_;
144 PCAssign::PCAssign(PExpr*l, PExpr*r)
145 : lval_(l), expr_(r)
149 PCAssign::~PCAssign()
151 delete lval_;
152 delete expr_;
155 PCondit::PCondit(PExpr*ex, Statement*i, Statement*e)
156 : expr_(ex), if_(i), else_(e)
160 PCondit::~PCondit()
162 delete expr_;
163 delete if_;
164 delete else_;
167 PDeassign::PDeassign(PExpr*l)
168 : lval_(l)
172 PDeassign::~PDeassign()
174 delete lval_;
178 PDelayStatement::PDelayStatement(PExpr*d, Statement*st)
179 : delay_(d), statement_(st)
183 PDelayStatement::~PDelayStatement()
187 PDisable::PDisable(const pform_name_t&sc)
188 : scope_(sc)
192 PDisable::~PDisable()
196 PEventStatement::PEventStatement(const svector<PEEvent*>&ee)
197 : expr_(ee), statement_(0)
199 assert(expr_.count() > 0);
203 PEventStatement::PEventStatement(PEEvent*ee)
204 : expr_(1), statement_(0)
206 expr_[0] = ee;
209 PEventStatement::PEventStatement(void)
210 : statement_(0)
214 PEventStatement::~PEventStatement()
216 // delete the events and the statement?
219 void PEventStatement::set_statement(Statement*st)
221 statement_ = st;
224 PForce::PForce(PExpr*l, PExpr*r)
225 : lval_(l), expr_(r)
229 PForce::~PForce()
231 delete lval_;
232 delete expr_;
235 PForever::PForever(Statement*s)
236 : statement_(s)
240 PForever::~PForever()
242 delete statement_;
245 PForStatement::PForStatement(PExpr*n1, PExpr*e1, PExpr*cond,
246 PExpr*n2, PExpr*e2, Statement*st)
247 : name1_(n1), expr1_(e1), cond_(cond), name2_(n2), expr2_(e2),
248 statement_(st)
252 PForStatement::~PForStatement()
256 PProcess::~PProcess()
258 delete statement_;
261 PRelease::PRelease(PExpr*l)
262 : lval_(l)
266 PRelease::~PRelease()
268 delete lval_;
271 PRepeat::PRepeat(PExpr*e, Statement*s)
272 : expr_(e), statement_(s)
276 PRepeat::~PRepeat()
278 delete expr_;
279 delete statement_;
282 PTrigger::PTrigger(const pform_name_t&e)
283 : event_(e)
287 PTrigger::~PTrigger()
291 PWhile::PWhile(PExpr*e1, Statement*st)
292 : cond_(e1), statement_(st)
296 PWhile::~PWhile()
298 delete cond_;
299 delete statement_;
303 * $Log: Statement.cc,v $
304 * Revision 1.30 2007/05/24 04:07:11 steve
305 * Rework the heirarchical identifier parse syntax and pform
306 * to handle more general combinations of heirarch and bit selects.
308 * Revision 1.29 2004/02/18 17:11:54 steve
309 * Use perm_strings for named langiage items.
311 * Revision 1.28 2002/08/12 01:34:58 steve
312 * conditional ident string using autoconfig.
314 * Revision 1.27 2002/04/21 22:31:02 steve
315 * Redo handling of assignment internal delays.
316 * Leave it possible for them to be calculated
317 * at run time.
319 * Revision 1.26 2002/04/21 04:59:07 steve
320 * Add support for conbinational events by finding
321 * the inputs to expressions and some statements.
322 * Get case and assignment statements working.
324 * Revision 1.25 2001/12/03 04:47:14 steve
325 * Parser and pform use hierarchical names as hname_t
326 * objects instead of encoded strings.
328 * Revision 1.24 2001/11/22 06:20:59 steve
329 * Use NetScope instead of string for scope path.
331 * Revision 1.23 2001/07/25 03:10:48 steve
332 * Create a config.h.in file to hold all the config
333 * junk, and support gcc 3.0. (Stephan Boettcher)