3
$Id: declar.scm,v 1.10 2007/01/05 21:19:20 cph Exp $
3
$Id: declar.scm,v 1.12 2008/01/30 20:01:44 cph Exp $
5
5
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
6
6
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
7
2006, 2007 Massachusetts Institute of Technology
7
2006, 2007, 2008 Massachusetts Institute of Technology
9
9
This file is part of MIT/GNU Scheme.
30
30
(declare (usual-integrations))
32
(define (process-top-level-declarations! block declarations)
32
;;; A block's declarations are processed in two phases: before and
33
;;; after the flow graph is generated for the block's children. See
34
;;; GENERATE/BODY in fggen/fggen.scm. Some declarations need to refer
35
;;; to information about variables bound by the block, so they use
36
;;; post-declarations; others need to establish information that the
37
;;; children can inherit from, so they use pre-declarations.
39
(define (process-top-level-declarations! block declarations handlers)
33
40
(process-declarations!
40
47
(loop (if (assq (caar defaults) declarations)
42
49
(cons (car defaults) declarations))
45
(define (process-declarations! block declarations)
53
(define (process-declarations! block declarations handlers)
46
54
(for-each (lambda (declaration)
47
(process-declaration! block declaration))
55
(process-declaration! block declaration handlers))
50
(define (process-declaration! block declaration)
51
(let ((entry (assq (car declaration) known-declarations)))
58
(define (process-declaration! block declaration handlers)
59
(let ((entry (assq (car declaration) handlers)))
53
61
((cdr entry) block (car declaration) (cdr declaration))
54
62
(warn "Unknown declaration name" (car declaration)))))
56
(define known-declarations
59
(define (define-declaration keyword handler)
60
(let ((entry (assq keyword known-declarations)))
62
(set-cdr! entry handler)
63
(set! known-declarations
64
(cons (cons keyword handler)
65
known-declarations))))
64
(define (declaration-processor get-handlers)
65
(lambda (block declarations)
66
(process-top-level-declarations! block declarations (get-handlers))))
68
(define (declaration-definer get-handlers set-handlers!)
69
(lambda (keyword handler)
70
(let ((handlers (get-handlers)))
71
(cond ((assq keyword handlers)
73
(set-cdr! entry handler)))
75
(set-handlers! (cons (cons keyword handler) handlers)))))
78
(define pre-declarations '())
79
(define post-declarations '())
81
(define process-pre-declarations!
82
(declaration-processor (lambda () pre-declarations)))
84
(define process-post-declarations!
85
(declaration-processor (lambda () post-declarations)))
87
(define define-pre-declaration
88
(declaration-definer (lambda () pre-declarations)
89
(lambda (handlers) (set! pre-declarations handlers))))
91
(define define-post-declaration
92
(declaration-definer (lambda () post-declarations)
93
(lambda (handlers) (set! post-declarations handlers))))
95
(define (define-pre-only-declaration keyword handler)
96
(define-pre-declaration keyword handler)
97
(define-post-declaration keyword ignored-declaration))
99
(define (define-post-only-declaration keyword handler)
100
(define-pre-declaration keyword ignored-declaration)
101
(define-post-declaration keyword handler))
103
(define ignored-declaration
104
(lambda (block keyword parameters)
105
block keyword parameters ;ignore
68
108
(package (boolean-variable-property)
132
(define-declaration 'UUO-LINK boolean-variable-property)
133
(define-declaration 'CONSTANT boolean-variable-property)
134
(define-declaration 'IGNORE-REFERENCE-TRAPS boolean-variable-property)
135
(define-declaration 'IGNORE-ASSIGNMENT-TRAPS boolean-variable-property)
136
(define-declaration 'USUAL-DEFINITION boolean-variable-property)
137
(define-declaration 'SIDE-EFFECT-FREE boolean-variable-property)
138
(define-declaration 'PURE-FUNCTION boolean-variable-property)
b'\\ No newline at end of file'
172
(define-post-only-declaration 'UUO-LINK boolean-variable-property)
173
(define-post-only-declaration 'CONSTANT boolean-variable-property)
174
(define-post-only-declaration 'IGNORE-REFERENCE-TRAPS
175
boolean-variable-property)
176
(define-post-only-declaration 'IGNORE-ASSIGNMENT-TRAPS
177
boolean-variable-property)
178
(define-post-only-declaration 'USUAL-DEFINITION boolean-variable-property)
179
(define-post-only-declaration 'SIDE-EFFECT-FREE boolean-variable-property)
180
(define-post-only-declaration 'PURE-FUNCTION boolean-variable-property)
182
;;;; Safety Check Declarations
185
(define (check-property block-checks set-block-checks! enable?)
186
(lambda (block keyword primitives)
190
(let ((checks (block-checks block)))
191
(if (null? primitives)
193
(if (boolean? checks)
194
(if (eqv? checks enable?)
197
(list checks primitives '())
198
(list checks '() primitives)))
199
(let ((default (car checks))
200
(do-check (cadr checks))
201
(dont-check (caddr checks)))
204
(eq-set-adjoin primitives do-check)
208
(eq-set-adjoin primitives dont-check))))))))))
209
(define-pre-only-declaration 'TYPE-CHECKS
210
(check-property block-type-checks set-block-type-checks! #t))
211
(define-pre-only-declaration 'NO-TYPE-CHECKS
212
(check-property block-type-checks set-block-type-checks! #f))
213
(define-pre-only-declaration 'RANGE-CHECKS
214
(check-property block-range-checks set-block-range-checks! #t))
215
(define-pre-only-declaration 'NO-RANGE-CHECKS
216
(check-property block-range-checks set-block-range-checks! #f)))