diff options
author | Adrian Thurston <thurston@complang.org> | 2016-03-16 16:41:29 +0100 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2016-03-16 16:41:29 +0100 |
commit | b0ec721d644d5f333048c7ccfbb0259cf0c27dbb (patch) | |
tree | b56f7fe271f13821fc091dc43ef3ed79e7c865fd | |
parent | c64d1d965b47cac4376e5968b5dd88004a2e1a5d (diff) | |
download | colm-b0ec721d644d5f333048c7ccfbb0259cf0c27dbb.tar.gz |
extract stream file names so we can use them after the colm program is deleted
-rw-r--r-- | src/compiler.cc | 9 | ||||
-rw-r--r-- | src/compiler.h | 4 | ||||
-rw-r--r-- | src/loadcolm.cc | 2 | ||||
-rw-r--r-- | src/loadinit.cc | 1 |
4 files changed, 16 insertions, 0 deletions
diff --git a/src/compiler.cc b/src/compiler.cc index 3020d7f5..808c6e95 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -415,6 +415,15 @@ Compiler::~Compiler() /* Delete all the nodes in the action list. Will cause all the * string data that represents the actions to be deallocated. */ actionList.empty(); + + for ( CharVectVect::Iter fns = streamFileNames; fns.lte(); fns++ ) { + const char **ptr = *fns; + while ( *ptr != 0 ) { + ::free( (void*)*ptr ); + ptr += 1; + } + free( (void*) *fns ); + } } ostream &operator<<( ostream &out, const Token &token ) diff --git a/src/compiler.h b/src/compiler.h index 13f32ba6..1888f300 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -64,6 +64,8 @@ struct FsmCodeGen; #define REDUCE_CODE 0x2 #define SHIFT_REDUCE_CODE 0x3 +typedef Vector<const char**> CharVectVect; + /* This is used for tracking the current stack of include file/machine pairs. It is * is used to detect and recursive include structure. */ struct IncludeStackItem @@ -644,6 +646,8 @@ struct Compiler UniqueType *mainReturnUT; + CharVectVect streamFileNames; + /* CONTEXT FREE */ ProdElList *makeProdElList( LangEl *langEl ); void wrapNonTerminals(); diff --git a/src/loadcolm.cc b/src/loadcolm.cc index e7bdbf2b..7d81e183 100644 --- a/src/loadcolm.cc +++ b/src/loadcolm.cc @@ -790,6 +790,7 @@ struct LoadColm } StmtList *stmtList = walkRootItemList( Start.RootItemList() ); + pd->streamFileNames.append( colm_extract_fns( program ) ); colm_delete_program( program ); return stmtList; } @@ -2703,6 +2704,7 @@ void LoadColm::go( long activeRealm ) } StmtList *stmtList = walkRootItemList( Start.RootItemList() ); + pd->streamFileNames.append( colm_extract_fns( program ) ); colm_delete_program( program ); pd->rootCodeBlock = CodeBlock::cons( stmtList, 0 ); diff --git a/src/loadinit.cc b/src/loadinit.cc index 2387cd05..b6f1bc74 100644 --- a/src/loadinit.cc +++ b/src/loadinit.cc @@ -408,6 +408,7 @@ void LoadInit::go( long activeRealm ) ItemList = ItemList.next(); } + pd->streamFileNames.append( colm_extract_fns( program ) ); colm_delete_program( program ); consParseStmt( stmtList ); |