Modify symbol_search() to only return declared nets and named events.
This only applies to simple identifiers. Only return a match if the lexical position of the identifier being searched is later in the source text than the lexical position of a matching symbol.
This commit is contained in:
parent
e22831553d
commit
649fbb9a59
2
PExpr.cc
2
PExpr.cc
|
|
@ -440,7 +440,7 @@ void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
|
||||||
bool PEIdent::has_aa_term(Design*des, NetScope*scope) const
|
bool PEIdent::has_aa_term(Design*des, NetScope*scope) const
|
||||||
{
|
{
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
if (!symbol_search(this, des, scope, path_, &sr))
|
if (!symbol_search(this, des, scope, path_, lexical_pos_, &sr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Class properties are not considered automatic since a non-blocking
|
// Class properties are not considered automatic since a non-blocking
|
||||||
|
|
|
||||||
10
elab_expr.cc
10
elab_expr.cc
|
|
@ -1731,7 +1731,7 @@ unsigned PECallFunction::test_width(Design*des, NetScope*scope,
|
||||||
|
|
||||||
// Search for the symbol. This should turn up a scope.
|
// Search for the symbol. This should turn up a scope.
|
||||||
symbol_search_results search_results;
|
symbol_search_results search_results;
|
||||||
bool search_flag = symbol_search(this, des, scope, path_, &search_results);
|
bool search_flag = symbol_search(this, des, scope, path_, UINT_MAX, &search_results);
|
||||||
|
|
||||||
if (debug_elaborate) {
|
if (debug_elaborate) {
|
||||||
cerr << get_fileline() << ": PECallFunction::test_width: "
|
cerr << get_fileline() << ": PECallFunction::test_width: "
|
||||||
|
|
@ -2843,7 +2843,7 @@ NetExpr* PECallFunction::elaborate_expr_(Design*des, NetScope*scope,
|
||||||
|
|
||||||
// Search for the symbol. This should turn up a scope.
|
// Search for the symbol. This should turn up a scope.
|
||||||
symbol_search_results search_results;
|
symbol_search_results search_results;
|
||||||
bool search_flag = symbol_search(this, des, scope, path_, &search_results);
|
bool search_flag = symbol_search(this, des, scope, path_, UINT_MAX, &search_results);
|
||||||
|
|
||||||
if (debug_elaborate) {
|
if (debug_elaborate) {
|
||||||
cerr << get_fileline() << ": PECallFunction::elaborate_expr: "
|
cerr << get_fileline() << ": PECallFunction::elaborate_expr: "
|
||||||
|
|
@ -4334,7 +4334,7 @@ ivl_type_t PEIdent::resolve_type_(Design *des, const symbol_search_results &sr,
|
||||||
unsigned PEIdent::test_width(Design*des, NetScope*scope, width_mode_t&mode)
|
unsigned PEIdent::test_width(Design*des, NetScope*scope, width_mode_t&mode)
|
||||||
{
|
{
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
bool found_symbol = symbol_search(this, des, scope, path_, &sr);
|
bool found_symbol = symbol_search(this, des, scope, path_, lexical_pos_, &sr);
|
||||||
|
|
||||||
// If there is a part/bit select expression, then process it
|
// If there is a part/bit select expression, then process it
|
||||||
// here. This constrains the results no matter what kind the
|
// here. This constrains the results no matter what kind the
|
||||||
|
|
@ -4490,7 +4490,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
|
||||||
bool need_const = NEED_CONST & flags;
|
bool need_const = NEED_CONST & flags;
|
||||||
|
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
symbol_search(this, des, scope, path_, &sr);
|
symbol_search(this, des, scope, path_, lexical_pos_, &sr);
|
||||||
|
|
||||||
if (!sr.net) {
|
if (!sr.net) {
|
||||||
cerr << get_fileline() << ": error: Unable to bind variable `"
|
cerr << get_fileline() << ": error: Unable to bind variable `"
|
||||||
|
|
@ -4680,7 +4680,7 @@ NetExpr* PEIdent::elaborate_expr_(Design*des, NetScope*scope,
|
||||||
// a net called "b" in the scope "main.a" and with a member
|
// a net called "b" in the scope "main.a" and with a member
|
||||||
// named "c". symbol_search() handles this for us.
|
// named "c". symbol_search() handles this for us.
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
symbol_search(this, des, scope, path_, &sr);
|
symbol_search(this, des, scope, path_, lexical_pos_, &sr);
|
||||||
|
|
||||||
// If the identifier name is a parameter name, then return
|
// If the identifier name is a parameter name, then return
|
||||||
// the parameter value.
|
// the parameter value.
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des,
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
symbol_search(this, des, scope, path_, &sr);
|
symbol_search(this, des, scope, path_, lexical_pos_, &sr);
|
||||||
|
|
||||||
NetNet *reg = sr.net;
|
NetNet *reg = sr.net;
|
||||||
pform_name_t &member_path = sr.path_tail;
|
pform_name_t &member_path = sr.path_tail;
|
||||||
|
|
|
||||||
|
|
@ -503,7 +503,7 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
|
||||||
ivl_assert(*this, scope);
|
ivl_assert(*this, scope);
|
||||||
|
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
symbol_search(this, des, scope, path_.name, &sr);
|
symbol_search(this, des, scope, path_.name, lexical_pos_, &sr);
|
||||||
|
|
||||||
if (sr.eve != 0) {
|
if (sr.eve != 0) {
|
||||||
cerr << get_fileline() << ": error: named events (" << path_
|
cerr << get_fileline() << ": error: named events (" << path_
|
||||||
|
|
@ -1113,7 +1113,7 @@ NetNet* PEIdent::elaborate_subport(Design*des, NetScope*scope) const
|
||||||
NetNet*PEIdent::elaborate_unpacked_net(Design*des, NetScope*scope) const
|
NetNet*PEIdent::elaborate_unpacked_net(Design*des, NetScope*scope) const
|
||||||
{
|
{
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
symbol_search(this, des, scope, path_, &sr);
|
symbol_search(this, des, scope, path_, lexical_pos_, &sr);
|
||||||
if (!sr.net) {
|
if (!sr.net) {
|
||||||
cerr << get_fileline() << ": error: Net " << path_
|
cerr << get_fileline() << ": error: Net " << path_
|
||||||
<< " is not defined in this context." << endl;
|
<< " is not defined in this context." << endl;
|
||||||
|
|
@ -1138,7 +1138,7 @@ bool PEIdent::is_collapsible_net(Design*des, NetScope*scope,
|
||||||
ivl_assert(*this, scope);
|
ivl_assert(*this, scope);
|
||||||
|
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
symbol_search(this, des, scope, path_.name, &sr);
|
symbol_search(this, des, scope, path_.name, lexical_pos_, &sr);
|
||||||
|
|
||||||
if (sr.eve != 0)
|
if (sr.eve != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
10
elaborate.cc
10
elaborate.cc
|
|
@ -1271,7 +1271,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
|
||||||
pform_name_t path_;
|
pform_name_t path_;
|
||||||
path_.push_back(name_component_t(rmod->ports[j]->name));
|
path_.push_back(name_component_t(rmod->ports[j]->name));
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
symbol_search(this, des, scope, path_, &sr);
|
symbol_search(this, des, scope, path_, UINT_MAX, &sr);
|
||||||
if (sr.net != 0) {
|
if (sr.net != 0) {
|
||||||
pins[j] = new PEIdent(rmod->ports[j]->name, UINT_MAX, true);
|
pins[j] = new PEIdent(rmod->ports[j]->name, UINT_MAX, true);
|
||||||
pins[j]->set_lineno(get_lineno());
|
pins[j]->set_lineno(get_lineno());
|
||||||
|
|
@ -3825,7 +3825,7 @@ NetProc* PCallTask::elaborate_method_(Design*des, NetScope*scope,
|
||||||
// (internally represented as "@") is handled by there being a
|
// (internally represented as "@") is handled by there being a
|
||||||
// "this" object in the instance scope.
|
// "this" object in the instance scope.
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
symbol_search(this, des, scope, use_path, &sr);
|
symbol_search(this, des, scope, use_path, UINT_MAX, &sr);
|
||||||
|
|
||||||
NetNet*net = sr.net;
|
NetNet*net = sr.net;
|
||||||
if (net == 0)
|
if (net == 0)
|
||||||
|
|
@ -4908,7 +4908,7 @@ cerr << endl;
|
||||||
|
|
||||||
if (PEIdent*id = dynamic_cast<PEIdent*>(expr_[idx]->expr())) {
|
if (PEIdent*id = dynamic_cast<PEIdent*>(expr_[idx]->expr())) {
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
symbol_search(this, des, scope, id->path(), &sr);
|
symbol_search(this, des, scope, id->path(), id->lexical_pos(), &sr);
|
||||||
|
|
||||||
if (sr.scope && sr.eve) {
|
if (sr.scope && sr.eve) {
|
||||||
wa->add_event(sr.eve);
|
wa->add_event(sr.eve);
|
||||||
|
|
@ -6038,7 +6038,7 @@ NetProc* PTrigger::elaborate(Design*des, NetScope*scope) const
|
||||||
ivl_assert(*this, scope);
|
ivl_assert(*this, scope);
|
||||||
|
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
if (!symbol_search(this, des, scope, event_, &sr)) {
|
if (!symbol_search(this, des, scope, event_, UINT_MAX, &sr)) {
|
||||||
cerr << get_fileline() << ": error: event <" << event_ << ">"
|
cerr << get_fileline() << ": error: event <" << event_ << ">"
|
||||||
<< " not found." << endl;
|
<< " not found." << endl;
|
||||||
des->errors += 1;
|
des->errors += 1;
|
||||||
|
|
@ -6062,7 +6062,7 @@ NetProc* PNBTrigger::elaborate(Design*des, NetScope*scope) const
|
||||||
ivl_assert(*this, scope);
|
ivl_assert(*this, scope);
|
||||||
|
|
||||||
symbol_search_results sr;
|
symbol_search_results sr;
|
||||||
if (!symbol_search(this, des, scope, event_, &sr)) {
|
if (!symbol_search(this, des, scope, event_, UINT_MAX, &sr)) {
|
||||||
cerr << get_fileline() << ": error: event <" << event_ << ">"
|
cerr << get_fileline() << ": error: event <" << event_ << ">"
|
||||||
<< " not found." << endl;
|
<< " not found." << endl;
|
||||||
des->errors += 1;
|
des->errors += 1;
|
||||||
|
|
|
||||||
|
|
@ -106,11 +106,12 @@ static inline bool test_function_return_value(const symbol_search_results&search
|
||||||
}
|
}
|
||||||
|
|
||||||
extern bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
extern bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
||||||
pform_name_t path, struct symbol_search_results*res,
|
pform_name_t path, unsigned lexical_pos,
|
||||||
|
struct symbol_search_results*res,
|
||||||
NetScope*start_scope = nullptr, bool prefix_scope = false);
|
NetScope*start_scope = nullptr, bool prefix_scope = false);
|
||||||
|
|
||||||
extern bool symbol_search(const LineInfo *li, Design *des, NetScope *scope,
|
extern bool symbol_search(const LineInfo *li, Design *des, NetScope *scope,
|
||||||
const pform_scoped_name_t &path,
|
const pform_scoped_name_t &path, unsigned lexical_pos,
|
||||||
struct symbol_search_results*res);
|
struct symbol_search_results*res);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-2021 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2003-2024 Stephen Williams (steve@icarus.com)
|
||||||
* Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
|
* Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
|
|
@ -38,7 +38,8 @@ using namespace std;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
||||||
pform_name_t path, struct symbol_search_results*res,
|
pform_name_t path, unsigned lexical_pos,
|
||||||
|
struct symbol_search_results*res,
|
||||||
NetScope*start_scope, bool prefix_scope)
|
NetScope*start_scope, bool prefix_scope)
|
||||||
{
|
{
|
||||||
assert(scope);
|
assert(scope);
|
||||||
|
|
@ -68,8 +69,8 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
||||||
// recursively. Ideally, the result is a scope that we search
|
// recursively. Ideally, the result is a scope that we search
|
||||||
// for the tail key, but there are other special cases as well.
|
// for the tail key, but there are other special cases as well.
|
||||||
if (! path.empty()) {
|
if (! path.empty()) {
|
||||||
bool flag = symbol_search(li, des, scope, path, res, start_scope,
|
bool flag = symbol_search(li, des, scope, path, lexical_pos,
|
||||||
prefix_scope);
|
res, start_scope, prefix_scope);
|
||||||
if (! flag)
|
if (! flag)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -162,6 +163,7 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NetNet*net = scope->find_signal(path_tail.name)) {
|
if (NetNet*net = scope->find_signal(path_tail.name)) {
|
||||||
|
if (prefix_scope || (net->lexical_pos() <= lexical_pos)) {
|
||||||
path.push_back(path_tail);
|
path.push_back(path_tail);
|
||||||
res->scope = scope;
|
res->scope = scope;
|
||||||
res->net = net;
|
res->net = net;
|
||||||
|
|
@ -169,14 +171,17 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
||||||
res->path_head = path;
|
res->path_head = path;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (NetEvent*eve = scope->find_event(path_tail.name)) {
|
if (NetEvent*eve = scope->find_event(path_tail.name)) {
|
||||||
|
if (prefix_scope || (eve->lexical_pos() <= lexical_pos)) {
|
||||||
path.push_back(path_tail);
|
path.push_back(path_tail);
|
||||||
res->scope = scope;
|
res->scope = scope;
|
||||||
res->eve = eve;
|
res->eve = eve;
|
||||||
res->path_head = path;
|
res->path_head = path;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (const NetExpr*par = scope->get_parameter(des, path_tail.name, res->type)) {
|
if (const NetExpr*par = scope->get_parameter(des, path_tail.name, res->type)) {
|
||||||
path.push_back(path_tail);
|
path.push_back(path_tail);
|
||||||
|
|
@ -310,7 +315,7 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool symbol_search(const LineInfo *li, Design *des, NetScope *scope,
|
bool symbol_search(const LineInfo *li, Design *des, NetScope *scope,
|
||||||
const pform_scoped_name_t &path,
|
const pform_scoped_name_t &path, unsigned lexical_pos,
|
||||||
struct symbol_search_results *res)
|
struct symbol_search_results *res)
|
||||||
{
|
{
|
||||||
NetScope *search_scope = scope;
|
NetScope *search_scope = scope;
|
||||||
|
|
@ -323,6 +328,6 @@ bool symbol_search(const LineInfo *li, Design *des, NetScope *scope,
|
||||||
prefix_scope = true;
|
prefix_scope = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return symbol_search(li, des, search_scope, path.name, res, search_scope,
|
return symbol_search(li, des, search_scope, path.name, lexical_pos,
|
||||||
prefix_scope);
|
res, search_scope, prefix_scope);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue