-(macrolet ((frob (slot)
- `(let ((count 10)
- (current tn))
- (declare (type index count))
- (loop
- (let ((refs (,slot current)))
- (unless (and (plusp count) refs (not (tn-ref-next refs)))
- (return nil))
- (let ((target (tn-ref-target refs)))
- (unless target (return nil))
- (setq current (tn-ref-tn target))
- (when (tn-offset current)
- (return (check-ok-target current tn sc)))
- (decf count)))))))
- (defun find-ok-target-offset (tn sc)
- (declare (type tn tn) (type sc sc))
- (or (frob tn-reads)
- (frob tn-writes))))
-
+;;;
+;;; FIXME: (30 minutes of reverse engineering?) It'd be nice to
+;;; rewrite the header comment here to explain the interface and its
+;;; motivation, and move remarks about implementation details (like
+;;; 10!) inside.
+(defun find-ok-target-offset (tn sc)
+ (declare (type tn tn) (type sc sc))
+ (flet ((frob-slot (slot-fun)
+ (declare (type function slot-fun))
+ (let ((count 10)
+ (current tn))
+ (declare (type index count))
+ (loop
+ (let ((refs (funcall slot-fun current)))
+ (unless (and (plusp count)
+ refs
+ (not (tn-ref-next refs)))
+ (return nil))
+ (let ((target (tn-ref-target refs)))
+ (unless target (return nil))
+ (setq current (tn-ref-tn target))
+ (when (tn-offset current)
+ (return (check-ok-target current tn sc)))
+ (decf count)))))))
+ (declare (inline frob-slot)) ; until DYNAMIC-EXTENT works
+ (or (frob-slot #'tn-reads)
+ (frob-slot #'tn-writes))))
+\f