3
$Id: delint.scm,v 1.4 1999/01/02 06:06:43 cph Exp $
5
Copyright (c) 1989, 1990, 1999 Massachusetts Institute of Technology
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or (at
10
your option) any later version.
12
This program is distributed in the hope that it will be useful, but
13
WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
;;;; Delete integrated parameters
24
(declare (usual-integrations))
26
(define (delete-integrated-parameters blocks)
29
(if (stack-block? block)
30
(delete-integrated-parameters! block)))
33
(define (delete-integrated-parameters! block)
35
(procedure (block-procedure block)))
36
(let ((delete-integrations
37
(lambda (get-names set-names!)
40
(find-integrated-variables (get-names procedure)))
41
(lambda (not-integrated integrated)
42
(if (not (null? integrated))
44
(set-names! procedure not-integrated)
46
(eq-set-union deletions integrated)))))))))
47
(delete-integrations (lambda (procedure)
48
(cdr (procedure-required procedure)))
49
(lambda (procedure required)
50
(set-cdr! (procedure-required procedure)
52
(delete-integrations procedure-optional set-procedure-optional!))
53
(let ((rest (procedure-rest procedure)))
54
(if (and rest (variable-unused? rest))
56
(set! deletions (eq-set-adjoin deletions rest))
57
(set-procedure-rest! procedure false))))
60
(find-integrated-bindings (procedure-names procedure)
61
(procedure-values procedure)))
62
(lambda (names vals integrated)
63
(set-procedure-names! procedure names)
64
(set-procedure-values! procedure vals)
65
(set! deletions (eq-set-union deletions integrated))))
66
(if (not (null? deletions))
67
(set-block-bound-variables!
69
(eq-set-difference (block-bound-variables block) deletions)))))
71
(define (find-integrated-bindings names vals)
76
(find-integrated-bindings (cdr names) (cdr vals)))
77
(lambda (names* values* integrated)
78
(if (variable-unused? (car names))
79
(values names* values* (cons (car names) integrated))
80
(values (cons (car names) names*)
81
(cons (car vals) values*)
84
(define (find-integrated-variables variables)
89
(find-integrated-variables (cdr variables)))
90
(lambda (not-integrated integrated)
91
(if (or (variable-register (car variables))
92
(variable-unused? (car variables)))
93
(values not-integrated
94
(cons (car variables) integrated))
95
(values (cons (car variables) not-integrated)