vhdlpp: Fixing memory leaks and muting valgrind.
This commit is contained in:
parent
b711f16f05
commit
214c940a1a
|
|
@ -101,6 +101,7 @@ ExpObjAttribute::ExpObjAttribute(ExpName*base, perm_string name, list<Expression
|
|||
|
||||
ExpObjAttribute::~ExpObjAttribute()
|
||||
{
|
||||
delete base_;
|
||||
}
|
||||
|
||||
Expression*ExpObjAttribute::clone() const
|
||||
|
|
@ -121,10 +122,6 @@ ExpTypeAttribute::ExpTypeAttribute(const VType*base, perm_string name, list<Expr
|
|||
{
|
||||
}
|
||||
|
||||
ExpTypeAttribute::~ExpTypeAttribute()
|
||||
{
|
||||
}
|
||||
|
||||
Expression*ExpTypeAttribute::clone() const
|
||||
{
|
||||
return new ExpTypeAttribute(base_, name_, clone_args());
|
||||
|
|
@ -778,12 +775,14 @@ double ExpTime::to_fs() const
|
|||
}
|
||||
|
||||
ExpRange::ExpRange(Expression*left, Expression*right, range_dir_t direction)
|
||||
: left_(left), right_(right), direction_(direction), range_expr_(false)
|
||||
: left_(left), right_(right), direction_(direction), range_expr_(false),
|
||||
range_base_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
ExpRange::ExpRange(ExpName*base, bool reverse_range)
|
||||
: direction_(AUTO), range_expr_(true), range_base_(base), range_reverse_(reverse_range)
|
||||
: left_(NULL), right_(NULL), direction_(AUTO), range_expr_(true),
|
||||
range_base_(base), range_reverse_(reverse_range)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -832,7 +831,8 @@ Expression*ExpRange::left()
|
|||
{
|
||||
if(range_expr_ && !left_)
|
||||
// TODO check if it is an object or type
|
||||
left_ = new ExpObjAttribute(range_base_, ExpAttribute::LEFT, NULL);
|
||||
left_ = new ExpObjAttribute(static_cast<ExpName*>(range_base_->clone()),
|
||||
ExpAttribute::LEFT, NULL);
|
||||
|
||||
return left_;
|
||||
}
|
||||
|
|
@ -841,7 +841,7 @@ Expression*ExpRange::right()
|
|||
{
|
||||
if(range_expr_ && !right_)
|
||||
// TODO check if it is an object or type
|
||||
right_ = new ExpObjAttribute(range_base_, ExpAttribute::RIGHT, NULL);
|
||||
|
||||
right_ = new ExpObjAttribute(static_cast<ExpName*>(range_base_->clone()),
|
||||
ExpAttribute::RIGHT, NULL);
|
||||
return right_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ class ExpObjAttribute : public ExpAttribute {
|
|||
class ExpTypeAttribute : public ExpAttribute {
|
||||
public:
|
||||
ExpTypeAttribute(const VType*base, perm_string name, std::list<Expression*>*args);
|
||||
~ExpTypeAttribute();
|
||||
// no destructor - VType objects (base_) are shared between many expressions
|
||||
|
||||
Expression*clone() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -1264,8 +1264,8 @@ file_declaration
|
|||
|
||||
// add file_open() call in 'initial' block
|
||||
params.push_back(new ExpName(*cur));
|
||||
params.push_back($5->filename());
|
||||
params.push_back($5->kind());
|
||||
params.push_back($5->filename()->clone());
|
||||
params.push_back($5->kind()->clone());
|
||||
ProcedureCall*fopen_call = new ProcedureCall(perm_string::literal("file_open"), ¶ms);
|
||||
active_scope->add_initializer(fopen_call);
|
||||
|
||||
|
|
@ -1274,6 +1274,8 @@ file_declaration
|
|||
params.push_back(new ExpName(*cur));
|
||||
ProcedureCall*fclose_call = new ProcedureCall(perm_string::literal("file_close"), ¶ms);
|
||||
active_scope->add_finalizer(fclose_call);
|
||||
|
||||
delete $5;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@
|
|||
class named_expr_t {
|
||||
|
||||
public:
|
||||
named_expr_t (perm_string n, Expression*e) : name_(n), expr_(e) { }
|
||||
named_expr_t(perm_string n, Expression*e) : name_(n), expr_(e) { }
|
||||
~named_expr_t() { delete expr_; }
|
||||
|
||||
perm_string name() const { return name_; }
|
||||
Expression* expr() const { return expr_; }
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ void ScopeBase::cleanup()
|
|||
* objects from the other scopes untouched.
|
||||
*/
|
||||
delete_all(new_signals_);
|
||||
delete_all(new_variables_);
|
||||
delete_all(new_components_);
|
||||
delete_all(cur_types_);
|
||||
delete_all(cur_constants_);
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ ProcedureCall::ProcedureCall(perm_string name, std::list<Expression*>* param_lis
|
|||
for(std::list<Expression*>::const_iterator it = param_list->begin();
|
||||
it != param_list->end(); ++it)
|
||||
{
|
||||
param_list_->push_back(new named_expr_t(empty_perm_string, (*it)->clone()));
|
||||
param_list_->push_back(new named_expr_t(empty_perm_string, *it));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,6 +199,8 @@ ProcedureCall::~ProcedureCall()
|
|||
param_list_->pop_front();
|
||||
delete cur;
|
||||
}
|
||||
|
||||
delete param_list_;
|
||||
}
|
||||
|
||||
ReturnStmt::ReturnStmt(Expression*val)
|
||||
|
|
|
|||
|
|
@ -46,20 +46,20 @@ const VTypeArray primitive_UNSIGNED(&primitive_STDLOGIC, vector<VTypeArra
|
|||
void generate_global_types(ActiveScope*res)
|
||||
{
|
||||
// boolean
|
||||
list<perm_string>*enum_BOOLEAN_vals = new list<perm_string>;
|
||||
enum_BOOLEAN_vals->push_back(perm_string::literal("false"));
|
||||
enum_BOOLEAN_vals->push_back(perm_string::literal("true"));
|
||||
VTypeEnum*enum_BOOLEAN = new VTypeEnum(enum_BOOLEAN_vals);
|
||||
list<perm_string> enum_BOOLEAN_vals;
|
||||
enum_BOOLEAN_vals.push_back(perm_string::literal("false"));
|
||||
enum_BOOLEAN_vals.push_back(perm_string::literal("true"));
|
||||
VTypeEnum*enum_BOOLEAN = new VTypeEnum(&enum_BOOLEAN_vals);
|
||||
type_BOOLEAN.set_definition(enum_BOOLEAN);
|
||||
std_types[type_BOOLEAN.peek_name()] = &type_BOOLEAN;
|
||||
std_enums.push_back(enum_BOOLEAN);
|
||||
|
||||
// file_open_kind
|
||||
list<perm_string>*enum_FILE_OPEN_KIND_vals = new list<perm_string>;
|
||||
enum_FILE_OPEN_KIND_vals->push_back(perm_string::literal("read_mode"));
|
||||
enum_FILE_OPEN_KIND_vals->push_back(perm_string::literal("write_mode"));
|
||||
enum_FILE_OPEN_KIND_vals->push_back(perm_string::literal("append_mode"));
|
||||
VTypeEnum*enum_FILE_OPEN_KIND = new VTypeEnum(enum_FILE_OPEN_KIND_vals);
|
||||
list<perm_string> enum_FILE_OPEN_KIND_vals;
|
||||
enum_FILE_OPEN_KIND_vals.push_back(perm_string::literal("read_mode"));
|
||||
enum_FILE_OPEN_KIND_vals.push_back(perm_string::literal("write_mode"));
|
||||
enum_FILE_OPEN_KIND_vals.push_back(perm_string::literal("append_mode"));
|
||||
VTypeEnum*enum_FILE_OPEN_KIND = new VTypeEnum(&enum_FILE_OPEN_KIND_vals);
|
||||
type_FILE_OPEN_KIND.set_definition(enum_FILE_OPEN_KIND);
|
||||
std_types[type_FILE_OPEN_KIND.peek_name()] = &type_FILE_OPEN_KIND;
|
||||
std_enums.push_back(enum_FILE_OPEN_KIND);
|
||||
|
|
@ -80,10 +80,12 @@ void delete_global_types()
|
|||
{
|
||||
typedef_context_t typedef_ctx;
|
||||
for(map<perm_string, VTypeDef*>::iterator cur = std_types.begin();
|
||||
cur != std_types.end() ; ++ cur) {
|
||||
cur != std_types.end(); ++cur) {
|
||||
delete cur->second->peek_definition();
|
||||
delete cur->second;
|
||||
}
|
||||
|
||||
// std_enums are destroyed above
|
||||
}
|
||||
|
||||
const VTypeEnum*find_std_enum_name(perm_string name)
|
||||
|
|
|
|||
Loading…
Reference in New Issue