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]
|
||||
VlQueue slice(int32_t lsb, int32_t msb) const {
|
||||
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 >= m_deque.size())) lsb = 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]);
|
||||
return out;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ module t;
|
|||
`checkp(q, "'{\"d\", \"e\", \"f\"}");
|
||||
q = q[$:$];
|
||||
`checkp(q, "'{\"f\"}");
|
||||
q = q[1:$];
|
||||
`checkp("'{}");
|
||||
|
||||
|
||||
// Similar using implied notation
|
||||
q = '{"f"};
|
||||
|
|
@ -84,11 +87,6 @@ module t;
|
|||
q = {q, q};
|
||||
`checkp(q, "'{\"a\", \"b\", \"a\", \"b\"}");
|
||||
|
||||
q = {"a"};
|
||||
q = q[1:$];
|
||||
i = q.size();
|
||||
`checkh(i, 0);
|
||||
|
||||
begin
|
||||
static string ai[$] = '{"Foo", "Bar"};
|
||||
q = ai; // Copy
|
||||
|
|
|
|||
Loading…
Reference in New Issue