-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathintrospection.ss
79 lines (63 loc) · 2.49 KB
/
introspection.ss
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
; *************************************************************************
; Copyright (c) 1992 Xerox Corporation.
; All Rights Reserved.
;
; Use, reproduction, and preparation of derivative works are permitted.
; Any copy of this software or of any derivative work must include the
; above copyright notice of Xerox Corporation, this paragraph and the
; one after it. Any distribution of this software or derivative works
; must comply with all applicable United States export control laws.
;
; This software is made available AS IS, and XEROX CORPORATION DISCLAIMS
; ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
; PURPOSE, AND NOTWITHSTANDING ANY OTHER PROVISION CONTAINED HEREIN, ANY
; LIABILITY FOR DAMAGES RESULTING FROM THE SOFTWARE OR ITS USE IS
; EXPRESSLY DISCLAIMED, WHETHER ARISING IN CONTRACT, TORT (INCLUDING
; NEGLIGENCE) OR STRICT LIABILITY, EVEN IF XEROX CORPORATION IS ADVISED
; OF THE POSSIBILITY OF SUCH DAMAGES.
; *************************************************************************
;
; port to R6RS -- 2007 Christian Sloma
;
(library (clos introspection)
(export set-primitive-class-of!
class-of
class-direct-supers
class-direct-slots
class-precedence-list
class-slots
class-definition-name
generic-methods
method-specializers
method-qualifier
method-procedure)
(import (only (rnrs) define set! if quote)
(clos private allocation)
(clos slot-access))
(define primitive-class-of #f)
(define (set-primitive-class-of! proc)
(set! primitive-class-of proc))
(define (class-of obj)
(if (instance? obj)
(instance-class obj)
(primitive-class-of obj)))
(define (class-direct-supers class)
(slot-ref class 'direct-supers))
(define (class-direct-slots class)
(slot-ref class 'direct-slots))
(define (class-precedence-list class)
(slot-ref class 'precedence-list))
(define (class-slots class)
(slot-ref class 'slots))
(define (class-definition-name class)
(slot-ref class 'definition-name))
(define (generic-methods generic)
(slot-ref generic 'methods))
(define (method-specializers method)
(slot-ref method 'specializers))
(define (method-qualifier method)
(slot-ref method 'qualifier))
(define (method-procedure method)
(slot-ref method 'procedure))
) ;; library (clos introspection)