Added std::initializer_list<> constructor to SigSpec

This commit is contained in:
Clifford Wolf 2014-07-28 10:52:58 +02:00
parent f99495a895
commit d86a25f145
2 changed files with 15 additions and 0 deletions

View File

@ -1652,6 +1652,18 @@ RTLIL::SigSpec::SigSpec(const RTLIL::SigSpec &other)
*this = other; *this = other;
} }
RTLIL::SigSpec::SigSpec(std::initializer_list<RTLIL::SigSpec> parts)
{
cover("kernel.rtlil.sigspec.init.list");
width_ = 0;
hash_ = 0;
std::vector<RTLIL::SigSpec> parts_vec(parts.begin(), parts.end());
for (auto it = parts_vec.rbegin(); it != parts_vec.rend(); it++)
append(*it);
}
const RTLIL::SigSpec &RTLIL::SigSpec::operator=(const RTLIL::SigSpec &other) const RTLIL::SigSpec &RTLIL::SigSpec::operator=(const RTLIL::SigSpec &other)
{ {
cover("kernel.rtlil.sigspec.assign"); cover("kernel.rtlil.sigspec.assign");

View File

@ -26,6 +26,8 @@
#include <string> #include <string>
#include <assert.h> #include <assert.h>
#include <initializer_list>
// various helpers (unrelated to RTLIL) // various helpers (unrelated to RTLIL)
std::string stringf(const char *fmt, ...); std::string stringf(const char *fmt, ...);
#define SIZE(__obj) int(__obj.size()) #define SIZE(__obj) int(__obj.size())
@ -738,6 +740,7 @@ private:
public: public:
SigSpec(); SigSpec();
SigSpec(const RTLIL::SigSpec &other); SigSpec(const RTLIL::SigSpec &other);
SigSpec(std::initializer_list<RTLIL::SigSpec> parts);
const RTLIL::SigSpec &operator=(const RTLIL::SigSpec &other); const RTLIL::SigSpec &operator=(const RTLIL::SigSpec &other);
SigSpec(const RTLIL::Const &value); SigSpec(const RTLIL::Const &value);