Introducing the "lookup-constants runtime system" :)

Anoq of the Sun anoq@HardcoreProcessing.com
Sun, 30 Sep 2001 20:59:18 +0200


Hello!


The lookup-constants program seems to be something
like the following:

#include <stdio.h>
#include <targetfile1>
#include <targetfile2>
...
struct GC_state gcState;
int main (int argc, char **argv)
{
  FILE *f = fopen(argv [1], "w");
  fprintf ...
  fprintf ...
  fclose(f);
}

<stdio.h> has to be included for the HOST
system (for the functions fopen, fprintf and fclose to work),
while the other files are included for the TARGET system.

The way that include directories are specified, are by using
-Idir options for mlton. And these are directories for the
target system. Now, we could search for the included files in
those directories and insert explict paths to the #include directives -
and use gcc -Idir flags for the host system. Conversely we could
also add an explicit path instead of the #include <stdio.h>
directive and add -Idir flags for the target system. But either way -
directories included from those files are likely to search the wrong
directories.

So to solve this, I will compile one "lookup-constant runtime" file
for the host system - using host include flags:

#include <stdio.h>

static FILE *f;

void lookupConstantRuntimeFOpen(char *fileName)
{
	f = fopen(fileName, "w");
}

void lookupConstantRuntimeFClose(void)
{
	fclose(f);
}

void lookupConstantRuntimeFPrintf ... (etc...)


Then I will generate:

void lookupConstantRuntimeFOpen(char *fileName);
void lookupConstantRuntimeFClose(void);
void lookupConstantRuntimeFPrintf ...;
#include <targetfile1>
#include <targetfile2>
...
int main (int argc, char **argv)
{
  lookupConstantRuntimeFOpen(argv [1]);
  lookupConstantRuntimeFPrintf ...
  lookupConstantRuntimeFPrintf ...
  lookupConstantRuntimeFClose();
}

And compile this with target include flags - and then link
this into an executable for the host system.

I haven't implemented it yet, and I'm not going to work any
more on this today - but any comments? :)

And by the way - why is struct GC_state gcState there?


Cheers
-- 
http://www.HardcoreProcessing.com