-
Notifications
You must be signed in to change notification settings - Fork 4
/
load-environment.lisp
28 lines (27 loc) · 1.13 KB
/
load-environment.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(in-package #:cleavir-example)
(defun load-environment (&optional (env *environment*))
"Fill the given example environment full of much of the CL package, taken from the host.
Note that most macros are not taken, since they may not expand into portable code."
(do-external-symbols (s "CL")
(cond ((constantp s)
(%defconstant s (cl:eval s) env))
(t (multiple-value-bind (expansion expandedp)
(macroexpand-1 s)
(when expandedp
(%defsmacro s expansion env)))))
(cond ((or (and (fboundp s)
(not (macro-function s))
(not (special-operator-p s)))
(member s *functions*))
(%defun s env))
(t (let ((pair (assoc s *macros*)))
(when pair
(%defmacro s (cdr pair) env)))))
(loop for f in *functions* do (%defun f env))
(cond ((find-class s nil)
(%defclass s (find-class s) env))))
;; Force computing a policy
(proclaim-optimize '((safety 1) (debug 1) (speed 1) (space 1)
(compilation-speed 1))
env)
(values))