Add warning messages when popping from an empty queue

This commit is contained in:
Cary R 2020-07-23 22:03:03 -07:00
parent 1b52a4a578
commit f0f045f1f9
1 changed files with 20 additions and 6 deletions

View File

@ -5034,8 +5034,10 @@ bool of_QPOP_B_REAL(vthread_t thr, vvp_code_t cp)
if (size) { if (size) {
dqueue->get_word(size-1, value); dqueue->get_word(size-1, value);
dqueue->pop_back(); dqueue->pop_back();
} else } else {
cerr << "Warning: pop_back() on empty queue<real>." << endl;
value = 0.0; value = 0.0;
}
thr->push_real(value); thr->push_real(value);
return true; return true;
@ -5057,8 +5059,10 @@ bool of_QPOP_B_STR(vthread_t thr, vvp_code_t cp)
if (size) { if (size) {
dqueue->get_word(size-1, value); dqueue->get_word(size-1, value);
dqueue->pop_back(); dqueue->pop_back();
} else } else {
cerr << "Warning: pop_back() on empty queue<string>." << endl;
value = ""; value = "";
}
thr->push_str(value); thr->push_str(value);
return true; return true;
@ -5081,8 +5085,11 @@ bool of_QPOP_B_V(vthread_t thr, vvp_code_t cp)
if (size) { if (size) {
dqueue->get_word(size-1, value); dqueue->get_word(size-1, value);
dqueue->pop_back(); dqueue->pop_back();
} else } else {
cerr << "Warning: pop_back() on empty queue<vector["
<< width << "]>." << endl;
value = vvp_vector4_t(width); value = vvp_vector4_t(width);
}
assert(width == value.size()); assert(width == value.size());
thr->push_vec4(value); thr->push_vec4(value);
@ -5105,8 +5112,10 @@ bool of_QPOP_F_REAL(vthread_t thr, vvp_code_t cp)
if (size) { if (size) {
dqueue->get_word(0, value); dqueue->get_word(0, value);
dqueue->pop_front(); dqueue->pop_front();
} else } else {
cerr << "Warning: pop_front() on empty queue<real>." << endl;
value = 0.0; value = 0.0;
}
thr->push_real(value); thr->push_real(value);
return true; return true;
@ -5128,8 +5137,10 @@ bool of_QPOP_F_STR(vthread_t thr, vvp_code_t cp)
if (size) { if (size) {
dqueue->get_word(0, value); dqueue->get_word(0, value);
dqueue->pop_front(); dqueue->pop_front();
} else } else {
cerr << "Warning: pop_front() on empty queue<string>." << endl;
value = ""; value = "";
}
thr->push_str(value); thr->push_str(value);
return true; return true;
@ -5152,8 +5163,11 @@ bool of_QPOP_F_V(vthread_t thr, vvp_code_t cp)
if (size) { if (size) {
dqueue->get_word(0, value); dqueue->get_word(0, value);
dqueue->pop_front(); dqueue->pop_front();
} else } else {
cerr << "Warning: pop_front() on empty queue<vector["
<< width << "]>." << endl;
value = vvp_vector4_t(width); value = vvp_vector4_t(width);
}
assert(width == value.size()); assert(width == value.size());
thr->push_vec4(value); thr->push_vec4(value);