mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-16 14:21:48 -08:00
The braces code is now extended to callbacks, FLET/LABELS, lambda forms, LET/LET* forms
This commit is contained in:
parent
1c95758108
commit
a60ccc889d
5 changed files with 23 additions and 30 deletions
|
|
@ -110,7 +110,7 @@
|
|||
(setf comma ",")))
|
||||
(wt ")")
|
||||
(wt-h ");")
|
||||
(wt-nl1 "{")
|
||||
(wt-nl-open-brace)
|
||||
(when return-p
|
||||
(wt-nl return-type-name " output;"))
|
||||
(wt-nl "const cl_env_ptr cl_env_copy = ecl_process_env();")
|
||||
|
|
@ -132,4 +132,4 @@
|
|||
(wt-nl "ecl_foreign_data_set_elt(&output,"
|
||||
(foreign-elt-type-code return-type) ",aux);")
|
||||
(wt-nl "return output;"))
|
||||
(wt-nl1 "}")))
|
||||
(wt-nl-close-brace)))
|
||||
|
|
|
|||
|
|
@ -579,8 +579,7 @@
|
|||
(let ((var (make-lcl-var :rep-type type)))
|
||||
(wt-nl (rep-type-name type) " " var ";")
|
||||
var)))
|
||||
(incf *inline-blocks*)
|
||||
(wt-nl "{")
|
||||
(open-inline-block)
|
||||
(let ((output-vars (mapcar #'make-output-var output-rep-type)))
|
||||
(wt-c-inline-loc output-rep-type c-expression coerced-arguments side-effects output-vars)
|
||||
(cond ((= (length output-vars) 1)
|
||||
|
|
@ -614,8 +613,7 @@
|
|||
(let ((lcl (make-lcl-var :rep-type rep-type)))
|
||||
(wt-nl)
|
||||
(unless block-opened
|
||||
(incf *inline-blocks*)
|
||||
(wt-nl "{"))
|
||||
(open-inline-block))
|
||||
(wt (rep-type-name rep-type) " " lcl "= ")
|
||||
(wt-coerce-loc rep-type loc)
|
||||
(wt ";")
|
||||
|
|
|
|||
|
|
@ -179,8 +179,9 @@
|
|||
t)))
|
||||
|
||||
(defun c2locals (c1form funs body labels ;; labels is T when deriving from labels
|
||||
&aux block-p
|
||||
&aux
|
||||
(*env* *env*)
|
||||
(*inline-blocks* 0)
|
||||
(*env-lvl* *env-lvl*) env-grows)
|
||||
(declare (ignore c1form))
|
||||
;; create location for each function which is returned,
|
||||
|
|
@ -190,15 +191,13 @@
|
|||
(when (plusp (var-ref var)) ; the function is returned
|
||||
(unless (member (var-kind var) '(LEXICAL CLOSURE))
|
||||
(setf (var-loc var) (next-lcl))
|
||||
(unless block-p
|
||||
(setq block-p t) (wt-nl "{ "))
|
||||
(maybe-open-inline-block)
|
||||
(wt "cl_object " var ";"))
|
||||
(unless env-grows
|
||||
(setq env-grows (var-ref-ccb var))))))
|
||||
;; or in closure environment:
|
||||
(when (env-grows env-grows)
|
||||
(unless block-p
|
||||
(wt-nl "{ ") (setq block-p t))
|
||||
(maybe-open-inline-block)
|
||||
(let ((env-lvl *env-lvl*))
|
||||
(wt "volatile cl_object env" (incf *env-lvl*) " = env" env-lvl ";")))
|
||||
;; bind such locations:
|
||||
|
|
@ -216,7 +215,7 @@
|
|||
(set-var (list 'MAKE-CCLOSURE fun) var))))
|
||||
|
||||
(c2expr body)
|
||||
(when block-p (wt-nl "}")))
|
||||
(close-inline-blocks))
|
||||
|
||||
(defun c1decl-body (decls body)
|
||||
(if (null decls)
|
||||
|
|
|
|||
|
|
@ -353,7 +353,6 @@ The function thus belongs to the type of functions that ecl_make_cfun accepts."
|
|||
|
||||
;; check arguments
|
||||
(unless (or local-entry-p (not (policy-check-nargs)))
|
||||
(incf *inline-blocks*)
|
||||
(if (and use-narg (not varargs))
|
||||
(wt-nl "if (ecl_unlikely(narg!=" nreq ")) FEwrong_num_arguments_anonym();")
|
||||
(when varargs
|
||||
|
|
@ -361,7 +360,7 @@ The function thus belongs to the type of functions that ecl_make_cfun accepts."
|
|||
(wt-nl "if (ecl_unlikely(narg<" nreq ")) FEwrong_num_arguments_anonym();"))
|
||||
(unless (or rest keywords allow-other-keys)
|
||||
(wt-nl "if (ecl_unlikely(narg>" (+ nreq nopt) ")) FEwrong_num_arguments_anonym();"))))
|
||||
(wt-nl "{"))
|
||||
(open-inline-block))
|
||||
|
||||
;; If the number of required arguments exceeds the number of variables we
|
||||
;; want to pass on the C stack, we pass some of the arguments to the list
|
||||
|
|
@ -429,7 +428,7 @@ The function thus belongs to the type of functions that ecl_make_cfun accepts."
|
|||
do (bind `(LCL ,reqi) var)))
|
||||
|
||||
(when fname-in-ihs-p
|
||||
(wt-nl "{")
|
||||
(open-inline-block)
|
||||
(setf *ihs-used-p* t)
|
||||
(push 'IHS *unwind-exit*)
|
||||
(when (policy-debug-variable-bindings)
|
||||
|
|
@ -447,7 +446,8 @@ The function thus belongs to the type of functions that ecl_make_cfun accepts."
|
|||
;; which is what we do here.
|
||||
(let ((va-arg-loc (if simple-varargs 'VA-ARG 'CL-VA-ARG)))
|
||||
;; counter for optionals
|
||||
(wt-nl "{int i=" nreq ";")
|
||||
(wt-nl-open-brace)
|
||||
(wt-nl "int i=" nreq ";")
|
||||
(do ((opt optionals (cdddr opt)))
|
||||
((endp opt))
|
||||
(wt-nl "if (i >= narg) {")
|
||||
|
|
@ -459,7 +459,7 @@ The function thus belongs to the type of functions that ecl_make_cfun accepts."
|
|||
(bind va-arg-loc (first opt)))
|
||||
(when (third opt) (bind t (third opt)))
|
||||
(wt-nl "}"))
|
||||
(wt "}")))
|
||||
(wt-nl-close-brace)))
|
||||
|
||||
(when (or rest keywords allow-other-keys)
|
||||
(cond ((not (or keywords allow-other-keys))
|
||||
|
|
@ -503,10 +503,10 @@ The function thus belongs to the type of functions that ecl_make_cfun accepts."
|
|||
(t
|
||||
;; with initform
|
||||
(setf (second KEYVARS[i]) (+ nkey i))
|
||||
(wt-nl "if(") (wt-loc KEYVARS[i]) (wt "==ECL_NIL){")
|
||||
(wt-nl "if (") (wt-loc KEYVARS[i]) (wt "==ECL_NIL) {")
|
||||
(let ((*unwind-exit* *unwind-exit*))
|
||||
(bind-init init var))
|
||||
(wt-nl "}else{")
|
||||
(wt-nl "} else {")
|
||||
(setf (second KEYVARS[i]) i)
|
||||
(bind KEYVARS[i] var)
|
||||
(wt "}")))
|
||||
|
|
@ -521,11 +521,7 @@ The function thus belongs to the type of functions that ecl_make_cfun accepts."
|
|||
;;; Now the parameters are ready, after all!
|
||||
(c2expr body)
|
||||
|
||||
;;; Closing braces is done i cmptop.lsp
|
||||
(when fname-in-ihs-p
|
||||
(wt-nl "}"))
|
||||
(close-inline-blocks)
|
||||
)
|
||||
(close-inline-blocks))
|
||||
|
||||
(defun optimize-funcall/apply-lambda (lambda-form arguments apply-p
|
||||
&aux body apply-list apply-var
|
||||
|
|
|
|||
|
|
@ -266,16 +266,16 @@
|
|||
for kind = (local var)
|
||||
when kind
|
||||
do (progn
|
||||
(wt-nl)(maybe-open-inline-block)
|
||||
(maybe-open-inline-block)
|
||||
(bind (next-lcl) var)
|
||||
(wt *volatile* (rep-type-name kind) " " var ";")
|
||||
(wt-nl *volatile* (rep-type-name kind) " " var ";")
|
||||
(wt-comment (var-name var))))
|
||||
|
||||
;; Create closure bindings for closed-over variables
|
||||
(when (some #'var-ref-ccb vars)
|
||||
(wt-nl) (maybe-open-inline-block)
|
||||
(maybe-open-inline-block)
|
||||
(let ((env-lvl *env-lvl*))
|
||||
(wt *volatile* "cl_object env" (incf *env-lvl*) " = env" env-lvl ";")))
|
||||
(wt-nl *volatile* "cl_object env" (incf *env-lvl*) " = env" env-lvl ";")))
|
||||
|
||||
;; Assign values
|
||||
(loop for form in forms
|
||||
|
|
@ -293,11 +293,11 @@
|
|||
;; Optionally register the variables with the IHS frame for debugging
|
||||
(if (policy-debug-variable-bindings)
|
||||
(let ((*unwind-exit* *unwind-exit*))
|
||||
(wt-nl "{")
|
||||
(wt-nl-open-brace)
|
||||
(let* ((env (build-debug-lexical-env vars)))
|
||||
(when env (push 'IHS-ENV *unwind-exit*))
|
||||
(c2expr body)
|
||||
(wt-nl "}")
|
||||
(wt-nl-close-brace)
|
||||
(when env (pop-debug-lexical-env))))
|
||||
(c2expr body))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue