Add lexical position information to PEIdent objects.
This commit is contained in:
parent
8b3f0d63b4
commit
079108f32b
14
PExpr.cc
14
PExpr.cc
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998-2021 Stephen Williams <steve@icarus.com>
|
||||
* Copyright (c) 1998-2024 Stephen Williams <steve@icarus.com>
|
||||
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
|
|
@ -360,19 +360,19 @@ const verireal& PEFNumber::value() const
|
|||
return *value_;
|
||||
}
|
||||
|
||||
PEIdent::PEIdent(const pform_name_t&that)
|
||||
: path_(that), no_implicit_sig_(false)
|
||||
PEIdent::PEIdent(const pform_name_t&that, unsigned lexical_pos)
|
||||
: path_(that), lexical_pos_(lexical_pos), no_implicit_sig_(false)
|
||||
{
|
||||
}
|
||||
|
||||
PEIdent::PEIdent(perm_string s, bool no_implicit_sig)
|
||||
: no_implicit_sig_(no_implicit_sig)
|
||||
PEIdent::PEIdent(perm_string s, unsigned lexical_pos, bool no_implicit_sig)
|
||||
: lexical_pos_(lexical_pos), no_implicit_sig_(no_implicit_sig)
|
||||
{
|
||||
path_.name.push_back(name_component_t(s));
|
||||
}
|
||||
|
||||
PEIdent::PEIdent(PPackage*pkg, const pform_name_t&that)
|
||||
: path_(pkg, that), no_implicit_sig_(true)
|
||||
PEIdent::PEIdent(PPackage*pkg, const pform_name_t&that, unsigned lexical_pos)
|
||||
: path_(pkg, that), lexical_pos_(lexical_pos), no_implicit_sig_(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
9
PExpr.h
9
PExpr.h
|
|
@ -336,9 +336,9 @@ class PEFNumber : public PExpr {
|
|||
class PEIdent : public PExpr {
|
||||
|
||||
public:
|
||||
explicit PEIdent(perm_string, bool no_implicit_sig=false);
|
||||
explicit PEIdent(PPackage*pkg, const pform_name_t&name);
|
||||
explicit PEIdent(const pform_name_t&);
|
||||
explicit PEIdent(perm_string, unsigned lexical_pos, bool no_implicit_sig=false);
|
||||
explicit PEIdent(PPackage*pkg, const pform_name_t&name, unsigned lexical_pos);
|
||||
explicit PEIdent(const pform_name_t&, unsigned lexical_pos);
|
||||
~PEIdent();
|
||||
|
||||
// Add another name to the string of hierarchy that is the
|
||||
|
|
@ -386,8 +386,11 @@ class PEIdent : public PExpr {
|
|||
|
||||
const pform_scoped_name_t& path() const { return path_; }
|
||||
|
||||
unsigned lexical_pos() const { return lexical_pos_; }
|
||||
|
||||
private:
|
||||
pform_scoped_name_t path_;
|
||||
unsigned lexical_pos_;
|
||||
bool no_implicit_sig_;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
# include <algorithm>
|
||||
# include <typeinfo>
|
||||
# include <climits>
|
||||
# include <cstdlib>
|
||||
# include <cstring>
|
||||
# include <iostream>
|
||||
|
|
@ -1272,7 +1273,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
|
|||
symbol_search_results sr;
|
||||
symbol_search(this, des, scope, path_, &sr);
|
||||
if (sr.net != 0) {
|
||||
pins[j] = new PEIdent(rmod->ports[j]->name, true);
|
||||
pins[j] = new PEIdent(rmod->ports[j]->name, UINT_MAX, true);
|
||||
pins[j]->set_lineno(get_lineno());
|
||||
pins[j]->set_file(get_file());
|
||||
}
|
||||
|
|
|
|||
21
parse.y
21
parse.y
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
# include "config.h"
|
||||
|
||||
# include <climits>
|
||||
# include <cstdarg>
|
||||
# include "parse_misc.h"
|
||||
# include "compiler.h"
|
||||
|
|
@ -1084,7 +1085,7 @@ class_new /* IEEE1800-2005 A.2.4 */
|
|||
$$ = new_expr;
|
||||
}
|
||||
| K_new hierarchy_identifier
|
||||
{ PEIdent*tmpi = new PEIdent(*$2);
|
||||
{ PEIdent*tmpi = new PEIdent(*$2, @2.lexical_pos);
|
||||
FILE_NAME(tmpi, @2);
|
||||
PENewCopy*tmp = new PENewCopy(tmpi);
|
||||
FILE_NAME(tmp, @1);
|
||||
|
|
@ -3167,7 +3168,7 @@ delay_value_simple
|
|||
}
|
||||
}
|
||||
| IDENTIFIER
|
||||
{ PEIdent*tmp = new PEIdent(lex_strings.make($1));
|
||||
{ PEIdent*tmp = new PEIdent(lex_strings.make($1), @1.lexical_pos);
|
||||
FILE_NAME(tmp, @1);
|
||||
$$ = tmp;
|
||||
delete[]$1;
|
||||
|
|
@ -3963,13 +3964,13 @@ expr_primary
|
|||
$$ = tmp;
|
||||
}
|
||||
| K_this
|
||||
{ PEIdent*tmp = new PEIdent(perm_string::literal(THIS_TOKEN));
|
||||
{ PEIdent*tmp = new PEIdent(perm_string::literal(THIS_TOKEN), UINT_MAX);
|
||||
FILE_NAME(tmp,@1);
|
||||
$$ = tmp;
|
||||
}
|
||||
|
||||
| class_hierarchy_identifier
|
||||
{ PEIdent*tmp = new PEIdent(*$1);
|
||||
{ PEIdent*tmp = new PEIdent(*$1, @1.lexical_pos);
|
||||
FILE_NAME(tmp, @1);
|
||||
delete $1;
|
||||
$$ = tmp;
|
||||
|
|
@ -4633,7 +4634,7 @@ lpvalue
|
|||
}
|
||||
|
||||
| class_hierarchy_identifier
|
||||
{ PEIdent*tmp = new PEIdent(*$1);
|
||||
{ PEIdent*tmp = new PEIdent(*$1, @1.lexical_pos);
|
||||
FILE_NAME(tmp, @1);
|
||||
$$ = tmp;
|
||||
delete $1;
|
||||
|
|
@ -5729,7 +5730,7 @@ port_name
|
|||
named_pexpr_t*tmp = new named_pexpr_t;
|
||||
FILE_NAME(tmp, @$);
|
||||
tmp->name = lex_strings.make($3);
|
||||
tmp->parm = new PEIdent(lex_strings.make($3), true);
|
||||
tmp->parm = new PEIdent(lex_strings.make($3), @3.lexical_pos, true);
|
||||
FILE_NAME(tmp->parm, @3);
|
||||
delete[]$3;
|
||||
delete $1;
|
||||
|
|
@ -5814,7 +5815,7 @@ port_reference
|
|||
pform_name_t pname;
|
||||
pname.push_back(ntmp);
|
||||
|
||||
PEIdent*wtmp = new PEIdent(pname);
|
||||
PEIdent*wtmp = new PEIdent(pname, @1.lexical_pos);
|
||||
FILE_NAME(wtmp, @1);
|
||||
|
||||
Module::port_t*ptmp = new Module::port_t;
|
||||
|
|
@ -5837,7 +5838,7 @@ port_reference
|
|||
pform_name_t pname;
|
||||
pname.push_back(ntmp);
|
||||
|
||||
PEIdent*tmp = new PEIdent(pname);
|
||||
PEIdent*tmp = new PEIdent(pname, @1.lexical_pos);
|
||||
FILE_NAME(tmp, @1);
|
||||
|
||||
Module::port_t*ptmp = new Module::port_t;
|
||||
|
|
@ -5850,7 +5851,7 @@ port_reference
|
|||
| IDENTIFIER '[' error ']'
|
||||
{ yyerror(@1, "error: Invalid port bit select");
|
||||
Module::port_t*ptmp = new Module::port_t;
|
||||
PEIdent*wtmp = new PEIdent(lex_strings.make($1));
|
||||
PEIdent*wtmp = new PEIdent(lex_strings.make($1), @1.lexical_pos);
|
||||
FILE_NAME(wtmp, @1);
|
||||
ptmp->name = lex_strings.make($1);
|
||||
ptmp->expr.push_back(wtmp);
|
||||
|
|
@ -7168,7 +7169,7 @@ udp_sequ_entry
|
|||
udp_initial
|
||||
: K_initial IDENTIFIER '=' number ';'
|
||||
{ PExpr*etmp = new PENumber($4);
|
||||
PEIdent*itmp = new PEIdent(lex_strings.make($2));
|
||||
PEIdent*itmp = new PEIdent(lex_strings.make($2), @2.lexical_pos);
|
||||
PAssign*atmp = new PAssign(itmp, etmp);
|
||||
FILE_NAME(atmp, @2);
|
||||
delete[]$2;
|
||||
|
|
|
|||
12
pform.cc
12
pform.cc
|
|
@ -708,7 +708,7 @@ PEIdent* pform_new_ident(const struct vlltype&loc, const pform_name_t&name)
|
|||
if (gn_system_verilog())
|
||||
check_potential_imports(loc, name.front().name, false);
|
||||
|
||||
return new PEIdent(name);
|
||||
return new PEIdent(name, loc.lexical_pos);
|
||||
}
|
||||
|
||||
PTrigger* pform_new_trigger(const struct vlltype&loc, PPackage*pkg,
|
||||
|
|
@ -1376,7 +1376,7 @@ Module::port_t* pform_module_port_reference(const struct vlltype&loc,
|
|||
perm_string name)
|
||||
{
|
||||
Module::port_t*ptmp = new Module::port_t;
|
||||
PEIdent*tmp = new PEIdent(name);
|
||||
PEIdent*tmp = new PEIdent(name, loc.lexical_pos);
|
||||
FILE_NAME(tmp, loc);
|
||||
ptmp->name = name;
|
||||
ptmp->expr.push_back(tmp);
|
||||
|
|
@ -2486,7 +2486,7 @@ void pform_make_var_init(const struct vlltype&li,
|
|||
return;
|
||||
}
|
||||
|
||||
PEIdent*lval = new PEIdent(name);
|
||||
PEIdent*lval = new PEIdent(name, li.lexical_pos);
|
||||
FILE_NAME(lval, li);
|
||||
PAssign*ass = new PAssign(lval, expr, !gn_system_verilog(), true);
|
||||
FILE_NAME(ass, li);
|
||||
|
|
@ -2666,7 +2666,7 @@ void pform_makewire(const struct vlltype&li,
|
|||
if (type == NetNet::REG || type == NetNet::IMPLICIT_REG) {
|
||||
pform_make_var_init(li, first->name, expr);
|
||||
} else {
|
||||
PEIdent*lval = new PEIdent(first->name);
|
||||
PEIdent*lval = new PEIdent(first->name, li.lexical_pos);
|
||||
FILE_NAME(lval, li);
|
||||
PGAssign*ass = pform_make_pgassign(lval, expr, delay, str);
|
||||
FILE_NAME(ass, li);
|
||||
|
|
@ -2797,7 +2797,7 @@ PExpr* pform_genvar_inc_dec(const struct vlltype&loc, const char*name, bool inc_
|
|||
{
|
||||
pform_requires_sv(loc, "Increment/decrement operator");
|
||||
|
||||
PExpr*lval = new PEIdent(lex_strings.make(name));
|
||||
PExpr*lval = new PEIdent(lex_strings.make(name), loc.lexical_pos);
|
||||
PExpr*rval = new PENumber(new verinum(1));
|
||||
FILE_NAME(lval, loc);
|
||||
FILE_NAME(rval, loc);
|
||||
|
|
@ -2813,7 +2813,7 @@ PExpr* pform_genvar_compressed(const struct vlltype &loc, const char *name,
|
|||
{
|
||||
pform_requires_sv(loc, "Compressed assignment operator");
|
||||
|
||||
PExpr *lval = new PEIdent(lex_strings.make(name));
|
||||
PExpr *lval = new PEIdent(lex_strings.make(name), loc.lexical_pos);
|
||||
FILE_NAME(lval, loc);
|
||||
|
||||
PExpr *expr;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008-2021 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2008-2024 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -47,10 +47,10 @@ PExpr* pform_make_branch_probe_expression(const struct vlltype&loc,
|
|||
char*name, char*n1, char*n2)
|
||||
{
|
||||
vector<named_pexpr_t> parms (2);
|
||||
parms[0].parm = new PEIdent(lex_strings.make(n1));
|
||||
parms[0].parm = new PEIdent(lex_strings.make(n1), loc.lexical_pos);
|
||||
FILE_NAME(parms[0].parm, loc);
|
||||
|
||||
parms[1].parm = new PEIdent(lex_strings.make(n2));
|
||||
parms[1].parm = new PEIdent(lex_strings.make(n2), loc.lexical_pos);
|
||||
FILE_NAME(parms[1].parm, loc);
|
||||
|
||||
PECallFunction*res = new PECallFunction(lex_strings.make(name), parms);
|
||||
|
|
@ -62,7 +62,7 @@ PExpr* pform_make_branch_probe_expression(const struct vlltype&loc,
|
|||
char*name, char*branch_name)
|
||||
{
|
||||
vector<named_pexpr_t> parms (1);
|
||||
parms[0].parm = new PEIdent(lex_strings.make(branch_name));
|
||||
parms[0].parm = new PEIdent(lex_strings.make(branch_name), loc.lexical_pos);
|
||||
FILE_NAME(parms[0].parm, loc);
|
||||
|
||||
PECallFunction*res = new PECallFunction(lex_strings.make(name), parms);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2021 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2012-2024 Stephen Williams (steve@icarus.com)
|
||||
* Copyright CERN 2013 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
|
|
@ -232,7 +232,7 @@ PExpr* pform_package_ident(const struct vlltype&loc,
|
|||
PPackage*pkg, pform_name_t*ident_name)
|
||||
{
|
||||
ivl_assert(loc, ident_name);
|
||||
PEIdent*tmp = new PEIdent(pkg, *ident_name);
|
||||
PEIdent*tmp = new PEIdent(pkg, *ident_name, loc.lexical_pos);
|
||||
FILE_NAME(tmp, loc);
|
||||
return tmp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012-2021 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2012-2024 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -91,7 +91,7 @@ void pform_class_property(const struct vlltype&loc,
|
|||
FILE_NAME(&pform_cur_class->type->properties[curp->name], loc);
|
||||
|
||||
if (PExpr*rval = curp->expr.release()) {
|
||||
PExpr*lval = new PEIdent(curp->name);
|
||||
PExpr*lval = new PEIdent(curp->name, loc.lexical_pos);
|
||||
FILE_NAME(lval, loc);
|
||||
PAssign*tmp = new PAssign(lval, rval);
|
||||
FILE_NAME(tmp, loc);
|
||||
|
|
|
|||
Loading…
Reference in New Issue