diff options
-rw-r--r-- | src/colm.h | 3 | ||||
-rw-r--r-- | src/program.c | 5 | ||||
-rw-r--r-- | src/program.h | 3 | ||||
-rw-r--r-- | src/reduce.cc | 8 |
4 files changed, 11 insertions, 8 deletions
@@ -98,6 +98,9 @@ struct colm_tree *colm_run_func( struct colm_program *prg, int frame_id, /* Delete a colm program. Clears all memory. */ int colm_delete_program( struct colm_program *prg ); +/* Set the pointer to the reduce struct used. */ +void colm_set_reduce_ctx( struct colm_program *prg, void *ctx ); + #ifdef __cplusplus } #endif diff --git a/src/program.c b/src/program.c index 3958da9d..0f7396d8 100644 --- a/src/program.c +++ b/src/program.c @@ -226,6 +226,11 @@ static void colm_clear_heap( program_t *prg, tree_t **sp ) } } +void colm_set_reduce_ctx( struct colm_program *prg, void *ctx ) +{ + prg->red_ctx = ctx; +} + int colm_delete_program( program_t *prg ) { tree_t **sp = prg->stack_root; diff --git a/src/program.h b/src/program.h index 9949b386..cbca509b 100644 --- a/src/program.h +++ b/src/program.h @@ -99,7 +99,6 @@ struct colm_sections struct pda_run *pda_run, struct stream_impl *input_stream ); void (*init_bindings)( struct pda_run *pda_run ); void (*pop_binding)( struct pda_run *pda_run, parse_tree_t *tree ); - }; struct heap_list @@ -150,6 +149,8 @@ struct colm_program /* Returned value for main program and any exported functions. */ tree_t *return_val; + + void *red_ctx; }; #endif diff --git a/src/reduce.cc b/src/reduce.cc index 7880c27e..cb47e94f 100644 --- a/src/reduce.cc +++ b/src/reduce.cc @@ -253,12 +253,6 @@ void Compiler::writeCommit() "#include \"reducer.h\"\n" "\n"; - for ( ReductionVect::Iter r = rootNamespace->reductions; r.lte(); r++ ) { - Reduction *reduction = *r; - *outStream << - reduction->name << "* " << reduction->var << ";\n"; - } - *outStream << "\n"; for ( ReductionVect::Iter r = rootNamespace->reductions; r.lte(); r++ ) { @@ -307,7 +301,7 @@ void Compiler::writeCommit() Reduction *reduction = *r; *outStream << " case " << reduction->id << ":\n" - " " << reduction->var << "->commit_reduce_forward( " + " ((" << reduction->name << "*)prg->red_ctx)->commit_reduce_forward( " "prg, root, pda_run, pt );\n" " break;\n"; } |