Store user-supplied path to object in symbol_search results.

(wanted by next commit)
This commit is contained in:
Martin Whitaker 2021-07-31 12:42:53 +01:00
parent 3b1b611a18
commit b9863b4fde
3 changed files with 42 additions and 36 deletions

View File

@ -1305,7 +1305,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
if (debug_elaborate) {
cerr << get_fileline() << ": PECallFunction::test_width_method_: "
<< "search_results.path_item: " << search_results.path_item << endl;
<< "search_results.path_head: " << search_results.path_head << endl;
cerr << get_fileline() << ": PECallFunction::test_width_method_: "
<< "search_results.path_tail: " << search_results.path_tail << endl;
if (search_results.net)
@ -1336,7 +1336,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
// <scope>.x.size();
// In this example, x is a dynamic array.
if (search_results.net && search_results.net->data_type()==IVL_VT_DARRAY
&& search_results.path_item.index.empty()) {
&& search_results.path_head.back().index.empty()) {
NetNet*net = search_results.net;
const netdarray_t*darray = net->darray_type();
@ -1359,7 +1359,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
// <scope>.x.size();
// In this example, x is a queue.
if (search_results.net && search_results.net->data_type()==IVL_VT_QUEUE
&& search_results.path_item.index.empty()) {
&& search_results.path_head.back().index.empty()) {
NetNet*net = search_results.net;
const netdarray_t*darray = net->darray_type();
@ -1392,7 +1392,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
// x[e].len() is the length of the string.
if (search_results.net
&& (search_results.net->data_type()==IVL_VT_QUEUE || search_results.net->data_type()==IVL_VT_DARRAY)
&& search_results.path_item.index.size()) {
&& search_results.path_head.back().index.size()) {
NetNet*net = search_results.net;
const netdarray_t*darray = net->darray_type();
@ -1522,7 +1522,7 @@ unsigned PECallFunction::test_width(Design*des, NetScope*scope,
cerr << get_fileline() << ": PECallFunction::test_width: "
<< "search_results.net: " << search_results.net->name() << endl;
cerr << get_fileline() << ": PECallFunction::test_width: "
<< "search_results.path_item: " << search_results.path_item << endl;
<< "search_results.path_head: " << search_results.path_head << endl;
cerr << get_fileline() << ": PECallFunction::test_width: "
<< "search_results.path_tail: " << search_results.path_tail << endl;
}
@ -2611,7 +2611,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
cerr << get_fileline() << ": PECallFunction::elaborate_expr: "
<< "search_results.par_val: " << *search_results.par_val << endl;
cerr << get_fileline() << ": PECallFunction::elaborate_expr: "
<< "search_results.path_item: " << search_results.path_item << endl;
<< "search_results.path_head: " << search_results.path_head << endl;
cerr << get_fileline() << ": PECallFunction::elaborate_expr: "
<< "search_results.path_tail: " << search_results.path_tail << endl;
}
@ -2640,7 +2640,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
} else {
cerr << get_fileline() << ": error: "
<< "Object " << scope_path(search_results.scope)
<< "." << search_results.path_item
<< "." << search_results.path_head.back()
<< " has no method \"" << search_results.path_tail
<< "(...)\"." << endl;
des->errors += 1;
@ -2648,7 +2648,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
}
}
cerr << get_fileline() << ": error: Object " << search_results.path_item
cerr << get_fileline() << ": error: Object " << search_results.path_head.back()
<< " in " << scope_path(search_results.scope)
<< " is not a function." << endl;
des->errors += 1;
@ -2696,8 +2696,8 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
}
symbol_search_results use_search_results;
use_search_results.scope = scope;
use_search_results.path_tail.push_back(search_results.path_item);
use_search_results.path_item = name_component_t(perm_string::literal(THIS_TOKEN));
use_search_results.path_tail.push_back(search_results.path_head.back());
use_search_results.path_head.push_back(name_component_t(perm_string::literal(THIS_TOKEN)));
use_search_results.net = scope->find_signal(perm_string::literal(THIS_TOKEN));
ivl_assert(*this, use_search_results.net);
@ -2931,7 +2931,7 @@ unsigned PECallFunction::elaborate_arguments_(Design*des, NetScope*scope,
*
* <scope>.x.len()
*
* Then net refers to object named x, and path_item is "x". The method is
* Then net refers to object named x, and path_head is "<scope>.x". The method is
* "len" in path_tail, and if x is a string object, we can handle the case.
*/
NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
@ -2957,7 +2957,7 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
cerr << get_fileline() << ": PECallFunction::elaborate_expr_method_: "
<< "search_results.scope: " << scope_path(search_results.scope) << endl;
cerr << get_fileline() << ": PECallFunction::elaborate_expr_method_: "
<< "search_results.path_item: " << search_results.path_item << endl;
<< "search_results.path_head: " << search_results.path_head << endl;
cerr << get_fileline() << ": PECallFunction::elaborate_expr_method_: "
<< "search_results.path_tail: " << search_results.path_tail << endl;
if (search_results.net)
@ -2992,11 +2992,11 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
// If x is a queue of strings, then x[e] is a string. Elaborate the x[e]
// expression and pass that to the len() method.
if (search_results.net && search_results.net->data_type()==IVL_VT_QUEUE
&& search_results.path_item.index.size()==1) {
&& search_results.path_head.back().index.size()==1) {
NetNet*net = search_results.net;
const netdarray_t*darray = net->darray_type();
const index_component_t&use_index = search_results.path_item.index.back();
const index_component_t&use_index = search_results.path_head.back().index.back();
ivl_assert(*this, use_index.msb != 0);
ivl_assert(*this, use_index.lsb == 0);
@ -3022,7 +3022,7 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
// Dynamic array methods. This handles the case that the located signal
// is a dynamic array, and there is no index.
if (search_results.net && search_results.net->data_type()==IVL_VT_DARRAY
&& search_results.path_item.index.size()==0) {
&& search_results.path_head.back().index.size()==0) {
// Get the method name that we are looking for.
perm_string method_name = search_results.path_tail.back().name;
@ -3047,7 +3047,7 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope,
// Queue methods. This handles the case that the located signal is a
// QUEUE object, and there is a method.
if (search_results.net && search_results.net->data_type()==IVL_VT_QUEUE
&& search_results.path_item.index.size()==0) {
&& search_results.path_head.back().index.size()==0) {
// Get the method name that we are looking for.
perm_string method_name = search_results.path_tail.back().name;

View File

@ -38,8 +38,8 @@ class netsarray_t;
*
* The search will stop when it finds a component in the path that is an
* object of some sort (other then a scope. So for example, if a.b is an
* array, then the search for a.b[1].c will stop at a.b, leave b[1] in
* path_item, and "c" in path_tail. It is up to the caller to then note that
* array, then the search for a.b[1].c will stop at a.b, leave a.b[1] in
* path_head, and "c" in path_tail. It is up to the caller to then note that
* "c" must be a method of some sort.
*/
struct symbol_search_results {
@ -84,17 +84,16 @@ struct symbol_search_results {
// If this is a named event, ...
NetEvent*eve;
// Store bread crumbs of the search here. The path_tail is the parts of
// the original path that were not found, or are after an object (and so
// are probably members or methods.)
// Store bread crumbs of the search here. The path_tail is the parts
// of the original path that were not found, or are after an object
// (and so are probably members or methods).
pform_name_t path_tail;
// The path_item is the final name (possibly before the path_tail items)
// that identifies the object. This name may contain index
// expressions. Parts of the path left of the path_item name scopes, and
// should have all been resolved into the "scope" member above. If the
// search result is a scope, then this path_item is also the name of the
// scope identified.
name_component_t path_item;
// The path_head is the parts of the original path that were found.
// The last item in path_head is the final name (possibly before the
// path_tail items) that identifies the object. This name may contain
// index expressions. If the search result is a scope, then this name
// is also the name of the scope identified.
pform_name_t path_head;
};
/*

View File

@ -151,23 +151,26 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
// endmodule
if (!passed_module_boundary) {
if (NetNet*net = scope->find_signal(path_tail.name)) {
path.push_back(path_tail);
res->scope = scope;
res->net = net;
res->path_item = path_tail;
res->path_head = path;
return true;
}
if (NetEvent*eve = scope->find_event(path_tail.name)) {
path.push_back(path_tail);
res->scope = scope;
res->eve = eve;
res->path_item = path_tail;
res->path_head = path;
return true;
}
if (const NetExpr*par = scope->get_parameter(des, path_tail.name, res->par_type)) {
path.push_back(path_tail);
res->scope = scope;
res->par_val = par;
res->path_item = path_tail;
res->path_head = path;
return true;
}
@ -179,9 +182,10 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
ivl_type_t prop_type = clsnet->get_prop_type(pidx);
const netuarray_t*tmp_ua = dynamic_cast<const netuarray_t*>(prop_type);
if (tmp_ua) prop_type = tmp_ua->element_type();
path.push_back(path_tail);
res->scope = scope;
res->cls_val = prop_type;
res->path_item = path_tail;
res->path_head = path;
return true;
}
}
@ -193,7 +197,7 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
}
// Could not find an object. Maybe this is a child scope name? If
// so, evaluate the path conponents to find the exact scope this
// so, evaluate the path components to find the exact scope this
// refers to. This item might be:
// <scope>.s
// <scope>.s[n]
@ -208,8 +212,9 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
if (flag) {
cerr << li->get_fileline() << ": XXXXX: Errors evaluating scope index" << endl;
} else if (NetScope*chld = scope->child(path_item)) {
path.push_back(path_tail);
res->scope = chld;
res->path_item = path_tail;
res->path_head = path;
return true;
}
}
@ -232,8 +237,9 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
// foo by the name "foo" as well. In general, anything within
// "foo" can use the name "foo" to reference it.
if (scope->type()==NetScope::MODULE && scope->module_name()==path_tail.name) {
path.push_back(path_tail);
res->scope = scope;
res->path_item = path_tail;
res->path_head = path;
return true;
}
@ -275,8 +281,9 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
hname_t path_item (path_tail.name);
scope = des->find_scope(path_item);
if (scope) {
path.push_back(path_tail);
res->scope = scope;
res->path_item = path_tail;
res->path_head = path;
return true;
}
}