From fc09e191754e82d26723b7c6cbf3bfc24fedbf44 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 22 Oct 2015 00:46:28 +0100 Subject: [PATCH] src/: Wrap functionish bodies in an appropriately named `block'. --- src/c-types-proto.lisp | 2 +- src/codegen-proto.lisp | 2 +- src/module-proto.lisp | 5 ++++- src/optparse.lisp | 11 +++++++---- src/parser/parser-proto.lisp | 13 ++++++++----- src/utilities.lisp | 2 +- 6 files changed, 22 insertions(+), 13 deletions(-) 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 @@ ,@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 @@ (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 @@ 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 @@ ,@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 @@ 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 @@ ((,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 @@ 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 @@ (,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 -------------------------------------------------- -- 2.11.0