fix slice method, reuse other slice test stuff for [1:0] case
This commit is contained in:
parent
a4c09ffe02
commit
a31d14e8e6
|
|
@ -650,8 +650,14 @@ public:
|
||||||
// Return slice q[lsb:msb]
|
// Return slice q[lsb:msb]
|
||||||
VlQueue slice(int32_t lsb, int32_t msb) const {
|
VlQueue slice(int32_t lsb, int32_t msb) const {
|
||||||
VlQueue out;
|
VlQueue out;
|
||||||
|
if (VL_UNLIKELY(lsb > msb)) return out;
|
||||||
|
if (VL_UNLIKELY(lsb == msb)) {
|
||||||
|
if (lsb > 0 && lsb < m_deque.size()) {
|
||||||
|
out.push_back(m_deque[lsb]);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
if (VL_UNLIKELY(lsb < 0)) lsb = 0;
|
if (VL_UNLIKELY(lsb < 0)) lsb = 0;
|
||||||
if (VL_UNLIKELY(lsb >= m_deque.size())) lsb = m_deque.size() - 1;
|
|
||||||
if (VL_UNLIKELY(msb >= m_deque.size())) msb = m_deque.size() - 1;
|
if (VL_UNLIKELY(msb >= m_deque.size())) msb = m_deque.size() - 1;
|
||||||
for (int32_t i = lsb; i <= msb; ++i) out.push_back(m_deque[i]);
|
for (int32_t i = lsb; i <= msb; ++i) out.push_back(m_deque[i]);
|
||||||
return out;
|
return out;
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,9 @@ module t;
|
||||||
`checkp(q, "'{\"d\", \"e\", \"f\"}");
|
`checkp(q, "'{\"d\", \"e\", \"f\"}");
|
||||||
q = q[$:$];
|
q = q[$:$];
|
||||||
`checkp(q, "'{\"f\"}");
|
`checkp(q, "'{\"f\"}");
|
||||||
|
q = q[1:$];
|
||||||
|
`checkp("'{}");
|
||||||
|
|
||||||
|
|
||||||
// Similar using implied notation
|
// Similar using implied notation
|
||||||
q = '{"f"};
|
q = '{"f"};
|
||||||
|
|
@ -84,11 +87,6 @@ module t;
|
||||||
q = {q, q};
|
q = {q, q};
|
||||||
`checkp(q, "'{\"a\", \"b\", \"a\", \"b\"}");
|
`checkp(q, "'{\"a\", \"b\", \"a\", \"b\"}");
|
||||||
|
|
||||||
q = {"a"};
|
|
||||||
q = q[1:$];
|
|
||||||
i = q.size();
|
|
||||||
`checkh(i, 0);
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
static string ai[$] = '{"Foo", "Bar"};
|
static string ai[$] = '{"Foo", "Bar"};
|
||||||
q = ai; // Copy
|
q = ai; // Copy
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue