X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ftypedefs.lisp;h=e652fc48ccb955a710caa74e2aec51e1dbad533f;hb=0f3a5f2e8886d18d0b4f6485c38a42be629422ae;hp=98c3980a0e9e377d6f40049a2d9b7e84d6629c50;hpb=4dc4761909992ceb346d003f3fb19e5c837ee985;p=sbcl.git diff --git a/src/code/typedefs.lisp b/src/code/typedefs.lisp index 98c3980..e652fc4 100644 --- a/src/code/typedefs.lisp +++ b/src/code/typedefs.lisp @@ -41,29 +41,33 @@ ;; package!) (multiple-value-bind (whole wholeless-arglist) (if (eq '&whole (car arglist)) - (values (cadr arglist) (cddr arglist)) - (values (gensym) arglist)) + (values (cadr arglist) (cddr arglist)) + (values (sb!xc:gensym) arglist)) (multiple-value-bind (forms decls) - (parse-body body :doc-string-allowed nil) + (parse-body body :doc-string-allowed nil) `(progn - (!cold-init-forms - (setf (info :type :translator ',name) - (lambda (,whole) - (block ,name - (destructuring-bind ,wholeless-arglist - (rest ,whole) ; discarding NAME - ,@decls - ,@forms))))) - ',name)))) + (!cold-init-forms + (let ((fun (lambda (,whole) + (block ,name + (destructuring-bind ,wholeless-arglist + (rest ,whole) ; discarding NAME + ,@decls + ,@forms))))) + #-sb-xc-host + (setf (%simple-fun-arglist (the simple-fun fun)) ',wholeless-arglist) + (setf (info :type :translator ',name) fun))) + ',name)))) ;;; DEFVARs for these come later, after we have enough stuff defined. (declaim (special *wild-type* *universal-type* *empty-type*)) +(defvar *type-random-state*) + ;;; the base class for the internal representation of types (def!struct (ctype (:conc-name type-) - (:constructor nil) - (:make-load-form-fun make-type-load-form) - #-sb-xc-host (:pure t)) + (:constructor nil) + (:make-load-form-fun make-type-load-form) + #-sb-xc-host (:pure t)) ;; the class of this type ;; ;; FIXME: It's unnecessarily confusing to have a structure accessor @@ -77,9 +81,13 @@ (enumerable nil :read-only t) ;; an arbitrary hash code used in EQ-style hashing of identity ;; (since EQ hashing can't be done portably) - (hash-value (random #.(ash 1 15)) - :type (and fixnum unsigned-byte) - :read-only t) + (hash-value (random #.(ash 1 15) + (if (boundp '*type-random-state*) + *type-random-state* + (setf *type-random-state* + (make-random-state)))) + :type (and fixnum unsigned-byte) + :read-only t) ;; Can this object contain other types? A global property of our ;; implementation (which unfortunately seems impossible to enforce ;; with assertions or other in-the-code checks and constraints) is @@ -107,13 +115,13 @@ (multiple-value-bind (subtypep1 win1) (csubtypep type1 type2) (multiple-value-bind (subtypep2 win2) (csubtypep type2 type1) (cond (subtypep1 type1) - (subtypep2 type2) - ((and win1 win2) *empty-type*) - (t nil))))) + (subtypep2 type2) + ((and win1 win2) *empty-type*) + (t nil))))) (defun hierarchical-union2 (type1 type2) (cond ((csubtypep type1 type2) type2) - ((csubtypep type2 type1) type1) - (t nil))) + ((csubtypep type2 type1) type1) + (t nil))) ;;; Hash two things (types) down to 8 bits. In CMU CL this was an EQ ;;; hash, but since it now needs to run in vanilla ANSI Common Lisp at @@ -127,17 +135,17 @@ (declaim (ftype (function (ctype ctype) (unsigned-byte 8)) type-cache-hash)) (defun type-cache-hash (type1 type2) (logand (logxor (ash (type-hash-value type1) -3) - (type-hash-value type2)) - #xFF)) + (type-hash-value type2)) + #xFF)) #!-sb-fluid (declaim (inline type-list-cache-hash)) (declaim (ftype (function (list) (unsigned-byte 8)) type-list-cache-hash)) (defun type-list-cache-hash (types) - (logand (loop with res = 0 - for type in types - for hash = (type-hash-value type) - do (setq res (logxor res hash)) - finally (return res)) - #xFF)) + (logand #xFF + (loop with res fixnum = 0 + for type in types + for hash = (type-hash-value type) + do (setq res (logxor res hash)) + finally (return res)))) ;;;; cold loading initializations