Handle default expressions anywhere in port expression list.
This commit is contained in:
parent
d9e1bcf3d0
commit
46f551073e
|
|
@ -4604,14 +4604,8 @@ NetExpr* PENewClass::elaborate_expr(Design*des, NetScope*scope,
|
||||||
int parm_errors = 0;
|
int parm_errors = 0;
|
||||||
for (size_t idx = 1 ; idx < parms.size() ; idx += 1) {
|
for (size_t idx = 1 ; idx < parms.size() ; idx += 1) {
|
||||||
// While there are default arguments, check them.
|
// While there are default arguments, check them.
|
||||||
if (idx <= parms_.size()) {
|
if (idx <= parms_.size() && parms_[idx-1]) {
|
||||||
PExpr*tmp = parms_[idx-1];
|
PExpr*tmp = parms_[idx-1];
|
||||||
if (tmp == 0) {
|
|
||||||
parms[idx] = 0;
|
|
||||||
missing_parms += 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
parms[idx] = elaborate_rval_expr(des, scope, def->port(idx)->data_type(),
|
parms[idx] = elaborate_rval_expr(des, scope, def->port(idx)->data_type(),
|
||||||
def->port(idx)->vector_width(),
|
def->port(idx)->vector_width(),
|
||||||
tmp, false);
|
tmp, false);
|
||||||
|
|
|
||||||
38
parse.y
38
parse.y
|
|
@ -167,6 +167,18 @@ template <class T> void append(vector<T>&out, const vector<T>&in)
|
||||||
out.push_back(in[idx]);
|
out.push_back(in[idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look at the list and pull null pointers off the end.
|
||||||
|
*/
|
||||||
|
static void strip_tail_items(list<PExpr*>*lst)
|
||||||
|
{
|
||||||
|
while (lst->size() > 0) {
|
||||||
|
if (lst->back() != 0)
|
||||||
|
return;
|
||||||
|
lst->pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a shorthand for making a PECallFunction that takes a single
|
* This is a shorthand for making a PECallFunction that takes a single
|
||||||
* arg. This is used by some of the code that detects built-ins.
|
* arg. This is used by some of the code that detects built-ins.
|
||||||
|
|
@ -855,13 +867,10 @@ class_item_qualifier_opt
|
||||||
;
|
;
|
||||||
|
|
||||||
class_new /* IEEE1800-2005 A.2.4 */
|
class_new /* IEEE1800-2005 A.2.4 */
|
||||||
: K_new '(' ')'
|
: K_new '(' expression_list_with_nuls ')'
|
||||||
{ PENewClass*tmp = new PENewClass;
|
{ list<PExpr*>*expr_list = $3;
|
||||||
FILE_NAME(tmp, @1);
|
strip_tail_items(expr_list);
|
||||||
$$ = tmp;
|
PENewClass*tmp = new PENewClass(*expr_list);
|
||||||
}
|
|
||||||
| K_new '(' expression_list_proper ')'
|
|
||||||
{ PENewClass*tmp = new PENewClass(*$3);
|
|
||||||
FILE_NAME(tmp, @1);
|
FILE_NAME(tmp, @1);
|
||||||
delete $3;
|
delete $3;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
|
|
@ -3035,8 +3044,10 @@ expr_primary
|
||||||
function call. If a system identifier, then a system function
|
function call. If a system identifier, then a system function
|
||||||
call. */
|
call. */
|
||||||
|
|
||||||
| hierarchy_identifier '(' expression_list_proper ')'
|
| hierarchy_identifier '(' expression_list_with_nuls ')'
|
||||||
{ PECallFunction*tmp = pform_make_call_function(@1, *$1, *$3);
|
{ list<PExpr*>*expr_list = $3;
|
||||||
|
strip_tail_items(expr_list);
|
||||||
|
PECallFunction*tmp = pform_make_call_function(@1, *$1, *expr_list);
|
||||||
delete $1;
|
delete $1;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
|
|
@ -3047,15 +3058,6 @@ expr_primary
|
||||||
delete[]$1;
|
delete[]$1;
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
| hierarchy_identifier '(' ')'
|
|
||||||
{ const list<PExpr*> empty;
|
|
||||||
PECallFunction*tmp = pform_make_call_function(@1, *$1, empty);
|
|
||||||
delete $1;
|
|
||||||
$$ = tmp;
|
|
||||||
if (!gn_system_verilog()) {
|
|
||||||
yyerror(@1, "error: Empty function argument list requires SystemVerilog.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
| PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '(' expression_list_proper ')'
|
| PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '(' expression_list_proper ')'
|
||||||
{ perm_string use_name = lex_strings.make($3);
|
{ perm_string use_name = lex_strings.make($3);
|
||||||
PECallFunction*tmp = new PECallFunction($1, use_name, *$5);
|
PECallFunction*tmp = new PECallFunction($1, use_name, *$5);
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ void PENewClass::dump(ostream&out) const
|
||||||
parms_[0]->dump(out);
|
parms_[0]->dump(out);
|
||||||
for (size_t idx = 1 ; idx < parms_.size() ; idx += 1) {
|
for (size_t idx = 1 ; idx < parms_.size() ; idx += 1) {
|
||||||
out << ", ";
|
out << ", ";
|
||||||
parms_[idx]->dump(out);
|
if (parms_[idx]) parms_[idx]->dump(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out << ")";
|
out << ")";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue