From: Mark Wooding Date: Wed, 21 Oct 2015 23:46:28 +0000 (+0100) Subject: src/: Wrap functionish bodies in an appropriately named `block'. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/fc09e191754e82d26723b7c6cbf3bfc24fedbf44 src/: Wrap functionish bodies in an appropriately named `block'. --- diff --git a/src/c-types-proto.lisp b/src/c-types-proto.lisp index edadd64..7134962 100644 --- a/src/c-types-proto.lisp +++ b/src/c-types-proto.lisp @@ -181,7 +181,7 @@ (defmethod expand-c-type-form ((,head (eql ',name)) ,tail) ,@doc (destructuring-bind ,bvl ,tail ,@decls - ,@body)) + (block ,name ,@body))) ',name)))) (export 'c-type-alias) diff --git a/src/codegen-proto.lisp b/src/codegen-proto.lisp index a96c6ff..42175a5 100644 --- a/src/codegen-proto.lisp +++ b/src/codegen-proto.lisp @@ -154,7 +154,7 @@ (defmethod print-object ((,inst-var ,class-name) ,streamvar) (print-unreadable-object (,inst-var ,streamvar :type t) (format stream "~@<~@{~S ~@_~S~^ ~_~}~:>" ,@(mappend #'list keys args))) - (progn ,@body)))) + (block ,code ,@body)))) ,@(and export `((export '(,class-name ,constructor-name ,@(mapcar (lambda (arg) (symbolicate 'inst- arg)) diff --git a/src/module-proto.lisp b/src/module-proto.lisp index 9c7fcaf..dcf8d7c 100644 --- a/src/module-proto.lisp +++ b/src/module-proto.lisp @@ -84,7 +84,10 @@ (defmacro define-clear-the-decks (name &body body) When `clear-the-decks' is called, the BODY will be evaluated as a progn. The relative order of `clear-the-decks' operations is unspecified." - `(add-clear-the-decks-function ',name (lambda () ,@body))) + (multiple-value-bind (docs decls body) (parse-body body) + `(add-clear-the-decks-function ',name (lambda () + ,@docs ,@decls + (block ,name ,@body))))) (export 'clear-the-decks) (defun clear-the-decks () diff --git a/src/optparse.lisp b/src/optparse.lisp index a2ac290..9607df7 100644 --- a/src/optparse.lisp +++ b/src/optparse.lisp @@ -536,7 +536,7 @@ (defun ,func (,var ,arg ,@args) ,@docs ,@decls (declare (ignorable ,arg)) (with-locatives ,var - ,@body)) + (block ,name ,@body))) ',name)))) (defun parse-c-integer (string &key radix (start 0) end) @@ -727,9 +727,12 @@ (defmacro defoptmacro (name args &body body) Option macros should produce a list of expressions producing one option structure each." - `(progn - (setf (get ',name 'optmacro) (lambda ,args ,@body)) - ',name)) + (multiple-value-bind (docs decls body) (parse-body body) + `(progn + (setf (get ',name 'optmacro) (lambda ,args + ,@docs ,@decls + (block ,name ,@body))) + ',name))) (export 'parse-option-form) (eval-when (:compile-toplevel :load-toplevel :execute) diff --git a/src/parser/parser-proto.lisp b/src/parser/parser-proto.lisp index 4bd1ae4..4c04208 100644 --- a/src/parser/parser-proto.lisp +++ b/src/parser/parser-proto.lisp @@ -152,10 +152,9 @@ (defmacro defparse (name bvl &body body) ((,context ,ctxclass) (,head (eql ',name)) ,tail) ,@doc (declare (ignorable ,context)) - (block ,name - (destructuring-bind ,bvl ,tail - ,@decls - ,@body))))))) + (destructuring-bind ,bvl ,tail + ,@decls + (block ,name ,@body))))))) (export '(with-parser-context parse)) (defmacro with-parser-context ((class &rest initargs) &body body) @@ -573,7 +572,11 @@ (defmacro define-pluggable-parser (symbol tag (&rest bvl) &body body) If a parser with the given TAG is already attached to SYMBOL then the new parser replaces the old one; otherwise it is added to the collection." - `(pluggable-parser-add ',symbol ',tag (lambda ,bvl ,@body))) + (multiple-value-bind (docs decls body) (parse-body body) + `(pluggable-parser-add ',symbol ',tag + (lambda ,bvl + ,@docs ,@decls + (block ,symbol ,@body))))) ;;;-------------------------------------------------------------------------- ;;; Rewindable parser context protocol. diff --git a/src/utilities.lisp b/src/utilities.lisp index 023fc60..dfe2454 100644 --- a/src/utilities.lisp +++ b/src/utilities.lisp @@ -825,6 +825,6 @@ (defmacro define-on-demand-slot (class slot (instance) &body body) (,classvar (,instance ,class) (,slotvar (eql ',slot))) ,@docs ,@decls (declare (ignore ,classvar)) - (setf (slot-value ,instance ',slot) (progn ,@body)))))) + (setf (slot-value ,instance ',slot) (block ,slot ,@body)))))) ;;;----- That's all, folks --------------------------------------------------