Permalink
Browse files

Remove some uses of the svector template.

I'm adding more uses of the make_range_from_width function, so
it seems like time to get rid of its use of the svector template.
This thread led to a lot of other uses of svector that had to
also be removed.
  • Loading branch information...
1 parent eb4ed82 commit cced1e771b9ad7847eea071b6dd8694e0d3da89d @steveicarus committed Oct 26, 2010
Showing with 478 additions and 475 deletions.
  1. +6 −4 PDelays.cc
  2. +2 −1 PDelays.h
  3. +24 −8 PExpr.cc
  4. +4 −4 PExpr.h
  5. +32 −19 PGate.cc
  6. +20 −16 PGate.h
  7. +2 −1 PTask.h
  8. +16 −4 Statement.cc
  9. +8 −7 Statement.h
  10. +3 −3 elab_expr.cc
  11. +1 −1 elab_lval.cc
  12. +1 −1 elab_net.cc
  13. +2 −2 elab_pexpr.cc
  14. +5 −5 elab_scope.cc
  15. +5 −4 elab_sig.cc
  16. +14 −12 elaborate.cc
  17. +1 −1 eval.cc
  18. +227 −290 parse.y
  19. +70 −62 pform.cc
  20. +17 −17 pform.h
  21. +16 −13 pform_dump.cc
  22. +2 −0 util.h
View
@@ -55,12 +55,14 @@ void PDelays::set_delay(PExpr*del)
}
-void PDelays::set_delays(const svector<PExpr*>*del, bool df)
+void PDelays::set_delays(const list<PExpr*>*del, bool df)
{
assert(del);
- assert(del->count() <= 3);
- for (unsigned idx = 0 ; idx < del->count() ; idx += 1)
- delay_[idx] = (*del)[idx];
+ assert(del->size() <= 3);
+
+ list<PExpr*>::const_iterator cur = del->begin();
+ for (unsigned idx = 0 ; cur != del->end() ; idx += 1, ++cur)
+ delay_[idx] = *cur;
delete_flag_ = df;
}
View
@@ -21,6 +21,7 @@
# include "svector.h"
# include <string>
+# include <list>
# include <iostream>
#ifdef __GNUC__
@@ -48,7 +49,7 @@ class PDelays {
this object takes ownership of the expressions, and will
delete it in the destructor. */
void set_delay(PExpr*);
- void set_delays(const svector<PExpr*>*del, bool delete_flag=true);
+ void set_delays(const list<PExpr*>*del, bool delete_flag=true);
unsigned delay_count() const;
View
@@ -26,6 +26,7 @@
# include "PWire.h"
# include "Module.h"
# include "netmisc.h"
+# include "util.h"
# include <typeinfo>
PExpr::PExpr()
@@ -161,14 +162,24 @@ PECallFunction::PECallFunction(perm_string n)
}
// NOTE: Anachronism. Try to work all use of svector out.
-PECallFunction::PECallFunction(const pform_name_t&n, const svector<PExpr *> &parms)
-: path_(n), parms_(vector_from_svector(parms))
+PECallFunction::PECallFunction(const pform_name_t&n, const list<PExpr *> &parms)
+: path_(n), parms_(parms.size())
{
+ int tmp_idx = 0;
+ assert(parms_.size() == parms.size());
+ for (list<PExpr*>::const_iterator idx = parms.begin()
+ ; idx != parms.end() ; ++idx)
+ parms_[tmp_idx++] = *idx;
}
-PECallFunction::PECallFunction(perm_string n, const svector<PExpr*>&parms)
-: path_(pn_from_ps(n)), parms_(vector_from_svector(parms))
+PECallFunction::PECallFunction(perm_string n, const list<PExpr*>&parms)
+: path_(pn_from_ps(n)), parms_(parms.size())
{
+ int tmp_idx = 0;
+ assert(parms_.size() == parms.size());
+ for (list<PExpr*>::const_iterator idx = parms.begin()
+ ; idx != parms.end() ; ++idx)
+ parms_[tmp_idx++] = *idx;
}
PECallFunction::~PECallFunction()
@@ -191,9 +202,14 @@ bool PECallFunction::has_aa_term(Design*des, NetScope*scope) const
return flag;
}
-PEConcat::PEConcat(const svector<PExpr*>&p, PExpr*r)
-: parms_(p), tested_widths_(p.count()), repeat_(r)
+PEConcat::PEConcat(const list<PExpr*>&p, PExpr*r)
+: parms_(p.size()), tested_widths_(p.size()), repeat_(r)
{
+ int tmp_idx = 0;
+ assert(parms_.size() == p.size());
+ for (list<PExpr*>::const_iterator idx = p.begin()
+ ; idx != p.end() ; ++idx)
+ parms_[tmp_idx++] = *idx;
}
PEConcat::~PEConcat()
@@ -203,15 +219,15 @@ PEConcat::~PEConcat()
void PEConcat::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
{
- for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) {
+ for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
parms_[idx]->declare_implicit_nets(scope, type);
}
}
bool PEConcat::has_aa_term(Design*des, NetScope*scope) const
{
bool flag = false;
- for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) {
+ for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
flag = parms_[idx]->has_aa_term(des, scope) || flag;
}
if (repeat_)
View
@@ -160,7 +160,7 @@ ostream& operator << (ostream&, const PExpr&);
class PEConcat : public PExpr {
public:
- PEConcat(const svector<PExpr*>&p, PExpr*r =0);
+ PEConcat(const list<PExpr*>&p, PExpr*r =0);
~PEConcat();
virtual verinum* eval_const(Design*des, NetScope*sc) const;
@@ -187,7 +187,7 @@ class PEConcat : public PExpr {
NetNet* elaborate_lnet_common_(Design*des, NetScope*scope,
bool bidirectional_flag) const;
private:
- svector<PExpr*>parms_;
+ vector<PExpr*>parms_;
std::valarray<unsigned>tested_widths_;
PExpr*repeat_;
@@ -661,8 +661,8 @@ class PECallFunction : public PExpr {
explicit PECallFunction(perm_string n);
// svector versions. Should be removed!
- explicit PECallFunction(const pform_name_t&n, const svector<PExpr *> &parms);
- explicit PECallFunction(perm_string n, const svector<PExpr *> &parms);
+ explicit PECallFunction(const pform_name_t&n, const list<PExpr *> &parms);
+ explicit PECallFunction(perm_string n, const list<PExpr *> &parms);
~PECallFunction();
View
@@ -24,29 +24,42 @@
# include "verinum.h"
# include <cassert>
-PGate::PGate(perm_string name,
- svector<PExpr*>*pins,
- const svector<PExpr*>*del)
-: name_(name), pins_(pins)
+void PGate::set_pins_(list<PExpr*>*pins)
{
+ assert(pins);
+ assert(pins->size() == pins_.size());
+
+ for (size_t idx = 0 ; idx < pins_.size() ; idx += 1) {
+ pins_[idx] = pins->front();
+ pins->pop_front();
+ }
+
+ assert(pins->empty());
+ delete pins;
+}
+
+PGate::PGate(perm_string name, list<PExpr*>*pins, const list<PExpr*>*del)
+: name_(name), pins_(pins? pins->size() : 0)
+{
+ if (pins) set_pins_(pins);
if (del) delay_.set_delays(del);
str0_ = IVL_DR_STRONG;
str1_ = IVL_DR_STRONG;
}
-PGate::PGate(perm_string name,
- svector<PExpr*>*pins,
- PExpr*del)
-: name_(name), pins_(pins)
+PGate::PGate(perm_string name, list<PExpr*>*pins, PExpr*del)
+: name_(name), pins_(pins? pins->size() : 0)
{
+ if (pins) set_pins_(pins);
if (del) delay_.set_delay(del);
str0_ = IVL_DR_STRONG;
str1_ = IVL_DR_STRONG;
}
-PGate::PGate(perm_string name, svector<PExpr*>*pins)
-: name_(name), pins_(pins)
+PGate::PGate(perm_string name, list<PExpr*>*pins)
+: name_(name), pins_(pins? pins->size() : 0)
{
+ if (pins) set_pins_(pins);
str0_ = IVL_DR_STRONG;
str1_ = IVL_DR_STRONG;
}
@@ -104,31 +117,31 @@ unsigned PGate::delay_count() const
return delay_.delay_count();
}
-PGAssign::PGAssign(svector<PExpr*>*pins)
+PGAssign::PGAssign(list<PExpr*>*pins)
: PGate(perm_string(), pins)
{
- assert(pins->count() == 2);
+ assert(pin_count() == 2);
}
-PGAssign::PGAssign(svector<PExpr*>*pins, svector<PExpr*>*dels)
+PGAssign::PGAssign(list<PExpr*>*pins, list<PExpr*>*dels)
: PGate(perm_string(), pins, dels)
{
- assert(pins->count() == 2);
+ assert(pin_count() == 2);
}
PGAssign::~PGAssign()
{
}
PGBuiltin::PGBuiltin(Type t, perm_string name,
- svector<PExpr*>*pins,
- svector<PExpr*>*del)
+ list<PExpr*>*pins,
+ list<PExpr*>*del)
: PGate(name, pins, del), type_(t), msb_(0), lsb_(0)
{
}
PGBuiltin::PGBuiltin(Type t, perm_string name,
- svector<PExpr*>*pins,
+ list<PExpr*>*pins,
PExpr*del)
: PGate(name, pins, del), type_(t), msb_(0), lsb_(0)
{
@@ -246,7 +259,7 @@ const char* PGBuiltin::gate_name() const
return "<unknown>";
}
-PGModule::PGModule(perm_string type, perm_string name, svector<PExpr*>*pins)
+PGModule::PGModule(perm_string type, perm_string name, list<PExpr*>*pins)
: PGate(name, pins), overrides_(0), pins_(0),
npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0)
{
@@ -265,7 +278,7 @@ PGModule::~PGModule()
{
}
-void PGModule::set_parameters(svector<PExpr*>*o)
+void PGModule::set_parameters(list<PExpr*>*o)
{
assert(overrides_ == 0);
overrides_ = o;
View
@@ -26,6 +26,8 @@
# include "PDelays.h"
# include "netlist.h"
# include <map>
+# include <list>
+# include <vector>
# include <string>
class PExpr;
class PUdp;
@@ -48,13 +50,13 @@ class Module;
class PGate : public LineInfo {
public:
- explicit PGate(perm_string name, svector<PExpr*>*pins,
- const svector<PExpr*>*del);
+ explicit PGate(perm_string name, list<PExpr*>*pins,
+ const list<PExpr*>*del);
- explicit PGate(perm_string name, svector<PExpr*>*pins,
+ explicit PGate(perm_string name, list<PExpr*>*pins,
PExpr*del);
- explicit PGate(perm_string name, svector<PExpr*>*pins);
+ explicit PGate(perm_string name, list<PExpr*>*pins);
virtual ~PGate();
@@ -70,8 +72,8 @@ class PGate : public LineInfo {
unsigned delay_count() const;
- unsigned pin_count() const { return pins_? pins_->count() : 0; }
- PExpr*pin(unsigned idx) const { return (*pins_)[idx]; }
+ unsigned pin_count() const { return pins_.size(); }
+ PExpr*pin(unsigned idx) const { return pins_[idx]; }
ivl_drive_t strength0() const;
ivl_drive_t strength1() const;
@@ -87,18 +89,20 @@ class PGate : public LineInfo {
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
protected:
- const svector<PExpr*>& get_pins() const { return *pins_; }
+ const vector<PExpr*>& get_pins() const { return pins_; }
void dump_pins(ostream&out) const;
void dump_delays(ostream&out) const;
private:
perm_string name_;
PDelays delay_;
- svector<PExpr*>*pins_;
+ vector<PExpr*>pins_;
ivl_drive_t str0_, str1_;
+ void set_pins_(list<PExpr*>*pins);
+
private: // not implemented
PGate(const PGate&);
PGate& operator= (const PGate&);
@@ -111,8 +115,8 @@ class PGate : public LineInfo {
class PGAssign : public PGate {
public:
- explicit PGAssign(svector<PExpr*>*pins);
- explicit PGAssign(svector<PExpr*>*pins, svector<PExpr*>*dels);
+ explicit PGAssign(list<PExpr*>*pins);
+ explicit PGAssign(list<PExpr*>*pins, list<PExpr*>*dels);
~PGAssign();
void dump(ostream&out, unsigned ind =4) const;
@@ -143,10 +147,10 @@ class PGBuiltin : public PGate {
public:
explicit PGBuiltin(Type t, perm_string name,
- svector<PExpr*>*pins,
- svector<PExpr*>*del);
+ list<PExpr*>*pins,
+ list<PExpr*>*del);
explicit PGBuiltin(Type t, perm_string name,
- svector<PExpr*>*pins,
+ list<PExpr*>*pins,
PExpr*del);
~PGBuiltin();
@@ -189,7 +193,7 @@ class PGModule : public PGate {
// If the binding of ports is by position, this constructor
// builds everything all at once.
explicit PGModule(perm_string type, perm_string name,
- svector<PExpr*>*pins);
+ list<PExpr*>*pins);
// If the binding of ports is by name, this constructor takes
// the bindings and stores them for later elaboration.
@@ -201,7 +205,7 @@ class PGModule : public PGate {
// Parameter overrides can come as an ordered list, or a set
// of named expressions.
- void set_parameters(svector<PExpr*>*o);
+ void set_parameters(list<PExpr*>*o);
void set_parameters(named<PExpr*>*pa, unsigned npa);
// Modules can be instantiated in ranges. The parser uses this
@@ -219,7 +223,7 @@ class PGModule : public PGate {
private:
perm_string type_;
- svector<PExpr*>*overrides_;
+ list<PExpr*>*overrides_;
named<PExpr*>*pins_;
unsigned npins_;
View
@@ -24,6 +24,7 @@
# include "svector.h"
# include "StringHeap.h"
# include <string>
+# include <list>
class Design;
class NetScope;
class PWire;
@@ -44,7 +45,7 @@ enum PTaskFuncEnum {
struct PTaskFuncArg {
PTaskFuncEnum type;
- svector<PExpr*>*range;
+ vector<PExpr*>*range;
};
/*
Oops, something went wrong.

0 comments on commit cced1e7

Please sign in to comment.