summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-11-27 18:49:42 -0500
committerAdrian Thurston <thurston@complang.org>2015-11-27 18:49:42 -0500
commit3b91ea314d5b96f48955430b09d5bb072f7c1ef1 (patch)
tree0094ab71cb4a43ca4f9376938140431c87e294bb /src
parent255a339bf052fbc2a2412fd88b89936c95c7db33 (diff)
downloadcolm-3b91ea314d5b96f48955430b09d5bb072f7c1ef1.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/codegen.cc2
-rw-r--r--src/compiler.cc5
-rw-r--r--src/compiler.h2
-rw-r--r--src/main.cc17
-rw-r--r--src/pdacodegen.cc2
5 files changed, 22 insertions, 6 deletions
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"