File line information for expressions

Add ivl_target support for file and line numbers of expressions.
This commit is contained in:
Stephen Williams 2007-12-22 17:19:45 -05:00
parent 1db19b8703
commit 08752453b4
8 changed files with 40 additions and 12 deletions

View File

@ -512,6 +512,7 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope, int expr_w
NetESFunc*fun = new NetESFunc(peek_tail_name(path_), sfunc_type,
wid, nparms);
fun->set_line(*this);
if (sfunc_info->signed_flag)
fun->cast_signed(true);

View File

@ -29,6 +29,8 @@ ivl_expr_bits
ivl_expr_def
ivl_expr_dvalue
ivl_expr_event
ivl_expr_file
ivl_expr_lineno
ivl_expr_name
ivl_expr_opcode
ivl_expr_oper1

View File

@ -646,6 +646,8 @@ extern ivl_nexus_t ivl_event_pos(ivl_event_t net, unsigned idx);
extern ivl_expr_type_t ivl_expr_type(ivl_expr_t net);
extern ivl_variable_type_t ivl_expr_value(ivl_expr_t net);
extern const char*ivl_expr_file(ivl_expr_t net);
extern unsigned ivl_expr_lineno(ivl_expr_t net);
/* IVL_EX_NUMBER */
extern const char* ivl_expr_bits(ivl_expr_t net);

View File

@ -91,6 +91,17 @@ extern "C" ivl_expr_type_t ivl_expr_type(ivl_expr_t net)
return net->type_;
}
extern "C" const char*ivl_expr_file(ivl_expr_t net)
{
assert(net);
return net->file.str();
}
extern "C" unsigned ivl_expr_lineno(ivl_expr_t net)
{
assert(net);
return net->lineno;
}
inline static const char *basename(ivl_scope_t scope, const char *inst)
{

View File

@ -334,6 +334,7 @@ void dll_target::expr_sfunc(const NetESFunc*net)
assert(expr);
expr->type_ = IVL_EX_SFUNC;
FILE_NAME(expr, net);
expr->value_= net->expr_type();
expr->width_= net->expr_width();
expr->signed_ = net->has_sign()? 1 : 0;
@ -363,6 +364,7 @@ void dll_target::expr_ternary(const NetETernary*net)
assert(expr);
expr->type_ = IVL_EX_TERNARY;
FILE_NAME(expr, net);
expr->value_= net->expr_type();
expr->width_ = net->expr_width();
expr->signed_ = net->has_sign()? 1 : 0;
@ -429,6 +431,7 @@ void dll_target::expr_ufunc(const NetEUFunc*net)
assert(expr);
expr->type_ = IVL_EX_UFUNC;
FILE_NAME(expr, net);
expr->value_= net->expr_type();
expr->width_= net->expr_width();
expr->signed_ = net->has_sign()? 1 : 0;

View File

@ -34,16 +34,6 @@
#endif
# include <stdlib.h>
/*
* The FILE_NAME function is a shorthand for attaching file/line
* information to the statement object.
*/
static inline void FILE_NAME(ivl_statement_t stmt, const LineInfo*info)
{
stmt->file = info->get_file();
stmt->lineno = info->get_lineno();
}
bool dll_target::process(const NetProcTop*net)
{
ivl_process_t obj = (struct ivl_process_s*)

18
t-dll.h
View File

@ -199,6 +199,8 @@ struct ivl_event_s {
struct ivl_expr_s {
ivl_expr_type_t type_;
ivl_variable_type_t value_;
perm_string file;
unsigned lineno;
unsigned width_;
unsigned signed_ : 1;
@ -683,4 +685,20 @@ struct ivl_statement_s {
} u_;
};
/*
* The FILE_NAME function is a shorthand for attaching file/line
* information to the statement object.
*/
static inline void FILE_NAME(ivl_statement_t stmt, const LineInfo*info)
{
stmt->file = info->get_file();
stmt->lineno = info->get_lineno();
}
static inline void FILE_NAME(ivl_expr_t expr, const LineInfo*info)
{
expr->file = info->get_file();
expr->lineno = info->get_lineno();
}
#endif

View File

@ -233,8 +233,9 @@ void show_expression(ivl_expr_t net, unsigned ind)
break;
case IVL_EX_SFUNC:
fprintf(out, "%*s<function=\"%s\", width=%u, %s, type=%s>\n",
ind, "", ivl_expr_name(net), width, sign, vt);
fprintf(out, "%*s<function=\"%s\", width=%u, %s, type=%s file=%s:%u>\n",
ind, "", ivl_expr_name(net), width, sign, vt,
ivl_expr_file(net), ivl_expr_lineno(net));
{ unsigned cnt = ivl_expr_parms(net);
unsigned idx;
for (idx = 0 ; idx < cnt ; idx += 1)