mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-03 05:20:16 +02:00
Update texinfo documentation to match current implementation.
* check/Makefile.am: "make debug" target should pass only the main test tool program as argument for running gdb * configure.ac: Add the --enable-assertions options. * doc/Makefile.am, doc/body.texi, doc/lightning.texi: Major rewrite of the documentation to match the current implementation. * doc/version.texi: Automatic date update. * doc/ifib.c, doc/incr.c, doc/printf.c, doc/rfib.c, doc/rpn.c: Implementation of the documentation examples, that are also compiled during a normal build. * doc/p-lightning.texi, doc/porting.texi, doc/toc.texi, doc/u-lightning.texi, doc/using.texi: These files were renamed in the documentation rewrite, as the documentation was significantly trimmed due to full removal of the porting chapters. Better porting documentation should be added but for the moment it was just removed the documentation not matching the implementation.
This commit is contained in:
parent
2da31e82fa
commit
16d18f11d3
18 changed files with 1431 additions and 3389 deletions
49
doc/rfib.c
Normal file
49
doc/rfib.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
#include <stdio.h>
|
||||
#include <lightning.h>
|
||||
|
||||
static jit_state_t *_jit;
|
||||
|
||||
typedef int (*pifi)(int); /* Pointer to Int Function of Int */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pifi fib;
|
||||
jit_node_t *label;
|
||||
jit_node_t *call;
|
||||
jit_node_t *in; /* offset of the argument */
|
||||
jit_node_t *ref; /* to patch the forward reference */
|
||||
|
||||
init_jit(argv[0]);
|
||||
_jit = jit_new_state();
|
||||
|
||||
label = jit_label();
|
||||
jit_prolog ();
|
||||
in = jit_arg ();
|
||||
jit_getarg (JIT_V0, in); /* V0 = n */
|
||||
ref = jit_blti (JIT_V0, 2);
|
||||
jit_subi (JIT_V1, JIT_V0, 1); /* V1 = n-1 */
|
||||
jit_subi (JIT_V2, JIT_V0, 2); /* V2 = n-2 */
|
||||
jit_prepare();
|
||||
jit_pushargr(JIT_V1);
|
||||
call = jit_finishi(NULL);
|
||||
jit_patch_at(call, label);
|
||||
jit_retval(JIT_V1); /* V1 = fib(n-1) */
|
||||
jit_prepare();
|
||||
jit_pushargr(JIT_V2);
|
||||
call = jit_finishi(NULL);
|
||||
jit_patch_at(call, label);
|
||||
jit_retval(JIT_V2); /* V2 = fib(n-2) */
|
||||
jit_addi(JIT_V1, JIT_V1, 1);
|
||||
jit_addr(JIT_R0, JIT_V1, JIT_V2); /* R0 = V1 + V2 + 1 */
|
||||
jit_retr(JIT_R0);
|
||||
|
||||
jit_patch(ref); /* patch jump */
|
||||
jit_movi(JIT_R0, 1); /* R0 = 1 */
|
||||
jit_retr(JIT_R0);
|
||||
|
||||
/* call the generated code, passing 32 as an argument */
|
||||
fib = jit_emit();
|
||||
printf("fib(%d) = %d\n", 32, fib(32));
|
||||
finish_jit();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue