[m-dev.] How to add another grade (target language)
jfischer at opturion.com
Mon Jun 15 23:35:39 AEST 2015
On Mon, 15 Jun 2015, Charles Shuller wrote:
Presumably, you meant "and Java" there?
> Can someone point me at some docs for the general compiler structure, and maybe some code that emits the C and Java grades??
The main document describing the compiler's structure is in
The code that emits C is in compiler/llds_out.m and its submodules
(low-level C backend) and compiler/mlds_to_c.m (high-level C backend).
The code that emits Java is in compiler/mlds_to_java.m and that for C#
in in compiler/mlds_to_csharp.m. That said, those files are not the
best starting place IMO. For example, the compiler's high-level C,
Java and C# backends are all variants of what is variously referred to
as the ml_backend or MLDS backend. In its original form it is described
in the paper:
Compiling Mercury to high-level C code
Fergus Henderson and Zoltan Somogyi
Proceedings of the 2002 International Conference on Compiler
Construction Grenoble, France, April 2002.
Understanding the compilation scheme therein is the key to understanding
how those three backends above work. Likewise, the design of the
low-level C backend is covered in:
The execution algorithm of Mercury: an efficient purely declarative logic
Zoltan Somogyi, Fergus Henderson and Thomas Conway.
Journal of Logic Programming, volume 29, number 1-3, October-December
1996, pages 17-64.
(Both papers are available for download via tha papers page.)
to use Emscripten to compile the C code generated by the Mercury
More information about the developers