function binding fixes
[bpt/guile.git] / module / language / elisp / compile-tree-il.scm
1 ;;; Guile Emacs Lisp
2
3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation; either version 3, or (at your option)
8 ;; any later version.
9 ;;
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14 ;;
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program; see the file COPYING. If not, write to
17 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 ;; Boston, MA 02111-1307, USA.
19
20 ;;; Code:
21
22 (define-module (language elisp compile-tree-il)
23 #:use-module (language elisp bindings)
24 #:use-module (language elisp runtime)
25 #:use-module (language tree-il)
26 #:use-module (system base pmatch)
27 #:use-module (system base compile)
28 #:use-module (srfi srfi-1)
29 #:use-module (srfi srfi-8)
30 #:use-module (srfi srfi-11)
31 #:use-module (srfi srfi-26)
32 #:export (compile-tree-il
33 compile-progn
34 compile-eval-when-compile
35 compile-if
36 compile-defconst
37 compile-defvar
38 compile-setq
39 compile-let
40 compile-flet
41 compile-labels
42 compile-let*
43 compile-guile-ref
44 compile-guile-primitive
45 compile-function
46 compile-defmacro
47 compile-defun
48 #{compile-`}#
49 compile-quote
50 compile-%funcall
51 compile-%set-lexical-binding-mode))
52
53 ;;; Certain common parameters (like the bindings data structure or
54 ;;; compiler options) are not always passed around but accessed using
55 ;;; fluids to simulate dynamic binding (hey, this is about elisp).
56
57 ;;; The bindings data structure to keep track of symbol binding related
58 ;;; data.
59
60 (define bindings-data (make-fluid))
61
62 (define lexical-binding (make-fluid))
63
64 ;;; Find the source properties of some parsed expression if there are
65 ;;; any associated with it.
66
67 (define (location x)
68 (and (pair? x)
69 (let ((props (source-properties x)))
70 (and (not (null? props))
71 props))))
72
73 ;;; Values to use for Elisp's nil and t.
74
75 (define (nil-value loc)
76 (make-const loc (@ (language elisp runtime) nil-value)))
77
78 (define (t-value loc)
79 (make-const loc (@ (language elisp runtime) t-value)))
80
81 ;;; Modules that contain the value and function slot bindings.
82
83 (define runtime '(language elisp runtime))
84
85 (define value-slot (@ (language elisp runtime) value-slot-module))
86
87 (define function-slot (@ (language elisp runtime) function-slot-module))
88
89 ;;; The backquoting works the same as quasiquotes in Scheme, but the
90 ;;; forms are named differently; to make easy adaptions, we define these
91 ;;; predicates checking for a symbol being the car of an
92 ;;; unquote/unquote-splicing/backquote form.
93
94 (define (unquote? sym)
95 (and (symbol? sym) (eq? sym '#{,}#)))
96
97 (define (unquote-splicing? sym)
98 (and (symbol? sym) (eq? sym '#{,@}#)))
99
100 ;;; Build a call to a primitive procedure nicely.
101
102 (define (call-primitive loc sym . args)
103 (make-application loc (make-primitive-ref loc sym) args))
104
105 ;;; Error reporting routine for syntax/compilation problems or build
106 ;;; code for a runtime-error output.
107
108 (define (report-error loc . args)
109 (apply error args))
110
111 (define (access-variable loc symbol handle-lexical handle-dynamic)
112 (cond
113 ((get-lexical-binding (fluid-ref bindings-data) symbol)
114 => handle-lexical)
115 (else
116 (handle-dynamic))))
117
118 (define (reference-variable loc symbol)
119 (access-variable
120 loc
121 symbol
122 (lambda (lexical)
123 (make-lexical-ref loc lexical lexical))
124 (lambda ()
125 (call-primitive loc
126 'fluid-ref
127 (make-module-ref loc value-slot symbol #t)))))
128
129 (define (global? module symbol)
130 (module-variable module symbol))
131
132 (define (ensure-globals! loc names body)
133 (if (and (every (cut global? (resolve-module value-slot) <>) names)
134 (every symbol-interned? names))
135 body
136 (make-sequence
137 loc
138 `(,@(map
139 (lambda (name)
140 (ensure-fluid! value-slot name)
141 (make-application loc
142 (make-module-ref loc runtime 'ensure-fluid! #t)
143 (list (make-const loc value-slot)
144 (make-const loc name))))
145 names)
146 ,body))))
147
148 (define (set-variable! loc symbol value)
149 (access-variable
150 loc
151 symbol
152 (lambda (lexical)
153 (make-lexical-set loc lexical lexical value))
154 (lambda ()
155 (ensure-globals!
156 loc
157 (list symbol)
158 (call-primitive loc
159 'fluid-set!
160 (make-module-ref loc value-slot symbol #t)
161 value)))))
162
163 (define (access-function loc symbol handle-lexical handle-global)
164 (cond
165 ((get-function-binding (fluid-ref bindings-data) symbol)
166 => handle-lexical)
167 (else
168 (handle-global))))
169
170 (define (reference-function loc symbol)
171 (access-function
172 loc
173 symbol
174 (lambda (gensym) (make-lexical-ref loc symbol gensym))
175 (lambda () (make-module-ref loc function-slot symbol #t))))
176
177 (define (set-function! loc symbol value)
178 (access-function
179 loc
180 symbol
181 (lambda (gensym) (make-lexical-set loc symbol gensym value))
182 (lambda ()
183 (make-application
184 loc
185 (make-module-ref loc runtime 'set-symbol-function! #t)
186 (list (make-const loc symbol) value)))))
187
188 (define (bind-lexically? sym module decls)
189 (or (eq? module function-slot)
190 (let ((decl (assq-ref decls sym)))
191 (and (equal? module value-slot)
192 (or
193 (eq? decl 'lexical)
194 (and
195 (fluid-ref lexical-binding)
196 (not (global? (resolve-module module) sym))))))))
197
198 (define (parse-let-binding loc binding)
199 (pmatch binding
200 ((unquote var)
201 (guard (symbol? var))
202 (cons var #nil))
203 ((,var)
204 (guard (symbol? var))
205 (cons var #nil))
206 ((,var ,val)
207 (guard (symbol? var))
208 (cons var val))
209 (else
210 (report-error loc "malformed variable binding" binding))))
211
212 (define (parse-flet-binding loc binding)
213 (pmatch binding
214 ((,var ,args . ,body)
215 (guard (symbol? var))
216 (cons var `(function (lambda ,args ,@body))))
217 (else
218 (report-error loc "malformed function binding" binding))))
219
220 (define (parse-declaration expr)
221 (pmatch expr
222 ((lexical . ,vars)
223 (map (cut cons <> 'lexical) vars))
224 (else
225 '())))
226
227 (define (parse-body-1 body lambda?)
228 (let loop ((lst body)
229 (decls '())
230 (intspec #f)
231 (doc #f))
232 (pmatch lst
233 (((declare . ,x) . ,tail)
234 (loop tail (append-reverse x decls) intspec doc))
235 (((interactive . ,x) . ,tail)
236 (guard lambda? (not intspec))
237 (loop tail decls x doc))
238 ((,x . ,tail)
239 (guard lambda? (string? x) (not doc) (not (null? tail)))
240 (loop tail decls intspec x))
241 (else
242 (values (append-map parse-declaration decls)
243 intspec
244 doc
245 lst)))))
246
247 (define (parse-lambda-body body)
248 (parse-body-1 body #t))
249
250 (define (parse-body body)
251 (receive (decls intspec doc body) (parse-body-1 body #f)
252 (values decls body)))
253
254 ;;; Partition the argument list of a lambda expression into required,
255 ;;; optional and rest arguments.
256
257 (define (parse-lambda-list lst)
258 (define (%match lst null optional rest symbol)
259 (pmatch lst
260 (() (null))
261 ((&optional . ,tail) (optional tail))
262 ((&rest . ,tail) (rest tail))
263 ((,arg . ,tail) (guard (symbol? arg)) (symbol arg tail))
264 (else (fail))))
265 (define (return rreq ropt rest)
266 (values #t (reverse rreq) (reverse ropt) rest))
267 (define (fail)
268 (values #f #f #f #f))
269 (define (parse-req lst rreq)
270 (%match lst
271 (lambda () (return rreq '() #f))
272 (lambda (tail) (parse-opt tail rreq '()))
273 (lambda (tail) (parse-rest tail rreq '()))
274 (lambda (arg tail) (parse-req tail (cons arg rreq)))))
275 (define (parse-opt lst rreq ropt)
276 (%match lst
277 (lambda () (return rreq ropt #f))
278 (lambda (tail) (fail))
279 (lambda (tail) (parse-rest tail rreq ropt))
280 (lambda (arg tail) (parse-opt tail rreq (cons arg ropt)))))
281 (define (parse-rest lst rreq ropt)
282 (%match lst
283 (lambda () (fail))
284 (lambda (tail) (fail))
285 (lambda (tail) (fail))
286 (lambda (arg tail) (parse-post-rest tail rreq ropt arg))))
287 (define (parse-post-rest lst rreq ropt rest)
288 (%match lst
289 (lambda () (return rreq ropt rest))
290 (lambda () (fail))
291 (lambda () (fail))
292 (lambda (arg tail) (fail))))
293 (parse-req lst '()))
294
295 (define (make-simple-lambda loc meta req opt init rest vars body)
296 (make-lambda loc
297 meta
298 (make-lambda-case #f req opt rest #f init vars body #f)))
299
300 (define (compile-lambda loc meta args body)
301 (receive (valid? req-ids opt-ids rest-id)
302 (parse-lambda-list args)
303 (if valid?
304 (let* ((all-ids (append req-ids
305 opt-ids
306 (or (and=> rest-id list) '())))
307 (all-vars (map (lambda (ignore) (gensym)) all-ids)))
308 (let*-values (((decls intspec doc forms)
309 (parse-lambda-body body))
310 ((lexical dynamic)
311 (partition
312 (compose (cut bind-lexically? <> value-slot decls)
313 car)
314 (map list all-ids all-vars)))
315 ((lexical-ids lexical-vars) (unzip2 lexical))
316 ((dynamic-ids dynamic-vars) (unzip2 dynamic)))
317 (with-dynamic-bindings
318 (fluid-ref bindings-data)
319 dynamic-ids
320 (lambda ()
321 (with-lexical-bindings
322 (fluid-ref bindings-data)
323 lexical-ids
324 lexical-vars
325 (lambda ()
326 (ensure-globals!
327 loc
328 dynamic-ids
329 (let* ((tree-il (compile-expr `(progn ,@forms)))
330 (full-body
331 (if (null? dynamic)
332 tree-il
333 (make-dynlet
334 loc
335 (map (cut make-module-ref loc value-slot <> #t)
336 dynamic-ids)
337 (map (cut make-lexical-ref loc <> <>)
338 dynamic-ids
339 dynamic-vars)
340 tree-il))))
341 (make-simple-lambda loc
342 meta
343 req-ids
344 opt-ids
345 (map (const (nil-value loc))
346 opt-ids)
347 rest-id
348 all-vars
349 full-body)))))))))
350 (report-error "invalid function" `(lambda ,args ,@body)))))
351
352 ;;; Handle the common part of defconst and defvar, that is, checking for
353 ;;; a correct doc string and arguments as well as maybe in the future
354 ;;; handling the docstring somehow.
355
356 (define (handle-var-def loc sym doc)
357 (cond
358 ((not (symbol? sym)) (report-error loc "expected symbol, got" sym))
359 ((> (length doc) 1) (report-error loc "too many arguments to defvar"))
360 ((and (not (null? doc)) (not (string? (car doc))))
361 (report-error loc "expected string as third argument of defvar, got"
362 (car doc)))
363 ;; TODO: Handle doc string if present.
364 (else #t)))
365
366 ;;; Handle macro and special operator bindings.
367
368 (define (find-operator name type)
369 (and
370 (symbol? name)
371 (module-defined? (resolve-interface function-slot) name)
372 (let ((op (module-ref (resolve-module function-slot) name)))
373 (if (and (pair? op) (eq? (car op) type))
374 (cdr op)
375 #f))))
376
377 ;;; See if a (backquoted) expression contains any unquotes.
378
379 (define (contains-unquotes? expr)
380 (if (pair? expr)
381 (if (or (unquote? (car expr)) (unquote-splicing? (car expr)))
382 #t
383 (or (contains-unquotes? (car expr))
384 (contains-unquotes? (cdr expr))))
385 #f))
386
387 ;;; Process a backquoted expression by building up the needed
388 ;;; cons/append calls. For splicing, it is assumed that the expression
389 ;;; spliced in evaluates to a list. The emacs manual does not really
390 ;;; state either it has to or what to do if it does not, but Scheme
391 ;;; explicitly forbids it and this seems reasonable also for elisp.
392
393 (define (unquote-cell? expr)
394 (and (list? expr) (= (length expr) 2) (unquote? (car expr))))
395
396 (define (unquote-splicing-cell? expr)
397 (and (list? expr) (= (length expr) 2) (unquote-splicing? (car expr))))
398
399 (define (process-backquote loc expr)
400 (if (contains-unquotes? expr)
401 (if (pair? expr)
402 (if (or (unquote-cell? expr) (unquote-splicing-cell? expr))
403 (compile-expr (cadr expr))
404 (let* ((head (car expr))
405 (processed-tail (process-backquote loc (cdr expr)))
406 (head-is-list-2 (and (list? head)
407 (= (length head) 2)))
408 (head-unquote (and head-is-list-2
409 (unquote? (car head))))
410 (head-unquote-splicing (and head-is-list-2
411 (unquote-splicing?
412 (car head)))))
413 (if head-unquote-splicing
414 (call-primitive loc
415 'append
416 (compile-expr (cadr head))
417 processed-tail)
418 (call-primitive loc 'cons
419 (if head-unquote
420 (compile-expr (cadr head))
421 (process-backquote loc head))
422 processed-tail))))
423 (report-error loc
424 "non-pair expression contains unquotes"
425 expr))
426 (make-const loc expr)))
427
428 ;;; Special operators
429
430 (defspecial progn (loc args)
431 (make-sequence loc
432 (if (null? args)
433 (list (nil-value loc))
434 (map compile-expr args))))
435
436 (defspecial eval-when-compile (loc args)
437 (make-const loc (compile `(progn ,@args) #:from 'elisp #:to 'value)))
438
439 (defspecial if (loc args)
440 (pmatch args
441 ((,cond ,then . ,else)
442 (make-conditional
443 loc
444 (call-primitive loc 'not
445 (call-primitive loc 'nil? (compile-expr cond)))
446 (compile-expr then)
447 (compile-expr `(progn ,@else))))))
448
449 (defspecial defconst (loc args)
450 (pmatch args
451 ((,sym ,value . ,doc)
452 (if (handle-var-def loc sym doc)
453 (make-sequence loc
454 (list (set-variable! loc sym (compile-expr value))
455 (make-const loc sym)))))))
456
457 (defspecial defvar (loc args)
458 (pmatch args
459 ((,sym) (make-const loc sym))
460 ((,sym ,value . ,doc)
461 (if (handle-var-def loc sym doc)
462 (make-sequence
463 loc
464 (list
465 (make-conditional
466 loc
467 (make-conditional
468 loc
469 (call-primitive
470 loc
471 'module-bound?
472 (call-primitive loc
473 'resolve-interface
474 (make-const loc value-slot))
475 (make-const loc sym))
476 (call-primitive loc
477 'fluid-bound?
478 (make-module-ref loc value-slot sym #t))
479 (make-const loc #f))
480 (make-void loc)
481 (set-variable! loc sym (compile-expr value)))
482 (make-const loc sym)))))))
483
484 (defspecial setq (loc args)
485 (define (car* x) (if (null? x) '() (car x)))
486 (define (cdr* x) (if (null? x) '() (cdr x)))
487 (define (cadr* x) (car* (cdr* x)))
488 (define (cddr* x) (cdr* (cdr* x)))
489 (make-sequence
490 loc
491 (let loop ((args args) (last (nil-value loc)))
492 (if (null? args)
493 (list last)
494 (let ((sym (car args))
495 (val (compile-expr (cadr* args))))
496 (if (not (symbol? sym))
497 (report-error loc "expected symbol in setq")
498 (cons
499 (set-variable! loc sym val)
500 (loop (cddr* args)
501 (reference-variable loc sym)))))))))
502
503 (defspecial let (loc args)
504 (pmatch args
505 ((,varlist . ,body)
506 (let ((bindings (map (cut parse-let-binding loc <>) varlist)))
507 (receive (decls forms) (parse-body body)
508 (receive (lexical dynamic)
509 (partition
510 (compose (cut bind-lexically? <> value-slot decls)
511 car)
512 bindings)
513 (let ((make-values (lambda (for)
514 (map (lambda (el) (compile-expr (cdr el)))
515 for)))
516 (make-body (lambda () (compile-expr `(progn ,@forms)))))
517 (ensure-globals!
518 loc
519 (map car dynamic)
520 (if (null? lexical)
521 (make-dynlet loc
522 (map (compose (cut make-module-ref
523 loc
524 value-slot
525 <>
526 #t)
527 car)
528 dynamic)
529 (map (compose compile-expr cdr)
530 dynamic)
531 (make-body))
532 (let* ((lexical-syms (map (lambda (el) (gensym)) lexical))
533 (dynamic-syms (map (lambda (el) (gensym)) dynamic))
534 (all-syms (append lexical-syms dynamic-syms))
535 (vals (append (make-values lexical)
536 (make-values dynamic))))
537 (make-let loc
538 all-syms
539 all-syms
540 vals
541 (with-lexical-bindings
542 (fluid-ref bindings-data)
543 (map car lexical)
544 lexical-syms
545 (lambda ()
546 (if (null? dynamic)
547 (make-body)
548 (make-dynlet loc
549 (map
550 (compose
551 (cut make-module-ref
552 loc
553 value-slot
554 <>
555 #t)
556 car)
557 dynamic)
558 (map
559 (lambda (sym)
560 (make-lexical-ref
561 loc
562 sym
563 sym))
564 dynamic-syms)
565 (make-body))))))))))))))))
566
567 (defspecial let* (loc args)
568 (pmatch args
569 ((,varlist . ,body)
570 (let ((bindings (map (cut parse-let-binding loc <>) varlist)))
571 (receive (decls forms) (parse-body body)
572 (let iterate ((tail bindings))
573 (if (null? tail)
574 (compile-expr `(progn ,@forms))
575 (let ((sym (caar tail))
576 (value (compile-expr (cdar tail))))
577 (if (bind-lexically? sym value-slot decls)
578 (let ((target (gensym)))
579 (make-let loc
580 `(,target)
581 `(,target)
582 `(,value)
583 (with-lexical-bindings
584 (fluid-ref bindings-data)
585 `(,sym)
586 `(,target)
587 (lambda () (iterate (cdr tail))))))
588 (ensure-globals!
589 loc
590 (list sym)
591 (make-dynlet loc
592 (list (make-module-ref loc value-slot sym #t))
593 (list value)
594 (iterate (cdr tail)))))))))))))
595
596 (defspecial flet (loc args)
597 (pmatch args
598 ((,bindings . ,body)
599 (let ((names+vals (map (cut parse-flet-binding loc <>) bindings)))
600 (receive (decls forms) (parse-body body)
601 (let ((names (map car names+vals))
602 (vals (map cdr names+vals))
603 (gensyms (map (lambda (x) (gensym)) names+vals)))
604 (with-function-bindings
605 (fluid-ref bindings-data)
606 names
607 gensyms
608 (lambda ()
609 (make-let loc
610 names
611 gensyms
612 (map compile-expr vals)
613 (compile-expr `(progn ,@forms)))))))))))
614
615 (defspecial labels (loc args)
616 (pmatch args
617 ((,bindings . ,body)
618 (let ((names+vals (map (cut parse-flet-binding loc <>) bindings)))
619 (receive (decls forms) (parse-body body)
620 (let ((names (map car names+vals))
621 (vals (map cdr names+vals))
622 (gensyms (map (lambda (x) (gensym)) names+vals)))
623 (with-function-bindings
624 (fluid-ref bindings-data)
625 names
626 gensyms
627 (lambda ()
628 (make-letrec #f
629 loc
630 names
631 gensyms
632 (map compile-expr vals)
633 (compile-expr `(progn ,@forms)))))))))))
634
635 ;;; guile-ref allows building TreeIL's module references from within
636 ;;; elisp as a way to access data within the Guile universe. The module
637 ;;; and symbol referenced are static values, just like (@ module symbol)
638 ;;; does!
639
640 (defspecial guile-ref (loc args)
641 (pmatch args
642 ((,module ,sym) (guard (and (list? module) (symbol? sym)))
643 (make-module-ref loc module sym #t))))
644
645 ;;; guile-primitive allows to create primitive references, which are
646 ;;; still a little faster.
647
648 (defspecial guile-primitive (loc args)
649 (pmatch args
650 ((,sym)
651 (make-primitive-ref loc sym))))
652
653 (defspecial function (loc args)
654 (pmatch args
655 (((lambda ,args . ,body))
656 (compile-lambda loc '() args body))
657 ((,sym) (guard (symbol? sym))
658 (reference-function loc sym))))
659
660 (defspecial defmacro (loc args)
661 (pmatch args
662 ((,name ,args . ,body)
663 (if (not (symbol? name))
664 (report-error loc "expected symbol as macro name" name)
665 (let* ((tree-il
666 (make-sequence
667 loc
668 (list
669 (set-function!
670 loc
671 name
672 (make-application
673 loc
674 (make-module-ref loc '(guile) 'cons #t)
675 (list (make-const loc 'macro)
676 (compile-lambda loc
677 `((name . ,name))
678 args
679 body))))
680 (make-const loc name)))))
681 (compile tree-il #:from 'tree-il #:to 'value)
682 tree-il)))))
683
684 (defspecial defun (loc args)
685 (pmatch args
686 ((,name ,args . ,body)
687 (if (not (symbol? name))
688 (report-error loc "expected symbol as function name" name)
689 (make-sequence loc
690 (list (set-function! loc
691 name
692 (compile-lambda loc
693 `((name . ,name))
694 args
695 body))
696 (make-const loc name)))))))
697
698 (defspecial #{`}# (loc args)
699 (pmatch args
700 ((,val)
701 (process-backquote loc val))))
702
703 (defspecial quote (loc args)
704 (pmatch args
705 ((,val)
706 (make-const loc val))))
707
708 (defspecial %funcall (loc args)
709 (pmatch args
710 ((,function . ,arguments)
711 (make-application loc
712 (compile-expr function)
713 (map compile-expr arguments)))))
714
715 (defspecial %set-lexical-binding-mode (loc args)
716 (pmatch args
717 ((,val)
718 (fluid-set! lexical-binding val)
719 (make-void loc))))
720
721 ;;; Compile a compound expression to Tree-IL.
722
723 (define (compile-pair loc expr)
724 (let ((operator (car expr))
725 (arguments (cdr expr)))
726 (cond
727 ((find-operator operator 'special-operator)
728 => (lambda (special-operator-function)
729 (special-operator-function loc arguments)))
730 ((find-operator operator 'macro)
731 => (lambda (macro-function)
732 (compile-expr (apply macro-function arguments))))
733 (else
734 (compile-expr `(%funcall (function ,operator) ,@arguments))))))
735
736 ;;; Compile a symbol expression. This is a variable reference or maybe
737 ;;; some special value like nil.
738
739 (define (compile-symbol loc sym)
740 (case sym
741 ((nil) (nil-value loc))
742 ((t) (t-value loc))
743 (else (reference-variable loc sym))))
744
745 ;;; Compile a single expression to TreeIL.
746
747 (define (compile-expr expr)
748 (let ((loc (location expr)))
749 (cond
750 ((symbol? expr)
751 (compile-symbol loc expr))
752 ((pair? expr)
753 (compile-pair loc expr))
754 (else (make-const loc expr)))))
755
756 ;;; Process the compiler options.
757 ;;; FIXME: Why is '(()) passed as options by the REPL?
758
759 (define (valid-symbol-list-arg? value)
760 (or (eq? value 'all)
761 (and (list? value) (and-map symbol? value))))
762
763 (define (process-options! opt)
764 (if (and (not (null? opt))
765 (not (equal? opt '(()))))
766 (if (null? (cdr opt))
767 (report-error #f "Invalid compiler options" opt)
768 (let ((key (car opt))
769 (value (cadr opt)))
770 (case key
771 ((#:warnings) ; ignore
772 #f)
773 (else (report-error #f
774 "Invalid compiler option"
775 key)))))))
776
777 (define (compile-tree-il expr env opts)
778 (values
779 (with-fluids ((bindings-data (make-bindings)))
780 (process-options! opts)
781 (compile-expr expr))
782 env
783 env))