Store user-supplied path to object in symbol_search results.
(wanted by next commit)
This commit is contained in:
parent
3b1b611a18
commit
b9863b4fde
32
elab_expr.cc
32
elab_expr.cc
|
|
@ -1305,7 +1305,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
|
||||||
|
|
||||||
if (debug_elaborate) {
|
if (debug_elaborate) {
|
||||||
cerr << get_fileline() << ": PECallFunction::test_width_method_: "
|
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_: "
|
cerr << get_fileline() << ": PECallFunction::test_width_method_: "
|
||||||
<< "search_results.path_tail: " << search_results.path_tail << endl;
|
<< "search_results.path_tail: " << search_results.path_tail << endl;
|
||||||
if (search_results.net)
|
if (search_results.net)
|
||||||
|
|
@ -1336,7 +1336,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
|
||||||
// <scope>.x.size();
|
// <scope>.x.size();
|
||||||
// In this example, x is a dynamic array.
|
// In this example, x is a dynamic array.
|
||||||
if (search_results.net && search_results.net->data_type()==IVL_VT_DARRAY
|
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;
|
NetNet*net = search_results.net;
|
||||||
const netdarray_t*darray = net->darray_type();
|
const netdarray_t*darray = net->darray_type();
|
||||||
|
|
@ -1359,7 +1359,7 @@ unsigned PECallFunction::test_width_method_(Design*, NetScope*,
|
||||||
// <scope>.x.size();
|
// <scope>.x.size();
|
||||||
// In this example, x is a queue.
|
// In this example, x is a queue.
|
||||||
if (search_results.net && search_results.net->data_type()==IVL_VT_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;
|
NetNet*net = search_results.net;
|
||||||
const netdarray_t*darray = net->darray_type();
|
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.
|
// x[e].len() is the length of the string.
|
||||||
if (search_results.net
|
if (search_results.net
|
||||||
&& (search_results.net->data_type()==IVL_VT_QUEUE || search_results.net->data_type()==IVL_VT_DARRAY)
|
&& (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;
|
NetNet*net = search_results.net;
|
||||||
const netdarray_t*darray = net->darray_type();
|
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: "
|
cerr << get_fileline() << ": PECallFunction::test_width: "
|
||||||
<< "search_results.net: " << search_results.net->name() << endl;
|
<< "search_results.net: " << search_results.net->name() << endl;
|
||||||
cerr << get_fileline() << ": PECallFunction::test_width: "
|
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: "
|
cerr << get_fileline() << ": PECallFunction::test_width: "
|
||||||
<< "search_results.path_tail: " << search_results.path_tail << endl;
|
<< "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: "
|
cerr << get_fileline() << ": PECallFunction::elaborate_expr: "
|
||||||
<< "search_results.par_val: " << *search_results.par_val << endl;
|
<< "search_results.par_val: " << *search_results.par_val << endl;
|
||||||
cerr << get_fileline() << ": PECallFunction::elaborate_expr: "
|
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: "
|
cerr << get_fileline() << ": PECallFunction::elaborate_expr: "
|
||||||
<< "search_results.path_tail: " << search_results.path_tail << endl;
|
<< "search_results.path_tail: " << search_results.path_tail << endl;
|
||||||
}
|
}
|
||||||
|
|
@ -2640,7 +2640,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
|
||||||
} else {
|
} else {
|
||||||
cerr << get_fileline() << ": error: "
|
cerr << get_fileline() << ": error: "
|
||||||
<< "Object " << scope_path(search_results.scope)
|
<< "Object " << scope_path(search_results.scope)
|
||||||
<< "." << search_results.path_item
|
<< "." << search_results.path_head.back()
|
||||||
<< " has no method \"" << search_results.path_tail
|
<< " has no method \"" << search_results.path_tail
|
||||||
<< "(...)\"." << endl;
|
<< "(...)\"." << endl;
|
||||||
des->errors += 1;
|
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)
|
<< " in " << scope_path(search_results.scope)
|
||||||
<< " is not a function." << endl;
|
<< " is not a function." << endl;
|
||||||
des->errors += 1;
|
des->errors += 1;
|
||||||
|
|
@ -2696,8 +2696,8 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
|
||||||
}
|
}
|
||||||
symbol_search_results use_search_results;
|
symbol_search_results use_search_results;
|
||||||
use_search_results.scope = scope;
|
use_search_results.scope = scope;
|
||||||
use_search_results.path_tail.push_back(search_results.path_item);
|
use_search_results.path_tail.push_back(search_results.path_head.back());
|
||||||
use_search_results.path_item = name_component_t(perm_string::literal(THIS_TOKEN));
|
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));
|
use_search_results.net = scope->find_signal(perm_string::literal(THIS_TOKEN));
|
||||||
ivl_assert(*this, use_search_results.net);
|
ivl_assert(*this, use_search_results.net);
|
||||||
|
|
||||||
|
|
@ -2931,7 +2931,7 @@ unsigned PECallFunction::elaborate_arguments_(Design*des, NetScope*scope,
|
||||||
*
|
*
|
||||||
* <scope>.x.len()
|
* <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.
|
* "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,
|
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_: "
|
cerr << get_fileline() << ": PECallFunction::elaborate_expr_method_: "
|
||||||
<< "search_results.scope: " << scope_path(search_results.scope) << endl;
|
<< "search_results.scope: " << scope_path(search_results.scope) << endl;
|
||||||
cerr << get_fileline() << ": PECallFunction::elaborate_expr_method_: "
|
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_: "
|
cerr << get_fileline() << ": PECallFunction::elaborate_expr_method_: "
|
||||||
<< "search_results.path_tail: " << search_results.path_tail << endl;
|
<< "search_results.path_tail: " << search_results.path_tail << endl;
|
||||||
if (search_results.net)
|
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]
|
// 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.
|
// expression and pass that to the len() method.
|
||||||
if (search_results.net && search_results.net->data_type()==IVL_VT_QUEUE
|
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;
|
NetNet*net = search_results.net;
|
||||||
const netdarray_t*darray = net->darray_type();
|
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.msb != 0);
|
||||||
ivl_assert(*this, use_index.lsb == 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
|
// Dynamic array methods. This handles the case that the located signal
|
||||||
// is a dynamic array, and there is no index.
|
// is a dynamic array, and there is no index.
|
||||||
if (search_results.net && search_results.net->data_type()==IVL_VT_DARRAY
|
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.
|
// Get the method name that we are looking for.
|
||||||
perm_string method_name = search_results.path_tail.back().name;
|
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 methods. This handles the case that the located signal is a
|
||||||
// QUEUE object, and there is a method.
|
// QUEUE object, and there is a method.
|
||||||
if (search_results.net && search_results.net->data_type()==IVL_VT_QUEUE
|
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.
|
// Get the method name that we are looking for.
|
||||||
perm_string method_name = search_results.path_tail.back().name;
|
perm_string method_name = search_results.path_tail.back().name;
|
||||||
|
|
|
||||||
23
netmisc.h
23
netmisc.h
|
|
@ -38,8 +38,8 @@ class netsarray_t;
|
||||||
*
|
*
|
||||||
* The search will stop when it finds a component in the path that is an
|
* 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
|
* 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
|
* array, then the search for a.b[1].c will stop at a.b, leave a.b[1] in
|
||||||
* path_item, and "c" in path_tail. It is up to the caller to then note that
|
* 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.
|
* "c" must be a method of some sort.
|
||||||
*/
|
*/
|
||||||
struct symbol_search_results {
|
struct symbol_search_results {
|
||||||
|
|
@ -84,17 +84,16 @@ struct symbol_search_results {
|
||||||
// If this is a named event, ...
|
// If this is a named event, ...
|
||||||
NetEvent*eve;
|
NetEvent*eve;
|
||||||
|
|
||||||
// Store bread crumbs of the search here. The path_tail is the parts of
|
// Store bread crumbs of the search here. The path_tail is the parts
|
||||||
// the original path that were not found, or are after an object (and so
|
// of the original path that were not found, or are after an object
|
||||||
// are probably members or methods.)
|
// (and so are probably members or methods).
|
||||||
pform_name_t path_tail;
|
pform_name_t path_tail;
|
||||||
// The path_item is the final name (possibly before the path_tail items)
|
// The path_head is the parts of the original path that were found.
|
||||||
// that identifies the object. This name may contain index
|
// The last item in path_head is the final name (possibly before the
|
||||||
// expressions. Parts of the path left of the path_item name scopes, and
|
// path_tail items) that identifies the object. This name may contain
|
||||||
// should have all been resolved into the "scope" member above. If the
|
// index expressions. If the search result is a scope, then this name
|
||||||
// search result is a scope, then this path_item is also the name of the
|
// is also the name of the scope identified.
|
||||||
// scope identified.
|
pform_name_t path_head;
|
||||||
name_component_t path_item;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -151,23 +151,26 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
||||||
// endmodule
|
// endmodule
|
||||||
if (!passed_module_boundary) {
|
if (!passed_module_boundary) {
|
||||||
if (NetNet*net = scope->find_signal(path_tail.name)) {
|
if (NetNet*net = scope->find_signal(path_tail.name)) {
|
||||||
|
path.push_back(path_tail);
|
||||||
res->scope = scope;
|
res->scope = scope;
|
||||||
res->net = net;
|
res->net = net;
|
||||||
res->path_item = path_tail;
|
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)) {
|
||||||
|
path.push_back(path_tail);
|
||||||
res->scope = scope;
|
res->scope = scope;
|
||||||
res->eve = eve;
|
res->eve = eve;
|
||||||
res->path_item = path_tail;
|
res->path_head = path;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const NetExpr*par = scope->get_parameter(des, path_tail.name, res->par_type)) {
|
if (const NetExpr*par = scope->get_parameter(des, path_tail.name, res->par_type)) {
|
||||||
|
path.push_back(path_tail);
|
||||||
res->scope = scope;
|
res->scope = scope;
|
||||||
res->par_val = par;
|
res->par_val = par;
|
||||||
res->path_item = path_tail;
|
res->path_head = path;
|
||||||
return true;
|
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);
|
ivl_type_t prop_type = clsnet->get_prop_type(pidx);
|
||||||
const netuarray_t*tmp_ua = dynamic_cast<const netuarray_t*>(prop_type);
|
const netuarray_t*tmp_ua = dynamic_cast<const netuarray_t*>(prop_type);
|
||||||
if (tmp_ua) prop_type = tmp_ua->element_type();
|
if (tmp_ua) prop_type = tmp_ua->element_type();
|
||||||
|
path.push_back(path_tail);
|
||||||
res->scope = scope;
|
res->scope = scope;
|
||||||
res->cls_val = prop_type;
|
res->cls_val = prop_type;
|
||||||
res->path_item = path_tail;
|
res->path_head = path;
|
||||||
return true;
|
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
|
// 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:
|
// refers to. This item might be:
|
||||||
// <scope>.s
|
// <scope>.s
|
||||||
// <scope>.s[n]
|
// <scope>.s[n]
|
||||||
|
|
@ -208,8 +212,9 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
||||||
if (flag) {
|
if (flag) {
|
||||||
cerr << li->get_fileline() << ": XXXXX: Errors evaluating scope index" << endl;
|
cerr << li->get_fileline() << ": XXXXX: Errors evaluating scope index" << endl;
|
||||||
} else if (NetScope*chld = scope->child(path_item)) {
|
} else if (NetScope*chld = scope->child(path_item)) {
|
||||||
|
path.push_back(path_tail);
|
||||||
res->scope = chld;
|
res->scope = chld;
|
||||||
res->path_item = path_tail;
|
res->path_head = path;
|
||||||
return true;
|
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 by the name "foo" as well. In general, anything within
|
||||||
// "foo" can use the name "foo" to reference it.
|
// "foo" can use the name "foo" to reference it.
|
||||||
if (scope->type()==NetScope::MODULE && scope->module_name()==path_tail.name) {
|
if (scope->type()==NetScope::MODULE && scope->module_name()==path_tail.name) {
|
||||||
|
path.push_back(path_tail);
|
||||||
res->scope = scope;
|
res->scope = scope;
|
||||||
res->path_item = path_tail;
|
res->path_head = path;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -275,8 +281,9 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
||||||
hname_t path_item (path_tail.name);
|
hname_t path_item (path_tail.name);
|
||||||
scope = des->find_scope(path_item);
|
scope = des->find_scope(path_item);
|
||||||
if (scope) {
|
if (scope) {
|
||||||
|
path.push_back(path_tail);
|
||||||
res->scope = scope;
|
res->scope = scope;
|
||||||
res->path_item = path_tail;
|
res->path_head = path;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue