3
votes

I just have a question which I can't find a accurate answer online ..

Using swipl-ld can help to combine Prolog and C code together, and eventually generating one signal executable binary.

But there is one thing I am confused with...

In the generated binary, does the Prolog Interpreter (Virtual Machine or others) still exist?

If so, then probably the original Prolog code is stored as string in the .rodata section of ELF binary, but after a searching inside this section, I didn't find the code.. But perhaps the original code has been transformed into bytecode, and that's why I just can't find it at all..

If not, then how can Prolog code directly translate into semantic equivalent asm code based on SWI-Prolog? I have read some materials about the implementation of GNU-Prolog, based on WAM virtual machine, however, I haven't found any materials about the implementation of SWI-Prolog...

Could anyone give me some help?

1

1 Answers

4
votes

The compiled binary does not contain your original source code nor the whole Prolog interpreter. However it does contain your program in form of bytecode compiled by the qsave_program/2 predicate. This bytecode is executed by Prolog emulator, which is a subset of the Prolog interpreter used during a normal interactive dialog, and which is also included in the compiled binary.

All relevant information can be found in the Generating Runtime Applications section of the SWI-Prolog documentation.