Function: comp--limplify-top-level
comp--limplify-top-level is a byte-compiled function defined in
comp.el.gz.
Signature
(comp--limplify-top-level FOR-LATE-LOAD)
Documentation
Create a Limple function to modify the global environment at load.
When FOR-LATE-LOAD is non-nil, the emitted function modifies only function definition.
Synthesize a function called top_level_run that gets one single
parameter (the compilation unit itself). To define native
functions, top_level_run will call back comp--register-subr
into the C code forwarding the compilation unit.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/comp.el.gz
(defun comp--limplify-top-level (for-late-load)
"Create a Limple function to modify the global environment at load.
When FOR-LATE-LOAD is non-nil, the emitted function modifies only
function definition.
Synthesize a function called `top_level_run' that gets one single
parameter (the compilation unit itself). To define native
functions, `top_level_run' will call back `comp--register-subr'
into the C code forwarding the compilation unit."
;; Once an .eln is loaded and Emacs is dumped 'top_level_run' has no
;; reasons to be executed ever again. Therefore all objects can be
;; just ephemeral.
(let* ((comp-curr-allocation-class 'd-ephemeral)
(func (make-comp-func-l :name (if for-late-load
'late-top-level-run
'top-level-run)
:c-name (if for-late-load
"late_top_level_run"
"top_level_run")
:args (make-comp-args :min 1 :max 1)
;; Frame is 2 wide: Slot 0 is the
;; compilation unit being loaded
;; (incoming parameter). Slot 1 is
;; the last function being
;; registered.
:frame-size 2
:speed (comp-ctxt-speed comp-ctxt)
:safety (comp-ctxt-safety comp-ctxt)))
(comp-func func)
(comp-pass (make-comp-limplify
:curr-block (make--comp-block-lap -1 0 'top-level)
:frame (comp--new-frame 1 0))))
(comp--make-curr-block 'entry (comp--sp))
(comp--emit-annotation (if for-late-load
"Late top level"
"Top level"))
;; Assign the compilation unit incoming as parameter to the slot frame 0.
(comp--emit `(set-par-to-local ,(comp--slot-n 0) 0))
(maphash (lambda (_ func)
(comp--emit-lambda-for-top-level func))
(comp-ctxt-byte-func-to-func-h comp-ctxt))
(mapc (lambda (x) (comp--emit-for-top-level x for-late-load))
(comp-ctxt-top-level-forms comp-ctxt))
(comp--emit `(return ,(make--comp-mvar :slot 1)))
(comp--limplify-finalize-function func)))