Merge branch 'master' into verilog-ams
[sverilog.git] / dup_expr.cc
blob7a8ec8a7675f320c981c4c5644c8061903384cd5
1 /*
2 * Copyright (c) 1999-2008 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
20 # include "config.h"
22 # include "netlist.h"
23 # include <cassert>
25 NetEBComp* NetEBComp::dup_expr() const
27 NetEBComp*tmp = new NetEBComp(op_, left_->dup_expr(),
28 right_->dup_expr());
29 assert(tmp);
30 tmp->set_line(*this);
31 return tmp;
34 NetEConst* NetEConst::dup_expr() const
36 NetEConst*tmp = new NetEConst(value_);
37 assert(tmp);
38 tmp->set_line(*this);
39 return tmp;
42 NetEConstParam* NetEConstParam::dup_expr() const
44 NetEConstParam*tmp = new NetEConstParam(scope_, name_, value());
45 assert(tmp);
46 tmp->set_line(*this);
47 return tmp;
50 NetECRealParam* NetECRealParam::dup_expr() const
52 NetECRealParam*tmp = new NetECRealParam(scope_, name_, value());
53 assert(tmp);
54 tmp->set_line(*this);
55 return tmp;
58 NetEEvent* NetEEvent::dup_expr() const
60 assert(0);
61 return 0;
64 NetEScope* NetEScope::dup_expr() const
66 assert(0);
67 return 0;
70 NetESelect* NetESelect::dup_expr() const
72 NetESelect*tmp = new NetESelect(expr_->dup_expr(),
73 base_? base_->dup_expr() : 0,
74 expr_width());
75 assert(tmp);
76 tmp->set_line(*this);
77 return tmp;
80 NetESFunc* NetESFunc::dup_expr() const
82 NetESFunc*tmp = new NetESFunc(name_, type_, expr_width(), nparms());
83 assert(tmp);
85 tmp->cast_signed(has_sign());
86 for (unsigned idx = 0 ; idx < nparms() ; idx += 1) {
87 assert(tmp->parm(idx));
88 tmp->parm(idx, tmp->parm(idx)->dup_expr());
91 tmp->set_line(*this);
92 return tmp;
95 NetESignal* NetESignal::dup_expr() const
97 NetESignal*tmp = new NetESignal(net_, word_);
98 assert(tmp);
99 tmp->expr_width(expr_width());
100 tmp->set_line(*this);
101 return tmp;
104 NetETernary* NetETernary::dup_expr() const
106 NetETernary*tmp = new NetETernary(cond_->dup_expr(),
107 true_val_->dup_expr(),
108 false_val_->dup_expr());
109 assert(tmp);
110 tmp->set_line(*this);
111 return tmp;
114 NetEUFunc* NetEUFunc::dup_expr() const
116 NetEUFunc*tmp;
117 svector<NetExpr*> tmp_parms (parms_.count());
119 for (unsigned idx = 0 ; idx < tmp_parms.count() ; idx += 1) {
120 assert(parms_[idx]);
121 tmp_parms[idx] = parms_[idx]->dup_expr();
124 tmp = new NetEUFunc(scope_, func_, result_sig_->dup_expr(), tmp_parms);
126 assert(tmp);
127 tmp->set_line(*this);
128 return tmp;
131 NetEUnary* NetEUnary::dup_expr() const
133 NetEUnary*tmp = new NetEUnary(op_, expr_->dup_expr());
134 assert(tmp);
135 tmp->set_line(*this);
136 return tmp;
139 NetEUReduce* NetEUReduce::dup_expr() const
141 NetEUReduce*tmp = new NetEUReduce(op_, expr_->dup_expr());
142 assert(tmp);
143 tmp->set_line(*this);
144 return tmp;