Next: , Previous: , Up: External Calls   [Index]


14.4 Using External Calls

Whatever language your source files are written in, when -e is used (see -e), the compiler will go through much the same steps.

First, the INTERCAL program specified is compiled into a C program that uses the INTERCAL external call conventions for its control flow operations. The resulting ‘.c’ file will be left behind in the same directory (even if -g isn’t used); if you look at it, you’ll see the #include <ick_ec.h> line, and the other hallmarks of an external call program (for instance, INTERCAL NEXTs will translate into slightly modified ick_nexts; the modification is simply to allow the correct line number to be displayed in case of error).

After that, the resulting files are preprocessed twice. First, the C preprocessor is run on the files; then, a special C-INTERCAL ‘preprocessor’ is run on the files. (‘Preprocessor’ is a bit of a misnomer here, as it’s near the end of the compilation process; ‘postprocessor’ would likely be more accurate, or maybe ‘interprocessor’.) Its job is to fix line labels between the gotos that are used to implement jumping into the middle of a C function, to assign unique numbers to things that need them, and to keep track of which functions need to be checked for line labels and for COME FROMs and NEXT FROMs. The resulting file will have the extension ‘.cio’; it is almost human-readable, especially if you run it through a C code indenter, and consists of C code (which might be a thin wrapper around some other language) and instructions to gcc. The ‘.cio’ file will be left behind for you to look at, if you like.

Once the ‘.cio’ files have been produced, gcc is used to compile all the ‘.cio’ files and link them together into an executable; the executable will have the same name as the INTERCAL source, minus any extension (and on DJGPP, assuming that its version of gcc could handle the resulting command line (not necessarily guaranteed), a ‘.exe’ extension is added), and will consist of all the C files linked together with the INTERCAL. Any functions named main in the C files will be deleted; likewise, if there is a name clash between any two functions, the one in the file named earlier on the command line will be used. There is presumably some use for this feature, although I haven’t figured out what it is yet.

Extending this to other compiled languages is mostly a problem of determining how they fit into the INTERCAL control structure, which is not a trivial task, and of figuring out how to link them to C code, which in some cases is trivial (especially if the language is one that gcc can compile!) and in other cases is very difficult. If anyone has any ideas of new languages that could be added to the external calls system, feel free to contact the current C-INTERCAL maintainer with suggestions or patches.


Next: , Previous: , Up: External Calls   [Index]