Added the special form FFI:C-PROGN

This commit is contained in:
Juan Jose Garcia Ripoll 2013-06-27 23:09:37 +02:00
parent e2ae310e2c
commit a40c1907cf
6 changed files with 33 additions and 1 deletions

View file

@ -12,6 +12,9 @@ ECL 13.7.1
such as in (declare (:double a)) and then the variable is enforced to
be unboxed to such type.
- New form EXT:C-PROGN used to interleave C statements with lisp code, where
the lisp code may refer to any number of variables.
;;; Local Variables: ***
;;; mode:text ***
;;; fill-column:79 ***

View file

@ -2265,6 +2265,7 @@ cl_symbols[] = {
{FFI_ "ALLOCATE-FOREIGN-OBJECT", FFI_ORDINARY, NULL, -1, OBJNULL},
{FFI_ "ALLOCATE-FOREIGN-STRING", FFI_ORDINARY, NULL, -1, OBJNULL},
{FFI_ "C-INLINE", FFI_ORDINARY, NULL, -1, OBJNULL},
{FFI_ "C-PROGN", FFI_ORDINARY, NULL, -1, OBJNULL},
{FFI_ "CALLBACK", FFI_ORDINARY, NULL, -1, OBJNULL},
{FFI_ "CHAR*", FFI_ORDINARY, NULL, -1, OBJNULL},
{FFI_ "CHAR-ARRAY-TO-POINTER", FFI_ORDINARY, NULL, -1, OBJNULL},

View file

@ -2265,6 +2265,7 @@ cl_symbols[] = {
{FFI_ "ALLOCATE-FOREIGN-OBJECT",NULL},
{FFI_ "ALLOCATE-FOREIGN-STRING",NULL},
{FFI_ "C-INLINE",NULL},
{FFI_ "C-PROGN",NULL},
{FFI_ "CALLBACK",NULL},
{FFI_ "CHAR*",NULL},
{FFI_ "CHAR-ARRAY-TO-POINTER",NULL},

View file

@ -370,6 +370,27 @@
(add-to-set-nodes var form)))
form)))
(defun c1c-progn (arguments)
(let* ((variables (mapcar #'c1fref (pop arguments)))
(statements (loop for form in arguments
collect (if (stringp form)
form
(c1expr form))))
(form (make-c1form* 'FFI:C-PROGN :type NIL
:side-effects t
:args variables statements)))
(add-to-set-nodes-of-var-list variables form)
form))
(defun c2c-progn (c1form statements)
(loop with *destination* = 'TRASH
for form in statements
if (stringp form)
do (wt-nl form)
else
do (c2expr* form))
(unwind-exit nil))
(defun produce-inline-loc (inlined-arguments arg-types output-rep-type
c-expression side-effects one-liner)
(let* (args-to-be-saved

View file

@ -37,6 +37,7 @@
c-expression-string
side-effects-p
one-liner-p)
(C-PROGN body)
(LOCALS local-fun-list body labels-p :pure)
(IF fmla-c1form true-c1form false-c1form :pure)
(FMLA-NOT fmla-c1form :pure)
@ -94,6 +95,7 @@
(ext:with-backend . c1with-backend) ; c1special
(ffi:clines . c1clines) ; c1special
(ffi:c-inline . c1c-inline) ; c1special
(ffi:c-progn . c1c-progn) ; c1special
(flet . c1flet) ; c1special
(labels . c1labels) ; c1special
(locally . c1locally) ; c1special
@ -212,6 +214,7 @@
(throw . c2throw) ; c2
(progn . c2progn) ; c2
(ffi:c-inline . c2c-inline) ; c2
(ffi:c-progn . c2c-progn) ; c2
(locals . c2locals) ; c2
(call-local . c2call-local) ; c2
@ -286,6 +289,7 @@
(values . p1values)
(location . p1trivial) ;; Some of these can be improved
(ffi:c-inline . p1trivial)
(ffi:c-progn . p1trivial)
(function . p1trivial)
(funcall . p1trivial)
(load-time-value . p1trivial)

View file

@ -668,7 +668,9 @@
(eval-when (:load-toplevel :execute)
(defmacro c-inline (args arg-types ret-type &body others)
`(error "The special form c-inline cannot be used in the interpreter: ~A"
(list (list ,@args) ',arg-types ',ret-type ,@others))))
(list (list ,@args) ',arg-types ',ret-type ,@others)))
(defmacro c-progn (&rest body)
'(error "The special form c-progn cannot be used in the interpreter.")))
(defmacro definline (fun arg-types type code)
"Syntax: (definline symbol (&rest arg-types) result-type &body body) " "