[Ecls-list] New compiler

Juan Jose Garcia Ripoll worm at arrakis.es
Mon May 12 10:42:13 UTC 2003


Easier than expected, I implemented DEFENTRY today. Notice, however, that the 
C type names change with respect to previous versions of EcoLisp: int -> 
:int, char -> :char, void -> :void, object -> :object, etc. Notice also, that 
the C function to be called, need not be a function (It can be a macro!). 
This is because we do not use the address itself, but create a wrapper.

The example which I show below is rather easy. Using third-parties C/C++ 
libraries requires one to use BUILD-LIBRARY or BUILD-PROGRAM to link the lisp 
code with them.

Regards,

Juanjo

--------------------- EXAMPLE SESSION ------------------------------

[jlr at mpq3p32 build]$ cat foo.lsp
(ffi:defentry myabs (:int) (:int abs))

[jlr at mpq3p32 build]$ cat foo.lsp
(ffi:defentry myabs (:int) (:int abs))

> (macroexpand '(ffi:defentry myabs (:int) (:int abs)))
(PROGN
  (SI:FSET 'MYABS
           #'(LAMBDA-BLOCK MYABS (#:G514)
               (FFI:C-INLINE (#:G514) (:INT) :INT "abs(#0)" :ONE-LINER
                   T)))
  'MYABS)
T
> (disassemble '(LAMBDA-BLOCK MYABS (#:G514)
               (FFI:C-INLINE (#:G514) (:INT) :INT "abs(#0)" :ONE-LINER
                   T)))
;;; Compiling #'(LAMBDA (#:G514) ...).
;;; The variable #:G514 is undefined.
;;; The compiler will assume this variable is a global.
;;; Warning: The variable #:G514 is not used.
;;; Emitting code for "lambda".

/*	local function CLOSURE                                        */
static cl_object LC1(int narg, cl_object V1)
{ VT3 VLEX3 CLSR3
	cl_object value0;
	check_arg(1);
	value0=MAKE_FIXNUM(abs(object_to_fixnum(symbol_value(VV[0])))); NValues=1;
	return value0;
}





More information about the ecl-devel mailing list