diff --git a/ivl.def b/ivl.def index c3771a2ab..4dc4f3edf 100644 --- a/ivl.def +++ b/ivl.def @@ -197,6 +197,8 @@ ivl_scope_attr_cnt ivl_scope_attr_val ivl_scope_basename ivl_scope_children +ivl_scope_child +ivl_scope_childs ivl_scope_class ivl_scope_classes ivl_scope_def diff --git a/ivl_target.h b/ivl_target.h index ba9ad1e63..c8af23946 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -20,6 +20,7 @@ */ # include +# include /* Re the _CLASS define: clang++ wants this to be class to match the * definition, but clang (the C) compiler needs it to be a struct @@ -1678,6 +1679,11 @@ extern unsigned ivl_parameter_lineno(ivl_parameter_t net); * If the scope has no children, this method will return 0 and * otherwise do nothing. * + * ivl_scope_childs + * ivl_scope_child + * This is an alternative way of getting at the childs scopes of a + * given scope. + * * ivl_scope_def * Task definition scopes carry a task definition, in the form of * a statement. This method accesses that definition. The @@ -1779,6 +1785,8 @@ extern ivl_statement_t ivl_scope_def(ivl_scope_t net); extern const char* ivl_scope_def_file(ivl_scope_t net); extern unsigned ivl_scope_def_lineno(ivl_scope_t net); +extern size_t ivl_scope_childs(ivl_scope_t net); +extern ivl_scope_t ivl_scope_child(ivl_scope_t net, size_t idx); extern unsigned ivl_scope_classes(ivl_scope_t net); extern ivl_type_t ivl_scope_class(ivl_scope_t net, unsigned idx); extern unsigned ivl_scope_enumerates(ivl_scope_t net); diff --git a/t-dll-api.cc b/t-dll-api.cc index de411b481..902930314 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -1919,6 +1919,18 @@ extern "C" int ivl_scope_children(ivl_scope_t net, return 0; } +extern "C" size_t ivl_scope_childs(ivl_scope_t net) +{ + assert(net->child.size() == net->children.size()); + return net->child.size(); +} + +extern "C" ivl_scope_t ivl_scope_child(ivl_scope_t net, size_t idx) +{ + assert(net && idx < net->child.size()); + return net->child[idx]; +} + extern "C" ivl_type_t ivl_scope_class(ivl_scope_t net, unsigned idx) { assert(idx < net->classes.size()); diff --git a/t-dll.cc b/t-dll.cc index 160e621f1..f7151084d 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -2363,6 +2363,7 @@ void dll_target::scope(const NetScope*net) scop->parent = find_scope(des_, net->parent()); assert(scop->parent); scop->parent->children[net->fullname()] = scop; + scop->parent->child .push_back(scop); scop->nlog_ = 0; scop->log_ = 0; scop->nevent_ = 0; diff --git a/t-dll.h b/t-dll.h index 06e5708c8..810daddcd 100644 --- a/t-dll.h +++ b/t-dll.h @@ -639,6 +639,9 @@ struct ivl_process_s { struct ivl_scope_s { ivl_scope_t parent; std::map children; + // This is just like the children map above, but in vector + // form for convenient access. + std::vector child; perm_string name_; perm_string tname_;