0.6.8.8: undid "MNA: re-defconstant patch", added long explanation
[sbcl.git] / src / compiler / generic / early-vm-macs.lisp
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
9
10 (in-package "SB!VM")
11
12 (defmacro defenum ((&key (prefix "") (suffix "") (start 0) (step 1))
13                    &rest identifiers)
14   (let ((results nil)
15         (index 0)
16         (start (eval start))
17         (step (eval step)))
18     (dolist (id identifiers)
19       (when id
20         (multiple-value-bind (root docs)
21             (if (consp id)
22                 (values (car id) (cdr id))
23                 (values id nil))
24           (push `(defconstant ,(intern (concatenate 'simple-string
25                                                     (string prefix)
26                                                     (string root)
27                                                     (string suffix)))
28                    ,(+ start (* step index))
29                    ,@docs)
30                 results)))
31       (incf index))
32     `(eval-when (:compile-toplevel :load-toplevel :execute)
33        ,@(nreverse results))))