Function: ebrowse-insert-supers

ebrowse-insert-supers is a byte-compiled function defined in ebrowse.el.gz.

Signature

(ebrowse-insert-supers TREE CLASSES)

Documentation

Build base class lists in class tree TREE.

CLASSES is an obarray used to collect classes.

Helper function for ebrowse-build-tree-table. Base classes should be ordered so that immediate base classes come first, then the base class of the immediate base class and so on. This means that we must construct the base-class list top down with adding each level at the beginning of the base-class list.

We have to be cautious here not to end up in an infinite recursion if for some reason a circle is in the inheritance graph.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/ebrowse.el.gz
(defun ebrowse-insert-supers (tree classes)
  "Build base class lists in class tree TREE.
CLASSES is an obarray used to collect classes.

Helper function for `ebrowse-build-tree-table'.  Base classes should
be ordered so that immediate base classes come first, then the base
class of the immediate base class and so on.  This means that we must
construct the base-class list top down with adding each level at the
beginning of the base-class list.

We have to be cautious here not to end up in an infinite recursion
if for some reason a circle is in the inheritance graph."
  (cl-loop for class in tree
           as subclasses = (ebrowse-ts-subclasses class) do
           ;; Make sure every class is represented by a unique object
           (cl-loop for subclass on subclasses
                    do
                    (let ((name (ebrowse-qualified-class-name
                                 (ebrowse-ts-class (car subclass)))))
                      ;; Replace the subclass tree with the one found in
                      ;; CLASSES if there is already an entry for that class
                      ;; in it. Otherwise make a new entry.
                      ;;
                      ;; CAVEAT: If by some means (e.g., use of the
                      ;; preprocessor in class declarations, a name is marked
                      ;; as a subclass of itself on some path, we would end up
                      ;; in an endless loop. We have to omit subclasses from
                      ;; the recursion that already have been processed.
                      (if (gethash name classes)
                          (setf (car subclass) (gethash name classes))
                        (setf (gethash name classes) (car subclass)))))
           ;; Process subclasses
           (ebrowse-insert-supers subclasses classes)))