From 3b91ea314d5b96f48955430b09d5bb072f7c1ef1 Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Fri, 27 Nov 2015 18:49:42 -0500 Subject: added an option, -b, for specifying the name of the program object This also triggers the omission of C adapter funcs, which need to be present only once in a binary that includes a colm code. --- src/codegen.cc | 2 +- src/compiler.cc | 5 +++-- src/compiler.h | 2 ++ src/main.cc | 17 +++++++++++++++-- src/pdacodegen.cc | 2 +- 5 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/codegen.cc b/src/codegen.cc index 821f1880..ecc45840 100644 --- a/src/codegen.cc +++ b/src/codegen.cc @@ -57,7 +57,7 @@ void FsmCodeGen::writeMain( long activeRealm ) " struct colm_program *prg;\n" " int exit_status;\n" "\n" - " prg = colm_new_program( &colm_object );\n" + " prg = colm_new_program( &" << objectName << " );\n" " colm_set_debug( prg, " << activeRealm << " );\n" " colm_run_program( prg, argc, argv );\n" " exit_status = colm_delete_program( prg );\n" diff --git a/src/compiler.cc b/src/compiler.cc index 7c44e7ba..6ee0d396 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -1154,9 +1154,10 @@ void Compiler::generateOutput( long activeRealm, bool includeCommit ) /* Write the runtime data. */ pdaGen->writeRuntimeData( runtimeData, pdaTables ); - writeHostCall(); + if ( hostAdapters ) + writeHostCall(); - if ( includeCommit ) + if ( hostAdapters && includeCommit ) writeCommitStub(); if ( !gblLibrary ) diff --git a/src/compiler.h b/src/compiler.h index 23195cfc..97ad0457 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -50,6 +50,8 @@ using std::ostream; struct exit_object { }; extern exit_object endp; void operator<<( std::ostream &out, exit_object & ); +extern const char *objectName; +extern bool hostAdapters; /* Forwards. */ struct RedFsm; diff --git a/src/main.cc b/src/main.cc index 6f8a28b9..e8fba5ca 100644 --- a/src/main.cc +++ b/src/main.cc @@ -84,7 +84,9 @@ const char *binaryFn = 0; const char *exportHeaderFn = 0; const char *exportCodeFn = 0; const char *commitCodeFn = 0; +const char *objectName = "colm_object"; bool exportCode = false; +bool hostAdapters = true; bool generateGraphviz = false; bool verbose = false; @@ -509,7 +511,7 @@ bool inSourceTree( const char *argv0 ) void processArgs( int argc, const char **argv ) { - ParamCheck pc( "cD:e:x:I:vdlio:S:M:vHh?-:sVa:m:", argc, argv ); + ParamCheck pc( "cD:e:x:I:vdlio:S:M:vHh?-:sVa:m:b:", argc, argv ); while ( pc.check() ) { switch ( pc.state ) { @@ -531,8 +533,8 @@ void processArgs( int argc, const char **argv ) case 'i': branchPointInfo = true; break; - /* Output. */ case 'o': + /* Output. */ if ( *pc.parameterArg == 0 ) error() << "a zero length output file name was given" << endl; else if ( outputFn != 0 ) @@ -543,6 +545,17 @@ void processArgs( int argc, const char **argv ) } break; + case 'b': + /* object name. */ + if ( *pc.parameterArg == 0 ) + error() << "a zero length object name was given" << endl; + else { + /* Ok, remember the output file name. */ + objectName = pc.parameterArg; + hostAdapters = false; + } + break; + case 'H': case 'h': case '?': usage(); exit(0); diff --git a/src/pdacodegen.cc b/src/pdacodegen.cc index 579b2125..3a8eca04 100644 --- a/src/pdacodegen.cc +++ b/src/pdacodegen.cc @@ -445,7 +445,7 @@ void PdaCodeGen::writeRuntimeData( colm_sections *runtimeData, struct pda_tables out << "};\n\n"; out << - "struct colm_sections colm_object = \n" + "struct colm_sections " << objectName << " = \n" "{\n" " " << lelInfo() << ",\n" " " << runtimeData->num_lang_els << ",\n" -- cgit v1.2.1