diff options
author | Adrian Thurston <thurston@colm.net> | 2018-05-05 22:59:52 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2018-05-05 22:59:52 -0400 |
commit | 776ddfc296be0edd2093b932e2b61c6407f29b94 (patch) | |
tree | e364f1efbf4506c82f3c73b4f3d4f94a9ffba78e | |
parent | 422308c1f28fd2251ebd435ef22780801826bb83 (diff) | |
download | colm-776ddfc296be0edd2093b932e2b61c6407f29b94.tar.gz |
allocate a unique struct id for streams
-rw-r--r-- | src/compiler.h | 1 | ||||
-rw-r--r-- | src/input.c | 2 | ||||
-rw-r--r-- | src/pdabuild.cc | 4 | ||||
-rw-r--r-- | src/pdacodegen.cc | 1 | ||||
-rw-r--r-- | src/program.h | 1 | ||||
-rw-r--r-- | src/struct.c | 2 |
6 files changed, 8 insertions, 3 deletions
diff --git a/src/compiler.h b/src/compiler.h index a9fe2558..971476a7 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -907,6 +907,7 @@ struct Compiler int nextLelId; int firstNonTermId; int structInbuiltId; + int structStreamId; LangEl **langElIndex; PdaState *actionDestState; diff --git a/src/input.c b/src/input.c index cb5522c3..f79c2758 100644 --- a/src/input.c +++ b/src/input.c @@ -1113,7 +1113,7 @@ stream_t *colm_stream_new_struct( program_t *prg ) struct colm_stream *stream = (struct colm_stream*) malloc( memsize ); memset( stream, 0, memsize ); colm_struct_add( prg, (struct colm_struct *)stream ); - stream->id = prg->rtd->struct_inbuilt_id; + stream->id = prg->rtd->struct_stream_id; stream->destructor = &colm_stream_destroy; return stream; } diff --git a/src/pdabuild.cc b/src/pdabuild.cc index 67ee20ac..3194f400 100644 --- a/src/pdabuild.cc +++ b/src/pdabuild.cc @@ -247,7 +247,8 @@ void Compiler::makeStructElIds() for ( StructElList::Iter sel = structEls; sel.lte(); sel++ ) sel->id = nextId++; - structInbuiltId = nextId; + structInbuiltId = nextId++; + structStreamId = nextId++; } void Compiler::refNameSpace( LangEl *lel, Namespace *nspace ) @@ -1689,6 +1690,7 @@ void Compiler::makeRuntimeData() runtimeData->global_id = globalSel->id; runtimeData->argv_el_id = argvElSel->id; runtimeData->struct_inbuilt_id = structInbuiltId; + runtimeData->struct_stream_id = structStreamId; runtimeData->fsm_execute = &internalFsmExecute; runtimeData->send_named_lang_el = &internalSendNamedLangEl; diff --git a/src/pdacodegen.cc b/src/pdacodegen.cc index 2e08ee3e..cd79962b 100644 --- a/src/pdacodegen.cc +++ b/src/pdacodegen.cc @@ -511,6 +511,7 @@ void PdaCodeGen::writeRuntimeData( colm_sections *runtimeData, struct pda_tables " " << runtimeData->global_id << ",\n" " " << runtimeData->argv_el_id << ",\n" " " << runtimeData->struct_inbuilt_id << ",\n" + " " << runtimeData->struct_stream_id << ",\n" " &fsm_execute,\n" " &sendNamedLangEl,\n" " &initBindings,\n" diff --git a/src/program.h b/src/program.h index e5cfbeea..0ce99c3a 100644 --- a/src/program.h +++ b/src/program.h @@ -99,6 +99,7 @@ struct colm_sections long global_id; long argv_el_id; long struct_inbuilt_id; + long struct_stream_id; void (*fsm_execute)( struct pda_run *pda_run, struct stream_impl *input_stream ); void (*send_named_lang_el)( struct colm_program *prg, tree_t **tree, diff --git a/src/struct.c b/src/struct.c index edf7e486..710115a1 100644 --- a/src/struct.c +++ b/src/struct.c @@ -73,7 +73,7 @@ struct struct_el_info *colm_sel_info( program_t *prg, int id ) void colm_struct_delete( program_t *prg, tree_t **sp, struct colm_struct *el ) { - if ( el->id == prg->rtd->struct_inbuilt_id ) { + if ( el->id == prg->rtd->struct_inbuilt_id || el->id == prg->rtd->struct_stream_id ) { colm_destructor_t destructor = ((struct colm_inbuilt*)el)->destructor; if ( destructor != 0 ) (*destructor)( prg, sp, el ); |