parser: Consistently pass line information as `vlltype`

Currently there is a mix of passing line information either as `struct
vlltype` or as a separate `const char *file` and `unsigned lineno`.

For consistency always use the struct vlltype variant.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-01-10 11:21:14 +01:00
parent 3906d043b9
commit 56f36a96d3
3 changed files with 80 additions and 95 deletions

39
parse.y
View File

@ -1187,7 +1187,7 @@ data_declaration /* IEEE1800-2005: A.2.1.3 */
pform_makewire(@2, 0, str_strength, $3, NetNet::IMPLICIT_REG, data_type, $1); pform_makewire(@2, 0, str_strength, $3, NetNet::IMPLICIT_REG, data_type, $1);
} }
| attribute_list_opt K_event event_variable_list ';' | attribute_list_opt K_event event_variable_list ';'
{ if ($3) pform_make_events($3, @2.text, @2.first_line); { if ($3) pform_make_events(@2, $3);
} }
| attribute_list_opt package_import_declaration | attribute_list_opt package_import_declaration
; ;
@ -2624,7 +2624,7 @@ block_item_decl
} }
| K_event event_variable_list ';' | K_event event_variable_list ';'
{ if ($2) pform_make_events($2, @1.text, @1.first_line); { if ($2) pform_make_events(@1, $2);
} }
| parameter_declaration | parameter_declaration
@ -4421,8 +4421,7 @@ list_of_port_declarations
| list_of_port_declarations ',' IDENTIFIER | list_of_port_declarations ',' IDENTIFIER
{ Module::port_t*ptmp; { Module::port_t*ptmp;
perm_string name = lex_strings.make($3); perm_string name = lex_strings.make($3);
ptmp = pform_module_port_reference(name, @3.text, ptmp = pform_module_port_reference(@3, name);
@3.first_line);
std::vector<Module::port_t*>*tmp = $1; std::vector<Module::port_t*>*tmp = $1;
tmp->push_back(ptmp); tmp->push_back(ptmp);
@ -4453,7 +4452,7 @@ port_declaration
perm_string name = lex_strings.make($5); perm_string name = lex_strings.make($5);
data_type_t*use_type = $4; data_type_t*use_type = $4;
if ($6) use_type = new uarray_type_t(use_type, $6); if ($6) use_type = new uarray_type_t(use_type, $6);
ptmp = pform_module_port_reference(name, @2.text, @2.first_line); ptmp = pform_module_port_reference(@2, name);
pform_module_define_port(@2, name, NetNet::PINPUT, $3, use_type, $1); pform_module_define_port(@2, name, NetNet::PINPUT, $3, use_type, $1);
port_declaration_context.port_type = NetNet::PINPUT; port_declaration_context.port_type = NetNet::PINPUT;
port_declaration_context.port_net_type = $3; port_declaration_context.port_net_type = $3;
@ -4465,8 +4464,7 @@ port_declaration
K_input K_wreal IDENTIFIER K_input K_wreal IDENTIFIER
{ Module::port_t*ptmp; { Module::port_t*ptmp;
perm_string name = lex_strings.make($4); perm_string name = lex_strings.make($4);
ptmp = pform_module_port_reference(name, @2.text, ptmp = pform_module_port_reference(@2, name);
@2.first_line);
real_type_t*real_type = new real_type_t(real_type_t::REAL); real_type_t*real_type = new real_type_t(real_type_t::REAL);
FILE_NAME(real_type, @3); FILE_NAME(real_type, @3);
pform_module_define_port(@2, name, NetNet::PINPUT, pform_module_define_port(@2, name, NetNet::PINPUT,
@ -4482,7 +4480,7 @@ port_declaration
Module::port_t*ptmp; Module::port_t*ptmp;
perm_string name = lex_strings.make($5); perm_string name = lex_strings.make($5);
data_type_t*use_type = $4; data_type_t*use_type = $4;
ptmp = pform_module_port_reference(name, @2.text, @2.first_line); ptmp = pform_module_port_reference(@2, name);
ptmp->default_value = $7; ptmp->default_value = $7;
pform_module_define_port(@2, name, NetNet::PINPUT, $3, use_type, $1); pform_module_define_port(@2, name, NetNet::PINPUT, $3, use_type, $1);
port_declaration_context.port_type = NetNet::PINPUT; port_declaration_context.port_type = NetNet::PINPUT;
@ -4494,7 +4492,7 @@ port_declaration
| attribute_list_opt K_inout net_type_opt data_type_or_implicit IDENTIFIER dimensions_opt | attribute_list_opt K_inout net_type_opt data_type_or_implicit IDENTIFIER dimensions_opt
{ Module::port_t*ptmp; { Module::port_t*ptmp;
perm_string name = lex_strings.make($5); perm_string name = lex_strings.make($5);
ptmp = pform_module_port_reference(name, @2.text, @2.first_line); ptmp = pform_module_port_reference(@2, name);
pform_module_define_port(@2, name, NetNet::PINOUT, $3, $4, $1); pform_module_define_port(@2, name, NetNet::PINOUT, $3, $4, $1);
port_declaration_context.port_type = NetNet::PINOUT; port_declaration_context.port_type = NetNet::PINOUT;
port_declaration_context.port_net_type = $3; port_declaration_context.port_net_type = $3;
@ -4510,8 +4508,7 @@ port_declaration
K_inout K_wreal IDENTIFIER K_inout K_wreal IDENTIFIER
{ Module::port_t*ptmp; { Module::port_t*ptmp;
perm_string name = lex_strings.make($4); perm_string name = lex_strings.make($4);
ptmp = pform_module_port_reference(name, @2.text, ptmp = pform_module_port_reference(@2, name);
@2.first_line);
real_type_t*real_type = new real_type_t(real_type_t::REAL); real_type_t*real_type = new real_type_t(real_type_t::REAL);
FILE_NAME(real_type, @3); FILE_NAME(real_type, @3);
pform_module_define_port(@2, name, NetNet::PINOUT, pform_module_define_port(@2, name, NetNet::PINOUT,
@ -4543,7 +4540,7 @@ port_declaration
use_type = NetNet::IMPLICIT_REG; use_type = NetNet::IMPLICIT_REG;
} }
} }
ptmp = pform_module_port_reference(name, @2.text, @2.first_line); ptmp = pform_module_port_reference(@2, name);
pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, use_dtype, $1); pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, use_dtype, $1);
port_declaration_context.port_type = NetNet::POUTPUT; port_declaration_context.port_type = NetNet::POUTPUT;
port_declaration_context.port_net_type = use_type; port_declaration_context.port_net_type = use_type;
@ -4555,8 +4552,7 @@ port_declaration
K_output K_wreal IDENTIFIER K_output K_wreal IDENTIFIER
{ Module::port_t*ptmp; { Module::port_t*ptmp;
perm_string name = lex_strings.make($4); perm_string name = lex_strings.make($4);
ptmp = pform_module_port_reference(name, @2.text, ptmp = pform_module_port_reference(@2, name);
@2.first_line);
real_type_t*real_type = new real_type_t(real_type_t::REAL); real_type_t*real_type = new real_type_t(real_type_t::REAL);
FILE_NAME(real_type, @3); FILE_NAME(real_type, @3);
pform_module_define_port(@2, name, NetNet::POUTPUT, pform_module_define_port(@2, name, NetNet::POUTPUT,
@ -4574,7 +4570,7 @@ port_declaration
if (use_type == NetNet::IMPLICIT) { if (use_type == NetNet::IMPLICIT) {
use_type = NetNet::IMPLICIT_REG; use_type = NetNet::IMPLICIT_REG;
} }
ptmp = pform_module_port_reference(name, @2.text, @2.first_line); ptmp = pform_module_port_reference(@2, name);
pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, $4, $1); pform_module_define_port(@2, name, NetNet::POUTPUT, use_type, $4, $1);
port_declaration_context.port_type = NetNet::PINOUT; port_declaration_context.port_type = NetNet::PINOUT;
port_declaration_context.port_net_type = use_type; port_declaration_context.port_net_type = use_type;
@ -5122,7 +5118,7 @@ module_item
cont_assign_list. */ cont_assign_list. */
| K_assign drive_strength_opt delay3_opt cont_assign_list ';' | K_assign drive_strength_opt delay3_opt cont_assign_list ';'
{ pform_make_pgassign_list($4, $3, $2, @1.text, @1.first_line); } { pform_make_pgassign_list(@1, $4, $3, $2); }
/* Always and initial items are behavioral processes. */ /* Always and initial items are behavioral processes. */
@ -5786,7 +5782,7 @@ port_reference
: IDENTIFIER : IDENTIFIER
{ Module::port_t*ptmp; { Module::port_t*ptmp;
perm_string name = lex_strings.make($1); perm_string name = lex_strings.make($1);
ptmp = pform_module_port_reference(name, @1.text, @1.first_line); ptmp = pform_module_port_reference(@1, name);
delete[]$1; delete[]$1;
$$ = ptmp; $$ = ptmp;
} }
@ -6608,7 +6604,6 @@ statement_item /* This is roughly statement_item in the LRM */
| lpvalue '=' K_repeat '(' expression ')' event_control expression ';' | lpvalue '=' K_repeat '(' expression ')' event_control expression ';'
{ PAssign*tmp = new PAssign($1,$5,$7,$8); { PAssign*tmp = new PAssign($1,$5,$7,$8);
FILE_NAME(tmp,@1); FILE_NAME(tmp,@1);
tmp->set_lineno(@1.first_line);
$$ = tmp; $$ = tmp;
} }
| lpvalue K_LE event_control expression ';' | lpvalue K_LE event_control expression ';'
@ -7082,9 +7077,7 @@ udp_primitive
K_endprimitive label_opt K_endprimitive label_opt
{ perm_string tmp2 = lex_strings.make($2); { perm_string tmp2 = lex_strings.make($2);
pform_make_udp(tmp2, $4, $7, $9, $8, pform_make_udp(@2, tmp2, $4, $7, $9, $8);
@2.text, @2.first_line);
check_end_label(@11, "primitive", $2, $11); check_end_label(@11, "primitive", $2, $11);
delete[]$2; delete[]$2;
} }
@ -7100,9 +7093,7 @@ udp_primitive
{ perm_string tmp2 = lex_strings.make($2); { perm_string tmp2 = lex_strings.make($2);
perm_string tmp6 = lex_strings.make($6); perm_string tmp6 = lex_strings.make($6);
pform_make_udp(tmp2, $5, tmp6, $7, $9, $12, pform_make_udp(@2, tmp2, $5, tmp6, $7, $9, $12);
@2.text, @2.first_line);
check_end_label(@14, "primitive", $2, $14); check_end_label(@14, "primitive", $2, $14);
delete[]$2; delete[]$2;
delete[]$6; delete[]$6;

110
pform.cc
View File

@ -1415,13 +1415,12 @@ void pform_end_parameter_port_list()
* reference. This is a name without a .X(...), so the internal name * reference. This is a name without a .X(...), so the internal name
* should be generated to be the same as the X. * should be generated to be the same as the X.
*/ */
Module::port_t* pform_module_port_reference(perm_string name, Module::port_t* pform_module_port_reference(const struct vlltype&loc,
const char*file, perm_string name)
unsigned lineno)
{ {
Module::port_t*ptmp = new Module::port_t; Module::port_t*ptmp = new Module::port_t;
PEIdent*tmp = new PEIdent(name); PEIdent*tmp = new PEIdent(name);
FILE_NAME(tmp, file, lineno); FILE_NAME(tmp, loc);
ptmp->name = name; ptmp->name = name;
ptmp->expr.push_back(tmp); ptmp->expr.push_back(tmp);
ptmp->default_value = 0; ptmp->default_value = 0;
@ -1836,7 +1835,7 @@ template <> inline svector<perm_string>::svector(unsigned size)
} }
static void process_udp_table(PUdp*udp, list<string>*table, static void process_udp_table(PUdp*udp, list<string>*table,
const char*file, unsigned lineno) const struct vlltype&loc)
{ {
const bool synchronous_flag = udp->sequential; const bool synchronous_flag = udp->sequential;
@ -1872,7 +1871,7 @@ static void process_udp_table(PUdp*udp, list<string>*table,
output string. */ output string. */
if (synchronous_flag) { if (synchronous_flag) {
if (tmp.size() != 4) { if (tmp.size() != 4) {
cerr << file<<":"<<lineno << ": error: " cerr << loc << ": error: "
<< "Invalid table format for" << "Invalid table format for"
<< " sequential primitive." << endl; << " sequential primitive." << endl;
error_count += 1; error_count += 1;
@ -1883,7 +1882,7 @@ static void process_udp_table(PUdp*udp, list<string>*table,
tmp = tmp.substr(2); tmp = tmp.substr(2);
} else if (tmp.size() != 2) { } else if (tmp.size() != 2) {
cerr << file<<":"<<lineno << ": error: " cerr << loc << ": error: "
<< "Invalid table format for" << "Invalid table format for"
<< " combinational primitive." << endl; << " combinational primitive." << endl;
error_count += 1; error_count += 1;
@ -1901,10 +1900,9 @@ static void process_udp_table(PUdp*udp, list<string>*table,
udp->toutput = output; udp->toutput = output;
} }
void pform_make_udp(perm_string name, list<perm_string>*parms, void pform_make_udp(const struct vlltype&loc, perm_string name,
vector<PWire*>*decl, list<string>*table, list<perm_string>*parms, vector<PWire*>*decl,
Statement*init_expr, list<string>*table, Statement*init_expr)
const char*file, unsigned lineno)
{ {
unsigned local_errors = 0; unsigned local_errors = 0;
assert(!parms->empty()); assert(!parms->empty());
@ -1968,10 +1966,10 @@ void pform_make_udp(perm_string name, list<perm_string>*parms,
assert(pins.count() > 0); assert(pins.count() > 0);
do { do {
if (pins[0] == 0) { if (pins[0] == 0) {
cerr << file<<":"<<lineno << ": error: " cerr << loc << ": error: "
<< "Output port of primitive " << name << "Output port of primitive " << name
<< " missing output declaration." << endl; << " missing output declaration." << endl;
cerr << file<<":"<<lineno << ": : " cerr << loc << ": : "
<< "Try: output " << pin_names[0] << ";" << "Try: output " << pin_names[0] << ";"
<< endl; << endl;
error_count += 1; error_count += 1;
@ -1979,10 +1977,10 @@ void pform_make_udp(perm_string name, list<perm_string>*parms,
break; break;
} }
if (pins[0]->get_port_type() != NetNet::POUTPUT) { if (pins[0]->get_port_type() != NetNet::POUTPUT) {
cerr << file<<":"<<lineno << ": error: " cerr << loc << ": error: "
<< "The first port of a primitive" << "The first port of a primitive"
<< " must be an output." << endl; << " must be an output." << endl;
cerr << file<<":"<<lineno << ": : " cerr << loc << ": : "
<< "Try: output " << pin_names[0] << ";" << "Try: output " << pin_names[0] << ";"
<< endl; << endl;
error_count += 1; error_count += 1;
@ -1993,11 +1991,11 @@ void pform_make_udp(perm_string name, list<perm_string>*parms,
for (unsigned idx = 1 ; idx < pins.count() ; idx += 1) { for (unsigned idx = 1 ; idx < pins.count() ; idx += 1) {
if (pins[idx] == 0) { if (pins[idx] == 0) {
cerr << file<<":"<<lineno << ": error: " cerr << loc << ": error: "
<< "Port " << (idx+1) << "Port " << (idx+1)
<< " of primitive " << name << " missing" << " of primitive " << name << " missing"
<< " input declaration." << endl; << " input declaration." << endl;
cerr << file<<":"<<lineno << ": : " cerr << loc << ": : "
<< "Try: input " << pin_names[idx] << ";" << "Try: input " << pin_names[idx] << ";"
<< endl; << endl;
error_count += 1; error_count += 1;
@ -2005,14 +2003,14 @@ void pform_make_udp(perm_string name, list<perm_string>*parms,
continue; continue;
} }
if (pins[idx]->get_port_type() != NetNet::PINPUT) { if (pins[idx]->get_port_type() != NetNet::PINPUT) {
cerr << file<<":"<<lineno << ": error: " cerr << loc << ": error: "
<< "Input port " << (idx+1) << "Input port " << (idx+1)
<< " of primitive " << name << " of primitive " << name
<< " has an output (or missing) declaration." << endl; << " has an output (or missing) declaration." << endl;
cerr << file<<":"<<lineno << ": : " cerr << loc << ": : "
<< "Note that only the first port can be an output." << "Note that only the first port can be an output."
<< endl; << endl;
cerr << file<<":"<<lineno << ": : " cerr << loc << ": : "
<< "Try \"input " << name << ";\"" << "Try \"input " << name << ";\""
<< endl; << endl;
error_count += 1; error_count += 1;
@ -2021,11 +2019,11 @@ void pform_make_udp(perm_string name, list<perm_string>*parms,
} }
if (pins[idx]->get_wire_type() == NetNet::REG) { if (pins[idx]->get_wire_type() == NetNet::REG) {
cerr << file<<":"<<lineno << ": error: " cerr << loc << ": error: "
<< "Port " << (idx+1) << "Port " << (idx+1)
<< " of primitive " << name << " is an input port" << " of primitive " << name << " is an input port"
<< " with a reg declaration." << endl; << " with a reg declaration." << endl;
cerr << file<<":"<<lineno << ": : " cerr << loc << ": : "
<< "primitive inputs cannot be reg." << "primitive inputs cannot be reg."
<< endl; << endl;
error_count += 1; error_count += 1;
@ -2072,7 +2070,7 @@ void pform_make_udp(perm_string name, list<perm_string>*parms,
} else { } else {
PUdp*udp = new PUdp(name, parms->size()); PUdp*udp = new PUdp(name, parms->size());
FILE_NAME(udp, file, lineno); FILE_NAME(udp, loc);
// Detect sequential udp. // Detect sequential udp.
if (pins[0]->get_wire_type() == NetNet::REG) if (pins[0]->get_wire_type() == NetNet::REG)
@ -2082,7 +2080,7 @@ void pform_make_udp(perm_string name, list<perm_string>*parms,
for (unsigned idx = 0 ; idx < pins.count() ; idx += 1) for (unsigned idx = 0 ; idx < pins.count() ; idx += 1)
udp->ports[idx] = pins[idx]->basename(); udp->ports[idx] = pins[idx]->basename();
process_udp_table(udp, table, file, lineno); process_udp_table(udp, table, loc);
udp->initial = init; udp->initial = init;
pform_primitives[name] = udp; pform_primitives[name] = udp;
@ -2096,10 +2094,10 @@ void pform_make_udp(perm_string name, list<perm_string>*parms,
delete init_expr; delete init_expr;
} }
void pform_make_udp(perm_string name, bool synchronous_flag, void pform_make_udp(const struct vlltype&loc, perm_string name,
perm_string out_name, PExpr*init_expr, bool synchronous_flag, perm_string out_name,
list<perm_string>*parms, list<string>*table, PExpr*init_expr, list<perm_string>*parms,
const char*file, unsigned lineno) list<string>*table)
{ {
svector<PWire*> pins(parms->size() + 1); svector<PWire*> pins(parms->size() + 1);
@ -2108,7 +2106,7 @@ void pform_make_udp(perm_string name, bool synchronous_flag,
pins[0] = new PWire(out_name, pins[0] = new PWire(out_name,
synchronous_flag? NetNet::REG : NetNet::WIRE, synchronous_flag? NetNet::REG : NetNet::WIRE,
NetNet::POUTPUT, IVL_VT_LOGIC); NetNet::POUTPUT, IVL_VT_LOGIC);
FILE_NAME(pins[0], file, lineno); FILE_NAME(pins[0], loc);
/* Make the PWire objects for the input ports. */ /* Make the PWire objects for the input ports. */
{ list<perm_string>::iterator cur; { list<perm_string>::iterator cur;
@ -2119,7 +2117,7 @@ void pform_make_udp(perm_string name, bool synchronous_flag,
assert(idx < pins.count()); assert(idx < pins.count());
pins[idx] = new PWire(*cur, NetNet::WIRE, pins[idx] = new PWire(*cur, NetNet::WIRE,
NetNet::PINPUT, IVL_VT_LOGIC); NetNet::PINPUT, IVL_VT_LOGIC);
FILE_NAME(pins[idx], file, lineno); FILE_NAME(pins[idx], loc);
} }
assert(idx == pins.count()); assert(idx == pins.count());
} }
@ -2153,7 +2151,7 @@ void pform_make_udp(perm_string name, bool synchronous_flag,
} else { } else {
PUdp*udp = new PUdp(name, pins.count()); PUdp*udp = new PUdp(name, pins.count());
FILE_NAME(udp, file, lineno); FILE_NAME(udp, loc);
// Detect sequential udp. // Detect sequential udp.
udp->sequential = synchronous_flag; udp->sequential = synchronous_flag;
@ -2164,7 +2162,7 @@ void pform_make_udp(perm_string name, bool synchronous_flag,
assert(udp); assert(udp);
assert(table); assert(table);
process_udp_table(udp, table, file, lineno); process_udp_table(udp, table, loc);
udp->initial = init; udp->initial = init;
pform_primitives[name] = udp; pform_primitives[name] = udp;
@ -2243,21 +2241,21 @@ static void pform_set_net_range(list<perm_string>*names,
* This is invoked to make a named event. This is the declaration of * This is invoked to make a named event. This is the declaration of
* the event, and not necessarily the use of it. * the event, and not necessarily the use of it.
*/ */
static void pform_make_event(perm_string name, const char*fn, unsigned ln) static void pform_make_event(const struct vlltype&loc, perm_string name)
{ {
PEvent*event = new PEvent(name); PEvent*event = new PEvent(name);
FILE_NAME(event, fn, ln); FILE_NAME(event, loc);
add_local_symbol(lexical_scope, name, event); add_local_symbol(lexical_scope, name, event);
lexical_scope->events[name] = event; lexical_scope->events[name] = event;
} }
void pform_make_events(list<perm_string>*names, const char*fn, unsigned ln) void pform_make_events(const struct vlltype&loc, list<perm_string>*names)
{ {
list<perm_string>::iterator cur; list<perm_string>::iterator cur;
for (cur = names->begin() ; cur != names->end() ; ++ cur ) { for (cur = names->begin() ; cur != names->end() ; ++ cur ) {
perm_string txt = *cur; perm_string txt = *cur;
pform_make_event(txt, fn, ln); pform_make_event(loc, txt);
} }
delete names; delete names;
@ -2539,18 +2537,17 @@ static PGAssign* pform_make_pgassign(PExpr*lval, PExpr*rval,
return cur; return cur;
} }
void pform_make_pgassign_list(list<PExpr*>*alist, void pform_make_pgassign_list(const struct vlltype&loc,
list<PExpr*>*alist,
list<PExpr*>*del, list<PExpr*>*del,
struct str_pair_t str, struct str_pair_t str)
const char* fn,
unsigned lineno)
{ {
assert(alist->size() % 2 == 0); assert(alist->size() % 2 == 0);
while (! alist->empty()) { while (! alist->empty()) {
PExpr*lval = alist->front(); alist->pop_front(); PExpr*lval = alist->front(); alist->pop_front();
PExpr*rval = alist->front(); alist->pop_front(); PExpr*rval = alist->front(); alist->pop_front();
PGAssign*tmp = pform_make_pgassign(lval, rval, del, str); PGAssign*tmp = pform_make_pgassign(lval, rval, del, str);
FILE_NAME(tmp, fn, lineno); FILE_NAME(tmp, loc);
} }
} }
@ -2773,7 +2770,7 @@ static PWire* pform_get_or_make_wire(const vlltype&li, perm_string name,
<< "."; << ".";
VLerror(msg.str().c_str()); VLerror(msg.str().c_str());
} }
FILE_NAME(cur, li.text, li.first_line); FILE_NAME(cur, li);
} }
return cur; return cur;
} }
@ -2785,7 +2782,7 @@ static PWire* pform_get_or_make_wire(const vlltype&li, perm_string name,
// remain in the local symbol map. // remain in the local symbol map.
cur = new PWire(name, type, ptype, dtype); cur = new PWire(name, type, ptype, dtype);
FILE_NAME(cur, li.text, li.first_line); FILE_NAME(cur, li);
pform_put_wire_in_scope(name, cur); pform_put_wire_in_scope(name, cur);
@ -2865,9 +2862,9 @@ void pform_makewire(const struct vlltype&li,
pform_make_var_init(li, first->name, expr); pform_make_var_init(li, first->name, expr);
} else { } else {
PEIdent*lval = new PEIdent(first->name); PEIdent*lval = new PEIdent(first->name);
FILE_NAME(lval, li.text, li.first_line); FILE_NAME(lval, li);
PGAssign*ass = pform_make_pgassign(lval, expr, delay, str); PGAssign*ass = pform_make_pgassign(lval, expr, delay, str);
FILE_NAME(ass, li.text, li.first_line); FILE_NAME(ass, li);
} }
} }
delete first; delete first;
@ -3345,7 +3342,7 @@ extern PSpecPath* pform_make_specify_path(const struct vlltype&li,
bool full_flag, list<perm_string>*dst) bool full_flag, list<perm_string>*dst)
{ {
PSpecPath*path = new PSpecPath(src->size(), dst->size(), pol, full_flag); PSpecPath*path = new PSpecPath(src->size(), dst->size(), pol, full_flag);
FILE_NAME(path, li.text, li.first_line); FILE_NAME(path, li);
unsigned idx; unsigned idx;
list<perm_string>::const_iterator cur; list<perm_string>::const_iterator cur;
@ -3405,13 +3402,13 @@ extern void pform_module_specify_path(PSpecPath*obj)
} }
static void pform_set_port_type(perm_string name, NetNet::PortType pt, static void pform_set_port_type(const struct vlltype&li,
const char*file, unsigned lineno) perm_string name, NetNet::PortType pt)
{ {
PWire*cur = pform_get_wire_in_scope(name); PWire*cur = pform_get_wire_in_scope(name);
if (cur == 0) { if (cur == 0) {
cur = new PWire(name, NetNet::IMPLICIT, NetNet::PIMPLICIT, IVL_VT_NO_TYPE); cur = new PWire(name, NetNet::IMPLICIT, NetNet::PIMPLICIT, IVL_VT_NO_TYPE);
FILE_NAME(cur, file, lineno); FILE_NAME(cur, li);
pform_put_wire_in_scope(name, cur); pform_put_wire_in_scope(name, cur);
} }
@ -3422,14 +3419,14 @@ static void pform_set_port_type(perm_string name, NetNet::PortType pt,
break; break;
case NetNet::NOT_A_PORT: case NetNet::NOT_A_PORT:
cerr << file << ":" << lineno << ": error: " cerr << li << ": error: "
<< "port " << name << " is not in the port list." << "port " << name << " is not in the port list."
<< endl; << endl;
error_count += 1; error_count += 1;
break; break;
default: default:
cerr << file << ":" << lineno << ": error: " cerr << li << ": error: "
<< "port " << name << " already has a port declaration." << "port " << name << " already has a port declaration."
<< endl; << endl;
error_count += 1; error_count += 1;
@ -3460,14 +3457,14 @@ void pform_set_port_type(const struct vlltype&li,
for (list<pform_port_t>::iterator cur = ports->begin() for (list<pform_port_t>::iterator cur = ports->begin()
; cur != ports->end() ; ++ cur ) { ; cur != ports->end() ; ++ cur ) {
pform_set_port_type(cur->name, pt, li.text, li.first_line); pform_set_port_type(li, cur->name, pt);
pform_set_net_range(cur->name, NetNet::NONE, range, signed_flag, pform_set_net_range(cur->name, NetNet::NONE, range, signed_flag,
IVL_VT_NO_TYPE, SR_PORT, attr); IVL_VT_NO_TYPE, SR_PORT, attr);
if (cur->udims) { if (cur->udims) {
cerr << li.text << ":" << li.first_line << ": warning: " cerr << li << ": warning: "
<< "Array dimensions in incomplete port declarations " << "Array dimensions in incomplete port declarations "
<< "are currently ignored." << endl; << "are currently ignored." << endl;
cerr << li.text << ":" << li.first_line << ": : " cerr << li << ": : "
<< "The dimensions specified in the net or variable " << "The dimensions specified in the net or variable "
<< "declaration will be used." << endl; << "declaration will be used." << endl;
delete cur->udims; delete cur->udims;
@ -3478,7 +3475,7 @@ void pform_set_port_type(const struct vlltype&li,
} }
} }
if (have_init_expr) { if (have_init_expr) {
cerr << li.text << ":" << li.first_line << ": error: " cerr << li << ": error: "
<< "Incomplete port declarations cannot be initialized." << "Incomplete port declarations cannot be initialized."
<< endl; << endl;
error_count += 1; error_count += 1;
@ -3663,8 +3660,7 @@ PProcess* pform_make_behavior(ivl_process_type_t type, Statement*st,
// always_latch statements. // always_latch statements.
if ((type == IVL_PR_ALWAYS_COMB) || (type == IVL_PR_ALWAYS_LATCH)) { if ((type == IVL_PR_ALWAYS_COMB) || (type == IVL_PR_ALWAYS_LATCH)) {
PEventStatement *tmp = new PEventStatement(true); PEventStatement *tmp = new PEventStatement(true);
tmp->set_file(st->get_file()); tmp->set_line(*st);
tmp->set_lineno(st->get_lineno());
tmp->set_statement(st); tmp->set_statement(st);
st = tmp; st = tmp;
} }

26
pform.h
View File

@ -183,9 +183,8 @@ extern void pform_module_define_port(const struct vlltype&li,
data_type_t*vtype, data_type_t*vtype,
std::list<named_pexpr_t>*attr); std::list<named_pexpr_t>*attr);
extern Module::port_t* pform_module_port_reference(perm_string name, extern Module::port_t* pform_module_port_reference(const struct vlltype&loc,
const char*file, perm_string name);
unsigned lineno);
extern void pform_endmodule(const char*, bool inside_celldefine, extern void pform_endmodule(const char*, bool inside_celldefine,
Module::UCDriveType uc_drive_def); Module::UCDriveType uc_drive_def);
@ -204,17 +203,16 @@ extern void pform_set_constructor_return(PFunction*net);
extern void pform_end_class_declaration(const struct vlltype&loc); extern void pform_end_class_declaration(const struct vlltype&loc);
extern bool pform_in_class(); extern bool pform_in_class();
extern void pform_make_udp(perm_string name, std::list<perm_string>*parms, extern void pform_make_udp(const struct vlltype&loc, perm_string name,
std::list<perm_string>*parms,
std::vector<PWire*>*decl, std::list<std::string>*table, std::vector<PWire*>*decl, std::list<std::string>*table,
Statement*init, Statement*init);
const char*file, unsigned lineno);
extern void pform_make_udp(perm_string name, extern void pform_make_udp(const struct vlltype&loc, perm_string name,
bool sync_flag, perm_string out_name, bool sync_flag, perm_string out_name,
PExpr*sync_init, PExpr*sync_init,
std::list<perm_string>*parms, std::list<perm_string>*parms,
std::list<std::string>*table, std::list<std::string>*table);
const char*file, unsigned lineno);
/* /*
* Package related functions. * Package related functions.
*/ */
@ -462,8 +460,8 @@ extern void pform_mc_translate_on(bool flag);
extern std::vector<PWire*>* pform_make_udp_input_ports(std::list<perm_string>*); extern std::vector<PWire*>* pform_make_udp_input_ports(std::list<perm_string>*);
extern void pform_make_events(std::list<perm_string>*names, extern void pform_make_events(const struct vlltype&loc,
const char*file, unsigned lineno); std::list<perm_string>*names);
/* /*
* The makegate function creates a new gate (which need not have a * The makegate function creates a new gate (which need not have a
* name) and connects it to the specified wires. * name) and connects it to the specified wires.
@ -482,10 +480,10 @@ extern void pform_make_modgates(const struct vlltype&loc,
std::list<named_pexpr_t>*attr); std::list<named_pexpr_t>*attr);
/* Make a continuous assignment node, with optional bit- or part- select. */ /* Make a continuous assignment node, with optional bit- or part- select. */
extern void pform_make_pgassign_list(std::list<PExpr*>*alist, extern void pform_make_pgassign_list(const struct vlltype&loc,
std::list<PExpr*>*alist,
std::list<PExpr*>*del, std::list<PExpr*>*del,
struct str_pair_t str, struct str_pair_t str);
const char* fn, unsigned lineno);
extern std::vector<pform_tf_port_t>*pform_make_task_ports(const struct vlltype&loc, extern std::vector<pform_tf_port_t>*pform_make_task_ports(const struct vlltype&loc,
NetNet::PortType pt, NetNet::PortType pt,