Add an enum type to the appropriate scope and add valgrind cleanup code.
Add the enum type to the scope when it is created. Also delete the type when checking with valgrind.
This commit is contained in:
parent
5a9e4aaec7
commit
19307ba9dc
|
|
@ -19,6 +19,9 @@
|
|||
|
||||
# include "compile.h"
|
||||
# include "enum_type.h"
|
||||
#ifdef CHECK_WITH_VALGRIND
|
||||
# include "vvp_cleanup.h"
|
||||
#endif
|
||||
# include <iostream>
|
||||
# include <cassert>
|
||||
|
||||
|
|
@ -172,6 +175,7 @@ void compile_enum2_type(char*label, long width, bool signed_flag,
|
|||
|
||||
assert(idx == spec->names.size());
|
||||
compile_vpi_symbol(label, vpi_handle(spec));
|
||||
vpip_attach_to_current_scope(vpi_handle(spec));
|
||||
|
||||
free(label);
|
||||
delete names;
|
||||
|
|
@ -198,7 +202,22 @@ void compile_enum4_type(char*label, long width, bool signed_flag,
|
|||
|
||||
assert(idx == spec->names.size());
|
||||
compile_vpi_symbol(label, vpi_handle(spec));
|
||||
vpip_attach_to_current_scope(vpi_handle(spec));
|
||||
|
||||
free(label);
|
||||
delete names;
|
||||
}
|
||||
|
||||
#ifdef CHECK_WITH_VALGRIND
|
||||
void enum_delete(vpiHandle item)
|
||||
{
|
||||
struct __vpiEnumTypespec*obj = (struct __vpiEnumTypespec*) item;
|
||||
|
||||
for (vector<enumconst_s>::iterator iter = obj->names.begin();
|
||||
iter != obj->names.end(); ++ iter ) {
|
||||
delete [] iter->name;
|
||||
}
|
||||
|
||||
delete obj;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@ static void delete_sub_scopes(struct __vpiScope *scope)
|
|||
case vpiRealVar:
|
||||
real_delete((scope->intern)[idx]);
|
||||
break;
|
||||
case vpiEnumTypespec:
|
||||
enum_delete((scope->intern)[idx]);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Need support for type: %d\n",
|
||||
scope->intern[idx]->vpi_type->type_code);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __vvp_cleanup_H
|
||||
#define __vvp_cleanup_H
|
||||
/*
|
||||
* Copyright (c) 2009 Cary R. (cygcary@yahoo.com)
|
||||
* Copyright (c) 2009-2011 Cary R. (cygcary@yahoo.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -43,6 +43,7 @@ extern void A_delete(struct __vpiHandle *item);
|
|||
extern void PV_delete(struct __vpiHandle *item);
|
||||
extern void constant_delete(struct __vpiHandle *item);
|
||||
extern void contexts_delete(struct __vpiScope *scope);
|
||||
extern void enum_delete(struct __vpiHandle *item);
|
||||
extern void memory_delete(struct __vpiHandle *item);
|
||||
extern void named_event_delete(struct __vpiHandle *item);
|
||||
extern void parameter_delete(struct __vpiHandle *item);
|
||||
|
|
|
|||
Loading…
Reference in New Issue