summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-04-01 17:15:29 -0400
committerAdrian Thurston <thurston@complang.org>2015-04-01 17:15:29 -0400
commit5637cd8e39200fd421a6cc77d79a2bbf78a3c925 (patch)
tree4e694d6c94401cbc81dd281d8cf8df07261982b6
parent24e144ea5fd1275bf6c864455b2dd4d96e589363 (diff)
downloadcolm-5637cd8e39200fd421a6cc77d79a2bbf78a3c925.tar.gz
always emit the host-call function
-rw-r--r--src/compiler.cc75
-rw-r--r--src/consinit.cc5
-rw-r--r--src/ctinput.cc5
3 files changed, 43 insertions, 42 deletions
diff --git a/src/compiler.cc b/src/compiler.cc
index 0d2d48d6..5a5bf71e 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1094,52 +1094,53 @@ void Compiler::generateOutput( long activeRealm )
if ( !gblLibrary )
fsmGen->writeMain( activeRealm );
- if ( !gblLibrary ) {
- for ( FunctionList::Iter hc = inHostList; hc.lte(); hc++ ) {
+ /*
+ * Host Call
+ */
+ for ( FunctionList::Iter hc = inHostList; hc.lte(); hc++ ) {
+ *outStream <<
+ "Value " << hc->hostCall << "( Program *prg";
+ for ( ParameterList::Iter p = *hc->paramList; p.lte(); p++ ) {
*outStream <<
- "Value " << hc->hostCall << "( Program *prg";
- for ( ParameterList::Iter p = *hc->paramList; p.lte(); p++ ) {
- *outStream <<
- ", Value";
- }
- *outStream << " );\n";
+ ", Value";
}
+ *outStream << " );\n";
+ }
+ *outStream <<
+ "Tree **host_call( Program *prg, long code, Tree **sp )\n"
+ "{\n"
+ " Value rtn = 0;\n"
+ " switch ( code ) {\n";
+
+ for ( FunctionList::Iter hc = inHostList; hc.lte(); hc++ ) {
*outStream <<
- "Tree **host_call( Program *prg, long code, Tree **sp )\n"
- "{\n"
- " Value rtn = 0;\n"
- " switch ( code ) {\n";
-
- for ( FunctionList::Iter hc = inHostList; hc.lte(); hc++ ) {
- *outStream <<
- " case " << hc->funcId << ": {\n";
+ " case " << hc->funcId << ": {\n";
- int pos = 0;
- for ( ParameterList::Iter p = *hc->paramList; p.lte(); p++, pos++ ) {
- *outStream <<
- " Value p" << pos << " = vm_pop_value();\n";
- }
-
+ int pos = 0;
+ for ( ParameterList::Iter p = *hc->paramList; p.lte(); p++, pos++ ) {
*outStream <<
- " rtn = " << hc->hostCall << "( prg";
-
- pos = 0;
- for ( ParameterList::Iter p = *hc->paramList; p.lte(); p++, pos++ ) {
- *outStream <<
- ", p" << pos;
- }
- *outStream << " );\n"
- " break;\n"
- " }\n";
+ " Value p" << pos << " = vm_pop_value();\n";
}
-
+
*outStream <<
- " }\n"
- " vm_push_value( rtn );\n"
- " return sp;\n"
- "}\n";
+ " rtn = " << hc->hostCall << "( prg";
+
+ pos = 0;
+ for ( ParameterList::Iter p = *hc->paramList; p.lte(); p++, pos++ ) {
+ *outStream <<
+ ", p" << pos;
+ }
+ *outStream << " );\n"
+ " break;\n"
+ " }\n";
}
+
+ *outStream <<
+ " }\n"
+ " vm_push_value( rtn );\n"
+ " return sp;\n"
+ "}\n";
outStream->flush();
}
diff --git a/src/consinit.cc b/src/consinit.cc
index cca00d40..c9ed3d97 100644
--- a/src/consinit.cc
+++ b/src/consinit.cc
@@ -31,6 +31,11 @@
#include "input.h"
#include "consinit.h"
+extern "C" Tree **host_call( Program *prg, long code, Tree **sp )
+{
+ return 0;
+}
+
using std::cout;
using std::cerr;
using std::endl;
diff --git a/src/ctinput.cc b/src/ctinput.cc
index 2e00bf55..24427dab 100644
--- a/src/ctinput.cc
+++ b/src/ctinput.cc
@@ -497,8 +497,3 @@ extern "C" void internalPopBinding( PdaRun *pdaRun, ParseTree *parseTree )
if ( lastBound == parseTree )
pdaRun->bindings->pop();
}
-
-extern "C" void host_call( long, Tree ** )
-{
-
-}