diff options
Diffstat (limited to 'cmamut.lisp')
-rw-r--r-- | cmamut.lisp | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/cmamut.lisp b/cmamut.lisp index d30821e..9918c5d 100644 --- a/cmamut.lisp +++ b/cmamut.lisp @@ -132,29 +132,16 @@ ; Typedefs get "flattened" so that resolving is just a lookup. (defun flatten-typedefs (raw-typedefs) (let ((type-associations (make-hash-table :test #'equal :size 256))) - (labels ((take-deps - (deps) - (let (remaining) - (dolist (i deps) - (let ((tag (gethash "tag" (gethash "type" i)))) - (if (gethash tag type-associations) - (setf (gethash (gethash "name" i) type-associations) tag) - (push i remaining)))) - (if (= (length deps) (length remaining)) - remaining - (take-deps remaining))))) - (let ((result (take-deps raw-typedefs))) - (labels ((associate-base-type - (k v) - (let ((new-v (gethash v type-associations))) - (if (eq new-v t) - (setf (gethash k type-associations) v) - (associate-base-type k new-v))))) - (maphash (lambda (k v) - (unless (eq v t) - (associate-base-type k v))) - type-associations)) - result)))) + (dolist (i raw-typedefs) + (setf (gethash (gethash "name" i) type-associations) (gethash "type" i))) + (labels ((flatten-typedef + (k v) + (let ((new-v (gethash (gethash "tag" v) type-associations))) + (when new-v + (setf (gethash k type-associations) new-v) + (flatten-typedef k new-v))))) + (maphash #'flatten-typedef type-associations)) + type-associations)) (defstruct spec functions |