Skip to content

Commit 8c2d511

Browse files
committed
Elaborate pop_back/pop_front methods on dynamic arrays.
1 parent 5ee253b commit 8c2d511

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

elab_expr.cc

+39-3
Original file line numberDiff line numberDiff line change
@@ -1285,10 +1285,27 @@ unsigned PECallFunction::test_width_method_(Design*des, NetScope*scope,
12851285
return expr_width_;
12861286
}
12871287

1288+
if (use_darray && (method_name == "pop_back" || method_name=="pop_front")) {
1289+
if (debug_elaborate) {
1290+
cerr << get_fileline() << ": PECallFunction::test_width_method_: "
1291+
<< "Detected " << method_name << " method"
1292+
<< " of dynamic arrays." << endl;
1293+
}
1294+
1295+
expr_type_ = use_darray->element_base_type();
1296+
expr_width_ = use_darray->element_width();
1297+
min_width_ = expr_width_;
1298+
signed_flag_= false;
1299+
1300+
return expr_width_;
1301+
}
1302+
12881303
if (const netclass_t*class_type = net->class_type()) {
1289-
cerr << get_fileline() << ": PECallFunction::test_width_method_: "
1290-
<< "Try to find method " << method_name
1291-
<< " of class " << class_type->get_name() << endl;
1304+
if (debug_elaborate) {
1305+
cerr << get_fileline() << ": PECallFunction::test_width_method_: "
1306+
<< "Try to find method " << method_name
1307+
<< " of class " << class_type->get_name() << endl;
1308+
}
12921309

12931310
NetScope*func = class_type->method_from_name(method_name);
12941311
if (func == 0) {
@@ -2324,6 +2341,25 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
23242341
sys_expr->set_line(*this);
23252342
return sys_expr;
23262343
}
2344+
2345+
if (method_name == "pop_back") {
2346+
NetESFunc*sys_expr = new NetESFunc("$ivl_darray_method$pop_back",
2347+
expr_type_,
2348+
expr_width_, 1);
2349+
sys_expr->parm(0, new NetESignal(net));
2350+
sys_expr->set_line(*this);
2351+
return sys_expr;
2352+
}
2353+
2354+
if (method_name == "pop_front") {
2355+
NetESFunc*sys_expr = new NetESFunc("$ivl_darray_method$pop_front",
2356+
expr_type_,
2357+
expr_width_, 1);
2358+
sys_expr->parm(0, new NetESignal(net));
2359+
sys_expr->set_line(*this);
2360+
return sys_expr;
2361+
}
2362+
23272363
}
23282364

23292365
if (const netclass_t*class_type = net->class_type()) {

0 commit comments

Comments
 (0)