[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.3 Generating code at run-time

To use GNU lightning, you should include the `lightning.h' file that is put in your include directory by the `make install' command. That include files defines about four hundred public macros (plus others that are private to GNU lightning), one for each opcode listed above.

Each of the instructions above translates to a macro. All you have to do is prepend jit_ (lowercase) to opcode names and JIT_ (uppercase) to register names. Of course, parameters are to be put between parentheses, just like with every other CPP macro.

This small tutorial presents three examples:

2.3.1 A function which increments a number by one  
2.3.2 A simple function call to printf  A simple function call to printf
2.3.3 A more complex example, an RPN calculator  
2.3.4 Fibonacci numbers  Calculating Fibonacci numbers

This document was generated by Alistair Turnbull on April, 12 2005 using texi2html