-;;; The Cleanup structure represents some dynamic binding action.
-;;; Blocks are annotated with the current cleanup so that dynamic
-;;; bindings can be removed when control is transferred out of the
-;;; binding environment. We arrange for changes in dynamic bindings to
-;;; happen at block boundaries, so that cleanup code may easily be
-;;; inserted. The "mess-up" action is explicitly represented by a
-;;; funny function call or Entry node.
+;;; Check that COMPONENT is suitable for roles which involve adding
+;;; new code. (gotta love imperative programming with lotso in-place
+;;; side effects...)
+(defun aver-live-component (component)
+ ;; FIXME: As of sbcl-0.pre7.115, we're asserting that
+ ;; COMPILE-COMPONENT hasn't happened yet. Might it be even better
+ ;; (certainly stricter, possibly also correct...) to assert that
+ ;; IR1-FINALIZE hasn't happened yet?
+ (aver (not (eql (component-info component) :dead))))
+
+;;; Before sbcl-0.7.0, there were :TOPLEVEL things which were magical
+;;; in multiple ways. That's since been refactored into the orthogonal
+;;; properties "optimized for locall with no arguments" and "externally
+;;; visible/referenced (so don't delete it)". The code <0.7.0 did a lot
+;;; of tests a la (EQ KIND :TOP_LEVEL) in the "don't delete it?" sense;
+;;; this function is a sort of literal translation of those tests into
+;;; the new world.
+;;;
+;;; FIXME: After things settle down, bare :TOPLEVEL might go away, at
+;;; which time it might be possible to replace the COMPONENT-KIND
+;;; :TOPLEVEL mess with a flag COMPONENT-HAS-EXTERNAL-REFERENCES-P
+;;; along the lines of FUNCTIONAL-HAS-EXTERNAL-REFERENCES-P.
+(defun lambda-toplevelish-p (clambda)
+ (or (eql (lambda-kind clambda) :toplevel)
+ (lambda-has-external-references-p clambda)))
+(defun component-toplevelish-p (component)
+ (member (component-kind component)
+ '(:toplevel :complex-toplevel)))
+
+;;; A CLEANUP structure represents some dynamic binding action. Blocks
+;;; are annotated with the current CLEANUP so that dynamic bindings
+;;; can be removed when control is transferred out of the binding
+;;; environment. We arrange for changes in dynamic bindings to happen
+;;; at block boundaries, so that cleanup code may easily be inserted.
+;;; The "mess-up" action is explicitly represented by a funny function
+;;; call or ENTRY node.