mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-14 21:32:49 -08:00
Implemented FFI:C-PROGN
This commit is contained in:
parent
c503bfa99b
commit
44c86e083c
3 changed files with 24 additions and 11 deletions
|
|
@ -13,7 +13,16 @@ ECL 13.7.1
|
|||
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.
|
||||
the lisp code may refer to any number of variables. Example:
|
||||
|
||||
(lambda (i)
|
||||
(let* ((limit i)
|
||||
(iterator 0))
|
||||
(declare (:int limit iterator))
|
||||
(ffi:c-progn (limit iterator)
|
||||
"for (#1 = 0; #1 < #0; #1++) {"
|
||||
(print iterator)
|
||||
"}")))
|
||||
|
||||
;;; Local Variables: ***
|
||||
;;; mode:text ***
|
||||
|
|
|
|||
|
|
@ -371,25 +371,29 @@
|
|||
form)))
|
||||
|
||||
(defun c1c-progn (arguments)
|
||||
(let* ((variables (mapcar #'c1fref (pop arguments)))
|
||||
(let* ((variables (mapcar #'c1vref (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)))
|
||||
:side-effects t
|
||||
:args variables statements)))
|
||||
(add-to-set-nodes-of-var-list variables form)
|
||||
form))
|
||||
|
||||
(defun c2c-progn (c1form statements)
|
||||
(defun c2c-progn (c1form variables statements)
|
||||
(loop with *destination* = 'TRASH
|
||||
for form in statements
|
||||
if (stringp form)
|
||||
do (wt-nl form)
|
||||
else
|
||||
do (c2expr* form))
|
||||
(unwind-exit nil))
|
||||
do (cond ((stringp form)
|
||||
(wt-nl)
|
||||
(wt-c-inline-loc :void form variables
|
||||
t ; side effects
|
||||
nil) ; no output variables
|
||||
)
|
||||
(t
|
||||
(c2expr* form)))
|
||||
finally (unwind-exit nil)))
|
||||
|
||||
(defun produce-inline-loc (inlined-arguments arg-types output-rep-type
|
||||
c-expression side-effects one-liner)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
c-expression-string
|
||||
side-effects-p
|
||||
one-liner-p)
|
||||
(C-PROGN body)
|
||||
(C-PROGN variables forms)
|
||||
(LOCALS local-fun-list body labels-p :pure)
|
||||
(IF fmla-c1form true-c1form false-c1form :pure)
|
||||
(FMLA-NOT fmla-c1form :pure)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue