Skip to content

Commit

Permalink
Fix vpiScope iterator.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Jul 14, 2002
1 parent 329e943 commit fbaf8f9
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions vvp/vpi_scope.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_scope.cc,v 1.17 2002/07/12 18:23:30 steve Exp $"
#ident "$Id: vpi_scope.cc,v 1.18 2002/07/14 02:52:05 steve Exp $"
#endif

# include "compile.h"
Expand Down Expand Up @@ -97,21 +97,37 @@ static vpiHandle scope_get_handle(int code, vpiHandle obj)
return 0;
}

/* Handle subclasses for vpiTypes */
static inline int compare_types(int code, int type)
{
if (code == type ||
code == vpiScope &&
type == vpiModule ||
type == vpiFunction ||
type == vpiTask ||
type == vpiNamedBegin ||
type == vpiNamedFork)
{
return 1;
} else
return 0;
}

static vpiHandle module_iter_subset(int code, struct __vpiScope*ref)
{
unsigned mcnt = 0, ncnt = 0;
vpiHandle*args;

for (unsigned idx = 0 ; idx < ref->nintern ; idx += 1)
if (ref->intern[idx]->vpi_type->type_code == code)
if (compare_types(code, ref->intern[idx]->vpi_type->type_code))
mcnt += 1;

if (mcnt == 0)
return 0;

args = (vpiHandle*)calloc(mcnt, sizeof(vpiHandle));
for (unsigned idx = 0 ; idx < ref->nintern ; idx += 1)
if (ref->intern[idx]->vpi_type->type_code == code)
if (compare_types(code, ref->intern[idx]->vpi_type->type_code))
args[ncnt++] = ref->intern[idx];

assert(ncnt == mcnt);
Expand All @@ -136,7 +152,7 @@ static vpiHandle module_iter(int code, vpiHandle obj)

switch (code) {
case vpiInternalScope:
return vpip_make_iterator(ref->nintern, ref->intern, false);
return module_iter_subset(vpiScope, ref);

/* Generate and iterator for all the modules contained
in this scope. */
Expand Down Expand Up @@ -392,6 +408,9 @@ void vpip_attach_to_current_scope(vpiHandle obj)

/*
* $Log: vpi_scope.cc,v $
* Revision 1.18 2002/07/14 02:52:05 steve
* Fix vpiScope iterator.
*
* Revision 1.17 2002/07/12 18:23:30 steve
* Use result buf for event and scope names.
*
Expand Down

0 comments on commit fbaf8f9

Please sign in to comment.