Add parser cleanup to vhdlpp
This commit adds removal of global objects in the execution of vhdlpp. This includes deleting design entities and the global parse scope.
This commit is contained in:
parent
eb98ed9ce2
commit
50f7e1b69e
|
|
@ -56,6 +56,7 @@ const char*dump_design_entities_path = 0;
|
|||
const char*dump_libraries_path = 0;
|
||||
|
||||
extern void dump_libraries(ostream&file);
|
||||
extern void parser_cleanup();
|
||||
|
||||
static void process_debug_token(const char*word)
|
||||
{
|
||||
|
|
@ -141,21 +142,25 @@ int main(int argc, char*argv[])
|
|||
dump_design_entities(file);
|
||||
}
|
||||
|
||||
if (errors > 0)
|
||||
if (errors > 0) {
|
||||
parser_cleanup();
|
||||
return 2;
|
||||
}
|
||||
|
||||
errors = elaborate_entities();
|
||||
if (errors > 0) {
|
||||
fprintf(stderr, "%d errors elaborating design.\n", errors);
|
||||
parser_cleanup();
|
||||
return 3;
|
||||
}
|
||||
|
||||
errors = emit_entities();
|
||||
if (errors > 0) {
|
||||
fprintf(stderr, "%d errors emitting design.\n", errors);
|
||||
parser_cleanup();
|
||||
return 4;
|
||||
}
|
||||
|
||||
lex_strings.cleanup();
|
||||
parser_cleanup();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,31 @@ void preload_global_types(void)
|
|||
generate_global_types(active_scope);
|
||||
}
|
||||
|
||||
//Remove the scope created at the beginning of parser's work.
|
||||
//After the parsing active_scope should keep it's address
|
||||
|
||||
static void delete_global_scope(void)
|
||||
{
|
||||
active_scope->destroy_global_scope();
|
||||
delete active_scope;
|
||||
}
|
||||
|
||||
//delete global entities that were gathered over the parsing process
|
||||
static void delete_design_entities(void)
|
||||
{
|
||||
for(map<perm_string,Entity*>::iterator cur = design_entities.begin()
|
||||
; cur != design_entities.end(); ++cur)
|
||||
delete cur->second;
|
||||
}
|
||||
|
||||
//clean the mess caused by the parser
|
||||
void parser_cleanup(void)
|
||||
{
|
||||
delete_design_entities();
|
||||
delete_global_scope();
|
||||
lex_strings.cleanup();
|
||||
}
|
||||
|
||||
const VType*parse_type_by_name(perm_string name)
|
||||
{
|
||||
return active_scope->find_type(name);
|
||||
|
|
|
|||
Loading…
Reference in New Issue