Add mechanism to write and read properties pertaining to the currently
authorChris Hanson <org/chris-hanson/cph>
Tue, 7 Mar 2006 06:40:24 +0000 (06:40 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 7 Mar 2006 06:40:24 +0000 (06:40 +0000)
loading file.

v7/src/runtime/load.scm
v7/src/runtime/runtime.pkg

index edba02017262108e51ce061e76aaa48d1d98d6f7..0c69cb8681ac8d35bd67bd0267654d4abf7368f1 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: load.scm,v 14.72 2005/07/19 03:48:44 cph Exp $
+$Id: load.scm,v 14.73 2006/03/07 06:40:17 cph Exp $
 
 Copyright 1988,1989,1990,1991,1992,1993 Massachusetts Institute of Technology
 Copyright 1994,1999,2000,2001,2002,2003 Massachusetts Institute of Technology
@@ -46,6 +46,7 @@ USA.
          ("bin" ,fasload/internal)))
   (set! load/default-find-pathname-with-type search-types-in-order)
   (set! load/current-pathname)
+  (set! *load-properties* #f)
   (set! condition-type:not-loading
        (make-condition-type 'NOT-LOADING condition-type:error '()
          "No file being loaded."))
@@ -61,6 +62,7 @@ USA.
 (define load/default-types)
 (define load/after-load-hooks)
 (define load/current-pathname)
+(define *load-properties*)
 (define condition-type:not-loading)
 (define load/default-find-pathname-with-type)
 (define fasload/default-types)
@@ -86,7 +88,8 @@ USA.
                (call-with-values
                    (lambda () (find-pathname filename load/default-types))
                  (lambda (pathname loader)
-                   (fluid-let ((load/current-pathname pathname))
+                   (fluid-let ((load/current-pathname pathname)
+                               (*load-properties* (list 'LOAD-PROPERTIES)))
                      (let ((load-it
                             (lambda ()
                               (loader pathname
@@ -112,11 +115,33 @@ USA.
              (if (default-object? suppress-loading-message?)
                  load/suppress-loading-message?
                  suppress-loading-message?)))))
-
+\f
 (define (current-load-pathname)
   (if (not load/loading?) (error condition-type:not-loading))
   load/current-pathname)
 
+(define (get-load-property key #!optional default)
+  (let ((props (get-load-properties)))
+    (let ((p (and props (assq key (cdr props)))))
+      (if p
+         (cdr p)
+         (begin
+           (if (default-object? default)
+               (error:bad-range-argument key 'GET-LOAD-PROPERTY))
+           default)))))
+
+(define (set-load-property! key datum)
+  (let ((props (get-load-properties)))
+    (if props
+       (let ((p (assq key (cdr props))))
+         (if p
+             (set-cdr! p datum)
+             (set-cdr! props (cons (cons key datum) (cdr props))))))))
+
+(define (get-load-properties)
+  (if (not *load-properties*) (warn "No file being loaded."))
+  *load-properties*)
+
 (define (load/push-hook! hook)
   (if (not load/loading?) (error condition-type:not-loading))
   (set! load/after-load-hooks (cons hook load/after-load-hooks))
index e5bcbe46919c29c42e09a326075be013be07006e..e575a0e3edb12d8c39594bfbd9dec839772e5906 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: runtime.pkg,v 14.575 2006/02/26 03:00:49 cph Exp $
+$Id: runtime.pkg,v 14.576 2006/03/07 06:40:24 cph Exp $
 
 Copyright 1988,1989,1990,1991,1992,1993 Massachusetts Institute of Technology
 Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology
@@ -2285,6 +2285,7 @@ USA.
          fasload
          fasload-latest
          fasload/default-types
+         get-load-property
          load
          load-latest
          load-library-object-file
@@ -2298,6 +2299,7 @@ USA.
          load/suppress-loading-message?
          read-file
          set-command-line-parser!
+         set-load-property!
          simple-command-line-parser)
   (initialization (initialize-package!)))