mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 03:30:27 +02:00
compile goops
The pending task is to make the accessors compiled too, and also to compile compile.scm and dispatch.scm, and to integrate dispatch into the VM. * oop/Makefile.am (SOURCES): VM-ify the makefile, so we compile goops.scm by default. * oop/goops.scm (load-toplevel): Load goops builtins when compiling too. (method): Fix a literal #<unspecified> in the generated procedure (for an empty body). (internal-add-method!): Cleverness when bootstrapping add-method!. Neat! (initialize for <generic>): Use the `method' macro so we get compilation support. * oop/goops/dispatch.scm (cache-methods): Don't assume entries are pairs.
This commit is contained in:
parent
41a2772c5c
commit
7d38f3d819
4 changed files with 24 additions and 31 deletions
|
@ -23,11 +23,8 @@ AUTOMAKE_OPTIONS = gnu
|
||||||
|
|
||||||
SUBDIRS = goops
|
SUBDIRS = goops
|
||||||
|
|
||||||
# These should be installed and distributed.
|
modpath = oop
|
||||||
oop_sources = goops.scm
|
SOURCES = goops.scm
|
||||||
|
include $(top_srcdir)/guilec.mk
|
||||||
|
|
||||||
subpkgdatadir = $(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)/oop
|
EXTRA_DIST += ChangeLog-2008
|
||||||
subpkgdata_DATA = $(oop_sources)
|
|
||||||
TAGS_FILES = $(subpkgdata_DATA)
|
|
||||||
|
|
||||||
EXTRA_DIST = $(oop_sources) ChangeLog-2008
|
|
||||||
|
|
|
@ -79,7 +79,9 @@
|
||||||
(define *goops-module* (current-module))
|
(define *goops-module* (current-module))
|
||||||
|
|
||||||
;; First initialize the builtin part of GOOPS
|
;; First initialize the builtin part of GOOPS
|
||||||
(%init-goops-builtins)
|
(eval-case
|
||||||
|
((load-toplevel compile-toplevel)
|
||||||
|
(%init-goops-builtins)))
|
||||||
|
|
||||||
;; Then load the rest of GOOPS
|
;; Then load the rest of GOOPS
|
||||||
(use-modules (oop goops util)
|
(use-modules (oop goops util)
|
||||||
|
@ -489,7 +491,7 @@
|
||||||
#:compile-env (compile-time-environment)
|
#:compile-env (compile-time-environment)
|
||||||
#:procedure (lambda ,(formals args)
|
#:procedure (lambda ,(formals args)
|
||||||
,@(if (null? body)
|
,@(if (null? body)
|
||||||
(list *unspecified*)
|
'(begin)
|
||||||
body)))))
|
body)))))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
@ -526,23 +528,21 @@
|
||||||
methods)
|
methods)
|
||||||
(loop (cdr l)))))))
|
(loop (cdr l)))))))
|
||||||
|
|
||||||
(define (internal-add-method! gf m)
|
(define internal-add-method!
|
||||||
(slot-set! m 'generic-function gf)
|
(method ((gf <generic>) (m <method>))
|
||||||
(slot-set! gf 'methods (compute-new-list-of-methods gf m))
|
(slot-set! m 'generic-function gf)
|
||||||
(let ((specializers (slot-ref m 'specializers)))
|
(slot-set! gf 'methods (compute-new-list-of-methods gf m))
|
||||||
(slot-set! gf 'n-specialized
|
(let ((specializers (slot-ref m 'specializers)))
|
||||||
(max (length* specializers)
|
(slot-set! gf 'n-specialized
|
||||||
(slot-ref gf 'n-specialized))))
|
(max (length* specializers)
|
||||||
(%invalidate-method-cache! gf)
|
(slot-ref gf 'n-specialized))))
|
||||||
(add-method-in-classes! m)
|
(%invalidate-method-cache! gf)
|
||||||
*unspecified*)
|
(add-method-in-classes! m)
|
||||||
|
*unspecified*))
|
||||||
|
|
||||||
(define-generic add-method!)
|
(define-generic add-method!)
|
||||||
|
|
||||||
(internal-add-method! add-method!
|
((method-procedure internal-add-method!) add-method! internal-add-method!)
|
||||||
(make <method>
|
|
||||||
#:specializers (list <generic> <method>)
|
|
||||||
#:procedure internal-add-method!))
|
|
||||||
|
|
||||||
(define-method (add-method! (proc <procedure>) (m <method>))
|
(define-method (add-method! (proc <procedure>) (m <method>))
|
||||||
(if (generic-capability? proc)
|
(if (generic-capability? proc)
|
||||||
|
@ -1407,12 +1407,8 @@
|
||||||
(name (get-keyword #:name initargs #f)))
|
(name (get-keyword #:name initargs #f)))
|
||||||
(next-method)
|
(next-method)
|
||||||
(slot-set! generic 'methods (if (is-a? previous-definition <procedure>)
|
(slot-set! generic 'methods (if (is-a? previous-definition <procedure>)
|
||||||
(list (make <method>
|
(list (method args
|
||||||
#:specializers <top>
|
(apply previous-definition args)))
|
||||||
#:procedure
|
|
||||||
(lambda l
|
|
||||||
(apply previous-definition
|
|
||||||
l))))
|
|
||||||
'()))
|
'()))
|
||||||
(if name
|
(if name
|
||||||
(set-procedure-property! generic 'name name))
|
(set-procedure-property! generic 'name name))
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
(define (cache-methods entries)
|
(define (cache-methods entries)
|
||||||
(do ((i (- (vector-length entries) 1) (- i 1))
|
(do ((i (- (vector-length entries) 1) (- i 1))
|
||||||
(methods '() (let ((entry (vector-ref entries i)))
|
(methods '() (let ((entry (vector-ref entries i)))
|
||||||
(if (struct? (car entry))
|
(if (or (not (pair? entry)) (struct? (car entry)))
|
||||||
(cons entry methods)
|
(cons entry methods)
|
||||||
methods))))
|
methods))))
|
||||||
((< i 0) methods)))
|
((< i 0) methods)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue