diff options
author | Adrian Thurston <thurston@complang.org> | 2013-04-18 22:37:20 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2013-04-18 22:37:20 +0000 |
commit | 9c724fd4745e1b62455bcfafcbfc42b25eaa8888 (patch) | |
tree | d440feb3a24d062e0a7a6aac7f81e0d3482c8eed | |
parent | 47f0ae11f2cfddc3aa7f98c1eadb19df329b9d67 (diff) | |
download | colm-9c724fd4745e1b62455bcfafcbfc42b25eaa8888.tar.gz |
added distinct func for setting the realm
-rw-r--r-- | colm/codegen.cc | 3 | ||||
-rw-r--r-- | colm/colm.h | 17 | ||||
-rw-r--r-- | colm/compiler.cc | 2 | ||||
-rw-r--r-- | colm/loadcolm.cc | 5 | ||||
-rw-r--r-- | colm/loadinit.cc | 2 | ||||
-rw-r--r-- | colm/main.cc | 1 | ||||
-rw-r--r-- | colm/program.c | 9 |
7 files changed, 27 insertions, 12 deletions
diff --git a/colm/codegen.cc b/colm/codegen.cc index 660f372e..b48ebbb7 100644 --- a/colm/codegen.cc +++ b/colm/codegen.cc @@ -35,7 +35,8 @@ void FsmCodeGen::writeMain( long activeRealm ) "{\n" " struct colm_program *prg;\n" " int exitStatus;\n" - " prg = colm_new_program( &colm_object, " << activeRealm << " );\n" + " prg = colm_new_program( &colm_object );\n" + " colm_set_debug( prg, " << activeRealm << " );\n" " colm_run_program( prg, argc, argv );\n" " exitStatus = colm_delete_program( prg );\n" " return exitStatus;\n" diff --git a/colm/colm.h b/colm/colm.h index 13df281a..b83cd7a1 100644 --- a/colm/colm.h +++ b/colm/colm.h @@ -12,10 +12,9 @@ struct colm_sections; struct colm_tree; struct colm_location; -struct colm_program *colm_new_program( struct colm_sections *rtd, long debug_realm ); -void colm_run_program( struct colm_program *prg, int argc, const char **argv ); -struct colm_tree *colm_run_func( struct colm_program *prg, int frame_id, const char **params, int param_count ); -int colm_delete_program( struct colm_program *prg ); +/* + * Interface + */ struct colm_print_args { @@ -51,6 +50,16 @@ struct colm_tree *colm_get_repeat_next( struct colm_tree *tree ); struct colm_tree *colm_get_repeat_val( struct colm_tree *tree ); struct colm_location *colm_find_location( struct colm_program *prg, struct colm_tree *tree ); +/* + * Primary interface. + */ + +struct colm_program *colm_new_program( struct colm_sections *rtd ); +void colm_set_debug( struct colm_program *prg, long active_realm ); +void colm_run_program( struct colm_program *prg, int argc, const char **argv ); +struct colm_tree *colm_run_func( struct colm_program *prg, int frame_id, const char **params, int param_count ); +int colm_delete_program( struct colm_program *prg ); + #ifdef __cplusplus } #endif diff --git a/colm/compiler.cc b/colm/compiler.cc index e1a403c3..8f6ca8d3 100644 --- a/colm/compiler.cc +++ b/colm/compiler.cc @@ -1004,7 +1004,7 @@ PdaRun *Compiler::parsePattern( Program *prg, Tree **sp, const InputLoc &loc, void Compiler::parsePatterns() { - Program *prg = colm_new_program( runtimeData, 0 ); + Program *prg = colm_new_program( runtimeData ); /* Turn off context-dependent parsing. */ prg->ctxDepParsing = 0; diff --git a/colm/loadcolm.cc b/colm/loadcolm.cc index 65c0ebfa..27f8cc79 100644 --- a/colm/loadcolm.cc +++ b/colm/loadcolm.cc @@ -635,7 +635,7 @@ struct LoadColm argv[0] = file.data; argv[1] = 0; - colm_program *program = colm_new_program( &colm_object, 0 ); + colm_program *program = colm_new_program( &colm_object ); colm_run_program( program, 1, argv ); /* Extract the parse tree. */ @@ -1904,7 +1904,8 @@ void LoadColm::go( long activeRealm ) argv[0] = inputFileName; argv[1] = 0; - colm_program *program = colm_new_program( &colm_object, activeRealm ); + colm_program *program = colm_new_program( &colm_object ); + colm_set_debug( program, activeRealm ); colm_run_program( program, 1, argv ); /* Extract the parse tree. */ diff --git a/colm/loadinit.cc b/colm/loadinit.cc index 3a6a965e..e2b1f812 100644 --- a/colm/loadinit.cc +++ b/colm/loadinit.cc @@ -338,7 +338,7 @@ void LoadInit::go( long activeRealm ) argv[0] = inputFileName; argv[1] = 0; - colm_program *program = colm_new_program( &colm_object, 0 ); + colm_program *program = colm_new_program( &colm_object ); colm_run_program( program, 1, argv ); /* Extract the parse tree. */ diff --git a/colm/main.cc b/colm/main.cc index eba57960..f73e661e 100644 --- a/colm/main.cc +++ b/colm/main.cc @@ -79,6 +79,7 @@ istream *inStream = 0; ostream *outStream = 0; const char *inputFileName = 0; const char *outputFileName = 0; +const char *intermedFileName = 0; const char *gblExportTo = 0; const char *gblExpImplTo = 0; bool exportCode = false; diff --git a/colm/program.c b/colm/program.c index 013d98ed..fc728344 100644 --- a/colm/program.c +++ b/colm/program.c @@ -179,13 +179,16 @@ Tree *colm_return_val( struct colm_program *prg ) return prg->returnVal; } -Program *colm_new_program( RuntimeData *rtd, long activeRealm ) +void colm_set_debug( Program *prg, long activeRealm ) +{ + prg->activeRealm = activeRealm; +} + +Program *colm_new_program( RuntimeData *rtd ) { Program *prg = malloc(sizeof(Program)); memset( prg, 0, sizeof(Program) ); - prg->activeRealm = activeRealm; - assert( sizeof(Int) <= sizeof(Tree) ); assert( sizeof(Str) <= sizeof(Tree) ); assert( sizeof(Pointer) <= sizeof(Tree) ); |