Function: comp--intern-func-in-ctxt

comp--intern-func-in-ctxt is a byte-compiled function defined in comp.el.gz.

Signature

(comp--intern-func-in-ctxt _ OBJ)

Documentation

Given OBJ of type byte-to-native-lambda, create a function in comp-ctxt.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/comp.el.gz
(defun comp--intern-func-in-ctxt (_ obj)
  "Given OBJ of type `byte-to-native-lambda', create a function in `comp-ctxt'."
  (when-let* ((byte-func (byte-to-native-lambda-byte-func obj)))
    (let* ((lap (byte-to-native-lambda-lap obj))
           (top-l-form (cl-loop
                        for form in (comp-ctxt-top-level-forms comp-ctxt)
                        when (and (byte-to-native-func-def-p form)
                                  (eq (byte-to-native-func-def-byte-func form)
                                      byte-func))
                        return form))
           (name (when top-l-form
                   (byte-to-native-func-def-name top-l-form)))
           (c-name (comp-c-func-name (or name "anonymous-lambda") "F"))
           (func (if (comp--lex-byte-func-p byte-func)
                     (make-comp-func-l
                      :args (comp--decrypt-arg-list (aref byte-func 0)
                                                   name))
                   (make-comp-func-d :lambda-list (aref byte-func 0)))))
      (setf (comp-func-name func) name
            (comp-func-byte-func func) byte-func
            (comp-func-doc func) (documentation byte-func t)
            (comp-func-int-spec func) (interactive-form byte-func)
            (comp-func-command-modes func) (command-modes byte-func)
            (comp-func-c-name func) c-name
            (comp-func-lap func) lap
            (comp-func-frame-size func) (comp--byte-frame-size byte-func)
            (comp-func-speed func) (comp--spill-speed name)
            (comp-func-safety func) (comp--spill-safety name)
            (comp-func-declared-type func) (comp--spill-decl-spec name 'function-type)
            (comp-func-pure func) (comp--spill-decl-spec name 'pure))

      ;; Store the c-name to have it retrievable from
      ;; `comp-ctxt-top-level-forms'.
      (when top-l-form
        (setf (byte-to-native-func-def-c-name top-l-form) c-name))
      (unless name
        (puthash byte-func func (comp-ctxt-byte-func-to-func-h comp-ctxt)))
      (comp--add-func-to-ctxt func)
      (comp-log (format "Function %s:\n" name) 1)
      (comp-log lap 1 t))))