C++-ify more __vpiScope members.
This commit is contained in:
parent
fff69390ac
commit
2fedb4942e
12
vvp/stop.cc
12
vvp/stop.cc
|
|
@ -81,8 +81,8 @@ static void cmd_call(unsigned argc, char*argv[])
|
||||||
vpip_make_root_iterator(table, ntable);
|
vpip_make_root_iterator(table, ntable);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
table = stop_current_scope->intern;
|
table = &stop_current_scope->intern[0];
|
||||||
ntable = stop_current_scope->nintern;
|
ntable = stop_current_scope->intern.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is an array of vpiHandles, for passing to the created
|
/* This is an array of vpiHandles, for passing to the created
|
||||||
|
|
@ -221,8 +221,8 @@ static void cmd_list(unsigned, char*[])
|
||||||
vpip_make_root_iterator(table, ntable);
|
vpip_make_root_iterator(table, ntable);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
table = stop_current_scope->intern;
|
table = &stop_current_scope->intern[0];
|
||||||
ntable = stop_current_scope->nintern;
|
ntable = stop_current_scope->intern.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%u items in this scope:\n", ntable);
|
printf("%u items in this scope:\n", ntable);
|
||||||
|
|
@ -327,8 +327,8 @@ static void cmd_push(unsigned argc, char* argv[])
|
||||||
struct __vpiScope*child = 0;
|
struct __vpiScope*child = 0;
|
||||||
|
|
||||||
if (stop_current_scope) {
|
if (stop_current_scope) {
|
||||||
table = stop_current_scope->intern;
|
table = &stop_current_scope->intern[0];
|
||||||
ntable = stop_current_scope->nintern;
|
ntable = stop_current_scope->intern.size();
|
||||||
} else {
|
} else {
|
||||||
vpip_make_root_iterator(table, ntable);
|
vpip_make_root_iterator(table, ntable);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1260,7 +1260,7 @@ static vpiHandle find_name(const char *name, vpiHandle handle)
|
||||||
rtn = handle;
|
rtn = handle;
|
||||||
|
|
||||||
/* brute force search for the name in all objects in this scope */
|
/* brute force search for the name in all objects in this scope */
|
||||||
for (unsigned i = 0 ; i < ref->nintern ; i += 1) {
|
for (unsigned i = 0 ; i < ref->intern.size() ; i += 1) {
|
||||||
/* The standard says that since a port does not have a full
|
/* The standard says that since a port does not have a full
|
||||||
* name it cannot be found by name. Because of this we need
|
* name it cannot be found by name. Because of this we need
|
||||||
* to skip ports here so the correct handle can be located. */
|
* to skip ports here so the correct handle can be located. */
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
# include <map>
|
# include <map>
|
||||||
# include <set>
|
# include <set>
|
||||||
# include <string>
|
# include <string>
|
||||||
|
# include <vector>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Added to use some "vvp_fun_modpath_src"
|
* Added to use some "vvp_fun_modpath_src"
|
||||||
|
|
@ -265,8 +266,7 @@ class __vpiScope : public __vpiHandle {
|
||||||
struct __vpiScopedSTime scoped_stime;
|
struct __vpiScopedSTime scoped_stime;
|
||||||
struct __vpiScopedRealtime scoped_realtime;
|
struct __vpiScopedRealtime scoped_realtime;
|
||||||
/* Keep an array of internal scope items. */
|
/* Keep an array of internal scope items. */
|
||||||
class __vpiHandle**intern;
|
std::vector<class __vpiHandle*> intern;
|
||||||
unsigned nintern;
|
|
||||||
/* Set of types */
|
/* Set of types */
|
||||||
std::map<std::string,class_type*> classes;
|
std::map<std::string,class_type*> classes;
|
||||||
/* Keep an array of items to be automatically allocated */
|
/* Keep an array of items to be automatically allocated */
|
||||||
|
|
|
||||||
|
|
@ -25,27 +25,26 @@
|
||||||
#ifdef CHECK_WITH_VALGRIND
|
#ifdef CHECK_WITH_VALGRIND
|
||||||
# include "vvp_cleanup.h"
|
# include "vvp_cleanup.h"
|
||||||
#endif
|
#endif
|
||||||
|
# include <vector>
|
||||||
# include <cstring>
|
# include <cstring>
|
||||||
# include <cstdlib>
|
# include <cstdlib>
|
||||||
# include <cassert>
|
# include <cassert>
|
||||||
# include "ivl_alloc.h"
|
# include "ivl_alloc.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
static vpiHandle *vpip_root_table_ptr = 0;
|
static vector<vpiHandle> vpip_root_table;
|
||||||
static unsigned vpip_root_table_cnt = 0;
|
|
||||||
|
|
||||||
vpiHandle vpip_make_root_iterator(void)
|
vpiHandle vpip_make_root_iterator(void)
|
||||||
{
|
{
|
||||||
assert(vpip_root_table_ptr);
|
return vpip_make_iterator(vpip_root_table.size(),
|
||||||
assert(vpip_root_table_cnt);
|
&vpip_root_table[0], false);
|
||||||
return vpip_make_iterator(vpip_root_table_cnt,
|
|
||||||
vpip_root_table_ptr, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vpip_make_root_iterator(__vpiHandle**&table, unsigned&ntable)
|
void vpip_make_root_iterator(__vpiHandle**&table, unsigned&ntable)
|
||||||
{
|
{
|
||||||
table = vpip_root_table_ptr;
|
table = &vpip_root_table[0];
|
||||||
ntable = vpip_root_table_cnt;
|
ntable = vpip_root_table.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CHECK_WITH_VALGRIND
|
#ifdef CHECK_WITH_VALGRIND
|
||||||
|
|
@ -148,16 +147,14 @@ static void delete_sub_scopes(struct __vpiScope *scope)
|
||||||
|
|
||||||
void root_table_delete(void)
|
void root_table_delete(void)
|
||||||
{
|
{
|
||||||
for (unsigned idx = 0; idx < vpip_root_table_cnt; idx += 1) {
|
for (unsigned idx = 0; idx < vpip_root_table.size(); idx += 1) {
|
||||||
struct __vpiScope *scope = static_cast<__vpiScope *>
|
struct __vpiScope *scope = static_cast<__vpiScope *>
|
||||||
(vpip_root_table_ptr[idx]);
|
(vpip_root_table[idx]);
|
||||||
vthreads_delete(scope);
|
vthreads_delete(scope);
|
||||||
delete_sub_scopes(scope);
|
delete_sub_scopes(scope);
|
||||||
delete scope;
|
delete scope;
|
||||||
}
|
}
|
||||||
free(vpip_root_table_ptr);
|
vpip_root_table.clear();
|
||||||
vpip_root_table_ptr = 0;
|
|
||||||
vpip_root_table_cnt = 0;
|
|
||||||
|
|
||||||
/* Clean up all the class definitions. */
|
/* Clean up all the class definitions. */
|
||||||
for (unsigned idx = 0; idx < class_list_count; idx += 1) {
|
for (unsigned idx = 0; idx < class_list_count; idx += 1) {
|
||||||
|
|
@ -298,7 +295,7 @@ static vpiHandle module_iter_subset(int code, struct __vpiScope*ref)
|
||||||
unsigned mcnt = 0, ncnt = 0;
|
unsigned mcnt = 0, ncnt = 0;
|
||||||
vpiHandle*args;
|
vpiHandle*args;
|
||||||
|
|
||||||
for (unsigned idx = 0 ; idx < ref->nintern ; idx += 1)
|
for (unsigned idx = 0 ; idx < ref->intern.size() ; idx += 1)
|
||||||
if (compare_types(code, ref->intern[idx]->get_type_code()))
|
if (compare_types(code, ref->intern[idx]->get_type_code()))
|
||||||
mcnt += 1;
|
mcnt += 1;
|
||||||
|
|
||||||
|
|
@ -306,7 +303,7 @@ static vpiHandle module_iter_subset(int code, struct __vpiScope*ref)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
args = (vpiHandle*)calloc(mcnt, sizeof(vpiHandle));
|
args = (vpiHandle*)calloc(mcnt, sizeof(vpiHandle));
|
||||||
for (unsigned idx = 0 ; idx < ref->nintern ; idx += 1)
|
for (unsigned idx = 0 ; idx < ref->intern.size() ; idx += 1)
|
||||||
if (compare_types(code, ref->intern[idx]->get_type_code()))
|
if (compare_types(code, ref->intern[idx]->get_type_code()))
|
||||||
args[ncnt++] = ref->intern[idx];
|
args[ncnt++] = ref->intern[idx];
|
||||||
|
|
||||||
|
|
@ -463,16 +460,7 @@ static struct __vpiScope*current_scope = 0;
|
||||||
void vpip_attach_to_scope(struct __vpiScope*scope, vpiHandle obj)
|
void vpip_attach_to_scope(struct __vpiScope*scope, vpiHandle obj)
|
||||||
{
|
{
|
||||||
assert(scope);
|
assert(scope);
|
||||||
unsigned idx = scope->nintern++;
|
scope->intern.push_back(obj);
|
||||||
|
|
||||||
if (scope->intern == 0)
|
|
||||||
scope->intern = (vpiHandle*)
|
|
||||||
malloc(sizeof(vpiHandle));
|
|
||||||
else
|
|
||||||
scope->intern = (vpiHandle*)
|
|
||||||
realloc(scope->intern, sizeof(vpiHandle)*scope->nintern);
|
|
||||||
|
|
||||||
scope->intern[idx] = obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -522,8 +510,6 @@ compile_scope_decl(char*label, char*type, char*name, char*tname,
|
||||||
scope->lineno = (unsigned) lineno;
|
scope->lineno = (unsigned) lineno;
|
||||||
scope->def_file_idx = (unsigned) def_file_idx;
|
scope->def_file_idx = (unsigned) def_file_idx;
|
||||||
scope->def_lineno = (unsigned) def_lineno;
|
scope->def_lineno = (unsigned) def_lineno;
|
||||||
scope->intern = 0;
|
|
||||||
scope->nintern = 0;
|
|
||||||
scope->item = 0;
|
scope->item = 0;
|
||||||
scope->nitem = 0;
|
scope->nitem = 0;
|
||||||
scope->live_contexts = 0;
|
scope->live_contexts = 0;
|
||||||
|
|
@ -556,11 +542,7 @@ compile_scope_decl(char*label, char*type, char*name, char*tname,
|
||||||
} else {
|
} else {
|
||||||
scope->scope = 0x0;
|
scope->scope = 0x0;
|
||||||
|
|
||||||
unsigned cnt = vpip_root_table_cnt + 1;
|
vpip_root_table.push_back(scope);
|
||||||
vpip_root_table_ptr = (vpiHandle*)
|
|
||||||
realloc(vpip_root_table_ptr, cnt * sizeof(vpiHandle));
|
|
||||||
vpip_root_table_ptr[vpip_root_table_cnt] = scope;
|
|
||||||
vpip_root_table_cnt = cnt;
|
|
||||||
|
|
||||||
/* Root scopes inherit time_units and precision from the
|
/* Root scopes inherit time_units and precision from the
|
||||||
system precision. */
|
system precision. */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue