;;
;; archives:archives is a hashmap for loadable files
;; core:core is the running binary file
-;; archive:main is the name of the first on-core member
-;; archive:incore is the byte position into core for the archive
+;;
+;; The "archive" context holds utility code.
+;; archive:main is the name of the first in-core member.
+;; archive:incore is the byte position into core for the archive.
+;;
+;; Use (archives member pathname) to register that the file "member"
+;; should be looked up in the ar style archive of the given pathname.
+;;
+;; Use (archive pathname) to register all members of the nominated ar
+;; style archive.
(new Tree 'archives)
-(define core:core (read-file (main-args 0)))
+(define core:core (read-file "/proc/self/exe"))
(context 'archive)
(constant
'load
- (letex (LOAD load)
+ (letex ((LOAD load) (CTX '(or (and (1 (args)) (args 1)) MAIN)))
(fn () (if (archives (args 0))
- (eval-string (archive:get $it (args 0)) MAIN)
- (LOAD (args 0)))))
+ (eval-string (archive:get $it (args 0)) CTX)
+ (LOAD (args 0) CTX))))
'read-file
(letex (READ-FILE read-file)
(fn ()
(if (archives (args 0)) (archive:get $it (args 0))
- (READ-FILE (args 0)))))
+ (READ-FILE (args 0)))))
'file?
(letex (FILE? file?)
(fn () (if (archives (args 0)) true (FILE? (args 0)))))