Add support for pop_back/front without ()
This commit is contained in:
parent
6ecd43d947
commit
520d5b392a
67
elab_expr.cc
67
elab_expr.cc
|
|
@ -35,6 +35,7 @@
|
||||||
# include "discipline.h"
|
# include "discipline.h"
|
||||||
# include "netmisc.h"
|
# include "netmisc.h"
|
||||||
# include "netdarray.h"
|
# include "netdarray.h"
|
||||||
|
# include "netqueue.h"
|
||||||
# include "netstruct.h"
|
# include "netstruct.h"
|
||||||
# include "netscalar.h"
|
# include "netscalar.h"
|
||||||
# include "util.h"
|
# include "util.h"
|
||||||
|
|
@ -2672,22 +2673,32 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
|
||||||
}
|
}
|
||||||
NetESFunc*sys_expr = new NetESFunc("$size",
|
NetESFunc*sys_expr = new NetESFunc("$size",
|
||||||
IVL_VT_BOOL, 32, 1);
|
IVL_VT_BOOL, 32, 1);
|
||||||
sys_expr->parm(0, new NetESignal(net));
|
|
||||||
sys_expr->set_line(*this);
|
sys_expr->set_line(*this);
|
||||||
|
|
||||||
|
NetESignal*arg = new NetESignal(net);
|
||||||
|
arg->set_line(*net);
|
||||||
|
|
||||||
|
sys_expr->parm(0, arg);
|
||||||
return sys_expr;
|
return sys_expr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (net->queue_type()) {
|
||||||
if (method_name == "pop_back") {
|
if (method_name == "pop_back") {
|
||||||
if (parms_.size() != 0) {
|
if (parms_.size() != 0) {
|
||||||
cerr << get_fileline() << ": error: pop_back() method "
|
cerr << get_fileline() << ": error: pop_back() method "
|
||||||
<< "takes no arguments" << endl;
|
<< "takes no arguments" << endl;
|
||||||
des->errors += 1;
|
des->errors += 1;
|
||||||
}
|
}
|
||||||
NetESFunc*sys_expr = new NetESFunc("$ivl_darray_method$pop_back",
|
NetESFunc*sys_expr = new NetESFunc("$ivl_queue_method$pop_back",
|
||||||
expr_type_,
|
expr_type_,
|
||||||
expr_width_, 1);
|
expr_width_, 1);
|
||||||
sys_expr->parm(0, new NetESignal(net));
|
|
||||||
sys_expr->set_line(*this);
|
sys_expr->set_line(*this);
|
||||||
|
|
||||||
|
NetESignal*arg = new NetESignal(net);
|
||||||
|
arg->set_line(*net);
|
||||||
|
|
||||||
|
sys_expr->parm(0, arg);
|
||||||
return sys_expr;
|
return sys_expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2697,11 +2708,15 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
|
||||||
<< "takes no arguments" << endl;
|
<< "takes no arguments" << endl;
|
||||||
des->errors += 1;
|
des->errors += 1;
|
||||||
}
|
}
|
||||||
NetESFunc*sys_expr = new NetESFunc("$ivl_darray_method$pop_front",
|
NetESFunc*sys_expr = new NetESFunc("$ivl_queue_method$pop_front",
|
||||||
expr_type_,
|
expr_type_,
|
||||||
expr_width_, 1);
|
expr_width_, 1);
|
||||||
sys_expr->parm(0, new NetESignal(net));
|
|
||||||
sys_expr->set_line(*this);
|
sys_expr->set_line(*this);
|
||||||
|
|
||||||
|
NetESignal*arg = new NetESignal(net);
|
||||||
|
arg->set_line(*net);
|
||||||
|
|
||||||
|
sys_expr->parm(0, arg);
|
||||||
return sys_expr;
|
return sys_expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4100,7 +4115,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
|
||||||
if (debug_elaborate) {
|
if (debug_elaborate) {
|
||||||
cerr << get_fileline() << ": PEIdent::elaborate_expr: "
|
cerr << get_fileline() << ": PEIdent::elaborate_expr: "
|
||||||
<< "Ident " << base_path
|
<< "Ident " << base_path
|
||||||
<< " look for array property " << member_path
|
<< " looking for array property " << member_path
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4118,6 +4133,46 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this is a queue object, and there are members in
|
||||||
|
// the member_path, check for array properties.
|
||||||
|
if (net->queue_type() && member_path.size() > 0) {
|
||||||
|
if (debug_elaborate) {
|
||||||
|
cerr << get_fileline() << ": PEIdent::elaborate_expr: "
|
||||||
|
<< "Ident " << base_path
|
||||||
|
<< " looking for queue property " << member_path
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
ivl_assert(*this, member_path.size() == 1);
|
||||||
|
const name_component_t member_comp = member_path.front();
|
||||||
|
const netqueue_t*queue = net->queue_type();
|
||||||
|
ivl_variable_type_t qelem_type = queue->element_base_type();
|
||||||
|
unsigned qelem_width = queue->element_width();
|
||||||
|
if (member_comp.name == "pop_back") {
|
||||||
|
NetESFunc*fun = new NetESFunc("$ivl_queue_method$pop_back",
|
||||||
|
qelem_type, qelem_width, 1);
|
||||||
|
fun->set_line(*this);
|
||||||
|
|
||||||
|
NetESignal*arg = new NetESignal(net);
|
||||||
|
arg->set_line(*net);
|
||||||
|
|
||||||
|
fun->parm(0, arg);
|
||||||
|
return fun;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (member_comp.name == "pop_front") {
|
||||||
|
NetESFunc*fun = new NetESFunc("$ivl_queue_method$pop_front",
|
||||||
|
qelem_type, qelem_width, 1);
|
||||||
|
fun->set_line(*this);
|
||||||
|
|
||||||
|
NetESignal*arg = new NetESignal(net);
|
||||||
|
arg->set_line(*net);
|
||||||
|
|
||||||
|
fun->parm(0, arg);
|
||||||
|
return fun;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (net->class_type() && member_path.size() > 0) {
|
if (net->class_type() && member_path.size() > 0) {
|
||||||
if (debug_elaborate) {
|
if (debug_elaborate) {
|
||||||
cerr << get_fileline() << ": PEIdent::elaborate_expr: "
|
cerr << get_fileline() << ": PEIdent::elaborate_expr: "
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,7 @@ static void real_ex_pop(ivl_expr_t expr)
|
||||||
const char*fb;
|
const char*fb;
|
||||||
ivl_expr_t arg;
|
ivl_expr_t arg;
|
||||||
|
|
||||||
if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_back")==0)
|
if (strcmp(ivl_expr_name(expr), "$ivl_queue_method$pop_back")==0)
|
||||||
fb = "b";
|
fb = "b";
|
||||||
else
|
else
|
||||||
fb = "f";
|
fb = "f";
|
||||||
|
|
@ -527,9 +527,9 @@ void draw_eval_real(ivl_expr_t expr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IVL_EX_SFUNC:
|
case IVL_EX_SFUNC:
|
||||||
if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_back")==0)
|
if (strcmp(ivl_expr_name(expr), "$ivl_queue_method$pop_back")==0)
|
||||||
real_ex_pop(expr);
|
real_ex_pop(expr);
|
||||||
else if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_front")==0)
|
else if (strcmp(ivl_expr_name(expr), "$ivl_queue_method$pop_front")==0)
|
||||||
real_ex_pop(expr);
|
real_ex_pop(expr);
|
||||||
else
|
else
|
||||||
draw_sfunc_real(expr);
|
draw_sfunc_real(expr);
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ static void string_ex_pop(ivl_expr_t expr)
|
||||||
const char*fb;
|
const char*fb;
|
||||||
ivl_expr_t arg;
|
ivl_expr_t arg;
|
||||||
|
|
||||||
if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_back")==0)
|
if (strcmp(ivl_expr_name(expr), "$ivl_queue_method$pop_back")==0)
|
||||||
fb = "b";
|
fb = "b";
|
||||||
else
|
else
|
||||||
fb = "f";
|
fb = "f";
|
||||||
|
|
@ -205,9 +205,9 @@ void draw_eval_string(ivl_expr_t expr)
|
||||||
case IVL_EX_SFUNC:
|
case IVL_EX_SFUNC:
|
||||||
if (strcmp(ivl_expr_name(expr), "$ivl_string_method$substr") == 0)
|
if (strcmp(ivl_expr_name(expr), "$ivl_string_method$substr") == 0)
|
||||||
string_ex_substr(expr);
|
string_ex_substr(expr);
|
||||||
else if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_back")==0)
|
else if (strcmp(ivl_expr_name(expr), "$ivl_queue_method$pop_back")==0)
|
||||||
string_ex_pop(expr);
|
string_ex_pop(expr);
|
||||||
else if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_front")==0)
|
else if (strcmp(ivl_expr_name(expr), "$ivl_queue_method$pop_front")==0)
|
||||||
string_ex_pop(expr);
|
string_ex_pop(expr);
|
||||||
else
|
else
|
||||||
draw_sfunc_string(expr);
|
draw_sfunc_string(expr);
|
||||||
|
|
|
||||||
|
|
@ -992,7 +992,7 @@ static void draw_select_pad_vec4(ivl_expr_t expr)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function handles the special case of a call to the internal
|
* This function handles the special case of a call to the internal
|
||||||
* functions $ivl_darray_method$pop_back et al. The first (and only)
|
* functions $ivl_queue_method$pop_back et al. The first (and only)
|
||||||
* argument is the signal that represents a dynamic queue. Generate a
|
* argument is the signal that represents a dynamic queue. Generate a
|
||||||
* %qpop instruction to pop a value and push it to the vec4 stack.
|
* %qpop instruction to pop a value and push it to the vec4 stack.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1000,7 +1000,7 @@ static void draw_darray_pop(ivl_expr_t expr)
|
||||||
{
|
{
|
||||||
const char*fb;
|
const char*fb;
|
||||||
|
|
||||||
if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_back")==0)
|
if (strcmp(ivl_expr_name(expr), "$ivl_queue_method$pop_back")==0)
|
||||||
fb = "b";
|
fb = "b";
|
||||||
else
|
else
|
||||||
fb = "f";
|
fb = "f";
|
||||||
|
|
@ -1029,11 +1029,11 @@ static void draw_sfunc_vec4(ivl_expr_t expr)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(ivl_expr_name(expr), "$ivl_darray_method$pop_back")==0) {
|
if (strcmp(ivl_expr_name(expr), "$ivl_queue_method$pop_back")==0) {
|
||||||
draw_darray_pop(expr);
|
draw_darray_pop(expr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strcmp(ivl_expr_name(expr),"$ivl_darray_method$pop_front")==0) {
|
if (strcmp(ivl_expr_name(expr),"$ivl_queue_method$pop_front")==0) {
|
||||||
draw_darray_pop(expr);
|
draw_darray_pop(expr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue