mirror of
https://github.com/PDP-10/its.git
synced 2026-03-27 10:30:50 +00:00
Added lots of new LSPLIB packages (and their sources).
This commit is contained in:
Binary file not shown.
71
src/graphs/close.42
Normal file
71
src/graphs/close.42
Normal file
@@ -0,0 +1,71 @@
|
||||
;;;-*-lisp-*-
|
||||
|
||||
(herald closure)
|
||||
|
||||
(eval-when (eval compile load)
|
||||
(cond ((status feature complr)
|
||||
(or (get 'closure-macros 'version)
|
||||
(load '((graphs)closem)))
|
||||
(*lexpr GCALL)
|
||||
(*expr make-closure))
|
||||
(t
|
||||
(mapc '(lambda (u) (putprop u '((graphs)closem) 'autoload))
|
||||
'(open-GCALL self-GCALL defclosure make-closure-1)))))
|
||||
|
||||
(DEFUN CLOSURE-SUBR-HOOK (X1 X2 X3 X4 X5)
|
||||
; this function MUST be compiled in order for the
|
||||
; system to work.
|
||||
(FUNCALL (CLOSURE-NAME *SELF*) X1 X2 X3 X4 X5))
|
||||
|
||||
(defun make-closure (name full-instance-vars full-instance-vals
|
||||
pre-instance-vars pre-instance-vals)
|
||||
(let ((c
|
||||
(make-closure-1 name name
|
||||
subr-pointer (OR (get name 'subr)
|
||||
(GET 'CLOSURE-SUBR-HOOK 'SUBR)
|
||||
(ERROR "Can't hook" NAME))
|
||||
full-instance-vars full-instance-vars
|
||||
full-instance-vals full-instance-vals
|
||||
pre-instance-vars `(*self* ,@pre-instance-vars)
|
||||
pre-instance-vals pre-instance-vals)))
|
||||
(push c (closure-pre-instance-vals c))
|
||||
c))
|
||||
|
||||
(defun GCALL (f &optional x1 x2 x3 x4 x5)
|
||||
(open-GCALL f x1 x2 x3 x4 x5))
|
||||
|
||||
(defvar traced-closure-msgfile tyo)
|
||||
(defvar traced-closure-linefeedp nil)
|
||||
|
||||
(defclosure traced-closure (x1 x2 x3 x4 x5)
|
||||
((level 0))
|
||||
(sub-closure)
|
||||
|
||||
(setq level (1+ level))
|
||||
(setq traced-closure-linefeedp t)
|
||||
(format traced-closure-msgfile
|
||||
"~%~A ~A :~A ~:[~;<~A~:[>~;,~A~:[>~;,~A~:[>~;,~A>~]~]~]~]"
|
||||
(closure-name sub-closure)
|
||||
level
|
||||
x1 x2 x2 x3 x3 x4 x4 x5 x5)
|
||||
(let ((traced-closure-linefeedp nil))
|
||||
(setq x1 (GCALL sub-closure x1 x2 x3 x4 x5))
|
||||
(format traced-closure-msgfile
|
||||
"~:[~2*~;~%~A ~A~] =>~A"
|
||||
traced-closure-linefeedp
|
||||
(closure-name sub-closure)
|
||||
level
|
||||
x1))
|
||||
(setq level (1- level))
|
||||
x1)
|
||||
|
||||
(defun make-traced-closure (sub-closure)
|
||||
(make-traced-closure-closure () (sub-closure sub-closure)))
|
||||
|
||||
(mapc '(lambda (u) (putprop u '((alan)dprint) 'autoload))
|
||||
'(describe dprint))
|
||||
|
||||
(defmap-self-GCALL fixnum 2)
|
||||
(defmap-self-GCALL fixnum 4)
|
||||
(defmap-self-GCALL flonum 2)
|
||||
(defmap-self-GCALL flonum 4)
|
||||
132
src/graphs/graphs.102
Normal file
132
src/graphs/graphs.102
Normal file
@@ -0,0 +1,132 @@
|
||||
;;;-*-LISP-*-
|
||||
;;; a package for graphics.
|
||||
;;; 'graphics-stream' takes floating point coordinates, can do
|
||||
;;; Scaling and clipping, and sends the resulting fixnums to
|
||||
;;; a stream which presumably translates those into hardware commands.
|
||||
;;; an example is the 'ards-stream' which of course can be used
|
||||
;;; directly also. Other possible sub-streams include Tektronics,
|
||||
;;; and pseudo-graphics (e.g. character display hacking)
|
||||
;;; a possible super-stream to the 'graphics-stream' is one
|
||||
;;; which takes 3 dimensional set-point and move-point messages
|
||||
;;; and translates them to.
|
||||
|
||||
(herald graphs)
|
||||
|
||||
(eval-when (eval compile load)
|
||||
(or (get 'closure 'version)
|
||||
(load '((graphs)close))))
|
||||
|
||||
(defprop make-ards-stream ((dsk graphs) grapha fasl) autoload)
|
||||
(defprop make-graphics-stream ((dsk graphs)graph$ fasl) autoload)
|
||||
(mapc '(lambda (u) (putprop u '((dsk graphs)circle fasl) 'autoload))
|
||||
'(draw-circle draw-spiral))
|
||||
(defprop make-clipping-stream ((dsk graphs) clip fasl) autoload)
|
||||
|
||||
(eval-when (compile load)
|
||||
(cond ((status feature complr)
|
||||
(*expr set-pen move-pen vector-pen draw-point
|
||||
set-viewport get-viewport set-window get-window)
|
||||
(*lexpr graphics-stream-close graphics-stream-open))))
|
||||
|
||||
|
||||
;;; the generic graphics functions. these all take a closure argument
|
||||
;;; and map over cannonical uniform structures.
|
||||
|
||||
(defun set-pen (f x y)
|
||||
(GCALL f 'set-pen x y))
|
||||
|
||||
(eval-when (compile eval)
|
||||
(defmacro gen-maptest (u)
|
||||
`(in-closure-env
|
||||
f
|
||||
(cond ((fixnum-configurationp x)
|
||||
(fixnum-map-self-GCALL-2 ',u x y))
|
||||
(t
|
||||
(flonum-map-self-GCALL-2 ',u x y))))))
|
||||
|
||||
(defun move-pen (f x y) (gen-maptest move-pen))
|
||||
|
||||
(defun vector-pen (f x y)(gen-maptest vector-pen))
|
||||
|
||||
(defun draw-point (f x y)(gen-maptest draw-point))
|
||||
|
||||
(defun draw-line (f x1 y1 x2 y2)
|
||||
(in-closure-env
|
||||
f
|
||||
(cond ((fixnum-configurationp x1)
|
||||
(fixnum-map-self-GCALL-4 'draw-line x1 y1 x2 y2))
|
||||
(t
|
||||
(flonum-map-self-GCALL-4 'draw-line x1 y1 x2 y2)))))
|
||||
|
||||
(defun fixnum-configurationp (x)
|
||||
(cond ((numberp x) (fixp x))
|
||||
((and x (atom x) (eq (typep x) 'array))
|
||||
(eq (car (arraydims x)) 'fixnum))
|
||||
(t
|
||||
(or (null x) (fixp (car x))))))
|
||||
|
||||
(defun graphics-stream-close (f &optional mode)(GCALL f 'close mode))
|
||||
|
||||
(defun graphics-stream-tyo (f arg) (GCALL f 'tyo arg))
|
||||
|
||||
(defun graphics-stream-open (f &optional (mode 'tty) (name nil))
|
||||
(GCALL f 'open mode name))
|
||||
|
||||
(defun set-viewport (f x0 x1 y0 y1)
|
||||
(GCALL f 'set-viewport x0 x1 y0 y1))
|
||||
|
||||
(defun get-viewport (f)
|
||||
(GCALL f 'viewport))
|
||||
|
||||
(defun set-window (f x0 x1 y0 y1)
|
||||
(GCALL f 'set-window x0 x1 y0 y1))
|
||||
|
||||
(defun get-window (f)
|
||||
(GCALL f 'window))
|
||||
|
||||
(defun set-invisiblep (f flag)
|
||||
(GCALL f 'set-invisiblep flag))
|
||||
|
||||
(defun set-dottep (f flag)
|
||||
(GCALL f 'set-dottep flag))
|
||||
|
||||
(defun draw-frame (s)
|
||||
(let (((x0 x1 y0 y1) (get-window s)))
|
||||
(set-pen s x0 y0)
|
||||
(move-pen s x1 y0)
|
||||
(move-pen s x1 y1)
|
||||
(move-pen s x0 y1)
|
||||
(move-pen s x0 y0)))
|
||||
|
||||
|
||||
|
||||
(eval-when (compile eval)
|
||||
(defstruct (graphics-sfa sfa conc-name
|
||||
(constructor make-graphics-sfa-1))
|
||||
out-stream))
|
||||
|
||||
(defun make-graphics-sfa (out-stream)
|
||||
(make-graphics-sfa-1 out-stream out-stream))
|
||||
|
||||
(defun graphics-sfa (sfa com arg)
|
||||
(caseq com
|
||||
(tyo
|
||||
(GCALL (graphics-sfa-out-stream sfa) 'tyo arg))
|
||||
(open
|
||||
(graphics-stream-open (graphics-sfa-out-stream sfa)
|
||||
(cond ((atom arg) arg)
|
||||
(t (car arg)))
|
||||
(cond ((atom arg) nil)
|
||||
(t (cadr arg)))))
|
||||
(close
|
||||
(graphics-stream-close (graphics-sfa-out-stream sfa)))
|
||||
(which-operations
|
||||
'(tyo open close))))
|
||||
|
||||
|
||||
(defun operations-union (s1 s2)
|
||||
(do ()
|
||||
((null s1) s2)
|
||||
(let ((elem (pop s1)))
|
||||
(or (memq elem s2)
|
||||
(push elem s2)))))
|
||||
64
src/graphs/graphs.demo
Normal file
64
src/graphs/graphs.demo
Normal file
@@ -0,0 +1,64 @@
|
||||
;;;-*-lisp-*-
|
||||
(comment)
|
||||
|
||||
(progn
|
||||
(load '((gjc)gjc lisp))
|
||||
(defaultf '((dsk graphs)))
|
||||
|
||||
(load 'demo)
|
||||
(setq prinlength 7)
|
||||
(setq read-pause-time 0.1)
|
||||
|
||||
(cursorpos 'c tyo)
|
||||
(format tyo
|
||||
"This is a very short demo of graphics.
|
||||
To get the demo type (DEMO) which invokes the
|
||||
lisp function DEMO defined by this file.
|
||||
What you will see is a sequence of lisp forms
|
||||
which if you typed would have the effect that
|
||||
you see.
|
||||
")
|
||||
(defun pause () (format tyo "~&-pause-") (cursorpos 'n))
|
||||
(defun hpause () (cursorpos 'top) (pause))
|
||||
(setq demo-forms
|
||||
'((or (get 'plot 'version) (load 'plot))
|
||||
(comment "Set the input and output numeric radix to TEN.")
|
||||
(setq base 10. ibase 10.)
|
||||
(gcall graphic-stream 'open 'dsk '((graphs) demo ards))
|
||||
(comment "set the number of points.")
|
||||
(setq plotnum 200)
|
||||
(plot (times 3 x (cos (times 4 x)) (sin x)) x -5 5)
|
||||
(hpause)
|
||||
(plot sin -3.1416 3.1416)
|
||||
(pause)
|
||||
(comment "Or you can define a function.")
|
||||
(defun f1 (x) (*$ x x))
|
||||
(pause)
|
||||
(plot f1 -3 3)
|
||||
(pause)
|
||||
(comment "there is a nice function for making spirals")
|
||||
(defun sp (n m)
|
||||
(draw-spiral graphic-stream 1.5 0.0 0.0 n m))
|
||||
(comment "use the auto-scaling of PLOT to set up the window.")
|
||||
(pause)
|
||||
(progn (plot x x -1 1) (sp 33 33))
|
||||
(hpause)
|
||||
(gcall graphic-stream 'cursorpos 'c)
|
||||
(sp 75. 3.)
|
||||
(hpause)
|
||||
(sp 75. 5.)
|
||||
(hpause)
|
||||
(comment " how about some 3d-graphics? ")
|
||||
(or (get 'plot3 'version) (load 'plot3))
|
||||
(gcall graphic-stream 'set-window -0.8 0.8 -0.8 0.8)
|
||||
(comment "set the euler angles. ")
|
||||
(gcall 3d-stream 'Set-theta -1.0)
|
||||
(gcall 3d-stream 'set-phi 0.1)
|
||||
(gcall 3d-stream 'set-psi 0.4)
|
||||
(gcall graphic-stream 'cursorpos 'c)
|
||||
(mobius 100 2)
|
||||
(hpause)
|
||||
(torus 100 10)
|
||||
(gcall graphic-stream 'close 'dsk)
|
||||
(comment "that is all. enjoy!")))
|
||||
'*)
|
||||
100
src/graphs/graphs.usage
Normal file
100
src/graphs/graphs.usage
Normal file
@@ -0,0 +1,100 @@
|
||||
Date: 1 July 1980 14:57-EDT
|
||||
From: George J. Carrette <GJC at MIT-MC>
|
||||
To: "(FILE [GJC;GRAPHS USAGE])" at MIT-MC
|
||||
|
||||
Date: 1 July 1980 14:53-EDT
|
||||
From: George J. Carrette <GJC at MIT-MC>
|
||||
To: MEM at MIT-MC, JGA at MIT-MC
|
||||
cc: "(FILE [FILE GJC;GRAPHS USAGE])" at MIT-MC
|
||||
|
||||
|
||||
The generic functions are
|
||||
|
||||
set-pen, move-pen, vector-pen, draw-point, draw-line.
|
||||
|
||||
set-window, set-viewport, get-window, get-viewport.
|
||||
|
||||
The first argument to these functions is always a graphic object.
|
||||
The rest of the arguments are always paired X,Y. e.g.
|
||||
(set-pen foo x y) and (draw-line foo x1 y1 x2 y2).
|
||||
The coordinate arguments can either be numbers, arrays of numbers,
|
||||
or lists of numbers.
|
||||
|
||||
(make-ards-stream) makes you an ards-object.
|
||||
(make-graphics-stream <ards-object>) takes an ards-object and returns
|
||||
a flonum-scaling graphics stream.
|
||||
|
||||
Other operations are conviently accessed with the CALL function.
|
||||
|
||||
(call <stream> 'cursorpos 'c)
|
||||
(call <stream> 'which-operations)
|
||||
(call <stream> 'open 'tty)
|
||||
(call <stream> 'open 'dsk '((foo) bar >))
|
||||
(call <stream> 'close)
|
||||
|
||||
No compile-time considerations are needed when using the generic operators.
|
||||
However, users of call should do (or (get 'closure 'version) (load '((gjc)close)))
|
||||
at eval and compile times.
|
||||
|
||||
|
||||
|
||||
A graphics stream is a special object which these generic functions
|
||||
can operate on. These objects keep an internal state, such as
|
||||
the position of the last point plotted, and the values of the
|
||||
scaling factors.
|
||||
|
||||
Loading GJC;GRAPHS FASL will make the the relevant functions
|
||||
autoloading. Functions for hardware specific objects are in
|
||||
different files.
|
||||
|
||||
See GRAPHZ DEMO for example usage.
|
||||
|
||||
(MAKE-ARDS-STREAM) returns an object which takes fixnum arguments
|
||||
and outputs ARDs graphics codes to file or TTY objects which it
|
||||
stores internaly. This is a primitive stream.
|
||||
|
||||
(MAKE-TEK-STREAM) is not yet implemented.
|
||||
|
||||
(MAKE-GRAPHICS-STREAM <OUTPUT-STREAM>) takes a primitive stream
|
||||
as argument and returns a stream which can do floating point
|
||||
scaling and clipping, and setting of windows and viewports.
|
||||
|
||||
(GRAPHICS-STREAM-OPEN <STREAM> <MODE> &OPTIONAL <ARG>)
|
||||
<mode> is 'TTY or 'DSK. <arg> is the file name when opened
|
||||
in 'DSK mode.
|
||||
|
||||
(GRAPHICS-STREAM-CLOSE <STREAM>) closes any DSK file.
|
||||
|
||||
(SET-PEN <GRAPHICS-STREAM> X Y)
|
||||
|
||||
(MOVE-PEN <GRAPHICS-STREAM> X Y)
|
||||
draws a line from the last point the new point.
|
||||
|
||||
(VECTOR-PEN <GRAPHICS-STREAM> X Y) does a relative move of the pen.
|
||||
|
||||
(DRAW-POINT <GRAPHICS-STREAM> X Y) draws a line of length 0.
|
||||
|
||||
(GRAPHICS-STREAM-TYO <STREAM> <ARG>) presently does a character
|
||||
TYO. Does not try and enforce clipping. #\CR may cause lossage.
|
||||
Line-drawing of characters and scaling may be supported in the
|
||||
future.
|
||||
|
||||
The following are not supported in primitive graphic streams.
|
||||
|
||||
(SET-WINDOW <GRAPHIC-STREAM> X0 X1 Y0 Y1)
|
||||
the window is the apparent flonum size.
|
||||
|
||||
(SET-VIEWPORT <GRAPHIC-STREAM> X0 X1 Y0 Y1)
|
||||
The viewport is set in "hardware" or rather, primitive stream
|
||||
dependant, fixnums.
|
||||
The default values for these are usually reasonable, by definition.
|
||||
|
||||
(MAKE-GRAPHICS-SFA <GRAPHICS-STREAM>) takes a graphics stream
|
||||
and returns and SFA which may be used as an argument to
|
||||
PRINT, FORMAT, etc.
|
||||
|
||||
(MAKE-TRACED-FUNCTOR <FUNCTOR>) takes a functor (a graphics stream is
|
||||
a functor) and returns a functor which is traced. Trace information
|
||||
is output to the value of TRACED-FUNCTOR-MSGFILE which should NOT be
|
||||
a stream which calls any traced functors! The returned functor is
|
||||
not equal to the argument, i.e. the argument is not side effected.
|
||||
1214
src/l/defns.240
Executable file
1214
src/l/defns.240
Executable file
File diff suppressed because it is too large
Load Diff
474
src/l/humble.42
Executable file
474
src/l/humble.42
Executable file
@@ -0,0 +1,474 @@
|
||||
|
||||
;;; **************************************************************
|
||||
TITLE ***** MACLISP ****** HUMBLE INFERIOR PACKAGE FOR ITS NEWIO ***
|
||||
;;; **************************************************************
|
||||
;;; ** (C) COPYRIGHT 1977 MASSACHUSETTS INSTITUTE OF TECHNOLOGY **
|
||||
;;; ****** THIS IS A READ-ONLY FILE! (ALL WRITES RESERVED) *******
|
||||
;;; **************************************************************
|
||||
|
||||
|
||||
.MLLIT==1
|
||||
.FASL
|
||||
IF1, .INSRT SYS:.FASL DEFS
|
||||
|
||||
VERPRT HUMBLE
|
||||
|
||||
UBPFJ==10 ;FOREIGN JOB REQUIRED BIT FOR USR OPENS
|
||||
TMPC==0 ;TEMP I/O CHANNEL
|
||||
|
||||
.SXEVAL (SETQ CURRENT-JOB NIL
|
||||
THE-JOB-INPUT-CHANNEL NIL
|
||||
THE-JOB-OUTPUT-CHANNEL NIL
|
||||
THE-JOB-INPUT-CHANNEL-FILE-OBJECT NIL
|
||||
THE-JOB-OUTPUT-CHANNEL-FILE-OBJECT NIL)
|
||||
|
||||
DEFINE CURJOB
|
||||
.SPECIAL CURRENT-JOB TERMIN
|
||||
|
||||
DEFINE USRI
|
||||
.SPECIAL THE-JOB-INPUT-CHANNEL TERMIN
|
||||
|
||||
DEFINE USRO
|
||||
.SPECIAL THE-JOB-OUTPUT-CHANNEL TERMIN
|
||||
|
||||
DEFINE USRIAR
|
||||
.SPECIAL THE-JOB-INPUT-CHANNEL-FILE-OBJECT TERMIN
|
||||
|
||||
DEFINE USROAR
|
||||
.SPECIAL THE-JOB-OUTPUT-CHANNEL-FILE-OBJECT TERMIN
|
||||
|
||||
;;; (CREATE-JOB <JOBINTFUN> <CHNINTFUN> <JNAME> <UNAME> <FOREIGN>)
|
||||
;;; CREATES A JOB OBJECT, AND MAKES IT CURRENT.
|
||||
;;; <UNAME> = NIL (DEFAULT) MEANS YOUR UNAME.
|
||||
;;; <FOREIGN> = T (NON-DEFAULT) MEANS REQUIRE FOREIGN JOB.
|
||||
;;; RETURNS LIST OF TWO THINGS:
|
||||
;;; (1) ONE OF THE FOLLOWING ATOMS:
|
||||
;;; INFERIOR
|
||||
;;; REOWNED
|
||||
;;; FOREIGN
|
||||
;;; (2) THE JOB OBJECT
|
||||
;;; IF <FOREIGN> WAS NON-NIL AND THE JOB WAS NOT FOUND, NIL IS RETURNED.
|
||||
|
||||
;;; (SELECT-JOB <JOB>) MAKES THE SPECIFIED JOB CURRENT IN THE
|
||||
;;; EXPECTED MODE (FOREIGN OR NOT), RETURNING VALUES AS FOR CREATE-JOB.
|
||||
|
||||
HACKJ0: WTA [BAD JOB OBJECT - SELECT-JOB!]
|
||||
.ENTRY SELECT-JOB SUBR 0002 ;SUBR 1
|
||||
PUSHJ P,JOBP
|
||||
JRST HACKJ0
|
||||
JSP T,NPUSH-5
|
||||
MOVEI TT,J.INTB
|
||||
SKIPN @TTSAR(A)
|
||||
HLLOS (P)
|
||||
HLLOS NOQUIT
|
||||
MOVEI TT,J.CINT
|
||||
MOVE B,@TTSAR(A)
|
||||
MOVE TT,TTSAR(A)
|
||||
JRST CRJOB5
|
||||
|
||||
.ENTRY CREATE-JOB LSUBR 004006 ;LSUBR (3 . 5)
|
||||
JSP TT,LWNACK
|
||||
LA345,,.ATOM CREATE-JOB ;LA345 MEANS 3-5 ARGS.
|
||||
CAML T,[-4]
|
||||
PUSH P,[NIL]
|
||||
CAML T,[-3]
|
||||
PUSH P,[NIL]
|
||||
SKIPN A,-1(P)
|
||||
TDZA TT,TT
|
||||
PUSHJ P,SIXMAK
|
||||
PUSH FXP,TT
|
||||
MOVE A,-2(P)
|
||||
PUSHJ P,SIXMAK
|
||||
PUSH FXP,TT
|
||||
PUSH FXP,[-1]
|
||||
HLLOS NOQUIT
|
||||
.CALL [ SETZ
|
||||
SIXBIT \OPEN\ ;OPEN FILE (JOB)
|
||||
5000,,UBPFJ+6 ;INSIST ALREADY EXIST, PLUS IMAGE BLOCK INPUT
|
||||
1000,,TMPC ;CHANNEL NUMBER
|
||||
,,[SIXBIT \USR\] ;DEVICE NAME
|
||||
,,-2(FXP) ;UNAME
|
||||
400000,,-1(FXP) ] ;JNAME
|
||||
SETZM (FXP)
|
||||
.CLOSE TMPC,
|
||||
HLLZS NOQUIT
|
||||
PUSHJ P,CHECKI
|
||||
SKIPN (FXP)
|
||||
SKIPN (P)
|
||||
CAIA
|
||||
JRST CRJOB8 ;RETURN NIL IF LOSE
|
||||
PUSHJ P,GTJCHN ;GET JOB CHANNELS
|
||||
PUSH P,[CRJOB2]
|
||||
PUSH P,[NIL]
|
||||
PUSH P,[.ATOM FIXNUM ]
|
||||
PUSH P,[.ATOM #LOJOBA ]
|
||||
MOVNI T,3
|
||||
JCALL 16,.FUNCTION *ARRAY
|
||||
CRJOB2: HLLOS NOQUIT
|
||||
MOVE TT,TTSAR(A)
|
||||
POP FXP,F
|
||||
POP FXP,F.FN2(TT)
|
||||
POP FXP,T
|
||||
SKIPN T
|
||||
.SUSET [.RUNAME,,T]
|
||||
MOVEM T,F.FN1(TT)
|
||||
MOVSI T,(SIXBIT \USR\)
|
||||
MOVEM T,F.DEV(TT)
|
||||
MOVSI D,AS<JOB>
|
||||
IORB D,ASAR(A)
|
||||
MOVSI T,-J.GC
|
||||
HLLM T,-1(D)
|
||||
MOVE B,-4(P)
|
||||
MOVEM B,J.INTF(TT)
|
||||
MOVE B,-3(P)
|
||||
MOVEM B,J.CINT(TT)
|
||||
CRJOB5: MOVEM A,CURJOB ;SELECT-JOB JOINS HERE
|
||||
MOVE C,USRIAR
|
||||
MOVE T,TTSAR(C)
|
||||
MOVEM B,FJ.INT(T)
|
||||
MOVE C,USROAR
|
||||
MOVE T,TTSAR(C)
|
||||
MOVEM B,FJ.INT(T)
|
||||
SKIPN (P)
|
||||
TDZA T,T
|
||||
MOVEI T,UBPFJ
|
||||
.CALL [ SETZ
|
||||
SIXBIT \OPEN\ ;OPEN FILE (JOB)
|
||||
5000,,6(T) ;IMAGE BLOCK INPUT MODE
|
||||
,,@USRI ;CHANNEL NUMBER
|
||||
,,F.DEV(TT) ;DEVICE NAME (USR)
|
||||
,,F.FN1(TT) ;UNAME
|
||||
400000,,F.FN2(TT) ] ;JNAME
|
||||
JRST CRJOB7
|
||||
.CALL [SETZ
|
||||
SIXBIT \USRVAR\
|
||||
,,@USRI
|
||||
1000,,.ROPTION
|
||||
1000,,0 ;IGNORED FOR IMMEDIATE-INST MODE
|
||||
SETZ [TLO %OPLSP]] ;TURN ON "LISP IS SUPERIOR" BIT
|
||||
JFCL ;IGNORE FAILURE, MIGHT NOT BE OUR JOB
|
||||
;; Don't put these .calls together, the OPTION is allowed to
|
||||
;; fail, but the uind shouldn't.
|
||||
.CALL [SETZ ? SIXBIT \USRVAR\
|
||||
,,@USRI
|
||||
1000,,.RUIND
|
||||
SETZM J.UIND(TT)]
|
||||
.LOSE %LSFIL ; ???
|
||||
MOVE T,@USRI ;PICK UP CHANNEL NUMBER
|
||||
MOVEM T,F.CHAN(TT) ;FORCE IT TO BE CHAN # OF JOB ARRAY
|
||||
.CALL [ SETZ
|
||||
SIXBIT \RCHST\ ;READ CHANNEL STATUS
|
||||
,,@USRI ;CHANNEL NUMBER OF JOB
|
||||
2000,,F.RDEV(TT) ;DEVICE NAME
|
||||
2000,,F.RFN1(TT) ;FILE NAME 1
|
||||
2000,,F.RFN2(TT) ;FILE NAME 2
|
||||
2000,,R ;SNAME (ZERO) (IGNORE)
|
||||
2000,,R ;ACCESS POINTER (ZERO) (IGNORE)
|
||||
402000,,R ] ;MODE BITS (1.4 => FOREIGN JOB)
|
||||
.VALUE
|
||||
SETZM J.INTB(TT)
|
||||
MOVEI B,.ATOM FOREIGN
|
||||
TRNE R,UBPFJ
|
||||
JRST CRJOB4
|
||||
MOVE D,@USRI
|
||||
LSH D,27
|
||||
IOR D,[.USET 0,[.RINTB,,T]]
|
||||
XCT D
|
||||
MOVEM T,J.INTB(TT)
|
||||
.CALL [ SETZ
|
||||
SIXBIT \OPEN\ ;OPEN JOB
|
||||
5000,,7 ;IMAGE BLOCK OUTPUT
|
||||
,,@USRO ;CHANNEL NUMBER
|
||||
,,F.DEV(TT) ;DEVICE NAME (USR)
|
||||
,,F.FN1(TT) ;UNAME
|
||||
400000,,F.FN2(TT) ] ;JNAME
|
||||
.VALUE
|
||||
.CALL [ SETZ
|
||||
SIXBIT \RCHST\ ;READ CHANNEL STATUS
|
||||
,,@USRO ;CHANNEL NUMBER OF JOB
|
||||
2000,,F.RDEV(TT) ;DEVICE NAME
|
||||
2000,,F.RFN1(TT) ;FILE NAME 1
|
||||
402000,,F.RFN2(TT) ] ;FILE NAME 2
|
||||
.VALUE
|
||||
JFFO T,.+1
|
||||
MOVNS TT
|
||||
MOVEM A,JOBTB+21(TT)
|
||||
MOVEI B,.ATOM INFERIOR
|
||||
SKIPE F
|
||||
MOVEI B,.ATOM REOWNED
|
||||
CRJOB4: HLLZS NOQUIT
|
||||
PUSHJ P,CHECKI
|
||||
PUSH P,B
|
||||
CALL 1,.FUNCTION NCONS
|
||||
POP P,B
|
||||
CALL 2,.FUNCTION XCONS
|
||||
CRJOB9: SUB P,[5,,5]
|
||||
POPJ P,
|
||||
|
||||
CRJOB7: HLLZS NOQUIT
|
||||
PUSHJ P,CHECKI
|
||||
CRJB7A: SETZB A,CURJOB
|
||||
JRST CRJOB9
|
||||
|
||||
CRJOB8: SUB FXP,[3,,3]
|
||||
JRST CRJB7A
|
||||
|
||||
GTJCH0: SUB P,[1,,1]
|
||||
MOVEI A,.SX (?)
|
||||
IOL [NOT ENOUGH I/O CHANNELS!]
|
||||
GTJCHN: SKIPE USRIAR
|
||||
POPJ P,
|
||||
PUSH P,[NIL]
|
||||
MOVSI TT,(SIXBIT \USR\)
|
||||
PUSHJ P,ALFILE
|
||||
JRST GTJCH0
|
||||
MOVEM A,(P)
|
||||
MOVSI TT,(SIXBIT \USR\)
|
||||
PUSHJ P,ALFILE
|
||||
JRST GTJCH0
|
||||
MOVEI AR1,(A)
|
||||
POP P,AR2A
|
||||
MOVSI TT,TTS<IO> ;THIS ONE IS OUTPUT
|
||||
IORM TT,TTSAR(AR2A)
|
||||
MOVEI TT,F.CHAN
|
||||
MOVE F,@TTSAR(AR1)
|
||||
MOVE TT,@TTSAR(AR2A)
|
||||
JSP T,FXCONS
|
||||
MOVEI B,(A)
|
||||
MOVE TT,F
|
||||
JSP T,FXCONS
|
||||
HLLOS NOQUIT
|
||||
MOVE T,TTSAR(AR1)
|
||||
MOVE TT,TTSAR(AR2A)
|
||||
MOVE D,[SIXBIT \ USRI \]
|
||||
MOVEM D,F.FN1(T)
|
||||
MOVEM D,F.RFN1(T)
|
||||
MOVE D,[SIXBIT \ USRO \]
|
||||
MOVEM D,F.FN1(TT)
|
||||
MOVEM D,F.RFN1(TT)
|
||||
MOVE D,[SIXBIT \ CHNL \]
|
||||
MOVEM D,F.FN2(T)
|
||||
MOVEM D,F.FN2(TT)
|
||||
MOVEM D,F.RFN2(T)
|
||||
MOVEM D,F.RFN2(TT)
|
||||
MOVEM A,USRI
|
||||
MOVEM B,USRO
|
||||
MOVEM AR1,USRIAR
|
||||
MOVEM AR2A,USROAR
|
||||
HLLZS NOQUIT
|
||||
JRST CHECKI
|
||||
|
||||
DEFINE JOBLOK FN ;LOCK USER INTS, CHECK OUT CURRENT-JOB
|
||||
LOCKI
|
||||
SKIPN A,CURJOB
|
||||
JRST UNLKNIL
|
||||
PUSHJ P,JOBP
|
||||
JRST [ SETZM CURJOB
|
||||
UNLOCKI
|
||||
FAC [CURRENT-JOB CONTAINED BAD JOB OBJECT - FN!!]
|
||||
]
|
||||
TERMIN
|
||||
|
||||
DEFINE INFLOK FN ;INSIST ON INFERIOR
|
||||
JOBLOK FN
|
||||
MOVE T,TTSAR(A)
|
||||
SKIPN T,J.INTB(T)
|
||||
JRST UNLKNIL
|
||||
TERMIN
|
||||
|
||||
|
||||
;;; (JOB-USET-READ <NUM>) RETURNS VALUE OF USET VAR <NUM>,
|
||||
;;; OR NIL IF NO CURRENT JOB.
|
||||
|
||||
.ENTRY JOB-USET-READ SUBR 0002 ;SUBR 1
|
||||
JSP T,FXNV1
|
||||
JOBLOK JOB-USET-READ
|
||||
MOVE D,@USRI
|
||||
LSH D,27
|
||||
IOR D,[.USET 0,T]
|
||||
HRLI T,(TT)
|
||||
HRRI T,TT
|
||||
XCT D
|
||||
UNLOCKI
|
||||
JRST FIX1
|
||||
|
||||
;;; (JOB-USET-WRITE <NUM> <VAL>) WRITES USET VAR <NUM>,
|
||||
;;; OR NIL IF NO CURRENT JOB OR FOREIGN JOB.
|
||||
;;; <NUM> SHOULD HAVE THE 400000 BIT SET.
|
||||
|
||||
.ENTRY JOB-USET-WRITE SUBR 0003 ;SUBR 2
|
||||
JSP T,FXNV1
|
||||
JSP T,FXNV2
|
||||
INFLOK JOB-USET-WRITE
|
||||
MOVE R,@USRI
|
||||
LSH R,27
|
||||
IOR R,[.USET 0,T]
|
||||
HRLI T,(TT)
|
||||
HRRI T,D
|
||||
XCT R
|
||||
UNLOCKI
|
||||
MOVEI A,.ATOM T
|
||||
POPJ P,
|
||||
|
||||
;;; (KILL-JOB) KILLS THE CURRENT JOB.
|
||||
|
||||
.ENTRY KILL-JOB SUBR 0001 ;SUBR 0
|
||||
JOBLOK KILL-JOB
|
||||
HLLOS NOQUIT
|
||||
SETZM CURJOB
|
||||
MOVE TT,TTSAR(A)
|
||||
TLNE TT,TTS<CL> ;IN CASE OF ASYNCHRONOUS LOSSES
|
||||
JRST KILLJ9
|
||||
MOVSI T,TTS<CL>
|
||||
IORM T,TTSAR(A)
|
||||
SKIPN T,J.INTB(TT)
|
||||
JRST KILLJ2
|
||||
JFFO T,.+1
|
||||
MOVNS TT
|
||||
SETZM JOBTB+21(TT)
|
||||
MOVE T,@USRI
|
||||
LSH T,27
|
||||
IOR T,[.UCLOSE 0,]
|
||||
XCT T
|
||||
JRST KILLJ8
|
||||
|
||||
KILLJ2: .CALL [ SETZ
|
||||
SIXBIT \CLOSE\ ;CLOSE CHANNEL
|
||||
400000,,@USRI ] ;CHANNEL NUMBER
|
||||
.VALUE
|
||||
.CALL [ SETZ
|
||||
SIXBIT \CLOSE\ ;CLOSE CHANNEL
|
||||
400000,,@USRO ] ;CHANNEL NUMBER
|
||||
.VALUE
|
||||
KILLJ8: MOVEI A,.ATOM T
|
||||
KILJ8A: HLLZS NOQUIT
|
||||
UNLKPOPJ
|
||||
|
||||
KILLJ9: MOVEI A,NIL
|
||||
JRST KILJ8A
|
||||
|
||||
;;; SKIPS IF VALID JOB OBJECT IN A.
|
||||
;;; USES ONLY A, B, T.
|
||||
|
||||
JOBP: MOVEI B,(A)
|
||||
CALL 1,.FUNCTION TYPEP
|
||||
EXCH A,B
|
||||
CAIE B,.ATOM ARRAY
|
||||
POPJ P,
|
||||
MOVE T,ASAR(A)
|
||||
TLNN T,AS<JOB>
|
||||
POPJ P,
|
||||
MOVE T,TTSAR(A)
|
||||
TLNN T,TTS<CL>
|
||||
AOS (P)
|
||||
POPJ P,
|
||||
|
||||
;;; (LOAD-JOB <FILENAME>) OPENS UP FILE <FILENAME>
|
||||
;;; AND LOADS IT INTO THE CURRENT JOB.
|
||||
;;; RETURNS:
|
||||
;;; NIL WON!
|
||||
;;; BIN? FILE NOT BIN
|
||||
;;; FILE? FILE NOT FOUND
|
||||
|
||||
.ENTRY LOAD-JOB SUBR 0002 ;SUBR 1
|
||||
MOVEI C,(A)
|
||||
INFLOK LOAD-JOB
|
||||
MOVEI A,(C)
|
||||
CALL 2,.FUNCTION MERGEF
|
||||
PUSHJ P,FIL6BT
|
||||
HLLOS NOQUIT
|
||||
MOVEI A,.ATOM FILE?
|
||||
.CALL [ SETZ
|
||||
SIXBIT \OPEN\ ;OPEN FILE
|
||||
5000,,6 ;IMAGE BLOCK INPUT
|
||||
1000,,TMPC ;CHANNEL NUMBER
|
||||
,,-3(FXP) ;DEVICE
|
||||
,,-1(FXP) ;FILE NAME 1
|
||||
,,0(FXP) ;FILE NAME 2
|
||||
400000,,-2(FXP) ] ;SNAME
|
||||
JRST LDJB9
|
||||
.CALL [ SETZ
|
||||
SIXBIT \RESET\ ;RESET THE JOB
|
||||
400000,,@USRI ] ;CHANNEL NUMBER
|
||||
.VALUE
|
||||
MOVEI A,.ATOM BIN?
|
||||
.CALL [ SETZ
|
||||
SIXBIT \LOAD\ ;LOAD JOB
|
||||
,,@USRO ;JOB SPEC
|
||||
400000,,TMPC ] ;DISK CHANNEL
|
||||
JRST LDJB9
|
||||
HRROI T,TT
|
||||
.IOT TMPC,T
|
||||
.CLOSE TMPC,
|
||||
HRRZ C,CURJOB
|
||||
MOVE T,TTSAR(C)
|
||||
MOVEM TT,J.STAD(T)
|
||||
MOVEI A,NIL
|
||||
LDJB9: SUB FXP,[4,,4]
|
||||
HLLZS NOQUIT
|
||||
UNLKPOPJ
|
||||
|
||||
;;; (EXAMINE-JOB <LOC>) EXAMINES LOCATION <LOC> OF CURRENT JOB.
|
||||
;;; RETURNS NIL ON FAILURE (INDICATES BAD ERROR).
|
||||
|
||||
.ENTRY EXAMINE-JOB SUBR 0002 ;SUBR 1 NCALLABLE
|
||||
PUSH P,[FIX1]
|
||||
JSP T,FXNV1
|
||||
JOBLOK EXAMINE-JOB
|
||||
JSP F,JOBED
|
||||
@USRI
|
||||
JRST UNLKNIL
|
||||
MOVE TT,D
|
||||
UNLOCKI
|
||||
POPJ P,
|
||||
|
||||
;;; (DEPOSIT-JOB <LOC> <VAL>) DEPOSITS <VAL> IN <LOC> OF CURRENT JOB.
|
||||
;;; RETURNS NIL ON FAILURE (INDICATES BAD ERROR).
|
||||
|
||||
.ENTRY DEPOSIT-JOB SUBR 0003 ;SUBR 2
|
||||
JSP T,FXNV1
|
||||
JSP T,FXNV2
|
||||
INFLOK DEPOSIT-JOB
|
||||
JSP F,JOBED
|
||||
@USRO
|
||||
UNLKNIL: TDZA A,A
|
||||
UNLKT: MOVEI A,.ATOM T
|
||||
UNLKPOPJ
|
||||
|
||||
JOBED: MOVEI A,NIL
|
||||
.CALL [ SETZ
|
||||
SIXBIT \ACCESS\ ;SET ACCESS POINTER
|
||||
,,@(F) ;CHANNEL NUMBER
|
||||
400000,,TT ] ;NEW ACCESS POINTER
|
||||
JRST 1(F)
|
||||
HRROI TT,D
|
||||
.CALL [ SETZ
|
||||
SIXBIT \IOT\ ;IOT
|
||||
,,@(F) ;CHANNEL NUMBER
|
||||
400000,,TT ] ;IOT POINTER
|
||||
JRST 1(F)
|
||||
JRST 2(F)
|
||||
|
||||
;;; (*ATTY) DOES A .ATTY TO THE CURRENT JOB.
|
||||
|
||||
.ENTRY *ATTY SUBR 0001 ;SUBR 0
|
||||
INFLOK *ATTY
|
||||
MOVE TT,TTSAR(A)
|
||||
SKIPN J.INTB(TT)
|
||||
JRST UNLKNIL
|
||||
MOVE D,@USRI
|
||||
LSH D,27
|
||||
IOR D,[.ATTY 0,]
|
||||
XCT D
|
||||
JRST UNLKNIL
|
||||
JRST UNLKT
|
||||
|
||||
;;; (*DTTY) DOES A .DTTY.
|
||||
|
||||
.ENTRY *DTTY SUBR 0001 ;SUBR 0
|
||||
.DTTY
|
||||
TDZA A,A
|
||||
MOVEI A,.ATOM T
|
||||
POPJ P,
|
||||
|
||||
FASEND
|
||||
198
src/libdoc/%print.gross3
Normal file
198
src/libdoc/%print.gross3
Normal file
@@ -0,0 +1,198 @@
|
||||
|
||||
;;; Circular-list hackers:
|
||||
|
||||
;;; The functions %PRINT and %PRIN1 herein
|
||||
;;; can print (or prin1) any arbitrarily involuted
|
||||
;;; list structure in a moderately readable form.
|
||||
|
||||
;;; There is a CPRINT-like facility available for doing
|
||||
;;; arbitrary formatting of things.
|
||||
;;; Currently, this file contains code for the
|
||||
;;; /' and /@ readmacros.
|
||||
|
||||
;;; Please direct comments regarding bugs/features to
|
||||
;;; Rick Grossman (AI:GROSS;), 825 Tech Square, 3-5848.
|
||||
|
||||
|
||||
;;; Note:
|
||||
;;; We avoid the overhead of a hash table by actually smashing
|
||||
;;; the cells to indicate that they have been traversed.
|
||||
;;; Thus we lose on pure list structure.
|
||||
|
||||
|
||||
;;; Output format:
|
||||
;;; (setq x '(foo bar)) (rplacd (cdr x) x) (%print x)
|
||||
;;; would print as: %:G0012 (foo bar . %-G0012)
|
||||
;;; where %:<label> defines a piece of list structure,
|
||||
;;; and %-<label> denotes a back-reference.
|
||||
;;;
|
||||
;;; The file %READ FASL DSK: LIBLSP; contains a readmacro
|
||||
;;; for "%" which allows reading this stuff back in.
|
||||
|
||||
|
||||
;;; Note that the functions %MUNGE and %UNMUNGE
|
||||
;;; in this package can be used for other kinds of
|
||||
;;; circular list hacking (such as a circular sxhash).
|
||||
|
||||
|
||||
|
||||
;;; Revision:
|
||||
;;; 21 Re-do the whole thing (clean it up).
|
||||
;;; 22 Add test for ^W and ^R.
|
||||
;;; Run in (nointerrupt t) mode.
|
||||
;;; 23 (7/2/75) Adapt to the fact that PRINC always returns T.
|
||||
;;; Do automatic %UNMUNGE if pure-page trap.
|
||||
;;; 24 (8/13/75) Flush :MAIL kludge.
|
||||
|
||||
|
||||
(declare (setq nfunvars t) (macros t) (genprefix /%p\))
|
||||
|
||||
|
||||
|
||||
(defun /%print (x) (princ '/n/î) (/%prin1 x) (princ '/ ) t)
|
||||
|
||||
(defun /%prin1 (x)
|
||||
(cond
|
||||
((and ^w (not ^r)))
|
||||
(t
|
||||
((lambda (nointerrupt errset)
|
||||
(errset (/%prin1* (/%munge x)) t)
|
||||
(/%unmunge x)
|
||||
(nointerrupt nointerrupt) )
|
||||
(nointerrupt t)
|
||||
nil
|
||||
) ) )
|
||||
t )
|
||||
|
||||
|
||||
;; Munged format:
|
||||
;; (A . B) becomes ((/%flag A . <marker>) . B).
|
||||
;; The <marker> is non-nil if this cell is multiply referenced.
|
||||
|
||||
|
||||
(declare (special /%flag /%unmunge))
|
||||
|
||||
(setq /%flag (copysymbol '/%flag nil))
|
||||
|
||||
|
||||
(defun /%munge (x)
|
||||
;; Munge from top to bottom.
|
||||
(cond
|
||||
((atom x))
|
||||
((eq (caar x) /%flag)
|
||||
;; Indicate this cell is multiply referenced.
|
||||
(rplacd (cdar x) t) )
|
||||
(t
|
||||
(rplaca x (list /%flag (car x)))
|
||||
(/%munge (cadar x))
|
||||
(/%munge (cdr x)) ) )
|
||||
x )
|
||||
|
||||
|
||||
(defun /%unmunge (x)
|
||||
;; Unmunge from bottom to top.
|
||||
(cond
|
||||
((atom x))
|
||||
((not (eq (caar x) /%flag)))
|
||||
(t
|
||||
(prog (y)
|
||||
(setq y (car x))
|
||||
(rplaca y nil) ;Prevent infinite recursion.
|
||||
(/%unmunge (cadr y)) (/%unmunge (cdr x))
|
||||
(rplaca x (cadr y))
|
||||
;...(reclaim y nil)
|
||||
) ) ) )
|
||||
|
||||
|
||||
|
||||
|
||||
;; ejs 2018-03-13: replaced with defmacro
|
||||
;;(defun macro /%atom (x)
|
||||
;; A munged cell with a non-nil marker should be
|
||||
;; printed as an atom (because of the label).
|
||||
;; (subst (cadr x) 'x
|
||||
;; '(or (atom x) (cddar x)) ) )
|
||||
|
||||
(defmacro /%atom (x)
|
||||
`(or (atom ,x) (cddar ,x))))
|
||||
|
||||
;; ejs 2018-03-13: replaced with defmacro
|
||||
;;(defun macro /%cdr (x) (cons 'cdr (cdr x)))
|
||||
|
||||
(defmacro /%cdr (x) `(cdr ,x))
|
||||
|
||||
;; ejs 2018-03-13: replaced with defmacro
|
||||
;;(defun macro /%car (x) (cons 'cadar (cdr x)))
|
||||
|
||||
(defmacro /%car (x) `(cadar ,x))
|
||||
|
||||
|
||||
(defun /%prin1* (x) (prog (y z)
|
||||
(cond
|
||||
((and ^w (not ^r)))
|
||||
((atom x)
|
||||
(cond
|
||||
((and (setq y (get x 'print0)) (funcall y x)))
|
||||
((prin1 x)) ) )
|
||||
((not (eq (caar x) /%flag))
|
||||
(error '/%print x 'fail-act) )
|
||||
((setq y (cddar x))
|
||||
;; The marker is set, thus we use a label.
|
||||
(cond
|
||||
((eq y t)
|
||||
;; First time -- generate a label.
|
||||
(princ '/%/:)
|
||||
(princ (setq y (gensym)))
|
||||
(rplacd (cdar x) y)
|
||||
(princ '/ ) (/%prin/.loop x) )
|
||||
(t
|
||||
;; Not first time.
|
||||
(princ '/%/-) (princ y) ) ) )
|
||||
;; A normal cell -- do cprint hackery.
|
||||
((atom (setq z (/%car x)))
|
||||
(cond
|
||||
((and (setq y (get z '/%print1)) (funcall y x)))
|
||||
((/%prin/.loop x)) ) )
|
||||
((atom (setq z (/%car z)))
|
||||
(cond
|
||||
((and (setq y (get z '/%print2)) (funcall y x)))
|
||||
((/%prin/.loop x)) ) )
|
||||
((/%prin/.loop x)) )
|
||||
(return t) ))
|
||||
|
||||
(defun /%prin/.loop (x)
|
||||
(princ '/()
|
||||
(/%prin1* (/%car x))
|
||||
(do ((x (/%cdr x) (/%cdr x)))
|
||||
((cond
|
||||
((null x))
|
||||
((and ^w (not ^r)))
|
||||
((or (/%atom x)
|
||||
(and (atom (/%car x)) (get (/%car x) 'print-cdr)) )
|
||||
(princ '/ /./ )
|
||||
(/%prin1* x) ) )
|
||||
(princ '/)) )
|
||||
(princ '/ )
|
||||
(/%prin1* (/%car x)) ) )
|
||||
|
||||
|
||||
|
||||
;; Stuff for readmacros.
|
||||
|
||||
|
||||
(defun /%print-/' (x)
|
||||
(cond
|
||||
((and (not (/%atom (/%cdr x))) (null (/%cdr (/%cdr x))))
|
||||
(princ '/') (/%prin1* (/%car (/%cdr x))) ) )
|
||||
;; if length not 2, we return nil so /%prin1* will print
|
||||
;; it as an ordinary form.
|
||||
)
|
||||
|
||||
(defprop quote /%print-/' /%print1)
|
||||
|
||||
|
||||
(defun /%print-/@ (e) (princ (/%car e)) (/%prin1* (/%cdr e)))
|
||||
|
||||
(defprop /@ /%print-/@ /%print1)
|
||||
(defprop /@ t print-cdr)
|
||||
|
||||
106
src/libdoc/6bit.jonl3
Executable file
106
src/libdoc/6bit.jonl3
Executable file
@@ -0,0 +1,106 @@
|
||||
;;; -*- Mode:Lisp; IBase:10.; -*-
|
||||
;;;
|
||||
;;; 6BIT: A package for conversions between sixbit or ascii representations
|
||||
;;; and lisp symbols.
|
||||
;;;
|
||||
;;; This library was created by KMP, 22 Oct 81, and added to by JONL 23 Oct 81.
|
||||
;;;
|
||||
;;; (SYMBOL-TO-ASCII sym &optional (n 1))
|
||||
;;; Returns the n'th PDP10 word of the ascii representation of
|
||||
;;; the symbol 'sym', with 1-origin indexing of the words.
|
||||
;;; (SYMBOL-TO-SIXBIT sym &optional (n 1))
|
||||
;;; Returns the n'th PDP10 word of the sixbit representation.
|
||||
;;; (SYMBOL->6BIT sym) Same as (SYMBOL-TO-ASCII sym 1), but marginally
|
||||
;;; faster calling sequence.
|
||||
;;;
|
||||
;;; (ASCII-TO-SYMBOL number &optional internp)
|
||||
;;; Returns a symbol [which is interned if 'internp' is non-()],
|
||||
;;; whose pname is designated by the fixnum 'number'.
|
||||
;;; (SIXBIT-TO-SYMBOL number &optional internp)
|
||||
;;; Returns a symbol [which is interned if 'internp' is non-()],
|
||||
;;; whose pname is constructed by converting the 'number' from
|
||||
;;; sixbit to ascii representation.
|
||||
;;; (6BIT->SYMBOL num) Same as (SIXBIT-TO-SYMBOL num 'T), but marginally
|
||||
;;; faster calling sequence.
|
||||
;;;
|
||||
|
||||
(herald /6BIT 2)
|
||||
|
||||
|
||||
(eval-when (eval compile load)
|
||||
(and (status feature COMPLR)
|
||||
(fixnum (symbol->6bit) (symbol-to-sixbit) (symbol-to-ascii))))
|
||||
|
||||
(declare (fixnum (si:SYMBOL->6BIT-or-ASCII)
|
||||
(1wd/| () fixnum)))
|
||||
|
||||
;;;; Conversions from symbols
|
||||
|
||||
|
||||
(defun SYMBOL-TO-ASCII (sym &optional (nth-word 1))
|
||||
(si:SYMBOL->6BIT-or-ASCII sym nth-word 'ASCII 'SYMBOL-TO-ASCII))
|
||||
|
||||
(defun SYMBOL-TO-SIXBIT (sym &optional (nth-word 1))
|
||||
(si:SYMBOL->6BIT-or-ASCII sym nth-word () 'SYMBOL-TO-SIXBIT))
|
||||
|
||||
(DEFUN SYMBOL->6BIT (SYM)
|
||||
(si:SYMBOL->6BIT-or-ASCII sym 1 () 'SYMBOL->6BIT))
|
||||
|
||||
|
||||
(defun si:SYMBOL->6BIT-or-ASCII (sym nth-word asciip funname)
|
||||
(if (not (symbolp sym))
|
||||
(check-type sym #'SYMBOLP funname))
|
||||
(if (not (fixnump nth-word))
|
||||
(check-type nth-word #'FIXNUMP funname))
|
||||
(if (eq asciip 'ASCII)
|
||||
(let ((pnl (pnget sym 7))
|
||||
(i (1- nth-word)))
|
||||
(declare (fixnum i))
|
||||
(if (= i 0)
|
||||
(car pnl)
|
||||
(nth i pnl)))
|
||||
(if (and (= nth-word 1) (< (flatc sym) 7))
|
||||
(car (pnget sym 6))
|
||||
(1wd/| sym nth-word () ))))
|
||||
|
||||
(or (getl '1WD/| '(SUBR AUTOLOAD))
|
||||
(putprop '1WD/| (get 'LAP 'AUTOLOAD) 'AUTOLOAD))
|
||||
|
||||
|
||||
;;;;Conversions to symbol
|
||||
|
||||
(defun ASCII-TO-SYMBOL (number &optional internp)
|
||||
(if (not (fixnump number))
|
||||
(check-type number #'FIXNUMP 'ASCII-TO-SYMBOL))
|
||||
(pnput (list number) internp))
|
||||
|
||||
(defun SIXBIT-TO-SYMBOL (number &optional internp)
|
||||
(si:SYMBOL-from-6BIT number internp 'SIXBIT-TO-SYMBOL))
|
||||
|
||||
(defun 6BIT->SYMBOL (number)
|
||||
(si:SYMBOL-from-6BIT number 'INTERN '6BIT->SYMBOL))
|
||||
|
||||
|
||||
(defun si:SYMBOL-from-6BIT (number internp funname)
|
||||
(if (not (fixnump number))
|
||||
(check-type number #'FIXNUMP funname))
|
||||
(do ((n number (lsh n 6))
|
||||
(position 29. (- position 7))
|
||||
(first-pname-word 0)
|
||||
(extra () ))
|
||||
((zerop n) ;Done when no more non-zero bits in number.
|
||||
(pnput (cons first-pname-word extra) internp))
|
||||
(declare (fixnum n position first-pname-word))
|
||||
(cond ((> position 0)
|
||||
(setq first-pname-word
|
||||
(deposit-byte first-pname-word
|
||||
position
|
||||
7
|
||||
(+ (load-byte n 30. 6) #O40))))
|
||||
('T ;;Ha, must be 6 chars in the number!
|
||||
(setq extra `(,(deposit-byte 0
|
||||
29.
|
||||
7
|
||||
(+ (load-byte n 30. 6) #O40))))))))
|
||||
|
||||
|
||||
42
src/libdoc/apropo.jonl12
Executable file
42
src/libdoc/apropo.jonl12
Executable file
@@ -0,0 +1,42 @@
|
||||
; -*-LISP-*-
|
||||
; Find all atoms in the current obarray whose PNAME's contain a given string.
|
||||
; TWAs (truly worthless atoms) are ignored unless value of APROPOS is non-null.
|
||||
; Example: (APROPOS 'CHAR) returns
|
||||
; (CHARPOS GETCHAR GETCHARN)
|
||||
|
||||
(DECLARE (SPECIAL APROPOS))
|
||||
|
||||
(OR (BOUNDP 'APROPOS) (SETQ APROPOS () ))
|
||||
|
||||
(DEFUN APROPOS (ARG)
|
||||
(DECLARE (FIXNUM I FIRSTI MAXFIRSTI NEXTFIRSTI CN))
|
||||
(PROG (MATCHL LARG ANSL)
|
||||
A (COND ((NOT (SYMBOLP ARG))
|
||||
(SETQ ARG (ERROR '|Non-symbol - APROPOS| ARG 'WRNG-TYPE-ARG))
|
||||
(GO A)))
|
||||
(SETQ MATCHL (EXPLODEN ARG) LARG (LENGTH MATCHL))
|
||||
(MAPATOMS
|
||||
'(LAMBDA (SYM)
|
||||
(COND ((OR APROPOS (BOUNDP SYM) (PLIST SYM)) ;Test if not TWA
|
||||
(DO ((FIRSTI 1 NEXTFIRSTI) ;First index for scanning
|
||||
(MAXFIRSTI (- (FLATC SYM) LARG -1))
|
||||
(NEXTFIRSTI 0)
|
||||
(CN 0))
|
||||
((> FIRSTI MAXFIRSTI) () )
|
||||
(SETQ NEXTFIRSTI (1+ FIRSTI))
|
||||
(COND ((NOT (= (CAR MATCHL) (GETCHARN SYM FIRSTI))))
|
||||
((DO ((I (1+ FIRSTI) (1+ I)) ;Found 1st char match
|
||||
(NFI-FL)
|
||||
(L (CDR MATCHL) (CDR L)))
|
||||
((NULL L) 'T)
|
||||
(SETQ CN (GETCHARN SYM I))
|
||||
(AND (NULL NFI-FL) ;Accellerator for FIRSTI
|
||||
(= (CAR MATCHL) CN)
|
||||
(SETQ NEXTFIRSTI I NFI-FL T))
|
||||
(AND (NOT (= (CAR L) CN)) (RETURN () )))
|
||||
(PUSH SYM ANSL)
|
||||
(RETURN 'T))))))))
|
||||
(RETURN ANSL)))
|
||||
|
||||
(DEFUN APROPOS-SORTED (ATOM)
|
||||
(SORT (APROPOS ATOM) (FUNCTION ALPHALESSP)))
|
||||
71
src/libdoc/arith.cffk2
Executable file
71
src/libdoc/arith.cffk2
Executable file
@@ -0,0 +1,71 @@
|
||||
|
||||
|
||||
;;;Functions for *$ //$ and scaling for use with compiled code.
|
||||
;;;Overflow is caught, and underflow gives 0.0 or an error depending
|
||||
;;;on the setting of the ZUNDERFLOW switch
|
||||
;;; Originally written by CFFK
|
||||
;;; Functions +f and -f added by JONL on 7 DEC 76
|
||||
|
||||
;;;in file put:
|
||||
;;;(and (not (get '*f 'subr))
|
||||
;;; (mapc '(lambda (x) (putprop x '(arith fasl dsk liblsp) 'autoload))
|
||||
;;; '(*f //f _f +f -f)))
|
||||
|
||||
;;;declarations needed:
|
||||
;;;(declare (flonum (*f flonum flonum) (//f flonum flonum)
|
||||
;;; (_f flonum fixnum) (+f flonum flonum) (-f flonum flonum))
|
||||
;;; (*expr *f //f _f +f -f))
|
||||
|
||||
|
||||
(declare (flonum (*f flonum flonum) (//f flonum flonum)
|
||||
(_f flonum fixnum) (+f flonum flonum) (-f flonum flonum))
|
||||
(*expr *f //f _f +f -f))
|
||||
|
||||
|
||||
(lap *f subr)
|
||||
(args *f (nil . 2))
|
||||
(push p (% 0 0 float1))
|
||||
(movei r 0)
|
||||
(jrst 2 @ (% 0 0 nexta)) ;zero all overflow and underflow flags
|
||||
(entry //f subr)
|
||||
(args //f (nil . 2))
|
||||
(push p (% 0 0 float1))
|
||||
(movei r 1)
|
||||
(jrst 2 @ (% 0 0 nexta)) ;zero all overflow and underflow flags
|
||||
(entry _f subr)
|
||||
(args _f (nil . 2))
|
||||
(push p (% 0 0 float1))
|
||||
(movei r 2)
|
||||
(jrst 2 @ (% 0 0 nexta)) ;zero all overflow and underflow flags
|
||||
(entry +f subr)
|
||||
(args +f (nil . 2))
|
||||
(push p (% 0 0 float1))
|
||||
(movei r 3)
|
||||
(jrst 2 @ (% 0 0 nexta)) ;zero all overflow and underflow flags
|
||||
(entry -f subr)
|
||||
(args -f (nil . 2))
|
||||
(push p (% 0 0 float1))
|
||||
(movei r 4)
|
||||
(jrst 2 @ (% 0 0 nexta)) ;zero all overflow and underflow flags
|
||||
|
||||
nexta (move tt 0 a) ;first arg into tt
|
||||
(move d 0 b) ;second arg into d
|
||||
(xct 0 instbl r) ;do floating point operation
|
||||
(jfcl 10 uflow) ;overflow detected?
|
||||
ans (popj p) ;return with result in tt
|
||||
uflow (jsp t (* 1))
|
||||
(tlnn t 100)
|
||||
(lerr 0 (% sixbit |floating-point overflow from f-series functions!|))
|
||||
(skipn 0 (special zunderflow))
|
||||
(lerr 0 (% sixbit |floating-point underflow from f-series functions!|))
|
||||
(movei tt 0)
|
||||
(jrst 0 ans)
|
||||
|
||||
instbl (fmpr tt d)
|
||||
(fdvr tt d)
|
||||
(fsc tt 0 d)
|
||||
(fadr tt d)
|
||||
(fsbr tt d)
|
||||
|
||||
nil
|
||||
|
||||
78
src/libdoc/aryadr.jonl7
Executable file
78
src/libdoc/aryadr.jonl7
Executable file
@@ -0,0 +1,78 @@
|
||||
|
||||
;;; -*-MIDAS-*-
|
||||
TITLE ARYADR
|
||||
.insrt sys:.fasl defs
|
||||
.fasl
|
||||
|
||||
VERPRT ARYADR
|
||||
|
||||
|
||||
;Following DECLARE should be in any file which uses this function
|
||||
;(declare (fixnum (ARRAY-ADDR () fixnum)))
|
||||
|
||||
;FILE-ARRAY-GET takes an "array" as first arg, and a symbolic name of a
|
||||
; numeric file-array constituent as second arg. (FILE-ARRAY-GET foo 'CHAN)
|
||||
; will get the internal channel number of the file, and on TWENEX type
|
||||
; systems, (FILE-ARRAY-GET foo 'JFN) will get the JFN. Permissible
|
||||
; "properties" are MODE, CHAN, JFN, and LENGTH.
|
||||
;ARRAY-ADDR takes an "array" as first arg, and a fixnum (say, 'i') as second,
|
||||
; and returns a fixnum, which is the address of the i'th word of the array
|
||||
;WARNING! be aware that if an array-relocation occurs between the time you
|
||||
; get the array address, and the time at which you use it, you will lose.
|
||||
; Of course, you wouldn't want to do anything in that time interval which
|
||||
; would likely force an array-space relocation (such as creating new arrays,
|
||||
; or loading in files, or calling GETSP etc), but what about asynchronous
|
||||
; interrupts? Well, try using the NOINTERRUPT function; e.g.
|
||||
; (PROGN (SETQ OLD-NOI (NOINTERRUPT 'T))
|
||||
; (SETQ ADDR (ARRAY-ADDR ARY 15.))
|
||||
; (FROBULATE-A-LITTLE ON ARGS)
|
||||
; (USE ADDR)
|
||||
; (NOINTERRUPT OLD-NOI)
|
||||
|
||||
|
||||
|
||||
.entry ARRAY-ADDR SUBR 003
|
||||
push p,cfix1
|
||||
jsp t,fxnv2 ;This depends upon GET not
|
||||
caml d,[-10]
|
||||
caile d,1_16. ; disturbing register D
|
||||
jrst IOOR
|
||||
move tt,A
|
||||
lsh tt,-11
|
||||
hrrz tt,st(tt)
|
||||
cain tt,.atom ARRAY
|
||||
jrst PT1
|
||||
caie tt,.atom SYMBOL
|
||||
jrst BADA
|
||||
movei B,.atom ARRAY
|
||||
call 2,.function GET
|
||||
jumpe A,BADA
|
||||
PT1: hrrz tt,ttsar(A)
|
||||
add tt,D
|
||||
popj p,
|
||||
BADA: lerr [SIXBIT |BAD ARG TO ARRAY-ADDR!|]
|
||||
IOOR: lerr [SIXBIT |INDEX OUT OF RANGE - ARRAY-ADDR!|]
|
||||
|
||||
.entry FILE-ARRAY-GET subr 003
|
||||
TG0: move ar2a,a
|
||||
call 1,.function FILEP
|
||||
jumpe a,NAF
|
||||
skipa a,b
|
||||
UFP: wta |UNRECOGNIZED FILE PROPERTY - FILE-ARRAY-GET!|
|
||||
seto tt,
|
||||
caie a,.atom MODE
|
||||
movei tt,F.MODE
|
||||
caie a,.atom CHAN
|
||||
movei tt,F.CHAN
|
||||
caie a,.atom JFN
|
||||
movei tt,F.JFN
|
||||
caie a,.atom LENGTH
|
||||
movei tt,F.FLEN
|
||||
jumpl tt,UFP
|
||||
move tt,@ttsar(ar2a)
|
||||
jrst fix1
|
||||
|
||||
NAF: wta |NOT A FILE - FILE-ARRAY-GET!|
|
||||
jrst tg0
|
||||
|
||||
fasend
|
||||
32
src/libdoc/aryfil.jonl2
Executable file
32
src/libdoc/aryfil.jonl2
Executable file
@@ -0,0 +1,32 @@
|
||||
;;; -*-LISP-*-
|
||||
|
||||
;;; (LIVE-ARRAYS <kind>) returns a list of all allocated arrays (not
|
||||
;;; currently considered "dead" space). Its argument permits selecting
|
||||
;;; only certain kinds of arrays: OBARRAY, READTABLE, FILE, T, NIL,
|
||||
;;; FIXNUM, or FLONUM. An argument of ALL gets all non-dead arrays.
|
||||
;;; In addition, an argument of OPEN-FILE selects only open files.
|
||||
;;; (OPEN-FILES) returns a list of all open file objects
|
||||
|
||||
|
||||
(defun (OPEN-FILES macro) (()) `(LIVE-ARRAYS 'OPEN-FILE))
|
||||
|
||||
(defun LIVE-ARRAYS (kind)
|
||||
(or kind (setq kind 'T))
|
||||
(and (not (memq kind '(OBARRAY READTABLE FILE FIXNUM FLONUM T NIL)))
|
||||
(not (eq kind 'OPEN-FILE))
|
||||
(setq kind 'ALL))
|
||||
(let ((dedsar (getddtsym 'DEDSAR))
|
||||
(gcmkl (munkam (examine (getddtsym 'GCMKL))))
|
||||
(open-file-flag (cond ((eq kind 'OPEN-FILE)
|
||||
(setq kind 'FILE)
|
||||
'T))))
|
||||
(do ((l gcmkl (cddr l)) (z) )
|
||||
((null l) (nreverse z))
|
||||
(and (not (eq (car l) dedsar))
|
||||
(cond ((eq kind 'ALL))
|
||||
((eq kind (car (arraydims (car l))))
|
||||
(or (not open-file-flag)
|
||||
(status filemode (car l)))))
|
||||
(push (car l) z)))))
|
||||
|
||||
|
||||
1067
src/libdoc/askusr.psz1
Executable file
1067
src/libdoc/askusr.psz1
Executable file
File diff suppressed because it is too large
Load Diff
1068
src/libdoc/askusr.psz2
Normal file
1068
src/libdoc/askusr.psz2
Normal file
File diff suppressed because it is too large
Load Diff
19
src/libdoc/atan.jlk
Executable file
19
src/libdoc/atan.jlk
Executable file
@@ -0,0 +1,19 @@
|
||||
; fortran-atan computes atan of one or two arguments returning a range of values
|
||||
; compatible with standard fortran (particularly, IBM and MULTICS).
|
||||
; These are -%pi/2 to %pi/2 for single arg atan, and -%pi to %pi for 2 arg
|
||||
; atan. LISP unfortunately returns values in the range 0 to 2%pi, and only
|
||||
; takes two arguments.
|
||||
|
||||
(declare (fixnum n) (flonum (fortran-atan)))
|
||||
|
||||
(defun fortran-atan n
|
||||
(prog (x y fa) (declare (flonum x y fa))
|
||||
(setq x (arg 1) y (cond ((= n 2)(arg 2))(t 1.0))
|
||||
fa (atan x y))
|
||||
(return
|
||||
(cond ((= n 1)
|
||||
(cond ((> fa 3.14159265) (-$ fa (*$ 2.0 3.14159265)))
|
||||
(t fa)))
|
||||
(t (cond ((> fa 3.14159265)
|
||||
(-$ fa (*$ 2.0 3.14159265)))
|
||||
(t fa)))))))
|
||||
129
src/libdoc/autodf.3
Executable file
129
src/libdoc/autodf.3
Executable file
@@ -0,0 +1,129 @@
|
||||
;; AUTODF J. T. Galkowski 1975-09-30
|
||||
;; Updated to work with NEWIO by DTS 5/28/79
|
||||
;;;
|
||||
;;This file contains autoload properties for major functions in most files in the LIBLSP library.
|
||||
;;; NO OR INCOMPLETE AUTOLOAD PROPERTIES FOR FOLLOWING FILES
|
||||
;;; name reason
|
||||
;;; "MACRO contains readmacros
|
||||
;;; %READ contains readmacros
|
||||
;;; ERT not compiled
|
||||
;;; FUNVAL not compiled
|
||||
;;; GC&VAR better to load from lisp init file
|
||||
;;; PRFONT many externally callable functions
|
||||
;;; PROP! many independent functions
|
||||
;;; SMURF better to load from your INIT file
|
||||
|
||||
(DEFPROP %PRINT (%PRINT FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP %PRIN1 (%PRINT FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP LAND (BBOOLE FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP LOR (BBOOLE FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP LCOM (BBOOLE FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP LNOT (BBOOLE FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP LXOR (BBOOLE FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP DEBUG (DEBUG FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP DIREAD (DIREAD FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP FILE+ (FILE+ FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP LOGG (LOG FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP XGP (PRFONT FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP GET! (PROP! FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP PUTPROP! (PROP! FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP ADDPROP! (PROP! FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP INCRPROP! (PROP! FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP SELECTQ (SELECT FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP STEP (STEPR FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP STEPMM (STEPPMM FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP SUBLOAD (SUBLOA FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP DEFVAR (PPAK FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP DV (PPAK FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP PPRIN1 (PPRINT FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP PPRINT (PPRINT FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP PFFF (FORMAT FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP PFPF (FORMAT FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP PFFX (FORMAT FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFPROP PICTURE (LFTV FASL DSK LIBLSP) AUTOLOAD)
|
||||
|
||||
(DEFUN LIBLSP-AUTODF-CALL-UPDATE NIL
|
||||
(PROG (N TIME-LAST-ACCESS ACCESS-RATE V0 V1 OIBASE OBASE)
|
||||
(SETQ OIBASE IBASE OBASE BASE)
|
||||
(SETQ IBASE 10. BASE 10.)
|
||||
(setq / ())
|
||||
(setq tinfile (open '((dsk libdoc)usage autodf)))
|
||||
(setq / ())
|
||||
(SETQ N (CAR (READ tinfile))
|
||||
TIME-LAST-ACCESS (READ tinfile)
|
||||
ACCESS-RATE (CAR (READ tinfile)))
|
||||
(setq / ())
|
||||
(SETQ
|
||||
V0
|
||||
(+$
|
||||
(*$ (FLOAT (CAR TIME-LAST-ACCESS)) (*$ 365.0 24.0))
|
||||
(+$
|
||||
(*$ (FLOAT (CADR TIME-LAST-ACCESS)) (*$ 31.0 24.0))
|
||||
(+$
|
||||
(*$ (FLOAT (CADDR TIME-LAST-ACCESS)) 24.0)
|
||||
(+$ (FLOAT (CAR (CDDDR TIME-LAST-ACCESS)))
|
||||
(+$ (//$ (FLOAT (CADR (CDDDR TIME-LAST-ACCESS)))
|
||||
24.0)
|
||||
(//$ (FLOAT (CADDR (CDDDR TIME-LAST-ACCESS)))
|
||||
3600.0)))))))
|
||||
(SETQ TIME-LAST-ACCESS (APPEND (STATUS DATE)
|
||||
(STATUS DAYTIME)))
|
||||
(SETQ
|
||||
V1
|
||||
(+$
|
||||
(*$ (FLOAT (CAR TIME-LAST-ACCESS)) (*$ 365.0 24.0))
|
||||
(+$
|
||||
(*$ (FLOAT (CADR TIME-LAST-ACCESS)) (*$ 31.0 24.0))
|
||||
(+$
|
||||
(*$ (FLOAT (CADDR TIME-LAST-ACCESS)) 24.0)
|
||||
(+$ (FLOAT (CAR (CDDDR TIME-LAST-ACCESS)))
|
||||
(+$ (//$ (FLOAT (CADR (CDDDR TIME-LAST-ACCESS)))
|
||||
24.0)
|
||||
(//$ (FLOAT (CADDR (CDDDR TIME-LAST-ACCESS)))
|
||||
3600.0)))))))
|
||||
(SETQ ACCESS-RATE
|
||||
(//$ (FLOAT (1+ N))
|
||||
(+$ (//$ (FLOAT N) ACCESS-RATE) (-$ V1 V0))))
|
||||
(setq outfile (open '((dsk libdoc)usage autodf)'(out)))
|
||||
(setq / ())
|
||||
(PRINT (LIST (1+ N)) outfile)
|
||||
(PRINT TIME-LAST-ACCESS outfile)
|
||||
(PRINT (LIST ACCESS-RATE) outfile)
|
||||
(close outfile)
|
||||
(close tinfile)
|
||||
(setq / ())<
|
||||
(REMOB 'LIBLSP-AUTODF-CALL-UPDATE)
|
||||
(SETQ BASE OBASE IBASE OIBASE)
|
||||
(RETURN '--NOTED--)))
|
||||
|
||||
((lambda (/ / /)
|
||||
(clear-output (setq / t))
|
||||
(liblsp-autodf-call-update))
|
||||
()()())
|
||||
406
src/libdoc/bboole.pratt2
Executable file
406
src/libdoc/bboole.pratt2
Executable file
@@ -0,0 +1,406 @@
|
||||
;;; THIS FILE CONTAINS FUNCTIONS WHICH IMPLEMENT LOGICAL OPERATIONS
|
||||
;;; ON LISP INTEGERS AS IF THEY WERE SEMI-INFINITE BIT VECTORS IN
|
||||
;;; TWO'S COMPLEMENT NOTATION. THAT IS, 0 IS THE BIT VECTOR OF NO
|
||||
;;; BITS; AND -1 IS THE BIT VECTOR OF ALL 1'S.
|
||||
;;; THE MAIN FUNCTIONS THAT HAVE BEEN TESTED ARE:
|
||||
;;; 1) (LNOT A) -- LOGICAL COMPLEMENT OF BIT VECTOR A;
|
||||
;;; 2) (LAND A B) -- LOGICAL AND OF BIT VECTORS A, B;
|
||||
;;; 3) (LOR A B) -- LOGICAL OR OF BIT VECTORS A, B;
|
||||
;;; 4) (LCOM A B) -- LOGICAL COMPLEMENT (A-B) OF A, B;
|
||||
;;; 5) (LXOR A B) -- LOGICAL XOR (EXCLUSIVE OR) OF A, B;
|
||||
;;; 6) (LEFTSHIFT A N) -- (FLOOR (TIMES A (EXPT 2 N)));
|
||||
;;; 7) (PINTERSECTP A B) -- (NOT (ZEROP (LAND A B))) A,B GE 0;
|
||||
;;; 8) (LELEMENT N A) -- (NOT (ZEROP (LAND A (EXPT 2 N))));
|
||||
;;; 9) (LREDUCE A L) -- SELECT THOSE ITEMS FROM LIST L WHOSE
|
||||
;;; CORRESPONDING BIT IN A IS ON. SORT OF
|
||||
;;; LIKE MAPPING LELEMENT DOWN L. LREDUCE
|
||||
;;; USES CONS, NOT RPLACD.
|
||||
;;;
|
||||
;;; THESE FUNCTIONS ARE ALL "SUBR"S; USE THE "REDUCE" FUNCTION
|
||||
;;; A LA APL TO HANDLE ARBITRARY NUMBERS OF ARGUMENTS.
|
||||
|
||||
;;; MAKE MACROS AVAILABLE AT RUN TIME;
|
||||
;;; DON'T COMPLAIN ABOUT OPEN CODED ARITHMETIC.
|
||||
|
||||
(DECLARE (MACROS T) (MUZZLED T))
|
||||
|
||||
(DEFUN BBOOLE NIL (PRINT '(BBOOLE PACKAGE LOADED)))
|
||||
|
||||
(DEFUN LET MACRO (FORM)
|
||||
(CONS (CONS 'LAMBDA (CONS (CADR FORM) (CDDDR FORM)))
|
||||
(CADDR FORM)))
|
||||
|
||||
(DEFUN REDUCE (FN L)
|
||||
;;; REDUCE THE LIST "L" USING THE BINARY FUNCTION "FN" A LA APL.
|
||||
(COND ((NULL L) (AND (ATOM FN) (GET FN 'IDENTITY)))
|
||||
((ATOM L) L)
|
||||
((NULL (CDR L)) (CAR L))
|
||||
((FUNCALL FN (CAR L) (REDUCE FN (CDR L))))))
|
||||
|
||||
(DEFPROP LAND -1 IDENTITY)
|
||||
|
||||
(DEFPROP LOR 0 IDENTITY)
|
||||
|
||||
(DEFPROP LXOR 0 IDENTITY)
|
||||
|
||||
(DEFPROP LCOM 0 IDENTITY)
|
||||
|
||||
(DEFUN & MACRO (A)
|
||||
;;; "AND" FOR FIXNUMS
|
||||
(APPEND '(BOOLE 1.) (CDR A)))
|
||||
|
||||
(DEFUN V MACRO (A)
|
||||
;;; "OR" FOR FIXNUMS
|
||||
(APPEND '(BOOLE 7.) (CDR A)))
|
||||
|
||||
(DEFUN _ MACRO (A)
|
||||
;;; "COMPLEMENT" FOR FIXNUMS
|
||||
(APPEND '(BOOLE 4.) (CDR A)))
|
||||
|
||||
(DECLARE (FIXNUM M N Q R))
|
||||
|
||||
(DEFUN MOD (M N)
|
||||
;;; IMPLEMENTS "MOD" FUNCTION ON PAGE 38 OF "FUNDAMENTAL ALGORITHMS"
|
||||
;;; BY D. E. KNUTH.
|
||||
;;; LISP'S "REMAINDER" GIVES THE WRONG ANSWER IN THE 1ST
|
||||
;;; & 3RD QUADRANTS.
|
||||
(COND ;;; FIRST CHECK FOR N=0.
|
||||
((ZEROP N) M)
|
||||
;;; GET LISP'S REMAINDER AND CORRECT, IF NECESSARY.
|
||||
((LET (R)((REMAINDER M N))
|
||||
(COND ;;; R=0 OK.
|
||||
((ZEROP R) R)
|
||||
;;; NOW WE HAVE M, N, R ALL NOT 0.
|
||||
((PLUSP N)
|
||||
(COND ((PLUSP M)
|
||||
;;; (SIGN M) = (SIGN N), OK.
|
||||
R)
|
||||
(;;; M<0, N>0, R<0.
|
||||
(PLUS R N))))
|
||||
((PLUSP M)
|
||||
;;; M>0, N<0, R>0.
|
||||
(PLUS R N))
|
||||
(;;; M<0, N<0, R<0, (SIGN M) = (SIGN N), OK.
|
||||
R))))))
|
||||
|
||||
(DEFUN QUOT (M N)
|
||||
;;; (QUOT M N) = (FLOOR (QUOTIENT (FLOAT M) (FLOAT N)))
|
||||
(COND ((MINUSP M)
|
||||
(COND ((MINUSP N) (QUOTIENT M N))
|
||||
((QUOTIENT (DIFFERENCE M N -1) N))))
|
||||
((MINUSP N) (QUOTIENT (DIFFERENCE M N 1) N))
|
||||
((QUOTIENT M N))))
|
||||
|
||||
'(DEFUN QUOT (M N)
|
||||
;;; THIS FUNCTION FIXES LISP'S "QUOTIENT" IN THE 1ST AND
|
||||
;;; 3RD QUADRANTS.
|
||||
(LET (Q R)
|
||||
((QUOTIENT M N) (REMAINDER M N))
|
||||
(COND ((ZEROP R) Q)
|
||||
((PLUSP M) (COND ((PLUSP N) Q)
|
||||
((SUB1 Q))))
|
||||
((PLUSP N) (SUB1 Q))
|
||||
(Q))))
|
||||
|
||||
(DECLARE (NOTYPE M N Q R))
|
||||
|
||||
'(DEFUN QUOT MACRO (L)
|
||||
;;; LISP'S QUOTIENT GIVES THE WRONG ANSWER IN THE 1ST
|
||||
;;; AND 3RD QUADRANTS.
|
||||
(SUBLIS (LIST (CONS 'X (CADR L)) (CONS 'Y (CADDR L)))
|
||||
'(FIX (QUOTIENT (FLOAT X) (FLOAT Y)))))
|
||||
|
||||
(DEFUN CHECKLIS (NL)
|
||||
;;; DELETE ZEROS FROM END OF A LIST OF FIXNUMS.
|
||||
(COND ((NULL (CDR NL)) T)
|
||||
((CHECKLIS (CDR NL))
|
||||
(COND ((EQUAL '(0.) (CDR NL))
|
||||
(RPLACD NL NIL))))))
|
||||
|
||||
(VALRET '//:VP/ )
|
||||
|
||||
;;; GET SYMBOLS FROM DDT.
|
||||
|
||||
|
||||
(LAP CONSBIGNUM SUBR)
|
||||
(JRST 0 BNCONS)
|
||||
NIL
|
||||
|
||||
|
||||
;;; GIVEN A LIST OF POSITIVE FIXNUMS, WHOSE LAST ELEMENT IS NOT ZERO,
|
||||
;;; CREATE A BIGNUM WHOSE BIG DIGITS ARE THE FIXNUMS IN REVERSE ORDER.
|
||||
|
||||
(DEFUN LNOT (N)
|
||||
;;; THE LOGICAL "NOT" OF AN INTEGER N IS -N-1.
|
||||
(DIFFERENCE -1 N))
|
||||
|
||||
(DEFUN LNOT MACRO (A)
|
||||
;;; THE LOGICAL "NOT" OF AN INTEGER N IS -N-1.
|
||||
(LIST 'DIFFERENCE -1 (CADR A)))
|
||||
|
||||
(DECLARE (FIXNUM L N))
|
||||
|
||||
(DEFUN BLSH (M N)
|
||||
;;; BLSH(M N) = (FLOOR (TIMES M (EXPT 2. N)))
|
||||
(COND ((MINUSP N) (BRSH M (MINUS N)))
|
||||
((TIMES M (EXPT 2. N)))))
|
||||
|
||||
(DEFUN BRSH (M N)
|
||||
;;; BRSH(M N) = (FLOOR (TIMES M (EXPT 2. (MINUS N))))
|
||||
(COND ((MINUSP N) (BLSH M (MINUS N)))
|
||||
((MINUSP M) (LNOT (BRSH (LNOT M) N)))
|
||||
((QUOTIENT M (EXPT 2. N)))))
|
||||
|
||||
(DEFUN LEFTSHIFT (M N)
|
||||
;;; LEFTSHIFT SEMI-INFINITE BIT VECTOR BY AMOUNT N.
|
||||
(COND ((MINUSP N) (RIGHTSHIFT M (MINUS N)))
|
||||
((TIMES M (EXPT 2. N)))))
|
||||
|
||||
(DEFUN RIGHTSHIFT (M N)
|
||||
;;; RIGHTSHIFT SEMI-INFINITE BIT VECTOR BY AMOUNT N.
|
||||
(COND ((MINUSP N) (LEFTSHIFT M (MINUS N)))
|
||||
((MINUSP M) (LNOT (RIGHTSHIFT (LNOT M) N)))
|
||||
((LET (L)((HAULONG M))
|
||||
(COND ((< N L) (HAIPART M (- L N)))
|
||||
(0.))))))
|
||||
|
||||
(DECLARE (NOTYPE L N))
|
||||
|
||||
(DEFUN SWR MACRO (A)
|
||||
;;; "SWR" = SWITCH ROWS IN "BOOLE"-TYPE 2X2 MATRIX
|
||||
;;; SWR(ABCD) = BADC.
|
||||
(SUBST (CADR A)
|
||||
'ABCD
|
||||
'(V (LSH (& 5. ABCD) 1.) (LSH (& 10. ABCD) -1.))))
|
||||
|
||||
(DEFUN SWC MACRO (A)
|
||||
;;; "SWC" = SWITCH COLUMNS IN "BOOLE"-TYPE 2X2 MATRIX
|
||||
;;; SWC(ABCD) = CDAB.
|
||||
(SUBST (CADR A)
|
||||
'ABCD
|
||||
'(V (LSH (& 3. ABCD) 2.) (LSH (& 12. ABCD) -2.))))
|
||||
|
||||
(DEFUN BBOOLEAN (C A B)
|
||||
;;; COMPUTES GENERAL BOOLEAN FUNCTION OF TWO LISTS OF
|
||||
;;; POSITIVE FIXNUMS, NOT NECESSARILY OF THE SAME LENGTH.
|
||||
;;; RETURNS EITHER A LIST OF POSITIVE FIXNUMS, OR A SINGLE FIXNUM.
|
||||
(PROG (AA BB)
|
||||
(COND ((NULL (OR A B)) (RETURN 0.)))
|
||||
(SETQ AA (OR A (LIST 0.)) BB (OR B (LIST 0.)))
|
||||
(RETURN ((LAMBDA (W Z)
|
||||
(COND ((ATOM Z)
|
||||
(COND ((ZEROP Z) W) ((LIST W Z))))
|
||||
((CONS W Z))))
|
||||
(BOOLE C (CAR AA) (CAR BB))
|
||||
(BBOOLEAN C (CDR AA) (CDR BB))))))
|
||||
|
||||
(DEFUN PBOOLEAN (C X Y)
|
||||
;;; COMPUTES A BOOLEAN FUNCTION OF TWO NON-NEGATIVE
|
||||
;;; INTEGER ARGUMENTS. THE FUNCTION APPLIED TO (0, 0) MUST
|
||||
;;; RETURN 0.
|
||||
(COND ((BIGP X)
|
||||
(COND ((BIGP Y)
|
||||
(CONSBIGNUMBER (BBOOLEAN C (CDR X) (CDR Y))))
|
||||
((CONSBIGNUMBER (BBOOLEAN C (CDR X) (LIST Y))))))
|
||||
((COND ((BIGP Y)
|
||||
(CONSBIGNUMBER (BBOOLEAN C (LIST X) (CDR Y))))
|
||||
((BOOLE C X Y))))))
|
||||
|
||||
(DEFUN BOOLEA (C A B)
|
||||
;;; computes the general boolean function of two integer arguments.
|
||||
(COND ((MINUSP A)
|
||||
(COND ((MINUSP B)
|
||||
(COND ((ZEROP (& 1. C))
|
||||
(PBOOLEAN C (LNOT A) (LNOT B)))
|
||||
((LNOT (PBOOLEAN (_ 15. C)
|
||||
(LNOT A)
|
||||
(LNOT B))))))
|
||||
((COND ((ZEROP (& 4. C))
|
||||
(PBOOLEAN (SWR C) (LNOT A) B))
|
||||
((LNOT (PBOOLEAN (_ 15. (SWR C))
|
||||
(LNOT A)
|
||||
B)))))))
|
||||
((COND ((MINUSP B)
|
||||
(COND ((ZEROP (& 2. C))
|
||||
(PBOOLEAN (SWC C) A (LNOT B)))
|
||||
((LNOT (PBOOLEAN (_ 15. (SWC C))
|
||||
A
|
||||
(LNOT B))))))
|
||||
((COND ((ZEROP (& 8. C)) (PBOOLEAN C A B))
|
||||
((LNOT (PBOOLEAN (_ 15. C) A B)))))))))
|
||||
|
||||
(DEFUN BAND (X Y)
|
||||
;;; COMPUTES THE BOOLEAN AND OF TWO LISTS OF
|
||||
;;; POSITIVE FIXNUMS; POSSIBLY OF DIFFERING LENGTHS.
|
||||
(COND ((NULL X) 0.)
|
||||
((NULL Y) 0.)
|
||||
((LET (W Z)
|
||||
((& (CAR X) (CAR Y)) (BAND (CDR X) (CDR Y)))
|
||||
(COND ((ATOM Z) (COND ((ZEROP Z) W) ((LIST W Z))))
|
||||
((CONS W Z)))))))
|
||||
|
||||
(DEFUN BINTERSECTP (L1 L2)
|
||||
;;; TESTS WHETHER THE TWO LISTS OF POSITIVE FIXNUMS HAVE
|
||||
;;; ANY BITS IN COMMON.
|
||||
(COND ((NULL L1) NIL)
|
||||
((NULL L2) NIL)
|
||||
((OR (NOT (ZEROP (& (CAR L1) (CAR L2))))
|
||||
(BINTERSECTP (CDR L1) (CDR L2))))))
|
||||
|
||||
(DEFUN BOR (X Y)
|
||||
(COND ((NULL X) Y)
|
||||
((NULL Y) X)
|
||||
((CONS (V (CAR X) (CAR Y)) (BOR (CDR X) (CDR Y))))))
|
||||
|
||||
(DEFUN BLCOM (X Y)
|
||||
(COND ((NULL X) 0.)
|
||||
((NULL Y) X)
|
||||
((LET (W Z)
|
||||
((_ (CAR X) (CAR Y)) (BLCOM (CDR X) (CDR Y)))
|
||||
(COND ((ATOM Z) (COND ((ZEROP Z) W) ((LIST W Z))))
|
||||
((CONS W Z)))))))
|
||||
|
||||
(DEFUN BXOR (A B)
|
||||
;;; COMPUTES THE LOGICAL XOR OF TWO LISTS OF POSITIVE FIXNUMS
|
||||
(COND (A (COND (B (LET (W Z)
|
||||
((BOOLE 6. (CAR A) (CAR B))
|
||||
(BXOR (CDR A) (CDR B)))
|
||||
(COND ((ATOM Z)
|
||||
(COND ((ZEROP Z) W)
|
||||
((LIST W Z))))
|
||||
((CONS W Z)))))
|
||||
(A)))
|
||||
((OR B 0.))))
|
||||
|
||||
(DEFUN PLAND (X Y)
|
||||
;;; COMPUTES THE LOGICAL AND OF TWO POSITIVE INTEGERS
|
||||
(COND ((BIGP X)
|
||||
(COND ((BIGP Y) (CONSBIGNUMBER (BAND (CDR X) (CDR Y))))
|
||||
((& (CADR X) Y))))
|
||||
((COND ((BIGP Y) (& X (CADR Y))) ((& X Y))))))
|
||||
|
||||
(DEFUN PINTERSECTP (X Y)
|
||||
;;; COMPUTES WHETHER TWO POSITIVE INTEGERS HAVE ANY BITS IN COMMON.
|
||||
(COND ((BIGP X)
|
||||
(COND ((BIGP Y) (BINTERSECTP (CDR X) (CDR Y)))
|
||||
((NOT (ZEROP (& (CADR X) Y))))))
|
||||
((COND ((BIGP Y) (NOT (ZEROP (& X (CADR Y)))))
|
||||
((NOT (ZEROP (& X Y))))))))
|
||||
|
||||
(DEFUN PLOR (X Y)
|
||||
;;; COMPUTES THE LOGICAL OR OF TWO POSITIVE INTEGERS
|
||||
(COND ((BIGP X)
|
||||
(COND ((BIGP Y) (CONSBIGNUM (BOR (CDR X) (CDR Y))))
|
||||
((CONSBIGNUM (CONS (V (CADR X) Y) (CDDR X))))))
|
||||
((COND ((BIGP Y)
|
||||
(CONSBIGNUM (CONS (V X (CADR Y)) (CDDR Y))))
|
||||
((V X Y))))))
|
||||
|
||||
(DEFUN PLCOM (X Y)
|
||||
;;; COMPUTES THE LOGICAL COMPLEMENT OF TWO POSITIVE INTEGERS
|
||||
(COND ((BIGP X)
|
||||
(COND ((BIGP Y) (CONSBIGNUMBER (BLCOM (CDR X) (CDR Y))))
|
||||
((CONSBIGNUM (CONS (_ (CADR X) Y) (CDDR X))))))
|
||||
((COND ((BIGP Y) (_ X (CADR Y))) ((_ X Y))))))
|
||||
|
||||
(DEFUN PLXOR (X Y)
|
||||
;;; COMPUTES THE LOGICAL XOR OF TWO POSITIVE INTEGERS
|
||||
(COND ((BIGP X)
|
||||
(COND ((BIGP Y) (CONSBIGNUMBER (BXOR (CDR X) (CDR Y))))
|
||||
((CONSBIGNUM (CONS (BOOLE 6. (CADR X) Y)
|
||||
(CDDR X))))))
|
||||
((COND ((BIGP Y)
|
||||
(CONSBIGNUM (CONS (BOOLE 6. X (CADR Y))
|
||||
(CDDR Y))))
|
||||
((BOOLE 6. X Y))))))
|
||||
|
||||
(DEFUN CONSBIGNUMBER (X)
|
||||
(COND ((ATOM X) X) ((NULL (CDR X)) (CAR X)) ((CONSBIGNUM X))))
|
||||
|
||||
(DEFUN LAND (A B)
|
||||
;;; DOES LOGICAL AND OF TWO INTEGERS, POSITIVE OR NEGATIVE
|
||||
(COND ((EQ A B) A)
|
||||
((MINUSP A)
|
||||
(COND ((MINUSP B) (LNOT (PLOR (LNOT A) (LNOT B))))
|
||||
((PLCOM B (LNOT A)))))
|
||||
((COND ((MINUSP B) (PLCOM A (LNOT B))) ((PLAND A B))))))
|
||||
|
||||
(DEFUN LOR (A B)
|
||||
;;; DOES LOGICAL OR OF TWO INTEGERS, POSITIVE OR NEGATIVE
|
||||
(COND ((EQ A B) A)
|
||||
((MINUSP A)
|
||||
(COND ((MINUSP B) (LNOT (PLAND (LNOT A) (LNOT B))))
|
||||
((LNOT (PLCOM (LNOT A) B)))))
|
||||
((COND ((MINUSP B) (LNOT (PLCOM (LNOT B) A)))
|
||||
((PLOR A B))))))
|
||||
|
||||
(DEFUN LCOM (A B)
|
||||
;;; DOES LOGICAL COMPLEMENT OF TWO INTEGERS, POSITIVE OR NEGATIVE
|
||||
(COND ((EQ A B) 0.)
|
||||
((MINUSP A)
|
||||
(COND ((MINUSP B) (PLCOM (LNOT B) (LNOT A)))
|
||||
((LNOT (PLOR (LNOT A) B)))))
|
||||
((COND ((MINUSP B) (PLAND A (LNOT B))) ((PLCOM A B))))))
|
||||
|
||||
(DEFUN LXOR (A B)
|
||||
(COND ((EQ A B) A)
|
||||
((MINUSP A)
|
||||
(COND ((MINUSP B) (PLXOR (LNOT A) (LNOT B)))
|
||||
((LNOT (PLXOR (LNOT A) B)))))
|
||||
((COND ((MINUSP B) (LNOT (PLXOR A (LNOT B))))
|
||||
((PLXOR A B))))))
|
||||
|
||||
(DEFUN LREDUCE (N L)
|
||||
;;; LOGICALLY REDUCE A LIST VIA A BIT VECTOR A LA APL.
|
||||
(COND ((ZEROP N) NIL)
|
||||
((= N -1) L)
|
||||
((PLUSP N) (PREDUCE N L))
|
||||
((NPREDUCE N L))))
|
||||
|
||||
(DEFUN PREDUCE (N L)
|
||||
;;; LOGICALLY REDUCE A LIST VIA A POSITIVE BIT VECTOR.
|
||||
(COND ((BIGP N) (BREDUCE (CDR N) L))
|
||||
((FREDUCE N L))))
|
||||
|
||||
(DECLARE (SPECIAL LN) (FIXNUM C N))
|
||||
|
||||
(DEFUN BREDUCE (LN L)
|
||||
;;; LOGICALLY REDUCE A LIST VIA A LIST OF POSITIVE FIXNUMS.
|
||||
(COND ((NULL LN) NIL)
|
||||
((NULL L) NIL)
|
||||
((BFREDUCE 35. (CAR LN) L))))
|
||||
|
||||
(DEFUN BFREDUCE (C N L)
|
||||
(COND ((NULL L) NIL)
|
||||
((ZEROP C) (BREDUCE (CDR LN) L))
|
||||
((ODDP N) (CONS (CAR L)
|
||||
(BFREDUCE (1- C)
|
||||
(LSH N -1)
|
||||
(CDR L))))
|
||||
((BFREDUCE (1- C) (LSH N -1) (CDR L)))))
|
||||
|
||||
(DEFUN FREDUCE (N L)
|
||||
;;; LOGICALLY REDUCE A LIST VIA A POSITIVE FIXNUM BIT VECTOR.
|
||||
(COND ((ZEROP N) NIL)
|
||||
((ODDP N) (CONS (CAR L) (FREDUCE (LSH N -1) (CDR L))))
|
||||
((FREDUCE (LSH N -1) (CDR L)))))
|
||||
|
||||
(DEFUN LELEMENT (N L)
|
||||
;;; TEST IF THE N'TH BIT IS ON IN THE BIGNUM L.
|
||||
(COND ((MINUSP N) (ERR 'N<0-LELEMENT))
|
||||
;;; IF L NEG, SEE IF N MISSING IN L COMPLEMENT.
|
||||
((MINUSP L) (NOT (LELEMENT N (LNOT L))))
|
||||
;;; IF L A BIGNUM, RUN DOWN LIST OF FIXNUMS.
|
||||
((BIGP L) (BELEMENT N (CDR L)))
|
||||
;;; CHECK IF BIT ON IN SHIFTED FIXNUM.
|
||||
((ODDP (LSH L (MINUS N))))))
|
||||
|
||||
(DEFUN BELEMENT (N L)
|
||||
;;; TEST IF THE N'TH BIT IS ON IN THE LIST OF FIXNUMS L.
|
||||
(COND ((NULL L) NIL)
|
||||
;;; IF BIT IS IN CURRENT WORD, CHECK IT.
|
||||
((< N 35.) (ODDP (LSH (CAR L) (MINUS N))))
|
||||
;;; OTHERWISE, TRY NEXT WORD.
|
||||
((BELEMENT (- N 35.) (CDR L)))))
|
||||
|
||||
|
||||
110
src/libdoc/bench.gjc1
Executable file
110
src/libdoc/bench.gjc1
Executable file
@@ -0,0 +1,110 @@
|
||||
;;-*-LISP-*-
|
||||
;;
|
||||
;; Some code for generating BenchMark reports. I have run this
|
||||
;; in Maclisp, Franz, NIL, and Lispmachine lisps.
|
||||
;; This tries to provide reasonable timing information on each system,
|
||||
;; in a form which can be use for indirect comparisons. No attempt
|
||||
;; is made to normalize the numerical data, as this is best done
|
||||
;; during a second analysis pass.
|
||||
;; 2:21pm Friday, 2 October 1981 -George Carrette.
|
||||
|
||||
;; Summary of available timers:
|
||||
;; LISPM: (TIME) with (TIME-DIFFERENCE T1 T2) gives 60'th of sec wallclock.
|
||||
;; MACLISP: (RUNTIME) (STATUS GCTIME) give microseconds cpu time.
|
||||
;; FRANZ: (PTIME) gives a list (RUNTIME GCTIME) in 60'th of sec cpu time.
|
||||
;; NIL: (RUNTIME) gives cpu time in 100'th of sec.
|
||||
;; (TIME) gives wallclock accurate to seconds.
|
||||
;;
|
||||
;; Notes: Page fault information is also important, as is wallclock time
|
||||
;; on all systems.
|
||||
;; N.B. This code must be in all lower case, as to be easily read in
|
||||
;; multics maclisp and Franz.
|
||||
|
||||
(defprop bench 1 version)
|
||||
|
||||
#+(or pdp10 nil) (herald bench)
|
||||
|
||||
(declare (special bench-output-stream))
|
||||
|
||||
(defun benchmark-to-file (l filename)
|
||||
#+lispm
|
||||
(with-open-file (stream filename '(:out))
|
||||
(benchmark-to-stream l stream))
|
||||
#-lispm
|
||||
(let ((stream))
|
||||
(unwind-protect
|
||||
(benchmark-to-stream l (setq stream #-franz (open filename 'out)
|
||||
#+franz (outfile filename)))
|
||||
(and stream (close stream)))))
|
||||
|
||||
(defun benchmark (l)
|
||||
(benchmark-to-stream l
|
||||
#+(or lispm nil)
|
||||
terminal-io
|
||||
#-(or lispm nil)
|
||||
t))
|
||||
|
||||
(defun benchmark-to-stream (l bench-output-stream)
|
||||
(let (#+(or maclisp lispm) (base 10.)
|
||||
before accumulator)
|
||||
(bench-print-header l)
|
||||
(setq before (benchstate))
|
||||
(setq accumulator (benchstate-difference before before))
|
||||
(do ((l l (cdr l))
|
||||
(j 0 (1+ j)))
|
||||
((null l)
|
||||
(bench-print "**total accumulated time for this benchmark**")
|
||||
(benchstate-print accumulator)
|
||||
(bench-print "**total time including printing**")
|
||||
(benchstate-print (benchstate-difference (benchstate) before))
|
||||
(bench-print "***end of test***"))
|
||||
(bench-print `("expression number" ,j))
|
||||
(bench-print (car l))
|
||||
(let ((state (benchstate)))
|
||||
(let ((result (eval (car l))))
|
||||
(setq state (benchstate-difference (benchstate) state))
|
||||
(benchstate-print state)
|
||||
(setq accumulator (benchstate-accumulate accumulator state))
|
||||
(bench-print result))))))
|
||||
|
||||
(defun benchstate ()
|
||||
#+maclisp (list (runtime) (status gctime))
|
||||
#+nil (list (runtime) (time))
|
||||
#+franz (ptime)
|
||||
#+lispm (time))
|
||||
|
||||
(defun benchstate-difference (x y)
|
||||
#+maclisp (list (- (car x) (car y)) (- (cadr x) (cadr y)))
|
||||
#+nil (list (- (car x) (car y)) (-$ (cadr x) (cadr y)))
|
||||
#+franz (list (- (car x) (car y)) (- (cadr x) (cadr y)))
|
||||
#+lispm (time-difference x y))
|
||||
|
||||
(defun benchstate-accumulate (x y)
|
||||
#+maclisp (list (+ (car x) (car y)) (+ (cadr x) (cadr y)))
|
||||
#+nil (list (+ (car x) (car y)) (+$ (cadr x) (cadr y)))
|
||||
#+franz (list (+ (car x) (car y)) (+ (cadr x) (cadr y)))
|
||||
#+lispm (+ x y))
|
||||
|
||||
(defun benchstate-print (x)
|
||||
(bench-print
|
||||
#+maclisp `(,(car x) "cpu runtime" ,(cadr x) "gctime" "in microseconds")
|
||||
#+nil `(,(car x) "centiseconds cpu runtime" ,(cadr x) "seconds realtime.")
|
||||
#+franz`(,(car x) "cpu runtime" ,(cadr x) "gctime" "in 60'ths of a second")
|
||||
#+lispm `(,x "60'ths of a second realtime.")))
|
||||
|
||||
(defun bench-print (x)
|
||||
(print x bench-output-stream)
|
||||
#+franz
|
||||
;; ah yes, winning franz.
|
||||
(terpri bench-output-stream))
|
||||
|
||||
(defun bench-print-header (l)
|
||||
(bench-print `("benchmark by run by"
|
||||
#+(or maclisp nil) ,(status userid)
|
||||
#+lispm ,user-id
|
||||
#-(or maclisp nil lispm) "somebody"))
|
||||
(bench-print #+(or maclisp nil) `(,(status dow) ,(status daytime)
|
||||
,(status date))
|
||||
#+lispm (time:print-current-date ())
|
||||
#-(or maclisp nil lispm) "on some date")
|
||||
(bench-print `("ready to benchmark" ,(length l) "expressions.")))
|
||||
137
src/libdoc/binprt.12
Executable file
137
src/libdoc/binprt.12
Executable file
@@ -0,0 +1,137 @@
|
||||
;;; -*- Mode:Lisp; IBase:10.; -*- Package created by KMP, 1/15/80
|
||||
;;;
|
||||
;;; BINPRT: A package for doing octal output (PDP10 only)
|
||||
;;;
|
||||
;;; This package is designed primarily for use as an interactive
|
||||
;;; debugging tool, though it may have other applications as well. It
|
||||
;;; defines the following functions:
|
||||
;;;
|
||||
;;; (BINPRINT object &optional stream) -- Terpri, BINPRIN1, Space
|
||||
;;; (BINPRIN1 object &optional stream) -- Like PRIN1, but integers (at
|
||||
;;; toplevel or imbedded will appear as nnnnnn,,nnnnnn (for fixnums)
|
||||
;;; +nnnnnn,,nnnnnn_nnnnnn,,nnnnnn_... or
|
||||
;;; -nnnnnn,,nnnnnn_nnnnnn,,nnnnnn_...
|
||||
;;; (for bignums). If the switch BINPRINTYPE (Default NIL) is non-NIL
|
||||
;;; fixnums and bignums will show up as above but with wrappers of
|
||||
;;; #<FIXNUM ...> or #<BIGNUM ...> around them as appropriate.
|
||||
;;;
|
||||
;;; It should be emphasized that the output from this program is far from
|
||||
;;; lisp-readable due to the free use of ",," but output is still visually
|
||||
;;; parsable and that makes it a valuable aid in debugging bit-intensive code.
|
||||
;;;
|
||||
;;; Sample usage:
|
||||
;;;
|
||||
;;; (SETQ PRIN1 'BINPRIN1) => BINPRIN1
|
||||
;;; 3 => 000000,,000003
|
||||
;;; -1 => 777777,,777777
|
||||
;;; '(3 5) => (000000,,000003 000000,,000005)
|
||||
;;; (SETQ BINPRINTYPE T) => T
|
||||
;;; -1 => #<FIXNUM 777777,,777777>
|
||||
|
||||
#-PDP10 (ERROR "This package not written to work except on a PDP10.")
|
||||
|
||||
(DECLARE (*LEXPR BINPRIN\NUM BINPRINT BINPRIN1)
|
||||
(SPECIAL BINPRINTYPE))
|
||||
|
||||
(COND ((NOT (BOUNDP 'BINPRINTYPE))
|
||||
(SETQ BINPRINTYPE NIL)))
|
||||
|
||||
(DEFUN BINPRIN\NUM (N &OPTIONAL (WHERE TYO) (TYPEFLAG BINPRINTYPE))
|
||||
(DECLARE (SPECIAL CAR CDR))
|
||||
(LET ((CAR T) (CDR T) (BASE (COND ((= BASE 2.) 2.) (T 8.))))
|
||||
(COND (TYPEFLAG
|
||||
(PRINC "#<" WHERE)
|
||||
(PRINC (TYPEP N) WHERE)
|
||||
(PRINC " " WHERE)))
|
||||
(COND ((AND (OR (FIXP N) (FLOATP N)) (NOT (BIGP N)))
|
||||
(SETQ N (LSH N 0.))
|
||||
(DO ((I 33. (- I 3.)))
|
||||
((MINUSP I))
|
||||
(COND ((= I 15.) (PRINC ",," WHERE)))
|
||||
(PRINC (LSH (BOOLE 1. N (LSH 7. I)) (- I)) WHERE)))
|
||||
((BIGP N)
|
||||
(COND ((NULL (CAR N)) (PRINC "+" WHERE))
|
||||
(T (PRINC "-" WHERE)))
|
||||
(DO ((L (CDR N) (CDR L)))
|
||||
((NULL L))
|
||||
(BINPRIN\NUM (CAR L) WHERE NIL)
|
||||
(COND ((CDR L) (PRINC "_" WHERE)))))
|
||||
(T
|
||||
(PRINC "#<BINPRIN1 failure>" WHERE)))
|
||||
(IF TYPEFLAG (PRINC ">"))))
|
||||
|
||||
(DECLARE (SPECIAL BINPRIN1-/`/,-LEVEL))
|
||||
(SETQ BINPRIN1-/`/,-LEVEL 0.)
|
||||
|
||||
(DEFUN BINPRINT (FROB &OPTIONAL (STREAM TYO))
|
||||
(TERPRI STREAM)
|
||||
(BINPRIN1 FROB STREAM)
|
||||
(TYO #\SPACE STREAM))
|
||||
|
||||
(DEFUN BINPRIN1 (FROB &OPTIONAL (STREAM TYO))
|
||||
(DECLARE (SPECIAL CAR CDR))
|
||||
(LET ((CAR T) (CDR T))
|
||||
(COND ((FIXP FROB)
|
||||
(BINPRIN\NUM FROB STREAM))
|
||||
((ATOM FROB)
|
||||
(PRIN1 FROB STREAM))
|
||||
((HUNKP FROB)
|
||||
(PRINC "(" STREAM)
|
||||
(DO ((I 1. (1+ I))
|
||||
(END (1- (HUNKSIZE FROB))))
|
||||
((> I END))
|
||||
(BINPRIN1 (CXR I FROB) STREAM)
|
||||
(PRINC " . " STREAM))
|
||||
(PRINC (CXR 0. FROB) STREAM)
|
||||
(PRINC " .)" STREAM))
|
||||
((AND (EQ (CAR FROB) 'QUOTE)
|
||||
(= (LENGTH FROB) 2.))
|
||||
(PRINC "'" STREAM)
|
||||
(BINPRIN1 (CADR FROB) STREAM))
|
||||
((EQ (CAR FROB) '|`-expander/||)
|
||||
(LET ((BINPRIN1-/`/,-LEVEL (1+ BINPRIN1-/`/,-LEVEL)))
|
||||
(PRINC "`" STREAM)
|
||||
(BINPRIN1 (CDR FROB) STREAM)))
|
||||
((AND (EQ (CAR FROB) '|`,/||) (> BINPRIN1-/`/,-LEVEL 0.))
|
||||
(LET ((BINPRIN1-/`/,-LEVEL (1- BINPRIN1-/`/,-LEVEL)))
|
||||
(PRINC "," STREAM)
|
||||
(BINPRIN1 (CDR FROB) STREAM)))
|
||||
((AND (EQ (CAR FROB) '|`,@/||) (> BINPRIN1-/`/,-LEVEL 0.))
|
||||
(LET ((BINPRIN1-/`/,-LEVEL (1- BINPRIN1-/`/,-LEVEL)))
|
||||
(PRINC ",@" STREAM)
|
||||
(BINPRIN1 (CDR FROB) STREAM)))
|
||||
((AND (EQ (CAR FROB) '|`,./||) (> BINPRIN1-/`/,-LEVEL 0.))
|
||||
(LET ((BINPRIN1-/`/,-LEVEL (1- BINPRIN1-/`/,-LEVEL)))
|
||||
(PRINC ",." STREAM)
|
||||
(BINPRIN1 (CDR FROB) STREAM)))
|
||||
((AND (EQ (CAR FROB) '|`.,/||) (> BINPRIN1-/`/,-LEVEL 0.))
|
||||
(LET ((BINPRIN1-/`/,-LEVEL (1- BINPRIN1-/`/,-LEVEL)))
|
||||
(PRINC ".," STREAM)
|
||||
(BINPRIN1 (CDR FROB) STREAM)))
|
||||
((AND (EQ (CAR FROB) 'MACROEXPANDED)
|
||||
(GET (CADR FROB) 'MACRO))
|
||||
(BINPRIN1 (NTH 3. FROB) STREAM))
|
||||
((BIN$MEM '|`,/|| FROB)
|
||||
(BINPRIN1
|
||||
(DO ((L FROB (CDR L))
|
||||
(NL () (CONS (CAR L) NL)))
|
||||
((EQ (CAR L) '|`,/||)
|
||||
(NREVERSE (CONS (CONS '|`.,/|| (CDR L)) NL))))
|
||||
STREAM))
|
||||
(T
|
||||
(PRINC "(" STREAM)
|
||||
(BINPRIN1 (CAR FROB) STREAM)
|
||||
(DO ((F (CDR FROB) (CDR F)))
|
||||
((ATOM F)
|
||||
(COND ((NULL F) (PRINC ")" STREAM))
|
||||
(T (PRINC " . " STREAM)
|
||||
(BINPRIN1 F STREAM)
|
||||
(PRINC ")" STREAM))))
|
||||
(PRINC " " STREAM)
|
||||
(BINPRIN1 (CAR F) STREAM))))))
|
||||
|
||||
(DEFUN BIN$MEM (X Y)
|
||||
(DO ((L Y (CDR L)))
|
||||
((ATOM L) NIL)
|
||||
(COND ((EQ (CAR L) X) (RETURN L)))))
|
||||
|
||||
39
src/libdoc/carcdr.kmp1
Executable file
39
src/libdoc/carcdr.kmp1
Executable file
@@ -0,0 +1,39 @@
|
||||
|
||||
;;; -*-LISP-*-
|
||||
|
||||
;;; Purpose: to permit long names, like CADADADADDDR, to be easily
|
||||
;;; macro-defined into appropriate sequences of CARs and CDRs.
|
||||
;;; Use: (DEF-CARCDR CADADADADDDR CADADADDDDDR ... )
|
||||
;;; where the names must have at least 5 A/D's.
|
||||
|
||||
;;; Produces a format internal to the compiler when being expanded
|
||||
;;; for optimal compilation. For interpretation, produces a
|
||||
;;; LAMBDA form with a composition of initial carcdr functions
|
||||
;;; of up to 4 deep, which should be (already) defined primitively.
|
||||
|
||||
|
||||
|
||||
(DEFMACRO DEF-CARCDR L
|
||||
`(PROGN 'COMPILE
|
||||
,@(mapcar '(lambda (x) `(DEFPROP ,x C*R MACRO)) l)))
|
||||
|
||||
(DEFUN C*R (X)
|
||||
(DECLARE (SPECIAL CARCDR)) ;Gets the complr's CARCDR variable
|
||||
(LET (((NAME ARG1 . L) X))
|
||||
(AND L (ERROR '|Extra args in call to C*R macro| X 'WRNG-NO-ARGS))
|
||||
(AND (OR (< (LENGTH (SETQ L (EXPLODEC NAME))) 7)
|
||||
(NOT (EQ (CAR L) 'C))
|
||||
(NOT (EQ (CAR (SETQ L (NREVERSE (CDR L)))) 'R))
|
||||
(DO L (SETQ L (NREVERSE (CDR L))) (CDR L) (NULL L)
|
||||
(AND (NOT (MEMQ (CAR L) '(A D))) (RETURN 'T))))
|
||||
(ERROR '|Invalid name for C*R macro| X 'WRNG-TYPE-ARG))
|
||||
`(,(COND ((EQ COMPILER-STATE 'COMPILE) `(,carcdr ,@(nreverse l)))
|
||||
(`(LAMBDA (X) ,(|c*r-expander/|| l 'X))))
|
||||
,arg1)))
|
||||
|
||||
(DEFUN |c*r-expander/|| (L ARG)
|
||||
(COND ((< (LENGTH L) 5) `(,(implode (nconc (list 'C) l '(R))) ,arg))
|
||||
((LET* ((/3TAIL (NTHCDR 3 L)) (/4TAIL (CDR /3TAIL)))
|
||||
(RPLACD /3TAIL () )
|
||||
(|c*r-expander/|| L (|c*r-expander/|| /4TAIL ARG))))))
|
||||
|
||||
354
src/libdoc/char.gjc10
Executable file
354
src/libdoc/char.gjc10
Executable file
@@ -0,0 +1,354 @@
|
||||
;;-*-LISP-*-
|
||||
;; Practical character and string manipulation primitives for PDP-10 maclisp.
|
||||
;; The readmacro #~ is set up for reading of characters.
|
||||
;; This package has been tested for both robustness and speed,
|
||||
;; it won't blow up on you, and is very fast. It does better than
|
||||
;; certain famous and highly bumbed string packages for maclisp that
|
||||
;; will remain nameless. -GJC
|
||||
|
||||
(HERALD CHAR)
|
||||
|
||||
;; Character primitives:
|
||||
;; (TO-CHARACTER <any>) returns a character.
|
||||
;; (CHARACTERP <any>) True if and only if a character.
|
||||
;; (CHAR-CODE <char>) Returns ascii fixnum cooresponding to character.
|
||||
;; (CODE-CHAR <fixnum) Returns character.
|
||||
;; (CHAR-UPCASE <char>) Maps #~a to #~A etc.
|
||||
;; (CHAR-DOWNCASE <char>) Maps #~A to #~a etc.
|
||||
|
||||
;; String primitives:
|
||||
;; (TO-STRING <any>) Converts to string.
|
||||
;; (STRINGP <any>) True if and only if a string.
|
||||
;; (CHAR <string> <j>) Returns the <j>'th character in the string.
|
||||
;; (RPLACHAR <string> <j> <char>) Replaces the <j>'th character. Caution side-effect!
|
||||
;; (STRING-LENGTH <string>)
|
||||
;; (STRING-SUBSEQ <string> &optional (<skip-j> 0) (<dim>))
|
||||
;; (MAKE-STRING <n>) Returns a string with <n> null characters.
|
||||
;; (STRING-APPEND s1 s2 ...) Returns the concatenated string.
|
||||
;; (STRING-UPCASE <string>)
|
||||
;; (STRING-DOWNCASE <string>)
|
||||
;; (STRING-EQUAL <s1> <s2>)
|
||||
;; (STRING-LESSP <s1> <s2>)
|
||||
|
||||
;; Notes: Characters may be compared with EQ, so it is reasonable to do
|
||||
;; (IF (EQ C #~^C) (SEND-THE-MESSAGE)) or
|
||||
;; (ASSOC C KEY-TABLE).
|
||||
;; Strings should be compared with STRING-LESSP and STRING-EQUAL.
|
||||
;; Generic equal will not work on strings in this implementation,
|
||||
;; because strings are first SYMBOLS.
|
||||
;; Characters will not print out using the #~A syntax, so that
|
||||
;; they will not read back in as characters. Boo Hoo.
|
||||
;; However, they will remain characterp in FASL files.
|
||||
|
||||
(eval-when (eval compile load)
|
||||
(cond ((status feature complr)
|
||||
(*EXPR TO-CHARACTER CHARACTERP CHAR-CODE CODE-CHAR CHAR-UPCASE
|
||||
CHAR-DOWNCASE
|
||||
TO-STRING STRINGP CHAR RPLACHAR STRING-LENGTH
|
||||
STRING-EQUAL STRING-LESSP STRING-UPCASE STRING-DOWNCASE
|
||||
STRING-TRIM STRING-LEFT-TRIM STRING-RIGHT-TRIM)
|
||||
(*LEXPR STRING-SUBSEQ MAKE-STRING STRING-APPEND
|
||||
STRING-SEARCH STRING-REPLACE)
|
||||
(FIXNUM (STRING-SEARCH NIL NIL FIXNUM FIXNUM)
|
||||
(STRING-LENGTH NIL))
|
||||
(NOTYPE (CHAR NIL FIXNUM)
|
||||
(RPLACHAR NIL FIXNUM NIL)
|
||||
(STRING-SUBSEQ NIL FIXNUM FIXNUM)
|
||||
(STRING-REPLACE NIL NIL FIXNUM FIXNUM FIXNUM))
|
||||
(*LEXPR WRITE-CHAR READ-CHAR OUSTR))))
|
||||
|
||||
(DEFUN TO-CHARACTER (X)
|
||||
(COND ((CHARACTERP X) X)
|
||||
((STRINGP X) (CHAR X 0))
|
||||
((FIXP X) (CODE-CHAR X))
|
||||
((SYMBOLP X) (CODE-CHAR (GETCHARN X 1)))
|
||||
('ELSE
|
||||
(TO-CHARACTER (ERROR "can't go TO-CHARACTER" X 'WRNG-TYPE-ARG)))))
|
||||
|
||||
(DEFUN CHARACTERP (X)
|
||||
(AND (SYMBOLP X) (GET X 'CHAR-CODE) T))
|
||||
|
||||
(DEFUN CHAR-ERROR (F X)
|
||||
(FUNCALL F (ERROR (LIST "is not a character. --" F) X 'WRNG-TYPE-ARG)))
|
||||
|
||||
(DEFUN CHAR-CODE (C)
|
||||
(OR (GET C 'CHAR-CODE)
|
||||
(CHAR-ERROR #'CHAR-CODE C)))
|
||||
|
||||
(DEFVAR CODE-CHAR-ARRAY (*ARRAY NIL T #o200))
|
||||
|
||||
(DEFUN CODE-CHAR (J)
|
||||
(IF (AND (< J #o200)
|
||||
(NOT (< J 0)))
|
||||
(ARRAYCALL T CODE-CHAR-ARRAY J)
|
||||
(CODE-CHAR (ERROR "fixnum out of range to be a char-code" J
|
||||
'WRNG-TYPE-ARG))))
|
||||
|
||||
(DEFUN CHAR-UPCASE (C)
|
||||
(OR (GET C 'CHAR-UPCASE)
|
||||
(CHAR-ERROR #'CHAR-UPCASE C)))
|
||||
|
||||
(DEFUN CHAR-DOWNCASE (C)
|
||||
(OR (GET C 'CHAR-DOWNCASE)
|
||||
(CHAR-ERROR #'CHAR-DOWNCASE C)))
|
||||
|
||||
|
||||
;; Strings.
|
||||
|
||||
(DEFUN TO-STRING (X)
|
||||
(COND ((STRINGP X)
|
||||
X)
|
||||
((CHARACTERP X)
|
||||
(TO-STRING-SUB-MAKNAM (LIST (CHAR-CODE X))))
|
||||
((SYMBOLP X)
|
||||
(TO-STRING-SUB (PNPUT (APPEND (PNGET X 7.) NIL) NIL)))
|
||||
((FIXP X)
|
||||
(TO-STRING (CODE-CHAR X)))
|
||||
('ELSE
|
||||
(TO-STRING (ERROR "can't go to string." X 'WRNG-TYPE-ARG)))))
|
||||
|
||||
(DEFUN TO-STRING-SUB (S)
|
||||
(SETPLIST S '(+INTERNAL-STRING-MARKER T))
|
||||
(SET S S))
|
||||
|
||||
(DEFUN TO-STRING-SUB-MAKNAM (L)
|
||||
(PROG1 (TO-STRING-SUB (MAKNAM L))
|
||||
(RECLAIM L NIL)))
|
||||
|
||||
(DEFUN STRINGP (X)
|
||||
(AND (SYMBOLP X) (GET X '+INTERNAL-STRING-MARKER) T))
|
||||
|
||||
(DEFUN CHAR (S J)
|
||||
(CODE-CHAR (GETCHARN S (1+ J))))
|
||||
|
||||
(DEFUN RPLACHAR (S J C)
|
||||
(LET ((L (NTHCDR (// J 5.) (PNGET S 7.)))
|
||||
(K (- #.(- 36. 7.) (* 7. (\ J 5.)))))
|
||||
(DECLARE (FIXNUM K))
|
||||
(IF (NULL L)
|
||||
(RPLACHAR (ERROR (LIST "string too small for index =" J)
|
||||
S 'WRNG-TYPE-ARG) J C)
|
||||
(LET ((ADDRESS (MAKNUM (CAR L)))
|
||||
(VALUE (LOGIOR (BOOLE 4 (CAR L) (LSH #o177 K))
|
||||
(LSH (CHAR-CODE C) K))))
|
||||
(DECLARE (FIXNUM ADDRESS VALUE))
|
||||
(IF (PUREP (CAR L))
|
||||
;; error check now to avoid the rush!
|
||||
(RPLACA L VALUE)
|
||||
(DEPOSIT ADDRESS VALUE)))))
|
||||
C)
|
||||
|
||||
(DEFUN STRING-REPLACE (S1 S2 &OPTIONAL
|
||||
(INDEX1 0) (INDEX2 0)
|
||||
(COUNT (MIN (- (STRING-LENGTH S1) INDEX1)
|
||||
(- (STRING-LENGTH S2) INDEX2))))
|
||||
(DO ((J 0 (1+ J)))
|
||||
((= J COUNT) S1)
|
||||
(RPLACHAR S1 (+ J INDEX1) (CHAR S2 (+ J INDEX2)))))
|
||||
|
||||
(DEFUN STRING-LENGTH (S)
|
||||
(IF (STRINGP S)
|
||||
(FLATC S)
|
||||
(STRING-LENGTH (ERROR "is not a string." S 'WRNG-TYPE-ARG))))
|
||||
|
||||
(DEFUN STRING-SUBSEQ (S &OPTIONAL (IND 0) (DIM (- (STRING-LENGTH S) IND)))
|
||||
(IF (AND (STRINGP S)
|
||||
(NOT (< (STRING-LENGTH S) (+ DIM IND))))
|
||||
(TO-STRING-SUB-MAKNAM (STRING-SUBSEQ-SUB S IND DIM))
|
||||
(STRING-SUBSEQ (ERROR "not a string or string too short" S
|
||||
'WRNG-TYPE-ARG)
|
||||
IND
|
||||
DIM)))
|
||||
|
||||
(DEFUN STRING-SUBSEQ-SUB (S IND DIM)
|
||||
(DO ((L NIL (CONS (GETCHARN S (+ IND 1 J)) L))
|
||||
(J 0 (1+ J)))
|
||||
((= J DIM)
|
||||
(NREVERSE L))))
|
||||
|
||||
(DEFUN MAKE-STRING (DIM &OPTIONAL (C #/@))
|
||||
(SETQ C (TO-CHARACTER C))
|
||||
(TO-STRING-SUB-MAKNAM (MAP #'(LAMBDA (V) (RPLACA V C))
|
||||
(MAKE-LIST DIM))))
|
||||
|
||||
(DEFUN STRING-EXPLODEN-SUB (S) (EXPLODEN S))
|
||||
|
||||
(DEFUN STRING-APPEND N
|
||||
(DO ((J N (1- J))
|
||||
(L NIL))
|
||||
((ZEROP J)
|
||||
(TO-STRING-SUB-MAKNAM L))
|
||||
(SETQ L (NCONC (STRING-EXPLODEN-SUB (ARG J)) L))))
|
||||
|
||||
(DEFUN STRING-EQUAL (S1 S2)
|
||||
(SAMEPNAMEP S1 S2))
|
||||
|
||||
(DEFUN STRING-LESSP (S1 S2)
|
||||
(ALPHALESSP S1 S2))
|
||||
|
||||
(DEFUN STRING-UPCASE (S)
|
||||
(TO-STRING-SUB-MAKNAM
|
||||
(MAP #'(LAMBDA (V)
|
||||
(RPLACA V (CHAR-UPCASE (CODE-CHAR (CAR V)))))
|
||||
(STRING-EXPLODEN-SUB S))))
|
||||
|
||||
|
||||
(DEFUN STRING-DOWNCASE (S)
|
||||
(TO-STRING-SUB-MAKNAM
|
||||
(MAP #'(LAMBDA (V)
|
||||
(RPLACA V (CHAR-DOWNCASE (CODE-CHAR (CAR V)))))
|
||||
(STRING-EXPLODEN-SUB S))))
|
||||
|
||||
(DEFUN STRING-TRIM-SUB (CHAR-SET L)
|
||||
(DO ()
|
||||
((OR (NULL L) (NOT (MEMQ (CODE-CHAR (CAR L)) CHAR-SET))) L)
|
||||
(SETQ L (CDR L))))
|
||||
|
||||
(DEFUN STRING-TRIM-MAKE-SUB (L) (TO-STRING-SUB (MAKNAM L)))
|
||||
|
||||
(DEFUN STRING-TRIM (CHAR-SET STRING)
|
||||
(LET ((L (STRING-EXPLODEN-SUB STRING)))
|
||||
(PROG1 (STRING-TRIM-MAKE-SUB
|
||||
(NREVERSE (STRING-TRIM-SUB CHAR-SET
|
||||
(NREVERSE (STRING-TRIM-SUB CHAR-SET
|
||||
L)))))
|
||||
(RECLAIM L NIL))))
|
||||
|
||||
(DEFUN STRING-LEFT-TRIM (CHAR-SET STRING)
|
||||
(LET ((L (STRING-EXPLODEN-SUB STRING)))
|
||||
(PROG1 (STRING-TRIM-MAKE-SUB (STRING-TRIM-SUB CHAR-SET L))
|
||||
(RECLAIM L NIL))))
|
||||
|
||||
(DEFUN STRING-RIGHT-TRIM (CHAR-SET STRING)
|
||||
(LET ((L (STRING-EXPLODEN-SUB STRING)))
|
||||
(PROG1 (STRING-TRIM-MAKE-SUB (NREVERSE (STRING-TRIM-SUB CHAR-SET
|
||||
(NREVERSE L))))
|
||||
(RECLAIM L NIL))))
|
||||
|
||||
(DECLARE (FIXNUM (STRING-SEARCH-SUB NIL NIL FIXNUM)))
|
||||
|
||||
(DEFUN STRING-SEARCH (KEY STRING &OPTIONAL
|
||||
(FROM 0)
|
||||
(TO (STRING-LENGTH STRING)))
|
||||
(IF (< (- TO FROM) (STRING-LENGTH KEY))
|
||||
-1
|
||||
(LET ((L1 (STRING-EXPLODEN-SUB KEY))
|
||||
(L2 (STRING-EXPLODEN-SUB STRING)))
|
||||
(PROG1 (LET ((N (STRING-SEARCH-SUB L1 (NTHCDR FROM L2) (- TO FROM))))
|
||||
(IF (= N -1)
|
||||
-1
|
||||
(+ N FROM)))
|
||||
(RECLAIM L1 NIL)
|
||||
(RECLAIM L2 NIL)))))
|
||||
|
||||
(DEFUN STRING-SEARCH-SUB (SMALL LARGE DIM)
|
||||
(DO ((LARGE LARGE (CDR LARGE))
|
||||
(N 0 (1+ N)))
|
||||
((= N DIM) -1)
|
||||
(IF (DO ((SMALL SMALL (CDR SMALL))
|
||||
(LARGE LARGE (CDR LARGE)))
|
||||
((NULL SMALL) T)
|
||||
(OR (= (CAR SMALL) (CAR LARGE))
|
||||
(RETURN NIL)))
|
||||
(RETURN N))))
|
||||
|
||||
|
||||
;; Read syntax and initiatializations.
|
||||
|
||||
(DEFUN TILDE-READMACRO N
|
||||
(SQUID-CHAR
|
||||
(LET ((C (TYI)))
|
||||
(COND ((= C #//)
|
||||
(CODE-CHAR (TYI)))
|
||||
((= C #/^)
|
||||
(CODE-CHAR (LOGAND #o77
|
||||
(CHAR-CODE (CHAR-UPCASE (CODE-CHAR (TYI)))))))
|
||||
((= C #/\)
|
||||
(LET ((S (READ)))
|
||||
(OR (AND (SYMBOLP S) (GET S 'SYMBOLIC-CHARACTER))
|
||||
(ERROR "undefined symbolic character" S))))
|
||||
('ELSE
|
||||
(CODE-CHAR C))))))
|
||||
|
||||
(SETSYNTAX-SHARP-MACRO '/~ 'MACRO 'TILDE-READMACRO)
|
||||
|
||||
(DECLARE (SPECIAL SQUID COMPILER-STATE))
|
||||
(DEFUN SQUID-CHAR (C)
|
||||
(IF (MEMQ COMPILER-STATE '(NIL TOPLEVEL))
|
||||
C
|
||||
`(,SQUID (TO-CHARACTER ',C))))
|
||||
|
||||
|
||||
(COND ((NULL (ARRAYCALL T CODE-CHAR-ARRAY 0))
|
||||
(DO ((J 0 (1+ J))
|
||||
(C))
|
||||
((= J #o200))
|
||||
(SETQ C (MAKNAM (LIST J)))
|
||||
(SET C C)
|
||||
(STORE (ARRAYCALL T CODE-CHAR-ARRAY J) C))
|
||||
(DO ((J 0 (1+ J))
|
||||
(J-UP)(J-DOWN)(C))
|
||||
((= J #o200))
|
||||
(COND ((AND (NOT (< J #/A)) (NOT (> J #/Z)))
|
||||
(SETQ J-UP J
|
||||
J-DOWN (+ J #.(- #/a #/A))))
|
||||
((AND (NOT (< J #/a)) (NOT (> J #/z)))
|
||||
(SETQ J-UP (- J #.(- #/a #/A))
|
||||
J-DOWN J))
|
||||
(T
|
||||
(SETQ J-UP J J-DOWN J)))
|
||||
(SETQ C (ARRAYCALL T CODE-CHAR-ARRAY J))
|
||||
(PUTPROP C
|
||||
(ARRAYCALL T CODE-CHAR-ARRAY J-UP)
|
||||
'CHAR-UPCASE)
|
||||
(PUTPROP C
|
||||
(ARRAYCALL T CODE-CHAR-ARRAY J-DOWN)
|
||||
'CHAR-DOWNCASE)
|
||||
(PUTPROP C J 'CHAR-CODE)
|
||||
)))
|
||||
|
||||
(MAPC #'(LAMBDA (X) (PUTPROP (CAR X) (CODE-CHAR (CADR X)) 'SYMBOLIC-CHARACTER))
|
||||
'((NULL 0.)
|
||||
(ALPHA 2.)
|
||||
(BETA 3.)
|
||||
(EPSILON 6.)
|
||||
(BELL 7.)
|
||||
(BACKSPACE 8.)
|
||||
(BS 8.)
|
||||
(TAB 9.)
|
||||
(LINEFEED 10.)
|
||||
(LF 10.)
|
||||
(VT 11.)
|
||||
(FORM 12.)
|
||||
(FORMFEED 12.)
|
||||
(FF 12.)
|
||||
(RETURN 13.)
|
||||
(NEWLINE 13.)
|
||||
(CR 13.)
|
||||
(NL 13.)
|
||||
(ALTMODE 27.)
|
||||
(ALT 27.)
|
||||
(BACK-NEXT 31.)
|
||||
(SPACE 32.)
|
||||
(SP 32.)
|
||||
(DELETE 127.)
|
||||
(RUBOUT 127.)))
|
||||
|
||||
|
||||
|
||||
;; I/O primitives.
|
||||
|
||||
(defvar standard-input nil)
|
||||
(defvar standard-output nil)
|
||||
|
||||
(defun read-char (&optional (stream standard-input) (eof-char () eof-char-p))
|
||||
(if eof-char-p
|
||||
(let ((c (tyi stream -1)))
|
||||
(if (= c -1) eof-char (code-char c)))
|
||||
(code-char (tyi stream))))
|
||||
|
||||
(defun write-char (char &optional (stream standard-output))
|
||||
(tyo (char-code char) stream))
|
||||
|
||||
(defun oustr (string &optional (stream standard-output))
|
||||
(princ string stream))
|
||||
41
src/libdoc/cpyhnk.rwk14
Executable file
41
src/libdoc/cpyhnk.rwk14
Executable file
@@ -0,0 +1,41 @@
|
||||
title COPY HUNKS QUICKLY (the quick brown hunk)
|
||||
|
||||
;The function COPY-HUNK takes a hunk as an argument, and returns an EQUAL
|
||||
;hunk, using BLT to copy the elements of the hunk quickly.
|
||||
|
||||
.FASL
|
||||
.insrt SYS:FASDFS
|
||||
|
||||
verprt CPYHNK
|
||||
.sxeval (DEFPROP CPYHNK 14 VERSION)
|
||||
|
||||
.entry COPY-HUNK SUBR 002
|
||||
retry: skott a,HNK ;Is it really a hunk?
|
||||
jrst nothnk ; Not really a hunk, give an error
|
||||
movei t,(tt) ;Flush left half (leaving HUNKn in rh)
|
||||
subi t,.atom HUNK2 ;get log of size of hunk
|
||||
movei tt,2
|
||||
lsh tt,(t)
|
||||
movei b,(a) ;Save past the cons
|
||||
pushj p,alhunk ;CONS the right hunk
|
||||
movei tt,(a) ;BLT to the new hunk
|
||||
hrli tt,(b) ;from the old one
|
||||
xct blttab(t) ;perform the right blt
|
||||
retok: popj p, ;and return
|
||||
|
||||
nothnk: jumpe a,retok ;Equal time for ()
|
||||
wta [NOT A HUNK -- COPY-HUNK!]
|
||||
jrst retry ;If continued, A should have new value
|
||||
|
||||
blttab: blt tt,(a)
|
||||
blt tt,1(a)
|
||||
blt tt,3(a)
|
||||
blt tt,7(a)
|
||||
blt tt,17(a)
|
||||
blt tt,37(a)
|
||||
blt tt,77(a)
|
||||
blt tt,177(a)
|
||||
blt tt,377(a)
|
||||
blt tt,777(a)
|
||||
.lose ;Hunk 1024???
|
||||
fasend
|
||||
494
src/libdoc/debug*.rcw1
Executable file
494
src/libdoc/debug*.rcw1
Executable file
@@ -0,0 +1,494 @@
|
||||
;-*- LISP -*-
|
||||
(comment an improved version of DEBUG)
|
||||
|
||||
;this file written by Richard C. Waters Dec 1977. Send all comments to DICK@AI.
|
||||
|
||||
;DEBUG* is based on the function DEBUG. however, it fixes a few bugs that
|
||||
;debug has, and adds a lot of new features.
|
||||
;
|
||||
;OLD BUGS FIXED.
|
||||
;1. the function bt sometimes chokes and prints out everthing twice, this is
|
||||
; because baklist has an analogous problem. debug* doesn't call
|
||||
; baklist and therefore doesn't have this problem.
|
||||
;2. debug's C command doesn't work if applied to an evalframe of the
|
||||
; apply type. debug* does work in this case.
|
||||
;3. debug isn't supposed to complain when you type a ^L but it does, debug* doesn't
|
||||
;
|
||||
;IMPROVEMENTS OF DEBUG* OVER DEBUG
|
||||
;the major improvement in debug* is the way it looks at the stack, all of
|
||||
; debug*'s commands operate with respect to an edited version of what is
|
||||
; on the stack. this edited version is different from the actual stack
|
||||
; in that:
|
||||
; 1. every trace of the stepping package's actions are deleted (i.e. calls on
|
||||
; evalhook and evalhook*).
|
||||
; 2. duplicate stack entries caused by a macro expansion that displaced itself
|
||||
; by doing a rplaca and rplacd are deleted.
|
||||
; 3. when an R or C command is done a freturn starts an evaluation sequence which
|
||||
; effectively skips over a part of the stack. if you enter debug again
|
||||
; above such a point you see a lot of junk which is bypassed and does
|
||||
; not have any effect on the current evaluation sequence. debug*
|
||||
; deletes all this stuff so that from looking at the stack you can't
|
||||
; tell whether or not Rs and Cs have been done above you.
|
||||
; everything just looks normal. debug* does similar elisions for the V command
|
||||
; (NOTE these elisions only work 100% when the uuos are snapped. (for instance not
|
||||
; until the second time a feature is used after debug* is fasloaded) when the uuos
|
||||
; are not snapped you see some extra evals and applies on the stack.)
|
||||
; 4. further several of debug*'s commands look at a version of the stack which
|
||||
; is further restricted in that it only contains calls on user functions
|
||||
; (ie ones where (status system function-name) is nil)
|
||||
;another improvement of debug* is that it knows about step (Chuck Rich's stepper)
|
||||
; it allows you to:
|
||||
; 1. enter debug* while stepping without the stepping intruding on anything
|
||||
; you do in debug*. debug* sets evalhook* to nil when it is entered and
|
||||
; restores it before it exits via Q R or C.
|
||||
; 2. when you leave debug* stepping is smoothly resumed. (except for pathological cases)
|
||||
; 3. a command S is provided for changing the stepping mode from inside debug,
|
||||
; so that you can decide what type of stepping you want after you exit
|
||||
; debug. (see the documentation for step for what kinds of things you
|
||||
; can do)
|
||||
; 4. as mentioned above you don't see the garbage the stepper leaves on the
|
||||
; stack.
|
||||
;debug* takes an argument which tells it where to set the top of the stack.
|
||||
; the top of the stack is taken as the first frame below the frame
|
||||
; corresponding to the function name given as the argument to debug*.
|
||||
; this is useful because debug* automatically prints out the top of the
|
||||
; stack when it is entered and the argument helps you avoid seeing
|
||||
; irrelavent stuff. (you can see parts of the stack above the chosen top
|
||||
; point by simply moving up to them with [ or {)). as an example of how
|
||||
; this is usefull see the function *start*debug*
|
||||
;debug* prints a lot less terpris. As a result you get to see a lot more on the screen
|
||||
; basically twice as much.
|
||||
;there are a lot of additional commands (see below)
|
||||
;
|
||||
;COMPLETE COMPATABILITY WITH DEBUG
|
||||
;there are a lot of new features, and the typeout looks a bit different, but DEBUG*
|
||||
;responds to all of the same commands as DEBUG, and this file contains a redefinition
|
||||
;of DEBUG which calls DEBUG*. this can be used to do all the things DEBUG does. (including
|
||||
;setting *rset). debug* encourages a change from using the commands U and D to [ and ] but
|
||||
;doesn't force you to change.
|
||||
;BASIC USE OF DEBUG*
|
||||
;
|
||||
;HOW TO LOAD DEBUG* IN
|
||||
; a. do a (fasload debug* fasl dsk liblsp)
|
||||
;
|
||||
;HOW TO START DEBUG* UP
|
||||
; a. you can use the redefinition of debug in this file to start up
|
||||
; debug* just the way you start up debug (i.e. by doing (debug))
|
||||
; b. you can do a (debug* nil) if you don't care where debug* calls the
|
||||
; top point on the stack
|
||||
; c. you can do a (debug* topfn) in which case debug will choose as top
|
||||
; point the highest point on the stack where the stack frame is an
|
||||
; evaluation of the function TOPFN. note that where the top point is
|
||||
; put does not alter what parts of the stack are excessable for you
|
||||
; to look at, but rather only sets the initial position on the stack,
|
||||
; and the place the T command goes to. the option of specifying the
|
||||
; top point exists so that you can have debug* start up showing you a convenient
|
||||
; place on the stack.
|
||||
; d. you can use (sstatus ttyint # '*start*debug*) in order to put the
|
||||
; function *start*debug* on a control character. (this does not
|
||||
; automatically happen when debug* is loaded in) if you do, then
|
||||
; typing the control character (for example ^D) will start up debug*
|
||||
;
|
||||
;HOW TO INTERACT WITH DEBUG*
|
||||
; a. debug* runs as a read eval print loop where the commands it reads
|
||||
; are all one character. they can all be proceeded by an optional
|
||||
; positive integer argument (though all but [, ], {, and } ignore
|
||||
; it). some of the comands do input themselves. most commands cause
|
||||
; some object to be printed out. if you type a character which is
|
||||
; not a command, debug* goes into a mode where it ignores all input
|
||||
; until a cr is typed. it then returns to reading commands.
|
||||
;
|
||||
;BRIEF DESCRIPTION OF COMMANDS (SEE BELOW FOR MORE DETAIL);
|
||||
; a. EXAMINING THE STACK the commands -, =, and @ show you the entries
|
||||
; on the stack in various amounts of detail. the commands [, ], {,
|
||||
; }, and T move up and down the stack showing you the stack frame they
|
||||
; go to.
|
||||
; b. PRINTOUT cr redisplays the current stack frame. P prints the current
|
||||
; thing without abbreviation. (the user prin1 is used if supplied as
|
||||
; the value of DEBUG*PRIN1 or of PRIN1)
|
||||
; c. EVALUATING things in the environment of the current stack frame. E
|
||||
; reads in and evaluates a single expression and displays the result.
|
||||
; B and V enter read-eval-print loops in the current environment.
|
||||
; d. EXITING debug*. Q, R, and C all return to the computation in
|
||||
; process. a ^G can be used to go to toplevel. in addition you can
|
||||
; eval (with E) a GO or THROW if the situation is appropriate.
|
||||
; e. EFFECTING THE STEPPER the S command reads in an expression and
|
||||
; assigns it to evalhook*.
|
||||
; f. HELP the ? command types out a summary of the commands
|
||||
|
||||
;COMMANDS TO DEBUG*
|
||||
;[ - moves up (more recent in time) one stackframe and displays the new frame (U works too)
|
||||
;] - moves down (further back in time) one stackframe and displays the new frame (D works too)
|
||||
;{ - moves up to the next user function frame
|
||||
;} - moves down to the next user function frame
|
||||
;the four commands []{} take an optional numeric prefix arg n which
|
||||
; causes them to operate n times
|
||||
;cr - displays the current stack frame
|
||||
;T - moves to the top stack frame. which stack frame is the top one is based on
|
||||
; the value of the argument to debug*
|
||||
;- - displays the functions on the stack from top to bottom. "[]" is printed
|
||||
; around the function corresponding to the current stack frame.
|
||||
;= - displays the user functions on the stack. "[]" is printed as in "-".
|
||||
;@ - is like = except that between the first user function frame at or above
|
||||
; where you are and the first user function frame below where you are it displays
|
||||
; all of the functions.
|
||||
;E - reads in an sexpr and evaluates it in the environment of the current
|
||||
; stackframe. in addition, in this environment the variable *debug*
|
||||
; is bound to the result of evalframe which corresponds to the current
|
||||
; stack frame. it then displays the result. E does an errset in order to
|
||||
; prevent errors from generating a break while it evaluates the sexpr.
|
||||
;P - redisplays the last thing displayed with prinlevel and prinlength set to
|
||||
; nil. all other printout is done with prinlevel 4 and prinlength 3. all
|
||||
; printout is done by calling the value of the atom prin1 if it is not nil.
|
||||
; Additionally P will use the value of DEBUG*PRIN1 if non-nil.
|
||||
;S - reads in an sexpr which it sets as the value of evalhook*. this allows
|
||||
; you to alter the state of stepping from in debug. (the value of evalhook* is
|
||||
; not emediatly changed, rather things are set up so that it will change when
|
||||
; debug is exited through Q R or C. while in debug stepping is inhibited by
|
||||
; setting evalhook* to nil.)
|
||||
; (note that you can't start up stepping just by changing evalhook* if
|
||||
; stepping is completely disabled (ie evalhook is nil) in the environment you
|
||||
; return into. if this is the case, you must do an E(setq evalhook 'evalhook*)
|
||||
; in the same environment before returning to it. (note that it will not help
|
||||
; to do this from inside a B or V because they both bind evalhook.) Further, if
|
||||
; stepping is started up this way, it will not work 100%. it will not know what
|
||||
; level it is at; already invoked forms will not print out their values, and the
|
||||
; scope of stepping may be strange.)
|
||||
;B - starts up a break loop in the environment of the current stack frame. in
|
||||
; addition, in this environment the variable *debug* is bound to the
|
||||
; result of evalframe which corresponds to the current stack frame.
|
||||
; returning from the break reenters debug*
|
||||
;V - creates a mini top level in the environment of the current stack frame with *debug*
|
||||
; set as above. this mini top level operates basically like a break loop.
|
||||
; you can exit from it by typing a $p to it at top level. this causes you
|
||||
; to reenter debug*. the variables + - * are appropriately bound.
|
||||
; the key difference is that the mini top level DOES NOT DO AN ERRSET.
|
||||
; as a result, you can investigate any error which occures. at any time you can
|
||||
; pop back up to the mini top level by doing a (*throw '*debug* nil).
|
||||
; the mini top level is useful for setting up a checkpoint on the
|
||||
; stack which you can repeatedly back up to while debugging a program.
|
||||
;Q - causes debug* to exit returning '||.
|
||||
;R - forces the current stack frame to return. before doing anything, R asks
|
||||
; you to type a T to confirm that you really want to force a return. it
|
||||
; then reads an sexpr which is evaluated in the evironment of the current stack
|
||||
; frame and then returned as the result of the current stack frame. *debug* is
|
||||
; not bound in the evaluation environment. if stepping is enabled then the
|
||||
; evaluation of the sexpr will be stepped.
|
||||
;C - the C command is just like the R command except the sexpr evaluated is the
|
||||
; one which corresponds to the current stack frame. it allows you to
|
||||
; continue execution starting with a reevaluation of that expression.
|
||||
;? - prints out a short form of this page.
|
||||
;^L, space - are ignored. (note that if you have tyi open in twelve bit mode, you must
|
||||
; use the FORM key in order to actually type a ^L if you use the control key you
|
||||
; will get L or l with some high order bits. (to fix this debug* ignores L too))
|
||||
;other - any other character causes '| invalid character, type cr to continue |to be printed
|
||||
; and debug* goes into a mode where all input is refused until a cr is typed. this
|
||||
; is done to protect you from doing something strange if you don't realize you
|
||||
; are typing to debug*.
|
||||
|
||||
(declare (special *debug* tyo tyi terpri prinlevel prinlength evalhook*
|
||||
*debug*? debug*prin1)
|
||||
(fixnum code n i j))
|
||||
|
||||
(herald debug*)
|
||||
|
||||
;the system function which forms the bases for this program is EVALFRAME.
|
||||
;evalframe lets you look at what is on the stack, but only if *RSET is non
|
||||
;nil. each call on evalframe returns either NIL if it doesn't find anything,
|
||||
;or a 4 tuple (EVALTYPE STACKPTR EXP ENV). the argumant to evalframe is a
|
||||
;stack pointer which is either nil, or one of the numbers returned as the
|
||||
;second entry in the tuple returned by evalframe. each tuple corresponds to
|
||||
;a function invocation. the EXP is the expression evaluated. STACKPTR is a
|
||||
;number which if passed to evalframe will get you the invocation below this
|
||||
;one. ENV is the environment the EXP was invoked in. EVALTYPE is either
|
||||
;'EVAL or 'APPLY and says whether EXP was invoked by (EVAL EXP) or
|
||||
;(APPLY (CAR EXP) (CADR EXP)).
|
||||
; DEBUG* calls evalframe repeatedly and builds up a two-way linked list
|
||||
;of the 4 tuples (with some of them elliminated as discussed above). all of
|
||||
;the work done by the rest of debug* is with respect to this intermediate data
|
||||
;structure. this makes it easy to do the elision for all commands, and avoids
|
||||
;calling evalframe again and again. each entry in the intermediate structure
|
||||
;is of the form (FRAME UP DOWN . USERFN). where FRAME is a result of
|
||||
;evalframe, UP points to the next higher stack frame, DOWN points to the next
|
||||
;lower, and USEFN is a flag which says whether of not the function
|
||||
;correspanding to this frame is a user function or not. (ie. whether or not
|
||||
;(STATUS SYSTEM ...) is NIL.)
|
||||
|
||||
|
||||
;the following are just macro definitions used to make debug* more readable.
|
||||
|
||||
(eval-when (eval compile)
|
||||
(defmacro evaltypepart (e) `(car ,e))
|
||||
(defmacro evaltype (p) `(evaltypepart (car ,p)))
|
||||
(defmacro stackptrpart (e) `(cadr ,e))
|
||||
(defmacro stackptr (p) `(stackptrpart (car ,p)))
|
||||
(defmacro exppart (e) `(caddr ,e))
|
||||
(defmacro exp (p) `(exppart (car ,p)))
|
||||
(defmacro envpart (e) `(cadddr ,e))
|
||||
(defmacro env (p) `(envpart (car ,p)))
|
||||
(defmacro frame (p) `(car ,p))
|
||||
(defmacro up (p) `(cadr ,p))
|
||||
(defmacro down (p) `(caddr ,p))
|
||||
(defmacro userfn (p) `(cdddr ,p)))
|
||||
|
||||
(or (boundp 'evalhook*) (setq evalhook* nil))
|
||||
(or (boundp 'debug*prin1) (setq debug*prin1 nil))
|
||||
|
||||
;this function is intended to be put on an interupt character such as ^D
|
||||
; (i.e. (sstatus ttyint 4. '*start*debug*)) in order to make starting up
|
||||
;debug* easier.
|
||||
|
||||
(defun *start*debug* (ignore ignore-ch)
|
||||
(nointerrupt nil)
|
||||
(tyi tyi)
|
||||
(debug* '+internal-ttyscan-subr))
|
||||
|
||||
;this is used by debug* to do freturns in order to have an identifiable mark
|
||||
;on the stack to know what parts of the stack to skip when displaying it.
|
||||
|
||||
(defun *debug*freturn* (ptr evaltype exp old-evalhook*)
|
||||
(setq evalhook* old-evalhook*)
|
||||
(cond ((eq evaltype 'eval) (freturn ptr (eval exp)))
|
||||
(T (freturn ptr (apply (car exp) (cadr exp))))))
|
||||
|
||||
;this is the mini top level. it doesn't use its argument ptr but
|
||||
;debug* does use it when it is deciding how to skip over pieces of the
|
||||
;stack.
|
||||
|
||||
(defun *debug*top-level (ignore)
|
||||
(let (exit evalhook ^w ^q (* *) (+ +) (- -))
|
||||
(terpri)
|
||||
(princ '|*debug*top-level|)
|
||||
(prog ()
|
||||
L (*catch '*debug*
|
||||
(prog (exp)
|
||||
(setq * '*)
|
||||
L (terpri)
|
||||
(cond (prin1 (funcall prin1 *)) (T (prin1 *)))
|
||||
(terpri)
|
||||
(setq exp (read))
|
||||
(cond ((eq exp /p) (clear-input tyi)
|
||||
(setq exit T) (return nil)))
|
||||
(setq + - - exp * (eval exp))
|
||||
(go L)))
|
||||
(cond ((not exit)
|
||||
(terpri)
|
||||
(princ '|quit; reentering *debug*top-level|)
|
||||
(go L))))))
|
||||
|
||||
;the basic logic of debug* is as follows: when entered debug* tries
|
||||
;to fix everything up so that things will work ok i.e. ^w ^q evalhook
|
||||
;evalhook* and nointerrupt are set to nil. further tyi is cleared.
|
||||
;next debug* constructs an elided version of the stack. and decides
|
||||
;what the top point is based on its argument. (this takes a bit of
|
||||
;time, but it saves a lot of time in the long run). if *rset was not T
|
||||
;then debug* just does a break since there is no stack to look at.
|
||||
;otherwise debug* goes into a mode where it reads characters from tyi
|
||||
;and interprets them as commands (see commands comment above). it
|
||||
;continues reading and dispatching until a command which causes an
|
||||
;exit is encountered.
|
||||
|
||||
(defun debug* (topfn)
|
||||
(let ((ef (evalframe nil))
|
||||
(old-evalhook* evalhook*) evalhook ^w ^q)
|
||||
(setq evalhook* nil) (nointerrupt nil) (clear-input tyi)
|
||||
(if (not (zerop (charpos tyo))) (terpri))
|
||||
|
||||
(prog (top bot topend ptr code item n)
|
||||
;make internal copy of stack, with appropriate elisions.
|
||||
(prog (ex oldex uf i n)
|
||||
(setq i 1 n 100)
|
||||
L (setq i (1+ i))
|
||||
(cond ((> i n)
|
||||
(princ '|More than |) (princ n) (princ '| stack frames. |)
|
||||
(cond ((Y-or-N-p "Do you want them all viewable")
|
||||
(terpri)
|
||||
(setq n (* 2 n)))
|
||||
(T (terpri) (return nil)))))
|
||||
(setq ex (exppart ef))
|
||||
(cond ((null ef) (return nil))
|
||||
((and (not (atom ex))
|
||||
(or (memq (car ex) '(evalhook evalhook*))
|
||||
(and (not (atom oldex))
|
||||
(eq (cdr ex) (cdr oldex))
|
||||
(eq (car ex) (car oldex)))))
|
||||
(setq ef (evalframe (cadr ef))))
|
||||
((and (not (atom ex)) (eq (car ex) '*debug*freturn*))
|
||||
(setq ef (evalframe (caadr ex))))
|
||||
(T (setq uf (and (not (atom ex))
|
||||
(eq (typep (car ex)) 'symbol)
|
||||
(not (status system (car ex))))
|
||||
bot (list* ef bot nil uf))
|
||||
(cond ((up bot) (setf (caddr (up bot)) bot))
|
||||
(T (setq topend bot)))
|
||||
(cond ((and (not top) (or (eq ex topfn)
|
||||
(and (not (atom ex))
|
||||
(eq (car ex) topfn))))
|
||||
(setq top bot)))
|
||||
(setq oldex ex)
|
||||
(cond ((and (not (atom ex)) (eq (car ex) '*debug*top-level))
|
||||
(setq ef (evalframe (cadr ex))))
|
||||
(T (setq ef (evalframe (cadr ef)))))))
|
||||
(go L))
|
||||
(setq top (or (down top) top (down topend) topend))
|
||||
;if no stack (i.e. *rset nil) just do a break
|
||||
(cond ((null bot) (princ '|No evalframes try setting *rset to T. |)
|
||||
(break debug*) (return '||)))
|
||||
;get set for the main operation loop
|
||||
(setq ptr top item (exp top))
|
||||
|
||||
;print out the current thing
|
||||
print
|
||||
(let ((prinlevel 4) (prinlength 3))
|
||||
(errset (cond (prin1 (funcall prin1 item)) (T (prin1 item)))))
|
||||
(tyo #\space)
|
||||
;read in a command with optional number prefix.
|
||||
read
|
||||
(prog (i temp)
|
||||
L (setq i (boole 1 127. (tyi tyi)))
|
||||
(cond ((and (< 47. i) (< i 58.)) (push i temp) (go L)))
|
||||
(setq code i)
|
||||
(setq n (cond (temp (readlist (nreverse temp))) (T 1))))
|
||||
;dispatch on the command character to see what to do (see comments above)
|
||||
process
|
||||
(caseq code
|
||||
((#/] #/D #/d)
|
||||
(cond ((eq ptr bot) (princ '| at bottom |) (go read))
|
||||
(T (prog ()
|
||||
L (setq n (1- n) ptr (down ptr))
|
||||
(cond ((null ptr) (setq ptr bot))
|
||||
((plusp n) (go L))))))
|
||||
(setq item (exp ptr)))
|
||||
(#\cr (setq item (exp ptr)) (go print))
|
||||
((#/[#/U #/u)
|
||||
(cond ((eq ptr topend) (princ '| at top |) (go read))
|
||||
(T (prog ()
|
||||
L (setq n (1- n) ptr (up ptr))
|
||||
(cond ((null ptr) (setq ptr topend))
|
||||
((plusp n) (go L))))))
|
||||
(setq item (exp ptr)))
|
||||
(#/} (cond ((eq ptr bot) (princ '| at bottom |) (go read))
|
||||
(T (prog ()
|
||||
L (setq ptr (down ptr))
|
||||
(cond ((userfn ptr) (setq n (1- n))))
|
||||
(cond ((null ptr) (setq ptr bot))
|
||||
((plusp n) (go L))))))
|
||||
(setq item (exp ptr)))
|
||||
(#/{ (cond ((eq ptr topend) (princ '| at top |) (go read))
|
||||
(T (prog ()
|
||||
L (setq ptr (up ptr))
|
||||
(cond ((userfn ptr) (setq n (1- n))))
|
||||
(cond ((null ptr) (setq ptr topend))
|
||||
((plusp n) (go L))))))
|
||||
(setq item (exp ptr)))
|
||||
((#/T #/t) (setq item (exp (setq ptr top))))
|
||||
((#/- #/= #/@ #/+)
|
||||
(let ((prinlevel 1) (prinlength 1) (terpri nil) showlocal
|
||||
(firstufbefore (and (member code '(#/@ #/+))
|
||||
(prog (p)
|
||||
(setq p ptr)
|
||||
L (setq p (up p))
|
||||
(cond ((null p) (return topend))
|
||||
((userfn p) (return p)))
|
||||
(go L)))))
|
||||
(terpri)
|
||||
(prog (p)
|
||||
(setq p topend)
|
||||
L (setq showlocal (or (and showlocal (not (userfn p)))
|
||||
(eq p firstufbefore)))
|
||||
(cond ((eq p ptr) (princ '/[)))
|
||||
(cond ((or showlocal (userfn p) (= code #/-))
|
||||
(errset (prin1 (cond ((atom (exp p)) (exp p))
|
||||
(T (car (exp p))))))
|
||||
(cond ((eq p ptr) (princ '/]))) (tyo #\space))
|
||||
((eq p ptr) (princ '|] |)))
|
||||
(cond ((not (eq p bot)) (setq p (down p)) (go L)))))
|
||||
(go read))
|
||||
|
||||
((#/R #/r #/C #/c)
|
||||
(let ((fr (evalframe (stackptr ptr))) exp evalt)
|
||||
(cond ((eq (car (exppart fr)) 'evalhook)
|
||||
(setq fr (evalframe (stackptrpart fr)))))
|
||||
(cond ((not (eq (car (exppart fr)) 'evalhook*))
|
||||
(setq fr (frame ptr))))
|
||||
(setq exp (exppart fr) evalt (evaltypepart fr))
|
||||
(cond ((member code '(#/R #/r))
|
||||
(princ '| return form: |)
|
||||
(setq exp (read tyi) evalt 'eval)
|
||||
(clear-input tyi)
|
||||
(cond ((not (eq fr (frame ptr)))
|
||||
(setq exp (list 'evalhook* (ncons exp))
|
||||
evalt 'apply)))))
|
||||
(cond ((not (Y-or-N-p "confirm:"))
|
||||
(terpri)
|
||||
(setq code #\cr)
|
||||
(go process)))
|
||||
(apply '*debug*freturn*
|
||||
(list (stackptrpart fr) evalt exp old-evalhook*)
|
||||
(envpart fr))))
|
||||
((#/S #/s) (setq old-evalhook* (read tyi)) (clear-input tyi))
|
||||
((#/E #/e)
|
||||
(setq item (car (errset (eval `((lambda (*debug*)
|
||||
,(prog1 (read tyi)
|
||||
(clear-input tyi)))
|
||||
',(frame ptr))
|
||||
(env ptr))
|
||||
t))))
|
||||
((#/B #/b)
|
||||
(eval `((lambda (*debug*) (break debug* t))
|
||||
',(frame ptr)) (env ptr))
|
||||
(setq item (exp ptr))
|
||||
(go print))
|
||||
((#/V #/v)
|
||||
(eval `((lambda (*debug*) (*debug*top-level ,(stackptr ptr)))
|
||||
',(frame ptr)) (env ptr))
|
||||
(setq item (exp ptr)))
|
||||
((#/Q #/q)
|
||||
(princ '| end debug |)
|
||||
(setq evalhook* old-evalhook*)
|
||||
(return '||))
|
||||
((#/P #/p)
|
||||
(let (prinlevel prinlength)
|
||||
(terpri)
|
||||
(errset (funcall (or debug*prin1 prin1 'prin1) item))
|
||||
(tyo #\space))
|
||||
(go read))
|
||||
(#/? (mapc #'(lambda (x) (terpri) (princ x)) *debug*?) (go read))
|
||||
((#/L #/l #\ff #\space) (go read)) ;works in 12bit read in mode too
|
||||
(T (Y-or-N-p " invalid character, continue")
|
||||
(terpri)
|
||||
(setq code #\cr)
|
||||
(go process)))
|
||||
(terpri)
|
||||
(go print))))
|
||||
|
||||
;this just holds the message printed out by ?. If you don't want to
|
||||
;loose the space setq *debug*? to nil
|
||||
|
||||
(setq *debug*?
|
||||
'(|] move down one stack frame|
|
||||
|[ move up one stack frame|
|
||||
|} move down to next user function stack frame|
|
||||
|{ move up to next user function stack frame|
|
||||
|cr show current stack frame|
|
||||
|T go to top stack frame|
|
||||
|- show stack|
|
||||
|= show user functions on stack|
|
||||
|@ (or +) show user functions on stack, and all functions near current position|
|
||||
|E read and evaluate an expression in the current environment|
|
||||
|P print last thing in full|
|
||||
|S set evalhook*|
|
||||
|B start up a break point in the current environment|
|
||||
|V start up a mini top level in the current environment|
|
||||
|Q quit debug*|
|
||||
|R read in evaluate and freturn an expression in the current environment|
|
||||
|C continue execution starting from the current stack frame expression |))
|
||||
|
||||
;______________________________________________________________________________
|
||||
|
||||
;this is a redefinition of debug which calls debug* this gives you the
|
||||
;new features without having to rewrite anything.
|
||||
|
||||
(defun debug nargs
|
||||
(cond ((= nargs 0) (debug* nil))
|
||||
(T (*rset (nouuo (arg 1))))))
|
||||
67
src/libdoc/defsta.gjc1
Executable file
67
src/libdoc/defsta.gjc1
Executable file
@@ -0,0 +1,67 @@
|
||||
;;-*-lisp-*-
|
||||
;; It is often desirable in maclisp to get the efficiency possible
|
||||
;; by using non-reentrant static storage, while at the same time
|
||||
;; allowing for buffer reallocations if calls are made recusively
|
||||
;; or in breakpoints. Example usages are the tokenization level
|
||||
;; of a parser, adaptive numerical integrators, graph calculators.
|
||||
|
||||
;; Here is one way to formalize,in terms of the STATE-VARIABLES
|
||||
;; of a process, a need which can can otherwize lead
|
||||
;; to some rather messy programs simply for the sake of efficiency.
|
||||
|
||||
;; Note: These macros are also usefull in any application with state
|
||||
;; variables and clean-up, for example, Assemblers and Compilers,
|
||||
;; in fact, any file processor.
|
||||
|
||||
;; Usage: (DEFSTATE <NAME> <VARIABLE-SPEC> <VARIABLE-SPEC> ...)
|
||||
;; <VARIABLE-SPEC> : (<VARIABLE> <TOP-LEVEL-VAL>
|
||||
;; <RECURSIVE-VAL>
|
||||
;; <CLEAN-UP-CODE>)
|
||||
;; Produces: (APPLY-IN-<NAME>-STATE ...) a function.
|
||||
;; (<NAME>-STATE-VARS) a function.
|
||||
;; (<NAME>-STATE-VALS) a function.
|
||||
;; (<NAME>-STATE-RECL) a function.
|
||||
|
||||
;; From my private macros 1:07pm Wednesday, 25 February 1981 -GJC
|
||||
|
||||
(DECLARE (*LEXPR SYMBOLCONC))
|
||||
|
||||
;; This should be built-in
|
||||
(eval-when (eval compile)
|
||||
(DEFMACRO (VARS . BODY) `#'(LAMBDA ,VARS . ,BODY)))
|
||||
|
||||
(HERALD DEFSTATE)
|
||||
|
||||
(DEFMACRO DEFSTATE (NAME . VARIABLE-SPECS)
|
||||
(DO ((APPLY-FUN (SYMBOLCONC "APPLY-IN-" NAME "-STATE"))
|
||||
(VAR-FUN (SYMBOLCONC NAME "-STATE-VARS"))
|
||||
(VAL-FUN (SYMBOLCONC NAME "-STATE-VALS"))
|
||||
(REC-FUN (SYMBOLCONC NAME "-STATE-RECL"))
|
||||
(SPECS VARIABLE-SPECS (CDR SPECS))
|
||||
(VARS NIL)
|
||||
(VALS-TOP NIL)
|
||||
(VALS-REC NIL)
|
||||
(RECL NIL))
|
||||
((NULL SPECS)
|
||||
(SETQ VARS (NREVERSE VARS)
|
||||
VALS-TOP (NREVERSE VALS-TOP)
|
||||
VALS-REC (NREVERSE VALS-REC)
|
||||
RECL (NREVERSE RECL))
|
||||
`(PROGN
|
||||
'COMPILE
|
||||
,@(MAPCAR ( (A B) `(DEFVAR ,A ,B)) VARS VALS-TOP)
|
||||
(DEFUN ,VAR-FUN () ',VARS)
|
||||
(DEFUN ,VAL-FUN () (LIST ,@VALS-REC))
|
||||
(DEFUN ,REC-FUN () ,@RECL)
|
||||
(DEFUN ,APPLY-FUN (F L)
|
||||
(PROGV (,VAR-FUN)
|
||||
(,VAL-FUN)
|
||||
(UNWIND-PROTECT (APPLY F L)
|
||||
(,REC-FUN))))))
|
||||
(LET ((SPEC (IF (EQ (TYPEP (CAR SPECS)) 'LIST)
|
||||
(CAR SPECS)
|
||||
(ERROR "Bad variable spec" (CAR SPECS)))))
|
||||
(PUSH (POP SPEC) VARS)
|
||||
(PUSH (POP SPEC) VALS-TOP)
|
||||
(PUSH (POP SPEC) VALS-REC)
|
||||
(PUSH (POP SPEC) RECL))))
|
||||
404
src/libdoc/defvst.164
Executable file
404
src/libdoc/defvst.164
Executable file
@@ -0,0 +1,404 @@
|
||||
;;; DEFVST -*-Mode:Lisp;Package:SI-*-
|
||||
;;; *************************************************************************
|
||||
;;; ***** NIL ****** NIL/MACLISP/LISPM Structure Definer ********************
|
||||
;;; *************************************************************************
|
||||
;;; ******** (c) Copyright 1981 Massachusetts Institute of Technology *******
|
||||
;;; ************ this is a read-only file! (all writes reserved) ************
|
||||
;;; *************************************************************************
|
||||
|
||||
;;; Acronym for "DEFine a Vector-like STructure"
|
||||
;;; For documentation and examples, see the file LIBDOC;DEFVST DOC on the
|
||||
;;; various ITS systems, and LISP:DEFVST.DOC on TOPS10/20 systems.
|
||||
|
||||
;;; For MacLISP, to compile NADEFVST (version to use in NIL-aided MacLISP),
|
||||
;;; just load the SHARPC module, and set TARGET-FEATURES to 'NILAID
|
||||
|
||||
(herald DEFVST /164)
|
||||
|
||||
|
||||
(eval-when (eval compile)
|
||||
(or (get 'SUBLOAD 'VERSION)
|
||||
(load '((lisp) subload)))
|
||||
#-NIL
|
||||
(subload SHARPCONDITIONALS)
|
||||
)
|
||||
|
||||
;;Remember: a NILAID also will be a MacLISP
|
||||
|
||||
#+(or LISPM (and NIL (not MacLISP)))
|
||||
(progn (globalize "DEFVST")
|
||||
(globalize "CONSTRUCTOR-NAMESTRING-PREFIX")
|
||||
(globalize "SELECTOR-NAMESTRING-STYLE")
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
;; Load DEFVSX and DEFMAX now to get their "globalizations"
|
||||
;; Load EXTEND before DEFVSX so that CLASS system will be available
|
||||
#-NIL
|
||||
(eval-when (eval compile load)
|
||||
(subload EXTEND)
|
||||
(subload VECTOR)
|
||||
(subload DEFVSX) ;Will subload DEFMAX and DEFVSY
|
||||
)
|
||||
|
||||
#-(local NIL)
|
||||
(eval-when (eval compile)
|
||||
(subload EXTEND) ;Bring these guys in before DEFVSX,
|
||||
(subload EXTMAC) ; so that the CLASS system will be
|
||||
(subload VECTOR) ; alive by then.
|
||||
(subload DEFVSX) ;Loading DEFVSX will also do
|
||||
; (subload DEFMAX)
|
||||
; (subload DEFVSY)
|
||||
(subload DEFSETF)
|
||||
(subload UMLMAC)
|
||||
)
|
||||
|
||||
|
||||
(declare (special DEFMACRO-DISPLACE-CALL
|
||||
CONSTRUCTOR-NAMESTRING-PREFIX
|
||||
SELECTOR-NAMESTRING-STYLE
|
||||
STRUCT-CLASS
|
||||
STRUCT=INFO-CLASS
|
||||
|defvst-typchk/||
|
||||
|defvst-construction/||)
|
||||
#+MacLISP (*lexpr TO-VECTOR))
|
||||
|
||||
#+MacLISP
|
||||
(eval-when (eval compile load)
|
||||
(cond ((status feature COMPLR)
|
||||
(*expr |defvst-construction/|| |defvst-construction-1/||
|
||||
|defvst-typchk/||)
|
||||
(*lexpr |defvst-initialize/||)))
|
||||
)
|
||||
|
||||
(MAPC '(LAMBDA (X Y) (AND (NOT (BOUNDP X)) (SET X Y)))
|
||||
'(SELECTOR-NAMESTRING-STYLE CONSTRUCTOR-NAMESTRING-PREFIX )
|
||||
'(|-| |CONS-A-| ))
|
||||
|
||||
|
||||
#+(and MacLISP NIL)
|
||||
(include #+(local ITS) ((NILCOM) DEFVSY >)
|
||||
#-(local ITS) ((LISP) DEFVSY LSP))
|
||||
#+(and MacLISP NIL)
|
||||
(include #+(local ITS) ((NILCOM) DEFVSX >)
|
||||
#-(local ITS) ((LISP) DEFVSX LSP))
|
||||
|
||||
|
||||
#+(local MacLISP)
|
||||
(eval-when (compile)
|
||||
(defprop DEFVST T SKIP-WARNING)
|
||||
;; FOO! to prevent circularities when compiling
|
||||
(do ((i 0 (1+ i))
|
||||
(l '(VERS NAME CNSN SIZE INIS CLSS) (cdr l))
|
||||
(z))
|
||||
((null l))
|
||||
(setq z (symbolconc 'STRUCT=INFO- (car l)))
|
||||
(eval `(DEFMACRO ,z (X) `(SI:XREF ,X ,,i))))
|
||||
)
|
||||
|
||||
|
||||
;;;; DEFVST macro
|
||||
|
||||
(defmacro (DEFVST defmacro-displace-call () ) (sname &rest selkeys &whole form)
|
||||
(LET ((NKEYS 0)
|
||||
(SELECTOR-NAMESTRING-STYLE SELECTOR-NAMESTRING-STYLE)
|
||||
(CONSTRUCTOR-NAMESTRING-PREFIX CONSTRUCTOR-NAMESTRING-PREFIX)
|
||||
(OUTPUT-SELECTOR-MACROS 'T)
|
||||
CONSTRUCTOR-NAME RESTKEY RESTSIZEFORM RESTP SELINIS MAC-ARG-NM
|
||||
SNAME-CLASS-VAR TMP OPTION-LIST )
|
||||
(DECLARE (FIXNUM I NKEYS))
|
||||
(COND ((NOT (ATOM SNAME))
|
||||
(SETQ OPTION-LIST (CDR SNAME))
|
||||
(SETQ SNAME (CAR SNAME))
|
||||
(IF (ASSQ 'NO-SELECTOR-MACROS OPTION-LIST)
|
||||
(SETQ OUTPUT-SELECTOR-MACROS () ))))
|
||||
(AND (OR (NULL SNAME) (NOT (SYMBOLP SNAME)))
|
||||
(ERROR "Bad name arg - DEFVST" FORM))
|
||||
(SETQ SNAME-CLASS-VAR (SYMBOLCONC SNAME '-CLASS))
|
||||
(SETQ NKEYS (LENGTH SELKEYS))
|
||||
(COND ((SETQ TMP (MEMQ '&REST SELKEYS))
|
||||
(SETQ NKEYS (- NKEYS (LENGTH TMP))
|
||||
RESTKEY (CADR TMP)
|
||||
RESTSIZEFORM (CADDR TMP))
|
||||
(AND (OR (NOT (SYMBOLP RESTKEY)) (NULL RESTSIZEFORM))
|
||||
(ERROR "Bad &REST item - DEFVST" SELKEYS))))
|
||||
(COND ((GET SNAME 'STRUCT=INFO)
|
||||
(TERPRI MSGFILES)
|
||||
(PRINC "Warning! Redefining the STRUCTURE " MSGFILES)
|
||||
(PRIN1 SNAME MSGFILES)))
|
||||
(SETQ MAC-ARG-NM (SYMBOLCONC SNAME '|-MACRO-ARG|))
|
||||
(SETQ CONSTRUCTOR-NAME
|
||||
(COND ((SETQ TMP (ASSQ 'CONSTRUCTOR OPTION-LIST))
|
||||
(CADR TMP))
|
||||
('T (SYMBOLCONC CONSTRUCTOR-NAMESTRING-PREFIX SNAME))))
|
||||
;RESTP and SELINIS start out null here
|
||||
(DO ( (I 1 (1+ I))
|
||||
(L SELKEYS (CDR L))
|
||||
INIFORM TYP /=-/:-COUNT KEYNM SELNM )
|
||||
( (OR (NULL L) RESTP) )
|
||||
(COND ((ATOM (SETQ KEYNM (CAR L)))
|
||||
(COND ((EQ KEYNM '&REST)
|
||||
(SETQ KEYNM RESTKEY RESTP 'T)
|
||||
(AND (NOT (EQ RESTKEY (CADR L)))
|
||||
(+INTERNAL-LOSSAGE '&REST 'DEFVST SELKEYS)))
|
||||
((NOT (SYMBOLP KEYNM))
|
||||
(ERROR "Key name not a symbol - DEFVST" KEYNM)))
|
||||
(SETQ INIFORM () ))
|
||||
('T (AND (OR (NULL (SETQ KEYNM (CAR KEYNM)))
|
||||
(NOT (SYMBOLP KEYNM)))
|
||||
(ERROR "Bad key-list - DEFVST" SELKEYS))
|
||||
(COND ((ATOM (SETQ TMP (CDAR L))) (SETQ INIFORM () ))
|
||||
('T (SETQ /=-/:-COUNT 0 )
|
||||
(AND (NULL (CDR TMP)) ;Allow LISPM-
|
||||
(SETQ TMP `(= ,(car tmp)))) ; style inits
|
||||
(COND ((SETQ TYP (MEMQ '|:| TMP))
|
||||
(SETQ /=-/:-COUNT 1)
|
||||
(SETQ TYP (COND ((ATOM (CADR TYP))
|
||||
(LIST (CADR TYP)))
|
||||
((CADR TYP))))))
|
||||
(SETQ INIFORM
|
||||
(COND ((SETQ INIFORM (MEMQ '= TMP))
|
||||
(SETQ /=-/:-COUNT (1+ /=-/:-COUNT))
|
||||
(CADR INIFORM))
|
||||
(TYP (CDR (OR (ASSQ
|
||||
(CAR TYP)
|
||||
'((FIXNUM . 0)
|
||||
(FLONUM . 0.0)
|
||||
(BIGNUM . 500000000000000000000.)
|
||||
(LIST . () )
|
||||
(SYMBOL . 'FOO)
|
||||
(ARRAY . () )
|
||||
(HUNK . () )
|
||||
))
|
||||
#+NIL (ASSQ (CAR TYP)
|
||||
'((SMALL-FLONUM 0.0)
|
||||
(PAIR . '(() ))
|
||||
(VECTOR . #.(if (fboundp 'make-vector)
|
||||
(make-vector 0)
|
||||
() ))
|
||||
(STRING . "" )))
|
||||
)))))
|
||||
(AND (NOT (= /=-/:-COUNT 0))
|
||||
(SETQ INIFORM (CONS INIFORM TYP)))
|
||||
(COND ((NOT (= (* 2 /=-/:-COUNT) (LENGTH TMP)))
|
||||
(PRINT (CAR L) MSGFILES)
|
||||
(PRINC "Option list has options not yet coded ")))
|
||||
))
|
||||
))
|
||||
(COND
|
||||
((NOT OUTPUT-SELECTOR-MACROS) (PUSH `(,keynm) SELINIS))
|
||||
('T (SETQ SELNM (IF (NULL SELECTOR-NAMESTRING-STYLE)
|
||||
KEYNM
|
||||
(SYMBOLCONC SNAME
|
||||
SELECTOR-NAMESTRING-STYLE
|
||||
KEYNM)))
|
||||
(COND ((NOT RESTP)
|
||||
;; INIFORM = (<initialization-form> <restrictions>...)
|
||||
(PUSH `(,keynm ,selnm ,.iniform) SELINIS))
|
||||
('T (SETQ RESTP `(,keynm ,selnm ,restsizeform))
|
||||
(OR (= I (1+ NKEYS))
|
||||
(+INTERNAL-LOSSAGE '&REST 'DEFVST i)))))))
|
||||
`(EVAL-WHEN (EVAL COMPILE LOAD)
|
||||
#-NIL #%(DEF-OR-AUTOLOADABLE |defvst-initialize/|| DEFVSY)
|
||||
(AND #-NIL (STATUS FEATURE COMPLR)
|
||||
(SPECIAL ,sname-class-var))
|
||||
;; The next line is a crock to replace the line commented out
|
||||
;; below --RWK
|
||||
(DEFPROP ,sname ,sname-class-var CLASS-VAR)
|
||||
(|defvst-initialize/||
|
||||
',sname
|
||||
',constructor-name
|
||||
,nkeys
|
||||
',(to-vector (cons restp (nreverse selinis)))
|
||||
,SI:STRUCT=INFO-VERSION ;a version number
|
||||
,(and (filep infile) `',(truename infile))
|
||||
;; The next line is commented out until dumped out versions of
|
||||
;; |defvst-initialize/|| without an &REST IGNORE or this argument
|
||||
;; are re-dumped.
|
||||
;; -- RWK, Sunday the twenty-first of June, 1981; 3:12:18 am
|
||||
;; ,sname-class-var
|
||||
)
|
||||
,.(if restp
|
||||
`((DEFPROP ,(cadr restp)
|
||||
(,sname ,(1+ nkeys) &REST)
|
||||
SELECTOR)))
|
||||
',sname)))
|
||||
|
||||
|
||||
;;;; Structure Printer
|
||||
;; Someday, hack printing of &REST stuff
|
||||
|
||||
(DEFVAR SI:PRINLEVEL-EXCESS '|#|)
|
||||
(DEFVAR SI:PRINLENGTH-EXCESS '|...|)
|
||||
|
||||
(defmethod* (:PRINT-SELF STRUCT-CLASS) (ob stream depth slashifyp)
|
||||
(declare (fixnum depth))
|
||||
(setq depth (1+ depth))
|
||||
(if (and prinlevel (not (< depth prinlevel)))
|
||||
(princ SI:PRINLEVEL-EXCESS stream)
|
||||
(let* ((name (si:class-name (class-of ob)))
|
||||
(info (get name 'STRUCT=INFO)))
|
||||
(if (null info)
|
||||
(si:print-extend-maknum ob stream)
|
||||
(progn
|
||||
(si:verify-defvst-version name (STRUCT=INFO-vers info))
|
||||
(princ '|#{| stream)
|
||||
(do ((z (si:listify-struct-for-print ob name info) (cdr z))
|
||||
(n 0 (1+ n))
|
||||
(first 'T ()))
|
||||
((null z))
|
||||
(declare (fixnum n))
|
||||
(or first (tyo #\SPACE stream))
|
||||
(print-object (car z) depth slashifyp stream)
|
||||
(cond ((and prinlength (not (< n PRINLENGTH)))
|
||||
(tyo #\SPACE stream)
|
||||
(princ SI:PRINLENGTH-EXCESS stream)
|
||||
(return () ))))
|
||||
(tyo #/} stream))))))
|
||||
|
||||
(defmethod* (SPRINT STRUCT-CLASS) (ob n m)
|
||||
(declare (special L N M))
|
||||
(let* ((name (si:class-name (class-of ob)))
|
||||
(info (get name 'STRUCT=INFO)))
|
||||
(if (null info)
|
||||
(si:print-extend-maknum ob outfiles)
|
||||
(let ((z (si:listify-struct-for-print ob name info)))
|
||||
(si:verify-defvst-version name (STRUCT=INFO-vers info))
|
||||
(if (> (- (grchrct) 3.) (gflatsize z))
|
||||
(prin1 ob)
|
||||
(progn
|
||||
(princ '|#{|)
|
||||
(prin1 (car z))
|
||||
(cond ((cdr z)
|
||||
(tyo #\SPACE)
|
||||
(setq N (grchrct) M (1+ M))
|
||||
(do ((l (cdr z)))
|
||||
((null l))
|
||||
(grindform 'LINE)
|
||||
(grindform 'CODE)
|
||||
(cond (l (indent-to N))))))
|
||||
(tyo #/})))))))
|
||||
|
||||
#+(or (not NIL) MacLISP)
|
||||
(eval-when (eval compile)
|
||||
(defmacro (VECTOR-LENGTH defmacro-for-compiling () defmacro-displace-call () )
|
||||
(&rest w)
|
||||
`(SI:EXTEND-LENGTH ,.w))
|
||||
(defmacro (VREF defmacro-for-compiling () defmacro-displace-call () )
|
||||
(&rest w)
|
||||
`(SI:XREF ,.w))
|
||||
)
|
||||
|
||||
;; Sure, this could do less consing, if it really wanted to. But who
|
||||
;; wants to trouble to write such hairy code?
|
||||
(DEFUN SI:LISTIFY-STRUCT-FOR-PRINT (OB NAME INFO)
|
||||
(LET* ((SUPPRESS (GET NAME 'SUPPRESSED-COMPONENT-NAMES))
|
||||
(INIS (STRUCT=INFO-INIS INFO)))
|
||||
(DO ((I 1 (1+ I))
|
||||
(N (VECTOR-LENGTH INIS))
|
||||
(THE-LIST (LIST NAME)))
|
||||
((NOT (< I N)) (NREVERSE THE-LIST))
|
||||
;The (1+ i)th component of INIS corresponds to the ith
|
||||
;component of OB. The 0th component of INIS corresponds
|
||||
;to the &REST stuff which this code doesn't address.
|
||||
(LET* (((NAME SELECTOR INIT) (VREF INIS I))
|
||||
(VAL (SI:XREF OB
|
||||
(OR (AND SELECTOR
|
||||
(CADR (GET SELECTOR 'SELECTOR)))
|
||||
(1- I)))))
|
||||
(COND ((MEMQ NAME SUPPRESS))
|
||||
;;Incredible kludge to avoid printing defaulted vals
|
||||
((OR (AND (NULL INIT) (NULL VAL))
|
||||
(AND (|constant-p/|| INIT)
|
||||
(EQUAL VAL (EVAL INIT)))
|
||||
(AND (PAIRP INIT)
|
||||
(EQ (CAR INIT) 'QUOTE)
|
||||
(EQUAL VAL (CADR INIT)))))
|
||||
(T (PUSH NAME THE-LIST)
|
||||
(PUSH VAL THE-LIST)))))))
|
||||
|
||||
|
||||
|
||||
|
||||
(defmethod* (EQUAL struct-class) (ob other)
|
||||
(or (eq ob other) ;generally, this will have already been done
|
||||
(let ((ty1 (struct-typep ob))
|
||||
(ty2 (struct-typep other)))
|
||||
(cond ((or (null ty1) (null ty2) (not (eq ty1 ty2))) () )
|
||||
((si:component-equal ob other))))))
|
||||
|
||||
|
||||
(defmethod* (SUBST struct-class) (ob a b)
|
||||
(si:subst-into-extend ob a b))
|
||||
|
||||
(defmethod* (SXHASH struct-class) (ob)
|
||||
(si:hash-Q-extend ob #.(sxhash 'STRUCT)))
|
||||
|
||||
(defmethod* (DESCRIBE struct-class) (ob stream level)
|
||||
(declare (special SI:DESCRIBE-MAX-LEVEL))
|
||||
(if (not (> level SI:DESCRIBE-MAX-LEVEL))
|
||||
(let* ((name (struct-typep ob))
|
||||
(info (get name 'STRUCT=INFO)))
|
||||
(if (null info)
|
||||
()
|
||||
(let* ((inis (STRUCT=INFO-inis info))
|
||||
(ninis (vector-length inis))
|
||||
(suppress (get name 'SUPPRESSED-COMPONENT-NAMES)))
|
||||
(si:verify-defvst-version name (STRUCT=INFO-vers info))
|
||||
(format stream
|
||||
"~%~vTThe named structure has STRUCT-TYPEP ~S"
|
||||
level name)
|
||||
(if suppress
|
||||
(format stream
|
||||
"~%~vtThese component names are suppressed: ~S"
|
||||
level suppress))
|
||||
(format stream
|
||||
"~%~vtThe ~D. component names and contents are:"
|
||||
level (1- ninis))
|
||||
(do ((i 1 (1+ i)) (default () ()))
|
||||
((not (< i ninis)))
|
||||
(let* (((name selector init) (vref inis i))
|
||||
(sel (get (cadr (vref inis i)) 'SELECTOR))
|
||||
(val (vref ob (if sel (cadr sel) (1- i)))))
|
||||
(if (or (and (null init) (null val))
|
||||
(and (|constant-p/|| init)
|
||||
(equal val (eval init)))
|
||||
(and (pairp init)
|
||||
(eq (car init) 'QUOTE)
|
||||
(equal val (cadr init))))
|
||||
(setq default 'T))
|
||||
(format stream
|
||||
"~%~vt ~S: ~S ~:[~; [default]~]"
|
||||
level (car (vref inis i)) val default)))
|
||||
(if (vref inis 0)
|
||||
(format stream
|
||||
"~%~vt&REST part hasn't been Described."
|
||||
level)))))))
|
||||
|
||||
|
||||
#+(and MacLISP (not NIL))
|
||||
(or (fboundp 'STRUCT-LET)
|
||||
(equal (get 'STRUCT-LET 'AUTOLOAD) #%(autoload-filename UMLMAC))
|
||||
(prog2 (defun STRUCT-LET macro (x)
|
||||
((lambda (n FASLOAD)
|
||||
(cond ((null n))
|
||||
((alphalessp n "25")
|
||||
(remprop 'UMLMAC 'VERSION))
|
||||
((+internal-lossage 'UMLMAC 'STRUCT-LET n)))
|
||||
(load #%(autoload-filename UMLMAC))
|
||||
(macroexpand x))
|
||||
(get 'UMLMAC 'VERSION)
|
||||
() ))
|
||||
(defun STRUCT-SETF macro (x)
|
||||
((lambda (n FASLOAD)
|
||||
(cond ((null n))
|
||||
((alphalessp n "25")
|
||||
(remprop 'UMLMAC 'VERSION))
|
||||
((+internal-lossage 'UMLMAC 'STRUCT-SETF n)))
|
||||
(load #%(autoload-filename UMLMAC))
|
||||
(macroexpand x))
|
||||
(get 'UMLMAC 'VERSION)
|
||||
() ))))
|
||||
|
||||
1070
src/libdoc/doctor.jonl1
Executable file
1070
src/libdoc/doctor.jonl1
Executable file
File diff suppressed because it is too large
Load Diff
1070
src/libdoc/doctor.jonl2
Normal file
1070
src/libdoc/doctor.jonl2
Normal file
File diff suppressed because it is too large
Load Diff
34
src/libdoc/dow.jonl3
Executable file
34
src/libdoc/dow.jonl3
Executable file
@@ -0,0 +1,34 @@
|
||||
|
||||
;;; THE FOLLOWING FUNCTION, WHEN GIVEN THE DATE AS THREE NUMBERS,
|
||||
;;; WILL PRODUCE THE 0-ORIGIN NUMBER OF THE DAY-OF-WEEK FOR THAT DATE.
|
||||
;;; E.G., (DAY-NAME (DOW 1963. 11. 22.)) ==> FRIDAY, WHICH HAPPENED
|
||||
;;; TO BE THE DAY PRESIDENT JOHN F. KENNEDY WAS ASSASINATED.
|
||||
|
||||
|
||||
|
||||
(DEFUN DOW (YEAR MONTH DAY)
|
||||
(AND (AND (FIXP YEAR) (FIXP MONTH) (FIXP DAY))
|
||||
((LAMBDA (A)
|
||||
(DECLARE (FIXNUM A))
|
||||
(\ (+ (// (1- (* 13. (+ MONTH 10. (* (// (+ MONTH 10.) -13.) 12.))))
|
||||
5.)
|
||||
DAY
|
||||
77.
|
||||
(// (* 5. (- A (* (// A 100.) 100.))) 4.)
|
||||
(// A -2000.)
|
||||
(// A 400.)
|
||||
(* (// A -100.) 2.))
|
||||
7.))
|
||||
(+ YEAR (// (+ MONTH -14.) 12.)))))
|
||||
|
||||
|
||||
(DEFUN DAY-NAME (N)
|
||||
(DECLARE (FIXNUM N))
|
||||
(COND ((> N 3)
|
||||
(COND ((> N 5) 'SATURDAY)
|
||||
((> N 4) 'FRIDAY)
|
||||
('THURSDAY)))
|
||||
((> N 1) (COND ((> N 2) 'WEDNESDAY) ('TUESDAY)))
|
||||
((ZEROP N) 'SUNDAY)
|
||||
('MONDAY)))
|
||||
|
||||
36
src/libdoc/dow.jonl4
Normal file
36
src/libdoc/dow.jonl4
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
;;; THE FOLLOWING FUNCTION, WHEN GIVEN THE DATE AS THREE NUMBERS,
|
||||
;;; WILL PRODUCE THE 0-ORIGIN NUMBER OF THE DAY-OF-WEEK FOR THAT DATE.
|
||||
;;; E.G., (DAY-NAME (DOW 1963. 11. 22.)) ==> FRIDAY, WHICH HAPPENED
|
||||
;;; TO BE THE DAY PRESIDENT JOHN F. KENNEDY WAS ASSASINATED.
|
||||
|
||||
|
||||
|
||||
(DEFUN DOW (YEAR MONTH DAY)
|
||||
(AND (AND (FIXP YEAR) (FIXP MONTH) (FIXP DAY))
|
||||
((LAMBDA (A)
|
||||
(DECLARE (FIXNUM A))
|
||||
(\ (+ (// (1- (* 13. (+ MONTH 10. (* (// (+ MONTH 10.) -13.) 12.))))
|
||||
5.)
|
||||
DAY
|
||||
77.
|
||||
(// (* 5. (- A (* (// A 100.) 100.))) 4.)
|
||||
;; ejs: commented out as per Alan Sampson. This is a
|
||||
;; incorrect check
|
||||
;; (// A -2000.)
|
||||
(// A 400.)
|
||||
(* (// A -100.) 2.))
|
||||
7.))
|
||||
(+ YEAR (// (+ MONTH -14.) 12.)))))
|
||||
|
||||
|
||||
(DEFUN DAY-NAME (N)
|
||||
(DECLARE (FIXNUM N))
|
||||
(COND ((> N 3)
|
||||
(COND ((> N 5) 'SATURDAY)
|
||||
((> N 4) 'FRIDAY)
|
||||
('THURSDAY)))
|
||||
((> N 1) (COND ((> N 2) 'WEDNESDAY) ('TUESDAY)))
|
||||
((ZEROP N) 'SUNDAY)
|
||||
('MONDAY)))
|
||||
|
||||
87
src/libdoc/dribbl.rbr1
Executable file
87
src/libdoc/dribbl.rbr1
Executable file
@@ -0,0 +1,87 @@
|
||||
|
||||
(declare (special dribblefile startdribblefn stopdribblefn
|
||||
^r outfiles msgfiles echofiles defaultf)
|
||||
(macros nil)
|
||||
(*lexpr dribble))
|
||||
|
||||
(defun REMOVE-DRIBBLE macro (l)
|
||||
(list '(lambda (dfile)
|
||||
(or (setq outfiles (delq dfile outfiles))
|
||||
(setq ^r nil))
|
||||
(setq msgfiles (delq dfile msgfiles))
|
||||
(setq echofiles (delq dfile echofiles))
|
||||
dfile)
|
||||
(cadr l)))
|
||||
|
||||
(defun ADD-DRIBBLE macro (l)
|
||||
(list '(lambda (dfile)
|
||||
(or (memq dfile outfiles)
|
||||
(setq outfiles (cons dfile outfiles)))
|
||||
(or (memq dfile msgfiles)
|
||||
(setq msgfiles (cons dfile msgfiles)))
|
||||
(or (memq dfile echofiles)
|
||||
(setq echofiles (cons dfile echofiles)))
|
||||
(setq ^r t)
|
||||
dfile)
|
||||
(cadr l)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(cond((not(status features newio))
|
||||
(terpri)
|
||||
(princ '|DRIBBLE in NEWIO only!|)
|
||||
(^g)))
|
||||
|
||||
;; DRIBBLEFILE is the current open (or most recently closed) dribble file object.
|
||||
(setq DRIBBLEFILE nil)
|
||||
|
||||
|
||||
(defun DRIBBLE args
|
||||
;; (DRIBBLE filename) starts dribbling into the file.
|
||||
;; The filename can be a namestring or namelist.
|
||||
;; (DRIBBLE NIL) stops dribbling.
|
||||
;; (DRIBBLE) restarts dribbling into the old file in append mode,
|
||||
;; if a dribblefile already exists, that is.
|
||||
;; Otherwise, starts dribbling into the file DSK:udir;DRIBBL >.
|
||||
;; Dribbling entails creating a file and adding it to MSGFILES, ECHOFILES
|
||||
;; and OUTFILES. ^R is set to T. (NB In a breakpoint, for example, ^R
|
||||
;; is bound to NIL, thus inhibiting the dribble.)
|
||||
;; When a dribblefile is opened and closed, the functional values of
|
||||
;; STARTDRIBBLEFN and STOPDRIBBLEFN respectively will be executed; they will
|
||||
;; receive the dribble file object as argument.
|
||||
(prog (dribbling? return)
|
||||
(setq return
|
||||
(and (setq dribbling? (and dribblefile (status filemode dribblefile)))
|
||||
(truename dribblefile)))
|
||||
(cond
|
||||
((or (zerop args) (eq (arg 1) T))
|
||||
;; Restart DRIBBLE.
|
||||
(cond((not dribbling?)
|
||||
(setq dribblefile
|
||||
(add-dribble (cond(dribblefile
|
||||
(open dribblefile (cond((probef dribblefile)
|
||||
'append)
|
||||
('out))))
|
||||
((open (list (list 'DSK (STATUS UDIR))
|
||||
'DRIBBL '>) 'out)))))))
|
||||
(and (boundp 'startdribblefn) startdribblefn
|
||||
(funcall startdribblefn dribblefile)))
|
||||
((eq (arg 1) NIL)
|
||||
;; UNDRIBBLE.
|
||||
(cond(dribbling?
|
||||
(and (boundp 'stopdribblefn) stopdribblefn
|
||||
(funcall stopdribblefn dribblefile))
|
||||
(close (remove-dribble dribblefile)))))
|
||||
|
||||
(t ;; DRIBBLE.
|
||||
(dribble nil) ;close current dribble file.
|
||||
(setq dribblefile
|
||||
(add-dribble (open (defaultf
|
||||
(mergef (namelist (arg 1))
|
||||
defaultf))
|
||||
'out)))
|
||||
(and (boundp 'startdribblefn) startdribblefn
|
||||
(funcall startdribblefn dribblefile))))
|
||||
(return return)))
|
||||
|
||||
|
||||
230
src/libdoc/dumpgc.gjc2
Executable file
230
src/libdoc/dumpgc.gjc2
Executable file
@@ -0,0 +1,230 @@
|
||||
;;;-*-lisp-*-
|
||||
;;; program to aid in the garbage collection (i.e. file deletion)
|
||||
;;; of systems dumped in lisp.
|
||||
;;; 3:21pm Saturday, 14 February 1981 -GJC
|
||||
|
||||
(HERALD DUMPGC 1)
|
||||
|
||||
(DECLARE (*LEXPR TYIPEEK-GOBBLE-WHITESPACE))
|
||||
(DEFVAR VERBOSE? T "Set to NIL if no while-running comments are wanted.")
|
||||
(DEFVAR INCLUDE-DELETED-FILES? T "NIL to keep deleted files out of listings.")
|
||||
|
||||
;;; Raw data file is created by lusers who MAIL to the
|
||||
;;; file LISP;LOCK MAIL.
|
||||
;;; PURE-SUSPEND in LIBDOC;SHARAB sends such mail, also, you can
|
||||
;;; load this file and run the function
|
||||
;;; (SEND-LOCK-MAIL <SYSTEM-FILENAME> &OPTIONAL <LOCK-MAILFILE>)
|
||||
;;; which will send mail to keep the lispversion around as long
|
||||
;;; as <SYSTEM-FILENAME> is not deleted.
|
||||
|
||||
;;; (GENERATE-LOCK-REPORT &OPTIONAL <INPUT-FILENAME> <OUTPUT-FILENAME>)
|
||||
|
||||
;;; (READ-LOCK-MAIL-FILE &optional filename) returns a list of
|
||||
;;; plists of information.
|
||||
;;; (FORMAT-LOCK-INFO <STREAM> <stuff from READ-LOCK-MAIL-FILE>)
|
||||
;;; Gives an indented listing, with one lisp version per page.
|
||||
;;; Files which no longer exist are marked with a "*"
|
||||
|
||||
(DEFUN READ-LOCK-MAIL-FILE (&OPTIONAL (FILENAME "") &AUX STREAM)
|
||||
(SETQ FILENAME (MERGEF FILENAME "DSK:LISP;LOCK MAIL"))
|
||||
(UNWIND-PROTECT (READ-LOCK-MAIL-STREAM (SETQ STREAM (OPEN FILENAME)))
|
||||
(AND STREAM (CLOSE STREAM))))
|
||||
|
||||
(DEFUN READ-LOCK-MAIL-STREAM (STREAM)
|
||||
(IF VERBOSE? (FORMAT MSGFILES "~%; Reading /"~A/"~%"
|
||||
(NAMESTRING (TRUENAME STREAM))))
|
||||
(DO ((L NIL (CONS ENTRY L))
|
||||
(ENTRY))
|
||||
((NULL (SETQ ENTRY (READ-LOCK-MAIL-ENTRY STREAM)))
|
||||
(IF VERBOSE? (FORMAT MSGFILES "~&; Done.~%"))
|
||||
(NREVERSE L))))
|
||||
|
||||
(DEFUN READ-LOCK-MAIL-ENTRY (STREAM)
|
||||
(IF (= (TYIPEEK-GOBBLE-WHITESPACE STREAM) -1)
|
||||
NIL
|
||||
(LET ((UNAME (READ-LOCK-UNAME STREAM))
|
||||
(DATE (READ-LOCK-DATE STREAM))
|
||||
(DAYTIME (READ-LOCK-DAYTIME STREAM))
|
||||
(SHARING (READ STREAM)))
|
||||
(GOBBLE-END-OF-MAIL-MARK STREAM)
|
||||
;; Sharing list is (<LISP-VERSION> <BASEFILE> . <brain-damage>)
|
||||
;; so we give this a more useful ordering.
|
||||
(SETQ SHARING (LIST* (CAR SHARING)
|
||||
(CADR SHARING)
|
||||
(NREVERSE (CDDR SHARING))))
|
||||
;; Now it is ordered most primitive to least primitive, the
|
||||
;; reverse of which would be just as useful of course.
|
||||
(LIST (CAR (LAST SHARING))
|
||||
'UNAME UNAME
|
||||
'DATE DATE
|
||||
'DAYTIME DAYTIME
|
||||
'SHARING SHARING))))
|
||||
|
||||
|
||||
;;; Format of a mail-header is assumed to be "FOO 02/14/81 15:15:24"
|
||||
|
||||
(DEFUN READ-LOCK-UNAME (STREAM)
|
||||
(READ STREAM))
|
||||
|
||||
(DEFUN READ-LOCK-DATE (STREAM)
|
||||
(LET ((MONTH (READ-INT STREAM))
|
||||
(DAY (READ-INT STREAM))
|
||||
(YEAR (READ-INT STREAM)))
|
||||
;; compatable with (STATUS DATE)
|
||||
(LIST YEAR MONTH DAY)))
|
||||
|
||||
(DEFUN READ-LOCK-DAYTIME (STREAM)
|
||||
(LIST (READ-INT STREAM) (READ-INT STREAM) (READ-INT STREAM)))
|
||||
|
||||
(DEFUN GOBBLE-END-OF-MAIL-MARK (STREAM)
|
||||
(IF (= (TYIPEEK-GOBBLE-WHITESPACE STREAM #'(LAMBDA (C) (NOT (= C #^_))))
|
||||
#^_)
|
||||
(TYI STREAM)))
|
||||
|
||||
(DEFUN WHITESPACEP (X)
|
||||
(MEMBER X '(#\SP #\TAB #\CR #\LF #\FF)))
|
||||
(DEFUN NONDIGITP (X) (OR (< X #/0) (> X #/9)))
|
||||
|
||||
(DEFUN TYIPEEK-GOBBLE-WHITESPACE (STREAM &OPTIONAL (F #'WHITESPACEP))
|
||||
(DO ((C))
|
||||
((NOT (FUNCALL F (SETQ C (TYIPEEK NIL STREAM -1)))) C)
|
||||
(TYI STREAM)))
|
||||
|
||||
(DEFUN READ-INT (STREAM)
|
||||
(DO ((C (TYIPEEK-GOBBLE-WHITESPACE STREAM #'NONDIGITP)
|
||||
(TYIPEEK () STREAM))
|
||||
(X 0 (+ (- C #/0) (* X 10.))))
|
||||
((NONDIGITP C) X)
|
||||
(TYI STREAM)))
|
||||
|
||||
;; A RALIST is a recursive alist.
|
||||
|
||||
(defun rinsert (list ralist)
|
||||
(if (null list)
|
||||
ralist
|
||||
(let ((next-ralist (assoc (car list) ralist)))
|
||||
(cond ((null next-ralist)
|
||||
(cons (cons (car list) (rinsert (cdr list) nil))
|
||||
ralist))
|
||||
('else
|
||||
(rplacd next-ralist (rinsert (cdr list) (cdr next-ralist)))
|
||||
ralist)))))
|
||||
|
||||
(DEFUN SHARING-FILE-RALIST (PLISTS)
|
||||
(DO ((RALIST NIL (RINSERT (GET (POP PLISTS) 'SHARING) RALIST)))
|
||||
((NULL PLISTS)
|
||||
(SORTCAR RALIST #'ALPHALESSP))))
|
||||
|
||||
(DEFVAR LOCK-MAIL-ALIST ())
|
||||
|
||||
(DEFUN FORMAT-SHARED-FILENAME (STREAM FILENAME INDENTATION-LEVEL)
|
||||
(LET* ((INFO (ASSOC FILENAME LOCK-MAIL-ALIST))
|
||||
(PROBEF? (LET ((L (GETL INFO '(PROBEF))))
|
||||
(IF L (CADR L) (PROBEF FILENAME)))))
|
||||
(IF (OR PROBEF? INCLUDE-DELETED-FILES?)
|
||||
(FORMAT STREAM
|
||||
"~&~VX/"~A/"~:[*~; ~] ~40T~A ~S ~S~%"
|
||||
INDENTATION-LEVEL
|
||||
(NAMESTRING FILENAME)
|
||||
PROBEF?
|
||||
(GET INFO 'UNAME)
|
||||
(GET INFO 'DATE)
|
||||
(GET INFO 'DAYTIME)))))
|
||||
|
||||
(DEFUN FORMAT-SHARING-RALIST (STREAM RALIST INDENTATION-LEVEL)
|
||||
(DO ((L RALIST (CDR L)))
|
||||
((NULL L))
|
||||
(FORMAT-SHARED-FILENAME STREAM (CAAR L) INDENTATION-LEVEL)
|
||||
(FORMAT-SHARING-RALIST STREAM (CDAR L) (1+ INDENTATION-LEVEL))))
|
||||
|
||||
(DEFUN GENERATE-LOCK-REPORT (&OPTIONAL (INPUT "") (OUTPUT ""))
|
||||
(SETQ INPUT (MERGEF INPUT "DSK:LISP;LOCK MAIL"))
|
||||
(SETQ OUTPUT (MERGEF OUTPUT (MERGEF "* REPORT" INPUT)))
|
||||
(LET ((LOCK-MAIL-ALIST (REMOVE-EARLIER-LOCK-ENTRIES
|
||||
(READ-LOCK-MAIL-FILE INPUT)))
|
||||
(BASE 10.)
|
||||
(*NOPOINT T)
|
||||
(STREAM))
|
||||
(IF VERBOSE? (FORMAT MSGFILES "~&; Doing PROBEF of ~D files~%"
|
||||
(LENGTH LOCK-MAIL-ALIST)))
|
||||
(MAPC #'(LAMBDA (U) (PUTPROP U (PROBEF (CAR U)) 'PROBEF)) LOCK-MAIL-ALIST)
|
||||
(IF VERBOSE? (FORMAT MSGFILES "~&; Generating report file.~%"))
|
||||
(UNWIND-PROTECT
|
||||
(PROGN (SETQ STREAM (OPEN (MERGEF "* _REPO_" OUTPUT) 'OUT))
|
||||
(FORMAT STREAM
|
||||
"~
|
||||
~&** File Dependencies given by the file /"~A/"~60T**~
|
||||
~:[~;~
|
||||
~%** Files marked with a /"*/" no longer exist. ~60T**~
|
||||
~]~
|
||||
~%** Generated by ~S on ~S ~S~60T**~%~%"
|
||||
(NAMESTRING (PROBEF INPUT))
|
||||
INCLUDE-DELETED-FILES?
|
||||
(STATUS UNAME) (STATUS DATE) (STATUS DAYTIME))
|
||||
(DO ((L (SHARING-FILE-RALIST LOCK-MAIL-ALIST) (CDR L)))
|
||||
((NULL L))
|
||||
(FORMAT STREAM "~&-- MacLisp version ~A --~%"
|
||||
(CAAR L))
|
||||
(FORMAT-SHARING-RALIST STREAM (CDAR L) 0)
|
||||
(TYO #\FF STREAM)
|
||||
(TERPRI STREAM))
|
||||
(RENAMEF STREAM OUTPUT))
|
||||
(AND STREAM (CLOSE STREAM)))
|
||||
(LET ((S (NAMESTRING (TRUENAME STREAM))))
|
||||
(PUTPROP S T '+INTERNAL-STRING-MARKER)
|
||||
S)))
|
||||
|
||||
(DEFUN LOCK-DATE-GREATERP (ENTRY-A ENTRY-B)
|
||||
(OR (DICT-GREATERP (GET ENTRY-A 'DATE)
|
||||
(GET ENTRY-B 'DATE))
|
||||
(DICT-GREATERP (GET ENTRY-A 'DAYTIME)
|
||||
(GET ENTRY-B 'DAYTIME))))
|
||||
|
||||
(DEFUN DICT-GREATERP (L-A L-B)
|
||||
(AND L-A
|
||||
(OR (GREATERP (CAR L-A) (CAR L-B))
|
||||
(DICT-GREATERP (CDR L-A) (CDR L-B)))))
|
||||
|
||||
(DEFUN REMOVE-EARLIER-LOCK-ENTRIES (L)
|
||||
(IF (NULL L) NIL
|
||||
(LET ((A (CAR L)))
|
||||
(LET ((B (ASSOC (CAR A) (CDR L))))
|
||||
(IF (OR (NULL B)
|
||||
(LOCK-DATE-GREATERP A B))
|
||||
(CONS (CAR L) (REMOVE-EARLIER-LOCK-ENTRIES (CDR L)))
|
||||
(REMOVE-EARLIER-LOCK-ENTRIES (CDR L)))))))
|
||||
|
||||
|
||||
(DEFUN SEND-LOCK-MAIL (SYSTEM-FILENAME &OPTIONAL (MF "DSK:LISP;LOCK MAIL"))
|
||||
(LET ((FN (PROBEF SYSTEM-FILENAME)))
|
||||
;; we need to do this to insure that a fully-expanded non-losing
|
||||
;; filename has been given, otherwise really meaningless stuff
|
||||
;; might be generated. In other words, this function is
|
||||
;; meant to be used AFTER you dump a system, not before.
|
||||
(OR FN (ERROR "SYSTEM-FILENAME does not exist yet!"
|
||||
SYSTEM-FILENAME
|
||||
'FAIL-ACT))
|
||||
(SETQ SYSTEM-FILENAME (NAMELIST FN)))
|
||||
(LET ((BASE 10.)
|
||||
(*NOPOINT 'T)
|
||||
F DATE TIME PRINLEVEL PRINLENGTH)
|
||||
(unwind-protect
|
||||
(DO ((I 3 (1- I)))
|
||||
((OR (< I 0)
|
||||
(ERRSET (SETQ F (OPEN MF '(APPEND))) NIL))
|
||||
(COND ((< I 0)
|
||||
(ERRSET (RENAMEF MF (MERGEF "LCKMAI >" MF)) NIL)
|
||||
(SETQ F (OPEN MF '(OUT)))))
|
||||
(SETQ DATE (STATUS DATE))
|
||||
(SETQ TIME (STATUS DAYTIME))
|
||||
(FORMAT F
|
||||
"~%~A ~A//~A//~A ~A:~A:~A~
|
||||
~%(~S ~S)~%"
|
||||
(STATUS USERID)
|
||||
(CADR DATE)(CADDR DATE)(CAR DATE)
|
||||
(CAR TIME) (CADR TIME) (CADDR TIME)
|
||||
(STATUS LISPV) SYSTEM-FILENAME))
|
||||
(TERPRI TYO)
|
||||
(PRINC "LOCK MAIL file not available -- waiting 10 seconds." TYO)
|
||||
(SLEEP 10.))
|
||||
(and f (close f)))))
|
||||
BIN
src/libdoc/fake-s.15
Executable file
BIN
src/libdoc/fake-s.15
Executable file
Binary file not shown.
40
src/libdoc/faslre.info
Executable file
40
src/libdoc/faslre.info
Executable file
@@ -0,0 +1,40 @@
|
||||
FASLREA is a package of functions for reading s-expressions and other
|
||||
information from a FASL file (see also FASDMP). The source is MC:RLB;FASLRE >.
|
||||
|
||||
The three main functions are:
|
||||
|
||||
(FASLREADOPEN <file spec>) which opens the file, initializes, and
|
||||
returns a FASL-OBJ for use by FASLREAD and FASLREADCLOSE.
|
||||
(FASLREAD <FASL-obj>) which reads an item and returns it, with a type code
|
||||
consed onto its front:
|
||||
EVAL - the item was an "EVAL Mungeable". The CDR is the item.
|
||||
ENTRY - the CDR is (<subr name> <subr type> <args prop>)
|
||||
EOF - the end of the FASL file was reached.
|
||||
(FASLREADCLOSE <FASL-obj>) which closes the file and flushes all
|
||||
associated arrays.
|
||||
|
||||
An additional function (QFASLREAD <fas-obj>) reads an object and returns
|
||||
it, with a code consed on its front:
|
||||
ENTRY - the CDR is the subr name
|
||||
EXT - the CDR is the symbol subject to the call
|
||||
EOF - the end of the FASL file was reached.
|
||||
|
||||
DDT symbols are needed for the following LAP symbols:
|
||||
BNCONS
|
||||
In Lisp versions > /1567, DDT symbols won't be needed.
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
IMPLEMENTATION --
|
||||
|
||||
A FASL-OBJ is a Lisp T-type array with 6 entries:
|
||||
(0) is byte-obj, a Lisp FIXNUM array with 9. entries storing the
|
||||
relocation bytes
|
||||
(1) is index indicating current (next) relocation type byte
|
||||
(2) is Newio file object
|
||||
(3) is the atom table, a Lisp T-type array
|
||||
(4) is the maximum subscript for the atom table (1- size)
|
||||
(5) is the greatest used subscript in the atom table.
|
||||
|
||||
For a discussion of FASL format, relocation bytes, and atom table,
|
||||
see .INFO.FASBIN FORMAT .
|
||||
514
src/libdoc/fforma.jonl13
Executable file
514
src/libdoc/fforma.jonl13
Executable file
@@ -0,0 +1,514 @@
|
||||
;;; FFORMA -*-LISP-*-
|
||||
;;; **************************************************************
|
||||
;;; ***** MACLISP ****** Fortran-style FORMAT package ************
|
||||
;;; **************************************************************
|
||||
;;; ** (C) COPYRIGHT 1981 MASSACHUSETTS INSTITUTE OF TECHNOLOGY **
|
||||
;;; ****** THIS IS A READ-ONLY FILE! (ALL WRITES RESERVED) *******
|
||||
;;; **************************************************************
|
||||
;;; *** Three functions for numeric print formating:
|
||||
;;; PRINT-FIXED-FIELD-FLOATING
|
||||
;;; PRINT-FIXED-PRECISION-FLOATING
|
||||
;;; PRINT-FIXED-FIELD-FIXED
|
||||
;;; **************************************************************
|
||||
;;; **************************************************************
|
||||
|
||||
(herald FFORMA /13)
|
||||
|
||||
;;; Two functions for formatted printing of floating-point numbers
|
||||
;;; and a simple one for fixed-point numbers. A null is returned if
|
||||
;;; the number cant be printed in the requested format; and otherwise
|
||||
;;; "T" (or a list of characters) is returned.
|
||||
|
||||
;;; PRINT-FIXED-FIELD-FLOATING - abbreviated "PFFF"
|
||||
;;; A function for printing a floating point number with a specified
|
||||
;;; number of integral places, and of fractional places.
|
||||
;;; Total field width is specified by second arg, and should
|
||||
;;; allow enough for the algebraic sign, and the decimal point.
|
||||
;;; Number of places to the right of the decimal-point is
|
||||
;;; specified by third arg. Similar to FORTRAN F8.3 style.
|
||||
;;; Two optional args are permitted (both default to null).
|
||||
;;; A list of options is fourth arg. see below under "variables".
|
||||
;;; A file, or list of files, for output is fifth.
|
||||
|
||||
;;; PRINT-FIXED-PRECISION-FLOATING - abbreviated "PFPF"
|
||||
;;; A function for printing a specified number of leading non-zero
|
||||
;;; digits, using "E" format where necessary.
|
||||
;;; Total field width is specified by second arg, and should
|
||||
;;; be large enough to allow for sign, point, etc.
|
||||
;;; Number of significant digits wanted is specified by third arg.
|
||||
;;; Three optional args are permitted:
|
||||
;;; A list of options is fourth arg, default to null.
|
||||
;;; See below under "variables" for further description.
|
||||
;;; A file, or list of files, for output is fifth, default to null.
|
||||
;;; A list of "balance" numbers is sixth arg - one of these numbers
|
||||
;;; (the first) specifies the number of digits printed to the left
|
||||
;;; of the point when "E" format is selected; the second and third
|
||||
;;; determine the exponent range wherein "E" format is not forced.
|
||||
;;; For backwards-compatibility, if this argument is not a list,
|
||||
;;; but is a fixnum, say <n>, that is equivalent to the list
|
||||
;;; (<n> -3 8)
|
||||
;;; thus for 1.0E-3 < x < 1.0E8, x will not be forced "E" format.
|
||||
|
||||
|
||||
;;; PRINT-FIXED-FIELD-FIXED - abbreviated "PFFX"
|
||||
;;; A function to print a fixnum or bignum in a field of specified size.
|
||||
;;; First arg is number to be printed, second is field width,
|
||||
;;; Three optional arguments:
|
||||
;;; A fixnum, the radix for conversion, is third; defaults to BASE.
|
||||
;;; A list of options is fourth arg, default to null.
|
||||
;;; See below under "variables" for further description.
|
||||
;;; A file, or list of files, for output is fifth.
|
||||
|
||||
;;; Applicable input domains:
|
||||
;;; For "PFFF", 1.0E-9 < |CANDIDATE| < 1.0E+9 is required.
|
||||
;;; For "PFPF", "E" format is used if |CANDIDATE| < 1.0E-3, or
|
||||
;;; |CANDIDATE| >= 1.0E+9. Otherwise, an appropriatly
|
||||
;;; selected version of PFPF is used.
|
||||
;;; For "PFFX", |CANDIDATE| < 8.5E+37 is required.
|
||||
|
||||
|
||||
|
||||
;;; EXPLANATION OF ARGUMENT VARIABLES
|
||||
|
||||
;;; CANDIDATE - THE INPUT NUMBER
|
||||
;;; WIDTH - THE WIDTH OF THE FORMAT FIELD, INCLUDING ALGEBRAIC
|
||||
;;; SIGN, DECIMAL POINT, AND EXPONENT IF USED.
|
||||
;;; FRAC - [THIS IS THE THIRD ARGUMENT FOR "PFFF"]
|
||||
;;; NUMBER OF COLUMNS RESERVED FOR THE FRACTIONAL PART
|
||||
;;; PREC - [THIS IS THE THIRD ARGUMENT FOR "PFPF"]
|
||||
;;; TOTAL NUMBER OF SIGNIFICANT DIGITS REQUESTED.
|
||||
;;; MUST BE IN THE RANGE 0 < PREC < 9.
|
||||
;;; BASE - [THIRD ARGUMENT TO "PFFX". SAME AS IN LISP]
|
||||
;;; OPTIONS - LIST OF OPTION DESIGNATORS:
|
||||
;;; + - PRINT "+" FOR POSITIVE NUMBERS.
|
||||
;;; SUBSTITUTING <SPACE> IS DEFAULT
|
||||
;;; EXPLODE, EXPLODEC, OR EXPLODEN
|
||||
;;; - IF ANY OF THESE APPEAR, THEN INSTEAD
|
||||
;;; OF PRINTING THE DIGITS, THEY ARE COLLECTED
|
||||
;;; IN AN OUTPUT LIST, AND RETURNED.
|
||||
;;; ERROR - IF THE FORMATTING-PRINT FUNCTION CANNOT FIT
|
||||
;;; THE CANDIDATE IN THE REQUESTED FORMAT, IT
|
||||
;;; WILL NORMALLY RETURN A NULL. BUT IF "ERROR"
|
||||
;;; IS PRESENT, IT WILL RUN A FAIL-ACT ERROR.
|
||||
;;; LEFT - FOR "PFFF" AND "PFFX", PLACE SIGN IN LEFTMOST
|
||||
;;; COLUMN OF FIELD. DEFAULT: PLACE SIGN
|
||||
;;; ADJACENT TO LEFTMOST DIGIT.
|
||||
;;; FOR "PFPF", LEFT-JUSTIFY CHARACTERS IN FIELD.
|
||||
;;; RIGHT-JUSTIFICATION IS DEFAULT.
|
||||
;;; 0 - FOR "PFPF", PRINT TRAILING ZEROS IN THE FRACTION
|
||||
;;; PART (AND LEADING ZEROS IN THE EXPONENT PART);
|
||||
;;; FOR "PFFF" AND "PFFX", PRINT LEADING ZEROS.
|
||||
;;; SUPPRESSION IS DEFAULT.
|
||||
;;; [THE FOLLOWING IS APPLICABLE ONLY TO "PFPF"]
|
||||
;;; E - FORCE "E" FORMAT IN ALL CASES.
|
||||
;;; [THE FOLLOWING IS APPLICABLE ONLY TO "PFFX"]
|
||||
;;; . - *NOPOINT IS SET TO (NOT (MEMQ '/. OPTIONS))
|
||||
;;; THIS HAS A DISCERNIBLE EFFECT ONLY IF BASE = 10.
|
||||
;;; INT - [THIS IS THE FIFTH ARGUMENT TO "PFPF"]
|
||||
;;; NUMBER OF COLUMNS RESERVED FOR THE INTEGRAL PART
|
||||
;;; IF "E" FORMAT IS SELECTED; OTHERWISE IGNORED.
|
||||
;;; AMOUNTS TO A SCALE FACTOR FOR THE EXPONENT, WITH 1
|
||||
;;; YIELDING STANDARD SCIENTIFIC NOTATION.
|
||||
;;; MUST BE IN THE RANGE -1 < INT < 9.
|
||||
|
||||
|
||||
|
||||
;;; EXPLANATION OF SOME AUXILLIARY PROG VARIALBES
|
||||
|
||||
;;; ROUNDED - THE INPUT NUMBER SUITABLY ROUNDED
|
||||
;;; IPART - THE ACTUAL INTEGRAL PART OF "ROUNDED"
|
||||
;;; NID - NUMBER OF DECIMAL DIGITS IN "IPART"
|
||||
;;; FPART - FRACTIONAL PART OF "ROUNDED", AS AN INTEGER
|
||||
;;; FRAC - FOR "PFPF", THIS VALUE IS COMPUTED FROM THE INPUTS
|
||||
;;; EFLAG - NON-NULL IFF "E" FORMAT SELECTED
|
||||
;;; EPART - EXPONENT FOR "E" FORMAT
|
||||
;;; /|10S - AN ARRAY OF POWERS OF 10.0, FROM 1.0E-38 TO 1.0E+38
|
||||
;;; /|/.10S - SECOND WORD OF DOUBLE-PRECISION FOR POWERS OF 10.0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;;; Some example usages. Note that spaces are printed either before
|
||||
;;; or after the digit string as directed from the options list.
|
||||
|
||||
;;; (PRINT-FIXED-FIELD-FLOATING -385.236 8. 2 ()) -385.24
|
||||
;;; (PRINT-FIXED-FIELD-FLOATING 385.236 8. 2 '(+ LEFT))+ 385.24
|
||||
|
||||
|
||||
;;; (PRINT-FIXED-PRECISION-FLOATING 5.23759E2 10. 4 () () 1) 523.8
|
||||
;;; (PRINT-FIXED-PRECISION-FLOATING .00135 10. 5 () () 0) 0.00135
|
||||
;;; (PRINT-FIXED-PRECISION-FLOATING 58.2 10. 4 '(0) () 1) 58.20
|
||||
;;; (PRINT-FIXED-PRECISION-FLOATING 58.2 10. 4 '(LEFT +) () 1)+58.2
|
||||
;;; (PRINT-FIXED-PRECISION-FLOATING 58.2 10. 4 '(E) () 0) 0.582E+2
|
||||
;;; (PRINT-FIXED-PRECISION-FLOATING .00045 12. 6 () () 2) 45.0E-5
|
||||
;;; (PRINT-FIXED-PRECISION-FLOATING .00045 12. 6 () () '(2 -8 8)) 0.00045
|
||||
;;; (PRINT-FIXED-PRECISION-FLOATING .00045 12. 2 () () 2) 45.0E-5
|
||||
;;; (PRINT-FIXED-PRECISION-FLOATING .00045 12. 6 '(0) () 2) 45.0000E-05
|
||||
;;; (PRINT-FIXED-PRECISION-FLOATING 28. 12. 4 () () 1) 28.0
|
||||
|
||||
|
||||
|
||||
;;; (PRINT-FIXED-FIELD-FIXED -8400. 10. 10. '(/. LEFT))- 8400.
|
||||
;;; (PRINT-FIXED-FIELD-FIXED 8400. 10. 8. '(/. /+)) +20320
|
||||
;;; (PRINT-FIXED-FIELD-FIXED 1054. 6 10. '(/0 EXPLODE)) WILL RETURN
|
||||
;;; (/0 /0 /1 /0 /5 /4)
|
||||
|
||||
|
||||
|
||||
|
||||
(DECLARE (SPECIAL /+OR- EXPLODE FILLER)
|
||||
(*EXPR /1OUT/| NOUT/|)
|
||||
(FIXNUM /+OR- FILLER (NDD/| FIXNUM) (LG10/| FLONUM))
|
||||
(NOTYPE (1OUT/| FIXNUM) (REPEAT-OUT/| FIXNUM FIXNUM))
|
||||
(ARRAY* (FLONUM (/|10S 79.)) (FLONUM (/|/.10S 79.))))
|
||||
|
||||
|
||||
|
||||
(DECLARE (SETQ DEFMACRO-FOR-COMPILING ()
|
||||
DEFMACRO-DISPLACE-CALL ()
|
||||
DEFMACRO-CHECK-ARGS () ))
|
||||
(defmacro 10E (I) `(/|10S (+ 39. ,i)))
|
||||
(defmacro /.10E (I) `(/|/.10S (+ 39. ,i)))
|
||||
(defmacro <= (X Y) `(NOT (> ,x ,y)))
|
||||
(defmacro >= (X Y) `(NOT (< ,x ,y)))
|
||||
|
||||
|
||||
|
||||
|
||||
(DEFUN PRINT-FIXED-FIELD-FLOATING
|
||||
(ICANDIDATE IWIDTH IFRAC &OPTIONAL OPTIONS FILE)
|
||||
(DECLARE (FIXNUM IPART FPART NID FRAC WIDTH NSPCS)
|
||||
(FLONUM CANDIDATE ROUNDED))
|
||||
(LET ((BASE 10.) (/+OR- #\SPACE) (FILLER #\SPACE))
|
||||
(PROG (*NOPOINT EXPLODE ROUNDED IPART FPART NID LJUST NSPCS
|
||||
CANDIDATE WIDTH FRAC)
|
||||
(SETQ CANDIDATE (COND ((FLOATP ICANDIDATE) ICANDIDATE)
|
||||
((FLOAT ICANDIDATE)))
|
||||
WIDTH (COND ((EQ (TYPEP IWIDTH) 'FIXNUM) IWIDTH)
|
||||
((GO BARF)))
|
||||
FRAC (COND ((EQ (TYPEP IFRAC) 'FIXNUM) IFRAC)
|
||||
((GO BARF))))
|
||||
(SETQ ROUNDED (FSC CANDIDATE 0)
|
||||
NSPCS (COND ((= ROUNDED CANDIDATE) 0) (1))
|
||||
ROUNDED (ABS ROUNDED)
|
||||
LJUST (OUT-SET/| OPTIONS))
|
||||
(SETQ *NOPOINT 'T)
|
||||
(AND (MINUSP CANDIDATE) (SETQ /+OR- #/-))
|
||||
(AND (OR (MINUSP FRAC) (> FRAC 18.)) (GO BARF))
|
||||
(SETQ ROUNDED (+$ ROUNDED (*/$ 0.5 (10E (- FRAC)))))
|
||||
(AND (NOT (LESSP 1.0E-9 ROUNDED 1.0E9)) (GO BARF))
|
||||
(SETQ NID (NDD/| (SETQ IPART (FIX ROUNDED))))
|
||||
(AND (MINUSP (SETQ NSPCS (- WIDTH FRAC 2 NID NSPCS))) (GO BARF))
|
||||
;Algebraic sign and space-fillers
|
||||
(AND LJUST (1OUT/| /+OR- file))
|
||||
(REPEAT-OUT/| NSPCS FILLER file)
|
||||
(AND (NOT LJUST) (1OUT/| /+OR- file))
|
||||
(AND (NOT (= CANDIDATE (FSC CANDIDATE 0))) (1OUT/| #/# file))
|
||||
;Integer part, decimal point
|
||||
(NOUT/| IPART file)
|
||||
(1OUT/| #/. file)
|
||||
(COND ((NOT (ZEROP FRAC))
|
||||
(SETQ FPART (FIX (*$ (10E FRAC)
|
||||
(-$ ROUNDED (FLOAT IPART)))))
|
||||
;Zeros at right of .
|
||||
(REPEAT-OUT/| (- FRAC (NDD/| FPART)) #/0 file)
|
||||
(NOUT/| FPART file)))
|
||||
(RETURN (COND ((NULL EXPLODE)) ((NREVERSE (CDR EXPLODE)))))
|
||||
BARF (AND (NOT (MEMQ 'ERROR OPTIONS)) (RETURN () ))
|
||||
(ERROR (LIST 'PRINT-FIXED-FIELD-FLOATING CANDIDATE WIDTH FRAC OPTIONS)
|
||||
'|OUT OF RANGE|
|
||||
'FAIL-ACT)))
|
||||
)
|
||||
|
||||
|
||||
|
||||
(DEFUN PRINT-FIXED-PRECISION-FLOATING
|
||||
(ICANDIDATE IWIDTH IPREC &OPTIONAL OPTIONS FILE (BAL 1))
|
||||
(DECLARE (FIXNUM IPART NID FPART INT FRAC PREC EPART WIDTH NSPCS LO HI
|
||||
ELOW EHIGH )
|
||||
(FLONUM CANDIDATE ROUNDED))
|
||||
(LET ((BASE 10.) (/+OR- #\SPACE) (FILLER #\SPACE))
|
||||
(PROG (*NOPOINT EXPLODE ROUNDED IPART NID INT ELOW EHIGH TEM EFLAG
|
||||
FPART FRAC EPART NSPCS LJUST LO HI CANDIDATE WIDTH PREC)
|
||||
(SETQ CANDIDATE (COND ((FLOATP ICANDIDATE) ICANDIDATE)
|
||||
((FLOAT ICANDIDATE)))
|
||||
WIDTH (COND ((EQ (TYPEP IWIDTH) 'FIXNUM) IWIDTH)
|
||||
((GO BARF)))
|
||||
PREC (COND ((EQ (TYPEP IPREC) 'FIXNUM) IPREC)
|
||||
((GO BARF))))
|
||||
(SETQ ROUNDED (FSC CANDIDATE 0))
|
||||
(SETQ FPART -1 IPART 0 FRAC PREC NID 0
|
||||
INT 1 ELOW -3 EHIGH 8
|
||||
LJUST (OUT-SET/| OPTIONS)
|
||||
EFLAG (MEMQ 'E OPTIONS)
|
||||
*NOPOINT 'T
|
||||
NSPCS (COND ((= ROUNDED CANDIDATE) 0) (1))
|
||||
ROUNDED (ABS ROUNDED))
|
||||
(COND ((NOT (ATOM BAL))
|
||||
(AND (EQ (TYPEP (SETQ TEM (CAR BAL))) 'FIXNUM)
|
||||
(SETQ INT TEM))
|
||||
(AND (EQ (TYPEP (SETQ TEM (CADR BAL))) 'FIXNUM)
|
||||
(AND (< (SETQ ELOW TEM) -11.)
|
||||
(GO BARF)))
|
||||
(AND (EQ (TYPEP (SETQ TEM (CADDR BAL))) 'FIXNUM)
|
||||
(AND (> (SETQ EHIGH TEM) 11.)
|
||||
(GO BARF))))
|
||||
((EQ (TYPEP BAL) 'FIXNUM) (SETQ INT BAL)))
|
||||
(AND (MINUSP CANDIDATE) (SETQ /+OR- #/-))
|
||||
(SETQ EPART (COND ((< ROUNDED #.(FSC 4_24. 0))
|
||||
(COND ((NOT (ZEROP ROUNDED)) (GO BARF))
|
||||
(T (SETQ NID 1 FPART 0) (GO B))))
|
||||
((AND (< ROUNDED 3.4359738E+10) (>= ROUNDED 1.0))
|
||||
(1- (NDD/| (FIX ROUNDED))))
|
||||
((LG10/| ROUNDED))))
|
||||
(AND (NOT (LESSP 0 PREC 9.)) (GO BARF))
|
||||
(SETQ LO (- EPART PREC))
|
||||
(COND ((COND ((> LO 36.) (< ROUNDED 1.5E38))
|
||||
((> LO -39.)))
|
||||
;Round, if number not too small
|
||||
(SETQ ROUNDED (+$ ROUNDED (*$ 0.5 (10E (1+ LO)))))
|
||||
;Rounding may cause overflow to next power of 10.0
|
||||
(AND (>= ROUNDED (+$ (10E (SETQ HI (1+ EPART)))
|
||||
(/.10E HI)))
|
||||
(SETQ EPART HI LO (1+ LO)))))
|
||||
(COND (EFLAG)
|
||||
((OR (> EPART EHIGH) (< EPART ELOW)) (SETQ EFLAG 'T))
|
||||
((MINUSP EPART)
|
||||
;IPART stays 0
|
||||
(SETQ FRAC (1- (ABS LO)) NID 1))
|
||||
(T (SETQ NID (NDD/| (SETQ IPART (FIX ROUNDED)))
|
||||
FRAC (- PREC NID))
|
||||
(AND (NOT (PLUSP FRAC))
|
||||
(OR (NOT (= FILLER #/0)) (> (+ NID 2) WIDTH))
|
||||
(SETQ EFLAG 'T))))
|
||||
(COND (EFLAG
|
||||
(AND (OR (MINUSP INT) (> INT 8)) (GO BARF))
|
||||
(SETQ FRAC (- PREC INT) EPART (- EPART INT -1))
|
||||
(SETQ ROUNDED
|
||||
(COND ((= EPART 39.) (*$ 10.0 (*$ ROUNDED 1.0E38)))
|
||||
('T ;Normalize into proper interval
|
||||
;e.g., 1.0 <= ROUNDED < 10.0
|
||||
(+$ (*$ ROUNDED (10E (- EPART)))
|
||||
(*$ ROUNDED (/.10E (- EPART)))))))
|
||||
(SETQ NID (NDD/| (SETQ IPART (FIX ROUNDED))))
|
||||
(COND ((COND ((ZEROP INT) (< ROUNDED .1))
|
||||
((< NID INT))
|
||||
((ZEROP IPART) (NOT (ZEROP ROUNDED))))
|
||||
;Because of truncation in /|.10S, and roundings
|
||||
; in multiplication, possibly ROUNDED is a bit
|
||||
; too high or too low
|
||||
(SETQ ROUNDED (*$ ROUNDED 10.0)
|
||||
EPART (1- EPART) NID -1))
|
||||
((COND ((ZEROP INT) (>= ROUNDED 1.0))
|
||||
((> NID INT)))
|
||||
(SETQ ROUNDED (//$ ROUNDED 10.0)
|
||||
EPART (1+ EPART) NID -1)))
|
||||
(AND (MINUSP NID)
|
||||
(SETQ NID (NDD/| (SETQ IPART (FIX ROUNDED)))))))
|
||||
|
||||
B (COND ((PLUSP FRAC)
|
||||
;Maybe hafta strip out fraction part from "ROUNDED"
|
||||
(AND (MINUSP FPART)
|
||||
(SETQ FPART (FIX (*$ (COND ((ZEROP IPART) ROUNDED)
|
||||
((-$ ROUNDED (FLOAT IPART))))
|
||||
(10E FRAC)))))
|
||||
(COND ((= FILLER #/0))
|
||||
((ZEROP FPART) (SETQ FRAC 1))
|
||||
((PROG ()
|
||||
;Suppress trailing zeros
|
||||
A (AND (NOT (ZEROP (\ FPART 10.))) (RETURN () ))
|
||||
(SETQ FPART (// FPART 10.) FRAC (1- FRAC))
|
||||
(GO A)))))
|
||||
(T (AND (MINUSP FRAC) (SETQ HI (FIX (10E (- FRAC)))
|
||||
IPART (* (// IPART HI) HI)))
|
||||
(SETQ FRAC 1 FPART 0)))
|
||||
(SETQ NSPCS (- WIDTH
|
||||
NID
|
||||
FRAC
|
||||
NSPCS
|
||||
(COND ((NOT EFLAG)
|
||||
2)
|
||||
((OR (= FILLER #/0) ;EXPONENT FIELD
|
||||
(> EPART 9.) ; IS EITHER 5
|
||||
(< EPART -9.)) ; OR 6 PLACES
|
||||
6) ; xx.yyE+5
|
||||
(5)))) ; xx.yyE+05
|
||||
(AND (MINUSP NSPCS) (GO BARF))
|
||||
;Space fillers (if necessary) and algebraic sign
|
||||
(AND (NULL LJUST) (REPEAT-OUT/| NSPCS #\SPACE file))
|
||||
(1OUT/| /+OR- file)
|
||||
(AND (NOT (= CANDIDATE (FSC CANDIDATE 0))) (1OUT/| #/# file))
|
||||
;Integer part, decimal point, zeros at right of .
|
||||
(NOUT/| IPART file)
|
||||
(1OUT/| #/. file)
|
||||
(COND ((NOT (ZEROP FRAC))
|
||||
(REPEAT-OUT/| (- FRAC (NDD/| FPART)) #/0 file)
|
||||
(NOUT/| FPART file)))
|
||||
(COND (EFLAG
|
||||
(1OUT/| #/E file)
|
||||
(1OUT/| (COND ((MINUSP EPART)
|
||||
(SETQ EPART (- EPART))
|
||||
#/-)
|
||||
(#/+))
|
||||
file)
|
||||
(AND (= FILLER #/0)
|
||||
(< EPART +10.)
|
||||
(1OUT/| #/0 file))
|
||||
(NOUT/| EPART file)))
|
||||
(AND LJUST (REPEAT-OUT/| NSPCS #\SPACE file))
|
||||
(RETURN (COND ((NULL EXPLODE)) ((NREVERSE (CDR EXPLODE)))))
|
||||
BARF (AND (NOT (MEMQ 'ERROR OPTIONS)) (RETURN () ))
|
||||
(ERROR (LIST 'PRINT-FIXED-PRECISION-FLOATING CANDIDATE WIDTH PREC OPTIONS BAL)
|
||||
'|OUT OF RANGE|
|
||||
'FAIL-ACT))))
|
||||
|
||||
|
||||
|
||||
(DEFUN PRINT-FIXED-FIELD-FIXED
|
||||
(CANDIDATE WIDTH &OPTIONAL (FOOBASE BASE) OPTIONS FILE)
|
||||
(DECLARE (FIXNUM WIDTH BASE BITS NID NSPCS))
|
||||
(LET ((BASE BASE) (*NOPOINT 'T) (/+OR- #\SPACE) (FILLER #\SPACE))
|
||||
(PROG (EXPLODE NID BITS NSPCS LJUST TEM)
|
||||
(AND (NOT (FIXP CANDIDATE)) (SETQ CANDIDATE (FIX CANDIDATE)))
|
||||
(AND (OR (NOT (EQ (TYPEP FOOBASE) 'FIXNUM))
|
||||
(< FOOBASE 2)
|
||||
(> FOOBASE 36.))
|
||||
(GO BARF))
|
||||
(SETQ BASE FOOBASE LJUST (OUT-SET/| OPTIONS))
|
||||
(AND (= FILLER #/0) (SETQ LJUST T))
|
||||
(AND (MINUSP CANDIDATE)
|
||||
(SETQ /+OR- #/- CANDIDATE (ABS CANDIDATE)))
|
||||
(SETQ BITS (HAULONG CANDIDATE)
|
||||
NID (COND ((= BASE 8.) (1+ (// (1- BITS) 3)))
|
||||
((AND (< BITS 127.) (= BASE 10.))
|
||||
(COND ((< BITS 36.) (NDD/| CANDIDATE))
|
||||
((1+ (LG10/| (FLOAT CANDIDATE))))))
|
||||
('T (SETQ TEM (//$ (LOG (FLOAT CANDIDATE))
|
||||
(LOG BASE)))
|
||||
(COND ((= TEM
|
||||
(FLOAT (SETQ TEM (IFIX TEM))))
|
||||
TEM)
|
||||
((1+ TEM))))))
|
||||
(SETQ NSPCS (- WIDTH NID (COND ((OR *NOPOINT (NOT (= BASE 10.)))
|
||||
1)
|
||||
(2))))
|
||||
(AND (MINUSP NSPCS) (GO BARF))
|
||||
(AND LJUST (1OUT/| /+OR- file))
|
||||
(REPEAT-OUT/| NSPCS FILLER file)
|
||||
(AND (NOT LJUST) (1OUT/| /+OR- file))
|
||||
(NOUT/| CANDIDATE file)
|
||||
(RETURN (COND ((NULL EXPLODE)) ((NREVERSE (CDR EXPLODE)))))
|
||||
BARF (AND (NOT (MEMQ 'ERROR OPTIONS)) (RETURN () ))
|
||||
(ERROR (LIST 'PRINT-FIXED-FIELD-FIXED CANDIDATE WIDTH BASE OPTIONS)
|
||||
'|OUT OF RANGE|
|
||||
'FAIL-ACT))))
|
||||
|
||||
|
||||
|
||||
;COMPUTES INTEGRAL PART OF BASE-10.-LOG OF INPUT
|
||||
(DEFUN LG10/| (ROUNDED)
|
||||
(DECLARE (FLONUM ROUNDED) (FIXNUM LO HI EPART))
|
||||
(PROG (LO MID HI)
|
||||
;Approximation to exponent of 10.
|
||||
(SETQ HI (FIX (+$ .5 (TIMES (- (LSH ROUNDED -27.) 128.) 0.30103)))
|
||||
LO (- HI 4))
|
||||
(AND (< LO -38.) (SETQ LO -39.))
|
||||
A (COND ((>= ROUNDED (10E (SETQ MID (// (+ HI LO) 2))))
|
||||
(SETQ LO MID))
|
||||
(T (SETQ HI MID)))
|
||||
(AND (> (- HI LO) 1) (GO A))
|
||||
(RETURN (COND ((>= ROUNDED (+$ (10E HI) (/.10E HI))) HI)
|
||||
((>= ROUNDED (+$ (10E LO) (/.10E LO))) LO)
|
||||
(T (1- LO))))))
|
||||
|
||||
|
||||
;NUMBER OF DECIMAL DIGITS IN A FIXNUM
|
||||
(DEFUN NDD/| (N)
|
||||
(DECLARE (FIXNUM N))
|
||||
(COND ((< N 100000000.)
|
||||
(COND ((< N 10000.)
|
||||
(COND ((< N 100.) (COND ((< N 10.) 1) (2)))
|
||||
((< N 1000.) 3)
|
||||
(4)))
|
||||
(T (COND ((< N 1000000.) (COND ((< N 100000.) 5) (6)))
|
||||
((< N 10000000.) 7)
|
||||
(8.)))))
|
||||
((< N 10000000000.) (COND ((< N 1000000000.) 9.) (10.)))
|
||||
(11.)))
|
||||
|
||||
|
||||
|
||||
(DEFUN OUT-SET/| (OPTIONS)
|
||||
;Set up some global variables right at the outset
|
||||
(DO ((Y OPTIONS (CDR Y)) (FL))
|
||||
((NULL Y) FL)
|
||||
(COND ((EQ (CAR Y) 'LEFT) (SETQ FL T))
|
||||
((EQ (CAR Y) '/.) (SETQ *NOPOINT () ))
|
||||
((MEMQ (CAR Y) '(EXPLODE EXPLODEC EXPLODEN))
|
||||
(SETQ EXPLODE (LIST (EQ (CAR Y) 'EXPLODEN))))
|
||||
((EQ (CAR Y) '/+) (SETQ /+OR- #/+))
|
||||
((OR (EQ (CAR Y) '/0) (SIGNP E (CAR Y))) (SETQ FILLER #/0)))))
|
||||
|
||||
|
||||
(DEFUN 1OUT/| (CHAR FILE)
|
||||
(COND ((NULL EXPLODE) (TYO CHAR FILE))
|
||||
((RPLACD EXPLODE (CONS (COND ((CAR EXPLODE) CHAR)
|
||||
((ASCII CHAR)))
|
||||
(CDR EXPLODE)))))
|
||||
() )
|
||||
|
||||
(DEFUN NOUT/| (X FILE)
|
||||
(COND ((NULL EXPLODE) (PRIN1 X FILE))
|
||||
((RPLACD EXPLODE (NRECONC (COND ((CAR EXPLODE) (EXPLODEN X))
|
||||
((EXPLODE X)))
|
||||
(CDR EXPLODE)))))
|
||||
() )
|
||||
|
||||
|
||||
(DEFUN REPEAT-OUT/| (N CHAR FILE)
|
||||
(DECLARE (FIXNUM N I))
|
||||
(AND (PLUSP N) (DO I N (1- I) (ZEROP I) (1OUT/| CHAR FILE))))
|
||||
|
||||
|
||||
|
||||
|
||||
;CODE TO INITIALIZE THESE TWO FOOLISH ARRAYS
|
||||
(AND (OR (NULL (GET '/|10S 'ARRAY)) (NULL (ARRAYDIMS '/|10S)))
|
||||
(PROGN (ARRAY /|10S FLONUM 79.)
|
||||
(ARRAY /|/.10S FLONUM 79.)
|
||||
;Smallest magnitude normalized, floating-point number
|
||||
(STORE (/|10S 0) #.(FSC 4_24. 0))
|
||||
;Largest magnitude normalized, floating-point number
|
||||
(STORE (/|10S 78.) #.(FSC 377777777777 0))
|
||||
;Second word of double-precision
|
||||
(STORE (/|/.10S 78.) #.(FSC 344377777777 1_18.))
|
||||
;A well-known constan
|
||||
(STORE (/|10S 39.) 1.0)
|
||||
(COND ((STATUS FEATURE BIGNUM)
|
||||
(DO ((I 40. (1+ I)) (VAL 10. (TIMES VAL 10.)) (T1) (T2) (L) (INV))
|
||||
((= I 78.))
|
||||
(COND ((> (SETQ L (HAULONG VAL)) 53.)
|
||||
(SETQ T1 (HAIPART VAL 27.) T2 (HAIPART (HAIPART VAL 54.) -27.)))
|
||||
((> L 26.) (SETQ T1 (HAIPART VAL 27.) T2 (LSH (HAIPART VAL (- 27. L)) (- 54. L))))
|
||||
(T (SETQ T1 (LSH VAL (- 27. L)) T2 0)))
|
||||
(STORE (/|10S I) (FSC T1 (+ 128. L)))
|
||||
(AND (PLUSP T2)
|
||||
(STORE (/|/.10S I)
|
||||
(FSC (BOOLE 7 (LSH (+ 101. L) 27.) T2) 1_18.)))
|
||||
(STORE (/|10S (- 78. I))
|
||||
(FSC (HAIPART (SETQ INV (*QUO #.(EXPT 2 181.) VAL)) 27.)
|
||||
(- 129. L)))
|
||||
(AND (< I 70.)
|
||||
(STORE (/|/.10S (- 78. I))
|
||||
(FSC (BOOLE 7
|
||||
(LSH (- 102. L) 27.)
|
||||
(HAIPART (HAIPART INV 54.) -27.))
|
||||
1_18.)))))
|
||||
((DO ((I 40. (1+ I)) (VAL 10.0 (*$ VAL 10.0)))
|
||||
((= I 78.))
|
||||
(STORE (/|10S I) VAL)
|
||||
(STORE (/|10S (- 78. I)) (QUOTIENT 1.0 VAL)))))))
|
||||
|
||||
|
||||
|
||||
723
src/libdoc/fft.bwood1
Executable file
723
src/libdoc/fft.bwood1
Executable file
@@ -0,0 +1,723 @@
|
||||
;;;This file is the info and source file for the LISP FAST FOURIER TRANSFORM routines
|
||||
;;;
|
||||
;;;The routines are loaded via (FASLOAD FFT FASL DSK BWOOD)
|
||||
;;;
|
||||
;;;The two basic functions are:
|
||||
;;; FFT --> Fast Fourier Transform
|
||||
;;; IFT --> Inverse Fast Fourier Transform
|
||||
;;;
|
||||
;;;These functions perform a (complex) Fast Fourier Transform on either one
|
||||
;;;or two dimensional FLONUM arrays. For the one-dimensional case, the
|
||||
;;;FLONUM array must be of length a power of two. For the two-dimensional
|
||||
;;;case, the FLONUM array must be square (ie. n x n) where n is a power of two.
|
||||
;;;
|
||||
;;;Calling format is as follows:
|
||||
;;;(FFT <real-array-ptr> <complex-array-ptr>)
|
||||
;;;(IFT <real-array-ptr> <complex-array-ptr>)
|
||||
;;;
|
||||
;;;NOTE: The arguments are array pointers not array names
|
||||
;;;
|
||||
;;;Needless to say, the real and complex arrays must be of the same size
|
||||
;;;and dimension. The Fast Fourier Transform is performed in place. On
|
||||
;;;return, the original arrays contain respectively, the real and complex
|
||||
;;;part of the (Discrete) Fourier transform.
|
||||
;;;
|
||||
;;;Two additional functions are provided (useful for display purposes):
|
||||
;;; (COMPLEX-TO-POLAR <real-array-ptr> <complex-array-ptr>)
|
||||
;;; This function converts (in place) from FLONUM real/imaginery
|
||||
;;; format to FLONUM polar (ie. magnitude/phase) format. On
|
||||
;;; return, the real array contains the magnitude and
|
||||
;;; the complex array contains the phase.
|
||||
;;; (POLAR-TO-COMPLEX <magnitude-array-ptr> <phase-array-ptr>)
|
||||
;;; This function converts (in place) from FLONUM polar
|
||||
;;; format to FLONUM real/imaginery format. On return, the
|
||||
;;; magnitude array contains the real part and the phase
|
||||
;;; array contains the imaginery part.
|
||||
;;;
|
||||
;;;REMINDER:
|
||||
;;;Recall that the FFT is really a DFT. Thus the FFT assumes periodicity of
|
||||
;;;the data. In the one-dimensional case, the origin occurs at both ends
|
||||
;;;of the array. In the two-dimesional case, the origin occurs at all four
|
||||
;;;corners of the array. High frequency points are those furthest from the
|
||||
;;;origin.
|
||||
;;;
|
||||
;;;
|
||||
;;;To center the origin (for display purposes), say in the two-dimensional
|
||||
;;;case, one can use the following accessing function (for ARRAY1):
|
||||
;;;
|
||||
;;;(DEFUN ARRAY1-PT (X Y)
|
||||
;;; (ARRAYCALL FLONUM
|
||||
;;; ARRAY1
|
||||
;;; (BOOLE 1. (+ X (LSH N -1)) (1- N))
|
||||
;;; (BOOLE 1. (+ Y (LSH N -1)) (1- N))))
|
||||
;;;
|
||||
;;;(where ARRAY1 is N x N)
|
||||
;;;
|
||||
;;;
|
||||
;;;Everything is believed to work as advertised. Report any bugs/problems
|
||||
;;;to BWOOD.
|
||||
.FASL
|
||||
|
||||
.MLLIT==1
|
||||
|
||||
.INSRT LISP; DEFNS >
|
||||
|
||||
TITLE LISP FAST FOURIER TRANSFORM
|
||||
|
||||
;;;Need *MAKE-ARRAY (for creating SINE and COSINE tables)
|
||||
.SXEVA (DEFPROP *MAKE-ARRAY (ARRAY FASL AI BWOOD) AUTOLOAD)
|
||||
|
||||
;;;Some (local) AC definitions
|
||||
|
||||
T1==C ;temporary ac's (not preserved)
|
||||
T2==AR1
|
||||
T3==AR2A
|
||||
T4==T
|
||||
T5==TT
|
||||
|
||||
P1==D ;permanent ac's (must be saved)
|
||||
P2==R
|
||||
P3==F
|
||||
P4==FREEAC
|
||||
|
||||
;;;Define a few macros
|
||||
|
||||
DEFINE SACS PLACE
|
||||
MOVEM 17,PLACE+17
|
||||
MOVEI 17,PLACE
|
||||
BLT 17,PLACE+16
|
||||
TERMIN
|
||||
|
||||
DEFINE RACS PLACE
|
||||
MOVSI 17,PLACE
|
||||
BLT 17,16
|
||||
MOVE 17,PLACE+17
|
||||
TERMIN
|
||||
|
||||
ACS: BLOCK 20
|
||||
|
||||
DEFINE FLOAT AC
|
||||
FSC AC,232
|
||||
FADR AC,AC
|
||||
TERMIN
|
||||
|
||||
DEFINE BARF ARG
|
||||
LERR [SIXBIT \^M!ARG!!\]
|
||||
TERMIN
|
||||
|
||||
SINE==0
|
||||
COSINE==0
|
||||
;;;addr's tagged `sine' and `cosine' eventually get smashed (inelegant but fast)
|
||||
|
||||
.ENTRY FFT SUBR 3
|
||||
|
||||
FFT: SKIPA TT,[MOVE B,SINE(P4)]
|
||||
|
||||
.ENTRY IFT SUBR 3
|
||||
|
||||
IFT: MOVE TT,[MOVN B,SINE(P4)]
|
||||
MOVEM TT,FFTSIN
|
||||
|
||||
PUSH P,A
|
||||
PUSH P,B
|
||||
CALL 1,.FUNCTION TYPEP
|
||||
CAIE 1,.ATOM ARRAY
|
||||
BARF ARGUMENT NOT AN ARRAY POINTER (FFT)
|
||||
MOVE A,-1(P)
|
||||
CALL 1,.FUNCTION ARRAYDIMS
|
||||
NCALL 1,.FUNCTION LENGTH
|
||||
SKIPN TT
|
||||
BARF ARGUMENT #DEAD-ARRAY (FFT)
|
||||
CAIL TT,2
|
||||
CAILE TT,3
|
||||
BARF ARRAY HAS WRONG NUMBER OF DIMENSIONS (FFT)
|
||||
PUSH FXP,TT
|
||||
MOVE A,(P)
|
||||
CALL 1,.FUNCTION TYPEP
|
||||
CAIE 1,.ATOM ARRAY
|
||||
BARF ARGUMENT NOT AN ARRAY POINTER (FFT)
|
||||
MOVE A,(P)
|
||||
CALL 1,.FUNCTION ARRAYDIMS
|
||||
NCALL 1,.FUNCTION LENGTH
|
||||
SKIPN TT
|
||||
BARF ARGUMENT #DEAD-ARRAY (FFT)
|
||||
CAIL TT,2
|
||||
CAILE TT,3
|
||||
BARF ARRAY HAS WRONG NUMBER OF DIMENSIONS (FFT)
|
||||
POP FXP,D
|
||||
CAIE TT,(D)
|
||||
BARF REAL AND IMAGINARY ARRAY DIMENSIONS DIFFER (FFT)
|
||||
CAIE TT,2
|
||||
JRST 2DBEG
|
||||
|
||||
;;;1-dimensional FFT
|
||||
BEG: MOVE A,-1(P)
|
||||
MOVE B,(P)
|
||||
MOVEI TT,-1
|
||||
MOVE D,@1(A) ;get dimension
|
||||
MOVNI R,(D)
|
||||
ANDCAI R,(D)
|
||||
SKIPE R
|
||||
BARF ARRAY SIZE NOT POWER OF 2 (FFT)
|
||||
CAME D,@1(B)
|
||||
BARF REAL AND IMAGINARY ARRAY SIZES DIFFER (FFT)
|
||||
MOVEM D,NN
|
||||
MOVNI TT,(D)
|
||||
HRLZM TT,ABJPTR
|
||||
|
||||
CAME D,LASTNN
|
||||
PUSHJ P,FINIT
|
||||
|
||||
POP P,B
|
||||
POP P,A
|
||||
|
||||
;;;When array addresses are smashed, no garbage collection can be allowed
|
||||
;;;(since arrays may get relocated). Also, don't allow ^G interrupts.
|
||||
;;;The code is written this way for speed.
|
||||
HLLOS NOQUIT
|
||||
SACS ACS
|
||||
|
||||
;;;Now able to smash addr's of sine & cosine arrays (with impunity)
|
||||
MOVE TT,.ARRAY SINTBL
|
||||
MOVEI TT,(TT)
|
||||
HRRM TT,FFTSIN
|
||||
MOVE TT,.ARRAY COSTBL
|
||||
MOVEI TT,(TT)
|
||||
HRRM TT,FFTCOS
|
||||
|
||||
REAL==0
|
||||
IMAG==0
|
||||
;;;Now able to smash addr's tagged `real' and `imag' (with impunity)
|
||||
HRRZ A,1(A)
|
||||
HRRZ B,1(B)
|
||||
MOVSI TT,-TBLSIZ
|
||||
HRRM A,@RTBL(TT)
|
||||
HRRM B,@ITBL(TT)
|
||||
AOBJN TT,.-2
|
||||
|
||||
PUSHJ P,REVBS
|
||||
PUSHJ P,TRANS
|
||||
|
||||
JRST DONE
|
||||
|
||||
;;;2-dimensional FFT
|
||||
2DBEG: MOVE A,-1(P)
|
||||
MOVE B,(P)
|
||||
MOVEI TT,-2
|
||||
MOVE D,@1(A)
|
||||
MOVNI R,(D)
|
||||
ANDCAI R,(D)
|
||||
SKIPE R
|
||||
BARF ARRAY SIZE NOT POWER OF 2 (FFT)
|
||||
CAME D,@1(B)
|
||||
BARF REAL AND IMAGINARY ARRAY SIZES DIFFER (FFT)
|
||||
MOVEI TT,-1
|
||||
MOVE R,@1(A)
|
||||
CAME R,@1(B)
|
||||
BARF REAL AND IMAGINARY ARRAY SIZES DIFFER (FFT)
|
||||
CAIE D,(R)
|
||||
BARF ARRAY NOT SQUARE (FFT)
|
||||
MOVEM D,NN
|
||||
MOVEM D,LIMIT
|
||||
SOS LIMIT
|
||||
|
||||
MOVNI TT,(D)
|
||||
HRLZM TT,ABJPTR
|
||||
|
||||
CAME D,LASTNN
|
||||
PUSHJ P,FINIT
|
||||
|
||||
POP P,B
|
||||
POP P,A
|
||||
|
||||
;;;When array addresses are smashed, no garbage collection can be allowed
|
||||
;;;(since arrays may get relocated). Also, don't allow ^G interrupts.
|
||||
;;;The code is written this way for speed.
|
||||
HLLOS NOQUIT
|
||||
SACS ACS
|
||||
|
||||
;;;Now can smash addr's of sine & cosine arrays (with impunity)
|
||||
MOVE TT,.ARRAY SINTBL
|
||||
MOVEI TT,(TT)
|
||||
HRRM TT,FFTSIN
|
||||
MOVE TT,.ARRAY COSTBL
|
||||
MOVEI TT,(TT)
|
||||
HRRM TT,FFTCOS
|
||||
|
||||
SETZM COUNT
|
||||
SETZM FLAG
|
||||
SETZM INDEX
|
||||
|
||||
;;;save addr's of real & imaginary data
|
||||
HRRZ A,1(A)
|
||||
MOVEM A,DATA1
|
||||
HRRZ B,1(B)
|
||||
MOVEM B,DATA2
|
||||
|
||||
FFTLP:
|
||||
REAL==0
|
||||
IMAG==0
|
||||
;;;Now can smash addr's tagged `real' and `imag' (with impunity)
|
||||
MOVE A,DATA1
|
||||
ADD A,INDEX
|
||||
MOVE B,DATA2
|
||||
ADD B,INDEX
|
||||
MOVSI TT,-TBLSIZ
|
||||
HRRM A,@RTBL(TT)
|
||||
HRRM B,@ITBL(TT)
|
||||
AOBJN TT,.-2
|
||||
|
||||
PUSHJ P,REVBS
|
||||
PUSHJ P,TRANS
|
||||
|
||||
MOVE A,NN
|
||||
ADDM A,INDEX
|
||||
AOS A,COUNT
|
||||
CAMGE A,NN
|
||||
JRST FFTLP
|
||||
PUSHJ P,TPOS
|
||||
SKIPE FLAG
|
||||
JRST DONE
|
||||
SETOM FLAG
|
||||
SETZM INDEX
|
||||
SETZM COUNT
|
||||
JRST FFTLP
|
||||
|
||||
;;;This restores LISP world and returns
|
||||
DONE: RACS ACS
|
||||
HLLZS NOQUIT
|
||||
PUSHJ P,CHECKI
|
||||
POPJ P,
|
||||
|
||||
COUNT: 0
|
||||
FLAG: 0
|
||||
INDEX: 0
|
||||
LIMIT: 0
|
||||
|
||||
DATA1: 0 ;ptr to real data
|
||||
DATA2: 0 ;ptr to imaginary data
|
||||
|
||||
X=SP
|
||||
Y=FLP
|
||||
|
||||
;;;transpose array
|
||||
|
||||
TPOS: MOVE A,DATA1
|
||||
HRRM A,TR1
|
||||
HRRM A,TR2
|
||||
HRRM A,TR3
|
||||
MOVE A,DATA2
|
||||
HRRM A,TI1
|
||||
HRRM A,TI2
|
||||
HRRM A,TI3
|
||||
SETZB D,TT
|
||||
SETZB X,Y
|
||||
|
||||
TPLOP: MOVEI T,(D)
|
||||
ADDI T,(Y)
|
||||
MOVEI T3,(TT)
|
||||
ADDI T3,(X)
|
||||
TR1: MOVE A,(T)
|
||||
TI1: MOVE B,(T)
|
||||
TR2: EXCH A,(T3)
|
||||
TI2: EXCH B,(T3)
|
||||
TR3: MOVEM A,(T)
|
||||
TI3: MOVEM B,(T)
|
||||
ADD TT,NN
|
||||
AOJ Y,
|
||||
CAIGE Y,(X)
|
||||
JRST TPLOP
|
||||
SETZB Y,TT
|
||||
AOJ X,
|
||||
ADD D,NN
|
||||
CAMGE X,NN
|
||||
JRST TPLOP
|
||||
POPJ P,
|
||||
|
||||
|
||||
RTBL: R1
|
||||
R2
|
||||
R3
|
||||
R4
|
||||
R5
|
||||
R6
|
||||
R7
|
||||
R8
|
||||
R9
|
||||
R10
|
||||
R11
|
||||
TBLSIZ==.-RTBL
|
||||
|
||||
;;;note: rtbl and itbl must be of same length
|
||||
ITBL: I1
|
||||
I2
|
||||
I3
|
||||
I4
|
||||
I5
|
||||
I6
|
||||
I7
|
||||
I8
|
||||
I9
|
||||
I10
|
||||
I11
|
||||
|
||||
SNAME: .ATOM SINTBL
|
||||
CNAME: .ATOM COSTBL
|
||||
TYPE: .ATOM FLONUM
|
||||
|
||||
FINIT: MOVEM D,LASTNN
|
||||
FLOAT D
|
||||
MOVEM D,FLTNN ;float<nn>
|
||||
LDB TT,[330700,,D]
|
||||
SOJ TT,
|
||||
MOVEM TT,LN ;save log<nn>
|
||||
|
||||
;;;calculate required length of sintbl & costbl
|
||||
MOVE TT,NN
|
||||
LSH TT,-1
|
||||
AOJ TT,
|
||||
PUSH FXP,TT
|
||||
MOVEI FREEAC,(FXP)
|
||||
|
||||
MOVEI TT,FINIT1
|
||||
PUSH P,TT
|
||||
PUSH P,SNAME
|
||||
PUSH P,TYPE
|
||||
PUSH P,FREEAC
|
||||
MOVNI T,3
|
||||
JCALL 16,.FUNCTION *MAKE-ARRAY
|
||||
|
||||
FINIT1: MOVEI TT,FINIT2
|
||||
PUSH P,TT
|
||||
PUSH P,CNAME
|
||||
PUSH P,TYPE
|
||||
PUSH P,FREEAC
|
||||
MOVNI T,3
|
||||
JCALL 16,.FUNCTION *MAKE-ARRAY
|
||||
|
||||
FINIT2: SUB FXP,[1,,1]
|
||||
|
||||
;;;fill costbl and sintbl arrays (need only 0-pi)
|
||||
MOVE TT,TWPI
|
||||
FDVR TT,FLTNN
|
||||
MOVEM TT,STEP
|
||||
|
||||
MOVN TT,NN
|
||||
ASH TT,-2 ;-nn/4
|
||||
SOJ TT,
|
||||
HRLZI FREEAC,(TT)
|
||||
SETZ TT,
|
||||
PUSH FLP,TT
|
||||
|
||||
QUAD1: MOVEI A,(FLP)
|
||||
NCALL 1,.FUNCTION SIN
|
||||
EXCH TT,FREEAC
|
||||
MOVEM FREEAC,@ .ARRAY SINTBL
|
||||
MOVE FREEAC,TT
|
||||
MOVEI A,(FLP)
|
||||
NCALL 1,.FUNCTION COS
|
||||
EXCH TT,FREEAC
|
||||
MOVEM FREEAC,@ .ARRAY COSTBL
|
||||
MOVE FREEAC,TT
|
||||
MOVE TT,STEP
|
||||
FADRM TT,(FLP)
|
||||
AOBJN FREEAC,QUAD1
|
||||
SUB FLP,[1,,1]
|
||||
|
||||
MOVN TT,NN
|
||||
ASH TT,-2
|
||||
HRLI FREEAC,(TT)
|
||||
MOVEI TT,1
|
||||
|
||||
QUAD2: MOVE T,@ .ARRAY COSTBL
|
||||
EXCH FREEAC,TT
|
||||
MOVEM T,@ .ARRAY SINTBL
|
||||
EXCH FREEAC,TT
|
||||
MOVE T,@ .ARRAY SINTBL
|
||||
EXCH FREEAC,TT
|
||||
MOVNM T,@ .ARRAY COSTBL
|
||||
EXCH FREEAC,TT
|
||||
AOJ TT,
|
||||
AOBJN FREEAC,QUAD2
|
||||
MOVE TT,NN
|
||||
LSH TT,-2
|
||||
SETZB TT,@ .ARRAY COSTBL
|
||||
POPJ P,
|
||||
|
||||
TWPI: 6.283185307
|
||||
TOPSTR: 0
|
||||
LASTNN: 0 ;last value of nn
|
||||
ABJPTR: 0 ;aobjn ptr for data
|
||||
NN: 0 ;number of points to transform (must be power of 2)
|
||||
LN: 0 ;log base 2 of nn
|
||||
FLTNN: 0 ;floating pt version of nn
|
||||
STEP: 0 ;step size (in floating pt. radians)
|
||||
|
||||
|
||||
CYCLES==FLP
|
||||
FPERC==FXP
|
||||
ICS==SP
|
||||
XX==T4
|
||||
YY==T5
|
||||
K==P3
|
||||
|
||||
TRANS: MOVEI CYCLES,1
|
||||
MOVE FPERC,NN
|
||||
LSH FPERC,-1
|
||||
MOVEI ICS,2
|
||||
MOVE K,LN ;log nn
|
||||
JFCL 17,.+1 ;clear PC flags
|
||||
|
||||
RANK: SETZB P4,P2
|
||||
SETZM TOPSTR
|
||||
MOVEI P1,(CYCLES) ;bottom of first btrfly
|
||||
MOVEI YY,(CYCLES) ;count cycles
|
||||
RANK1: MOVEI XX,(FPERC) ;count btrflies
|
||||
FFTCOS: MOVE A,COSINE(P4) ;get cosine
|
||||
FFTSIN: MOVE B,SINE(P4) ;IFT --> MOVN B,SINE(P4)
|
||||
RANK2:
|
||||
R1: MOVE T1,REAL(P1)
|
||||
FMPR T1,A
|
||||
I1: MOVE T2,IMAG(P1)
|
||||
FMPR T2,B
|
||||
FSBR T1,T2
|
||||
R2: MOVE T2,REAL(P1)
|
||||
FMPR T2,B
|
||||
I2: MOVE T3,IMAG(P1)
|
||||
FMPR T3,A
|
||||
FADR T2,T3
|
||||
JFCL 10,RANK6 ;test for arithmetic underflow
|
||||
|
||||
RANK3:
|
||||
R3: MOVNM T1,REAL(P1)
|
||||
I3: MOVNM T2,IMAG(P1)
|
||||
R4: EXCH T1,REAL(P2)
|
||||
I4: EXCH T2,IMAG(P2)
|
||||
|
||||
R5: FADRM T1,REAL(P2)
|
||||
JFCL 10,[ SETZM @R5
|
||||
JRST I5]
|
||||
I5: FADRM T2,IMAG(P2)
|
||||
JFCL 10,[ SETZM @I5
|
||||
JRST R6]
|
||||
R6: FADRM T1,REAL(P1)
|
||||
JFCL 10,[ SETZM @R6
|
||||
JRST I6]
|
||||
I6: FADRM T2,IMAG(P1)
|
||||
JFCL 10,[ SETZM @I6
|
||||
JRST RANK4]
|
||||
|
||||
RANK4: ADDI P2,(ICS) ;do next
|
||||
ADDI P1,(ICS)
|
||||
SOJG XX,RANK2
|
||||
ADDI P4,(FPERC) ;do next cycle
|
||||
AOS P1,TOPSTR ;start of next cycle
|
||||
MOVEI P2,(P1)
|
||||
ADDI P1,(CYCLES) ;bottom
|
||||
SOJG YY,RANK1
|
||||
|
||||
LSH CYCLES,1 ;2*cycles
|
||||
LSH ICS,1 ;2*ics
|
||||
LSH FPERC,-1 ;fperc/2
|
||||
SOJG K,RANK ;do ln ranks
|
||||
|
||||
MOVE T2,FFTSIN
|
||||
TLNN T2,010000 ;ift?
|
||||
POPJ P,
|
||||
|
||||
;;;ift --> normalize transform
|
||||
MOVE T2,FLTNN
|
||||
MOVE T4,ABJPTR
|
||||
|
||||
RANK5: MOVE T1,T2
|
||||
R10: EXCH T1,REAL(T4)
|
||||
R11: FDVRM T1,REAL(T4)
|
||||
JFCL 10,[ SETZM @R11
|
||||
JRST RNK51]
|
||||
RNK51: MOVE T1,T2
|
||||
I10: EXCH T1,IMAG(T4)
|
||||
I11: FDVRM T1,IMAG(T4)
|
||||
JFCL 10,[ SETZM @I11
|
||||
JRST RNK52]
|
||||
RNK52: AOBJN T4,RANK5
|
||||
|
||||
POPJ P,
|
||||
|
||||
;;;Overflow flag set. Make sure it really was underflow and then repeat the
|
||||
;;;computation at RANK2 checking each step along the way
|
||||
RANK6: PUSH P,T
|
||||
JSP T,RANK7
|
||||
POP P,T
|
||||
JRST RANK3
|
||||
|
||||
RANK7: TLNN T,100
|
||||
.VALUE
|
||||
MOVE T1,@R1
|
||||
FMPR T1,A
|
||||
JFCL 10,[ MOVEI T1,
|
||||
JRST RNK71]
|
||||
RNK71: MOVE T2,@I1
|
||||
FMPR T2,B
|
||||
JFCL 10,[ MOVEI T2,
|
||||
JRST RNK72]
|
||||
RNK72: FSBR T1,T2
|
||||
JFCL 10,[ MOVEI T1,
|
||||
JRST RNK73]
|
||||
RNK73: MOVE T2,@R2
|
||||
FMPR T2,B
|
||||
JFCL 10,[ MOVEI T2,
|
||||
JRST RNK74]
|
||||
RNK74: MOVE T3,@I2
|
||||
FMPR T3,A
|
||||
JFCL 10,[ MOVEI T3,
|
||||
JRST RNK75]
|
||||
RNK75: FADR T2,T3
|
||||
JFCL 10,[ MOVEI T2,
|
||||
JRST (T)]
|
||||
JRST (T)
|
||||
|
||||
REVBS: MOVEI T5,2*36.
|
||||
SUB T5,LN
|
||||
MOVE T4,ABJPTR
|
||||
REVB: MOVEI T1,(T4)
|
||||
SETZ T1+1,
|
||||
CIRC T1,(T5)
|
||||
CAIL T1+1,(T4)
|
||||
JRST CONT
|
||||
R7: MOVE T1,REAL(T4)
|
||||
R8: EXCH T1,REAL(T1+1)
|
||||
R9: MOVEM T1,REAL(T4)
|
||||
I7: MOVE T1,IMAG(T4)
|
||||
I8: EXCH T1,IMAG(T1+1)
|
||||
I9: MOVEM T1,IMAG(T4)
|
||||
|
||||
CONT: AOBJN T4,REVB
|
||||
POPJ P,
|
||||
|
||||
|
||||
ARRAY1: 0
|
||||
ARRAY2: 0
|
||||
|
||||
.ENTRY COMPLEX-TO-POLAR SUBR 0
|
||||
|
||||
MOVEM A,ARRAY1
|
||||
MOVEM B,ARRAY2
|
||||
CALL 1,.FUNCTION ARRAYDIMS
|
||||
NCALL 1,.FUNCTION LENGTH
|
||||
MOVE A,ARRAY1
|
||||
MOVE B,ARRAY2
|
||||
CAIN TT,2
|
||||
JRST 1DCTP
|
||||
CAIN TT,3
|
||||
JRST 2DCTP
|
||||
BARF BAD ARRAY DIMENSIONS (COMPLEX-TO-POLAR)
|
||||
|
||||
1DCTP: MOVEI TT,-1
|
||||
MOVE FREEAC,@1(A) ;dimension
|
||||
JRST CTP1
|
||||
|
||||
2DCTP: MOVEI TT,-2
|
||||
MOVE FREEAC,@1(A) ;x dimension
|
||||
MOVEI TT,-1
|
||||
IMUL FREEAC,@1(A) ;times y dimension
|
||||
|
||||
CTP1: JFCL 17,.+1 ;clear PC flags
|
||||
MOVNI FREEAC,(FREEAC) ;negate it
|
||||
MOVSI FREEAC,(FREEAC) ;finally... an aobjn ptr
|
||||
|
||||
CTP2: MOVEI TT,(FREEAC)
|
||||
MOVE D,@1(A)
|
||||
PUSH FLP,D
|
||||
FMPR D,D
|
||||
JFCL 10,[ SETZ D,
|
||||
JRST CTP3]
|
||||
CTP3: MOVE TT,@1(B)
|
||||
PUSH FLP,TT
|
||||
FMPR TT,TT
|
||||
FADR TT,D
|
||||
JFCL 10,[ SETZ TT,
|
||||
JRST CTP4]
|
||||
CTP4: CAMG TT,[0.000000000001]
|
||||
JRST CTP5
|
||||
PUSH FLP,TT
|
||||
MOVEI A,(FLP)
|
||||
NCALL 1,.FUNCTION SQRT
|
||||
MOVEI B,-2(FLP)
|
||||
MOVEI A,-1(FLP)
|
||||
PUSH FLP,TT
|
||||
NCALL 2,.FUNCTION ATAN
|
||||
MOVE D,TT
|
||||
MOVE A,ARRAY1
|
||||
MOVE B,ARRAY2
|
||||
MOVEI TT,(FREEAC)
|
||||
MOVEM D,@1(B)
|
||||
MOVE D,(FLP)
|
||||
MOVEM D,@1(A)
|
||||
SUB FLP,[4,,4]
|
||||
AOBJN FREEAC,CTP2
|
||||
POPJ P,
|
||||
|
||||
CTP5: MOVEI TT,(FREEAC)
|
||||
SETZM @1(A)
|
||||
SETZM @1(B)
|
||||
SUB FLP,[2,,2]
|
||||
AOBJN FREEAC,CTP2
|
||||
POPJ P,
|
||||
|
||||
|
||||
.ENTRY POLAR-TO-COMPLEX SUBR 0
|
||||
|
||||
MOVEM A,ARRAY1
|
||||
MOVEM B,ARRAY2
|
||||
CALL 1,.FUNCTION ARRAYDIMS
|
||||
NCALL 1,.FUNCTION LENGTH
|
||||
MOVE A,ARRAY1
|
||||
MOVE B,ARRAY2
|
||||
CAIN TT,2
|
||||
JRST 1DPTC
|
||||
CAIN TT,3
|
||||
JRST 2DPTC
|
||||
BARF BAD ARRAY DIMENSIONS (POLAR-TO-COMPLEX)
|
||||
|
||||
1DPTC: MOVEI TT,-1
|
||||
MOVE FREEAC,@1(A) ;dimension
|
||||
JRST PTC1
|
||||
|
||||
2DPTC: MOVEI TT,-2
|
||||
MOVE FREEAC,@1(A) ;x dimension
|
||||
MOVEI TT,-1
|
||||
IMUL FREEAC,@1(A) ;times y dimension
|
||||
|
||||
PTC1: JFCL 17,.+1 ;clear PC flags
|
||||
MOVNI FREEAC,(FREEAC) ;negate it
|
||||
MOVSI FREEAC,(FREEAC) ;finally... an aobjn ptr
|
||||
|
||||
PTC2: MOVEI TT,(FREEAC)
|
||||
MOVE D,@1(A)
|
||||
PUSH FLP,D
|
||||
MOVE TT,@1(B)
|
||||
PUSH FLP,TT
|
||||
MOVEI A,(FLP)
|
||||
NCALL 1,.FUNCTION COS
|
||||
FMPR TT,-1(FLP)
|
||||
JFCL 10,[ SETZ TT,
|
||||
JRST PTC3]
|
||||
PTC3: PUSH FLP,TT
|
||||
MOVEI A,-1(FLP)
|
||||
NCALL 1,.FUNCTION SIN
|
||||
FMPR TT,-2(FLP)
|
||||
JFCL 10,[ SETZ TT,
|
||||
JRST PTC4]
|
||||
PTC4: MOVE D,TT
|
||||
MOVE A,ARRAY1
|
||||
MOVE B,ARRAY2
|
||||
MOVEI TT,(FREEAC)
|
||||
MOVEM D,@1(B)
|
||||
MOVE D,(FLP)
|
||||
MOVEM D,@1(A)
|
||||
SUB FLP,[3,,3]
|
||||
AOBJN FREEAC,PTC2
|
||||
POPJ P,
|
||||
|
||||
FASEND
|
||||
|
||||
30
src/libdoc/filbit.1
Executable file
30
src/libdoc/filbit.1
Executable file
@@ -0,0 +1,30 @@
|
||||
;; -*-Mode:LISP; Author:RWK-*-
|
||||
|
||||
(herald FILBIT /1)
|
||||
|
||||
(or (get 'UMLMAC 'VERSION)
|
||||
(load '((LISP) UMLMAC FASL)))
|
||||
|
||||
;; Return the modes a file was opened in (whether file is open or not).
|
||||
|
||||
(defun filemodes (file)
|
||||
(let ((modes (arraycall fixnum file 8.))
|
||||
(outlist))
|
||||
(if (zerop (logand modes (lsh #o400000 18.)))
|
||||
(push 'BLOCK outlist)
|
||||
(push 'SINGLE outlist))
|
||||
(if (not (zerop (logand modes (lsh #o20000 18.))))
|
||||
(push 'APPEND outlist))
|
||||
(if (not (zerop (logand modes (lsh #o40 18.))))
|
||||
(push 'CLA outlist))
|
||||
(if (zerop (logand modes #o2))
|
||||
(push 'DSK outlist)
|
||||
(push 'TTY outlist))
|
||||
(if (zerop (logand modes #o1))
|
||||
(push 'IN outlist)
|
||||
(push 'OUT outlist))
|
||||
(caseq (ldb #o0202 modes)
|
||||
(0 (push 'ASCII outlist))
|
||||
(1 (push 'FIXNUM outlist))
|
||||
(2 (push 'IMAGE outlist)))
|
||||
outlist))
|
||||
45
src/libdoc/fload.rich1
Executable file
45
src/libdoc/fload.rich1
Executable file
@@ -0,0 +1,45 @@
|
||||
(defun LET macro (s)
|
||||
(cons (cons 'lambda
|
||||
(cons (mapcar 'car (cadr s))
|
||||
(cddr s)))
|
||||
(mapcar 'cadr (cadr s))))
|
||||
|
||||
(declare (special defun))
|
||||
|
||||
(defun FLOAD fexpr (filespec)
|
||||
;; given filespec of FASL file, first FASLOAD it in
|
||||
;; then compare creation dates with corresponding EXPR (assuming
|
||||
;; second file name >) and if it is more recent,
|
||||
;; LOAD it in with DEFUN=T and snap uuolinks
|
||||
;; returns name of last file loaded
|
||||
(let ((faslfile (mergef (mergef filespec (cons '* 'fasl)) defaultf))
|
||||
(exprfile (probef (mergef (mergef (cons '* '>) filespec) defaultf))))
|
||||
(cond ((probef faslfile)
|
||||
(load faslfile)
|
||||
(cond ((ledit-olderp faslfile exprfile)
|
||||
(let ((defun t))(load exprfile))
|
||||
(sstatus uuolinks)
|
||||
(and (< (cadr (status uuolinks)) 10.)
|
||||
(princ '|;Warning - down to less than 10 uuolinks.|))
|
||||
exprfile)
|
||||
(faslfile)))
|
||||
(t (load exprfile)
|
||||
exprfile))))
|
||||
|
||||
(defun CLOAD fexpr (filespec)
|
||||
;; for ease of conversion from old LEDIT
|
||||
(let ((defun t))
|
||||
(load (mergef (mergef filespec (cons '* '>)) defaultf))))
|
||||
|
||||
(defun LEDIT-AGELIST (file)
|
||||
((lambda (plist)
|
||||
(nconc (get plist 'credate)(get plist 'cretime)))
|
||||
(car (directory (list file) '(credate cretime)))))
|
||||
|
||||
|
||||
(defun LEDIT-OLDERP (file1 file2)
|
||||
(do ((age1 (ledit-agelist file1)(cdr age1))
|
||||
(age2 (ledit-agelist file2)(cdr age2)))
|
||||
((null age1) nil)
|
||||
(cond ((< (car age1)(car age2))(return t))
|
||||
((> (car age1)(car age2))(return nil)))))
|
||||
60
src/libdoc/fontrd.baker1
Executable file
60
src/libdoc/fontrd.baker1
Executable file
@@ -0,0 +1,60 @@
|
||||
;;; This file contains functions for hacking Font files
|
||||
;;; in KST format.
|
||||
;;; Submitted by Henry G. Baker, Jr.
|
||||
|
||||
(defun let macro (form)
|
||||
(cons (cons 'lambda (cons (cadr form) (cdddr form)))
|
||||
(caddr form)))
|
||||
|
||||
(defun ^ macro (a)
|
||||
;;; define logical "and" function.
|
||||
(append '(boole 1.) (cdr a)))
|
||||
|
||||
(declare (fixnum n i j))
|
||||
|
||||
(defun readfont (font)
|
||||
;;; "font" is an atom filename used by newio.
|
||||
;;; For example, |fonts;30vr kst|.
|
||||
;;; Readfont also returns its argument as its value.
|
||||
;;; Readfont gives this atom the following properties:
|
||||
;;; kstid;
|
||||
;;; column-position-adjustment;
|
||||
;;; base-line;
|
||||
;;; height;
|
||||
;;; width.
|
||||
;;; "width" property is fixnum array of 128. entries
|
||||
;;; giving width of each character in the font.
|
||||
;;; For example, after doing (readfont '|fonts;30vr kst|),
|
||||
;;; (arraycall fixnum (get '|fonts;30vr kst| 'width) 65.)
|
||||
;;; returns the width of capital "A".
|
||||
(let (fontfile width)
|
||||
((open font '(in fixnum))
|
||||
(*array nil 'fixnum 128.))
|
||||
(putprop font width 'width)
|
||||
(putprop font (in fontfile) 'kstid)
|
||||
(let (n)((in fontfile))
|
||||
(putprop font (^ (lsh n -27.) 511.) 'column-position-adjustment)
|
||||
(putprop font (^ (lsh n -18.) 511.) 'base-line)
|
||||
(putprop font (^ n (1- (lsh 1. 18.))) 'height))
|
||||
(do ((i (in fontfile) i))
|
||||
((= i -1.))
|
||||
(let (char)((^ (in fontfile) 127.))
|
||||
(store (arraycall fixnum width char)
|
||||
(^ (in fontfile) (1- (lsh 1. 18.))))
|
||||
(do ((j (in fontfile) (in fontfile)))
|
||||
((oddp j) (setq i j)))))
|
||||
(close fontfile))
|
||||
font)
|
||||
|
||||
(declare (fixnum s l) (notype w))
|
||||
|
||||
(defun flatlength (arg font)
|
||||
;;; compute the length of arg in the font "font".
|
||||
(let (s w l)
|
||||
((flatc arg) (get font 'width) 0.)
|
||||
(do ((i 1. (1+ i)))
|
||||
((> i s) l)
|
||||
(setq l
|
||||
(+ l (arraycall fixnum w (getcharn arg i)))))))
|
||||
|
||||
|
||||
275
src/libdoc/for.info
Executable file
275
src/libdoc/for.info
Executable file
@@ -0,0 +1,275 @@
|
||||
;;;-*-Lisp-*-
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; ITERATION FUNCTIONS ;;;
|
||||
;;; Peter Szolovits (PSZ @ MIT-ML) ;;;
|
||||
;;; July 16, 1976 ;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; revised by PSZ & RAMESH on Mar. 22, 1979 ;;;
|
||||
;;; revised by LH@MIT-ML on May 9, 1979 ;;;
|
||||
;;; revised again by BYRON@MIT-ML on July 12, 1979 ;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;;;This package defines a set of functions to provide an
|
||||
;;;approximation of INTERLISP's iteration statement facility
|
||||
;;;within a MACRO package for MACLISP.
|
||||
;;;
|
||||
;;;
|
||||
;;;For the simplest exposition of its use and utility, here are
|
||||
;;;a few examples of how the iterations statements may be used:
|
||||
;;;
|
||||
;;; (FOR I FROM 1 TO 3 COLLECT I) ==> (1 2 3)
|
||||
;;;
|
||||
;;; (COLLECT (CONS I X) FOR X IN '(A B C D E) AS I BY 3)
|
||||
;;; ==> ((1 . A) (4 . B) (7 . C) (10 . D) (13 . E))
|
||||
;;;
|
||||
;;; (UNLESS (ATOM X) JOIN X FOR X IN '((A B C) (D E) F (G)))
|
||||
;;; ==> (A B C D E G)
|
||||
;;;
|
||||
;;; (FOR X ON '(A B C D) AS I FROM 1 ADJOIN (PRINT I) X)
|
||||
;;; 1
|
||||
;;; 2
|
||||
;;; 3
|
||||
;;; 4
|
||||
;;; ==> (A B C D B C D C D D)
|
||||
;;;
|
||||
;;; (FIRST (SETQ FOO '(A B (C D) E))
|
||||
;;; WHILE (ATOM (CAR FOO)) DO (SETQ FOO (CDR FOO)) (PRINT FOO))
|
||||
;;; (B (C D) E)
|
||||
;;; ((C D) E)
|
||||
;;; ==> NIL
|
||||
;;;
|
||||
;;; (BIND X (FOO '(A B (C D) E))
|
||||
;;; WHILE (ATOM (SETQ X (CAR FOO)))
|
||||
;;; COLLECT (SETQ FOO (CDR FOO)) (CONS X X))
|
||||
;;; ==> ((A . A) (B . B))
|
||||
;;;
|
||||
;;; (FOR X IN '(A B C D) FIRST-TIME (MEMQ X '(E F G C 1 2 3)))
|
||||
;;; ==> (C 1 2 3)
|
||||
;;;
|
||||
;;;FOR now supports LET-type "destructuring" wherever variables are
|
||||
;;; explicitly bound (by BIND, FOR, or AS) so:
|
||||
;;;
|
||||
;;; (FOR (X Y) IN '((1 2) (3 4)) COLLECT (+ X Y) ==> (3 7)
|
||||
;;;
|
||||
;;; (BIND ((X Y) '(2 4)) FOR I FROM 1 TO 2 COLLECT (+ X Y I)) ==> (7 8)
|
||||
;;;
|
||||
;;*page
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; GENERAL DESCRIPTION ;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;;;
|
||||
;;; An ITERATION is a convenient manner of writing a complex
|
||||
;;;LISP looping expression when control is desired of various
|
||||
;;;aspects of the iteration which make the system-provided
|
||||
;;;functions (e.g., MAPCAR, DO) too rigid or too cumbersome.
|
||||
;;;
|
||||
;;; An iteration statement consists of a number of clauses,
|
||||
;;;described below, written in succession within a single S-EXPR.
|
||||
;;;
|
||||
;;; Every iteration has at most one MAIN CLAUSE, which
|
||||
;;;controls what, if anything, is collected as the result of the
|
||||
;;;iteration. The default provided main clauses are:
|
||||
;;;
|
||||
;;; DO (or DOING) -- evaluated for side-effect only; return is
|
||||
;;; NIL.
|
||||
;;; COLLECT -- A list of the values of every evaluation of the
|
||||
;;; main clause is returned (c.f. MAPCAR).
|
||||
;;; JOIN -- The values of every evaluation of the main clause
|
||||
;;; are NCONCed together to form the value (c.f.
|
||||
;;; MAPCAN).
|
||||
;;; ADJOIN -- Like JOIN, but joining is by APPEND rather than
|
||||
;;; NCONC. Every joined segment is copied exactly
|
||||
;;; once, even if there is only one segment.
|
||||
;;; COUNT -- The number of non-NIL values of the evaluations of
|
||||
;;; the main clause is returned.
|
||||
;;; SUM -- The sum of the values of the evaluations of the main
|
||||
;;; clause is returned.
|
||||
;;; FIRST-TIME -- The value of the iteration is the first
|
||||
;;; non-NIL value of the main clause, and iteration
|
||||
;;; terminates when and if this occurs.
|
||||
;;; PRINT (or PRINTING) -- PRINT's the values of the evaluations
|
||||
;;; of the main clause.
|
||||
;;; RESULT -- Sets the RESULT variable to the value of the expression
|
||||
;;; and exits.
|
||||
;;;
|
||||
;;;Other main clauses may be added. Each must be signalled by a
|
||||
;;;keyword marked by the !FUNCTION property with an appropriate
|
||||
;;;function to fill in the iteration template for it.
|
||||
;;;
|
||||
;;;
|
||||
;;; The binding of LOOP VARIABLES and AUXILLIARY VARIABLES is
|
||||
;;;controlled by the BIND, FOR and AS clauses. The BIND keyword is
|
||||
;;;followed by the variables or (variable initial-val) or
|
||||
;;;(variable-structure initial-val) <as in LET> forms to be
|
||||
;;;bound. Those variables are bound, and the initial-vals are evaluated
|
||||
;;;before any of the bindings for this iteration. The FOR and AS
|
||||
;;;clauses are equivalent and provide a way to have several loop
|
||||
;;;variables. The keyword is followed by the name of the variable, and
|
||||
;;;optionally by FIXNUM, FLONUM, or NOTYPE. NOTYPE is the default
|
||||
;;;except for numeric (FROM, TO, DOWNTO, BY) variables, for which it is
|
||||
;;;FIXNUM. An appropriate declaration to the compiler is made. The rest
|
||||
;;;of each variable clause has one of the following forms:
|
||||
;;;
|
||||
;;; FROM e1 TO e2 BY e3 -- This is the numeric iteration clause.
|
||||
;;; Its terms may appear in any order. Instead of
|
||||
;;; the TO, we may have a DOWNTO term to indicate
|
||||
;;; that the loop is for decrementing the var. FROM
|
||||
;;; defaults to 1, BY to 1 with TO and -1 with
|
||||
;;; DOWNTO. Incrementing is assumed if neither is
|
||||
;;; stated. (Currently, no checking is performed to
|
||||
;;; see that the types of args are consistent, and
|
||||
;;; the type of arithmetic used is determined by the
|
||||
;;; type specified. NOTYPE implies general
|
||||
;;; arithmetic, and the default is FIXNUM.)
|
||||
;;; IN list -- This is iteration over a list. The var gets
|
||||
;;; successive elements of the list.
|
||||
;;; ON list -- This is iteration over successive tails of the
|
||||
;;; list.
|
||||
;;; STARTING e1 STEPPING e2 -- This is a general form for giving
|
||||
;;; initial and incremental values. The terms may
|
||||
;;; be in either order. STARTING defaults to NIL,
|
||||
;;; and if STEPPING is omitted, no stepping action
|
||||
;;; is set up.
|
||||
;;; TRAILING v1, or TRAILS v1 -- The iteration variable will take on the
|
||||
;;; value that v1 had on the previous iteration. V1 should
|
||||
;;; be some other iteration variable of this iteration. On
|
||||
;;; the first iteration, since there is no previous value of
|
||||
;;; v1, we use NIL.
|
||||
;;; SET-TO e1, or = e1 -- On each iteration, e1 is evaluated and
|
||||
;;; assigned to the variable. This is most useful when e1
|
||||
;;; is expressed in terms of some other iteration
|
||||
;;; variable(s). E1 is always computed in terms of the new
|
||||
;;; values of the iteration variables, not the old.
|
||||
;;; BEING pathname OF e1, or
|
||||
;;; BEING e1 AND ITS pathname -- These are the exclusive and
|
||||
;;; inclusive forms of the PATH ITERATION.
|
||||
;;; Pathnames must be explicitly marked by the
|
||||
;;; !PATH-FUNCTION property with a function to
|
||||
;;; process them. This is a special feature, most
|
||||
;;; useful for LMS and OWL, and in this package
|
||||
;;; there are no paths defined by default. The
|
||||
;;; keyword ALONG is synonymous with BEING. Note
|
||||
;;; that there are variants of these subclauses, not
|
||||
;;; described here, that are specifically tailored
|
||||
;;; for iterating through the objects in a zone of
|
||||
;;; an LMS node; these variants are recognized by
|
||||
;;; the fact that EACH occurs where the pathname or
|
||||
;;; ITS would normally have occurred.
|
||||
;;;
|
||||
;;; The sub-keywords like FROM, IN, etc., are recognized by having an
|
||||
;;;!ITER-FUNCTION property; thus, others may be added to the package.
|
||||
;;;
|
||||
;;; TERMINATION CLAUSES allow specification of additional
|
||||
;;; iteration termination conditions beyond any that are
|
||||
;;; implied by FOR and AS clauses. The following exist:
|
||||
;;;
|
||||
;;; WHILE e1 -- e1 is evaluated at the beginning of each
|
||||
;;; iteration, and the iteration terminates when e1
|
||||
;;; is NIL.
|
||||
;;; UNTIL e1 -- like WHILE but terminates when e1 is non-NIL.
|
||||
;;; REPEAT-WHILE e1 -- e1 is evaluated at the end of each
|
||||
;;; iteration, and the iteration terminates when e1
|
||||
;;; is NIL; this guarantees at least one
|
||||
;;; iteration.
|
||||
;;; REPEAT-UNTIL e1 -- like REPEAT-WHILE but terminates when e1 is
|
||||
;;; non-NIL.
|
||||
;;;
|
||||
;;;
|
||||
;;; A SELECTION-CLAUSE is a filter on which iteration the
|
||||
;;;main clause should be evaluated. A conjunction is implied if more
|
||||
;;; than one selection exists. The following exist:
|
||||
;;; WHEN e1 -- The main clause is evaluated if e1 is non-NIL.
|
||||
;;; UNLESS e1 -- The main clause is evaluated if e1 is NIL.
|
||||
;;;
|
||||
;;;
|
||||
;;; The PERIPHERAL CLAUSES are of three kinds:
|
||||
;;;
|
||||
;;; FIRST e1 -- Evaluates e1 after initially binding the vars
|
||||
;;; but before starting the first iteration.
|
||||
;;; FINALLY e1 -- Evaluates e1 after exiting the last iteration
|
||||
;;; but before returning the answer. If the main
|
||||
;;; clause is a value-returning clause, the result
|
||||
;;; to be returned is in the variable RESULT (see notes).
|
||||
;;; EACH-TIME e1 -- Evaluates e1 on every iteration of the loop,
|
||||
;;; whether or not the selection test is passed.
|
||||
;;;
|
||||
|
||||
;;*page
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; CAVEATS ;;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;;;
|
||||
;;;
|
||||
;;; A few notes should be made about implementation features
|
||||
;;;which affect the evaluation of iteration forms:
|
||||
;;;
|
||||
;;; 1. Like in the LISP DO, initialization and updating of the
|
||||
;;;iteration variables takes place in parallel. Only SET-TO varaibles
|
||||
;;;and their internally generated equivalents (e.g., "X in Y") are done
|
||||
;;;after the others, and these should never lead to trouble. This is a
|
||||
;;;significant change from earlier versions of the FOR package.
|
||||
;;;
|
||||
;;; 2. The iteration statement is translated to a LISP DO. In
|
||||
;;;particular, this means that a (RETURN val) form may be
|
||||
;;;evaluated at any place to return that particular val as the
|
||||
;;;value of the iteration. If it is desired that any FINALLY
|
||||
;;;clauses be evaluated and the value returned, then the
|
||||
;;; following may be done:
|
||||
;;; (SETQ RESULT val), if appropriate and if the main clause
|
||||
;;; is value-returning
|
||||
;;; (TERMINATE-ITERATION)
|
||||
;;;Note that the RESULT clause may be used in many cases where this is
|
||||
;;;desired.
|
||||
;;;
|
||||
;;; 3. Wherever possible, the order of evaluation of
|
||||
;;;expressions whose evaluation order is not otherwise
|
||||
;;;constrained is that suggested by the order of writing them in
|
||||
;;;the iteration statement. This is only of significance if
|
||||
;;;significant use of side effects is made.
|
||||
;;;
|
||||
;;; 4. Wherever a single expression may appear, more than one
|
||||
;;;may appear. They will be implicitly surrounded by a PROGN,
|
||||
;;;so all but the last will be evaluated for side effect only.
|
||||
;;;
|
||||
;;; 5. The name RESULT, in which the value of value-collecting
|
||||
;;;iterations is built up, is selected only by default. If the
|
||||
;;;value of the variable !RESULT-NAME is bound, that will be
|
||||
;;;used instead.
|
||||
;;;
|
||||
;;; 6. Almost no error checking is currently done, so it is
|
||||
;;;possible to get weird errors if the iterative statement is
|
||||
;;;not well-formed.
|
||||
;;;
|
||||
;;; 7. This code is written using (I think) only one macro,
|
||||
;;;!PUSH, which is not part of the standard LISP complement.
|
||||
;;;!PUSH is defined herein to be equivalent to PUSH with its
|
||||
;;;arguments reversed, except that it only works for simple
|
||||
;;;(atomic) variables.
|
||||
;;;
|
||||
;;; 8. For efficiency, translations produced by these macros
|
||||
;;;are saved in the array !MACRO-EXPANSIONS and further calls on
|
||||
;;;the same form are translated by retrieval rather than
|
||||
;;;recomputation. This, however, may cause some problems: For
|
||||
;;;efficiency considerations (i.e., SXHASH or EQUAL are slow),
|
||||
;;;retrieval is done by EQ comparison on the form. Thus, if the
|
||||
;;;form has been edited since its original translation, an
|
||||
;;;incorrect translation will be retrieved. Further, since all
|
||||
;;;translated forms are referred to from !MACRO-EXPANSIONS, many
|
||||
;;;un-garbage-collectable obsolete copies of a form can be
|
||||
;;;retained during debugging runs. (E.g., if one keeps
|
||||
;;;redefining some function which includes macro calls. For
|
||||
;;;anyone who thinks they can solve this problem by retrieval on
|
||||
;;;the MAKNUM of the form or by making the array untraced by the
|
||||
;;;GC, be warned that either "fix" causes mis-translations.) The
|
||||
;;;function !MACRO-FLUSH is provided to flush all existing
|
||||
;;;translations and guarantee that new translations of all these
|
||||
;;;macro forms are made. This also releases for
|
||||
;;;garbage-collection all the "old" forms which are only pointed
|
||||
;;;at by this translation mechanism.
|
||||
1149
src/libdoc/for.psz7
Executable file
1149
src/libdoc/for.psz7
Executable file
File diff suppressed because it is too large
Load Diff
307
src/libdoc/gcdemn.999999
Executable file
307
src/libdoc/gcdemn.999999
Executable file
@@ -0,0 +1,307 @@
|
||||
;;; GCDEMN -*-LISP-*-
|
||||
;;; **************************************************************
|
||||
;;; ***** MACLISP ******* Standard GC-DAEMON function ************
|
||||
;;; **************************************************************
|
||||
;;; ** (C) COPYRIGHT 1981 MASSACHUSETTS INSTITUTE OF TECHNOLOGY **
|
||||
;;; ****** THIS IS A READ-ONLY FILE! (ALL WRITES RESERVED) *******
|
||||
;;; **************************************************************
|
||||
|
||||
;; Note that "HERALD" call is below, to insure that the addition
|
||||
;; to GC-DAEMON has occured before the VERSION property is put
|
||||
;; (HERALD GCDEMN /14)
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; This is a dynamic garbage collector daemon which tries to predict
|
||||
;;; consing in the various spaces based on past performance and thus to
|
||||
;;; set space sizes such that garbage collection is minimized.
|
||||
;;;
|
||||
;;; The algorithm is from Henry Baker and the program is his with minor
|
||||
;;; modifications. JONL maintained Baker's code between 1978 and 1980,
|
||||
;;; and PSZ made significant modifications on July 12, 1980. GSB added
|
||||
;;; some type-declarations, and added a separater gc-statistics print
|
||||
;;; switch on Feb 6, 1981; GSB and JONL added some efficiency hacks
|
||||
;;; to do less consing on Feb 6-7, 1981, and to use HERALD
|
||||
;;; GSB hacked the gc-statistics print switch to be more usable Feb. 19,
|
||||
;;; 1981; the variable GC-DAEMON-PRINT should have as its value a variable
|
||||
;;; which will be SYMEVALed to see if the gc-daemon should print statistics.
|
||||
;;; By default its value is ^D, causing the gc-daemon to print statistics
|
||||
;;; when the Lisp gc does.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; For historical purposes, the original CGOL code is reproduced
|
||||
;;; here as commentary. All running code is now in LISP
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; (cgol)
|
||||
;;
|
||||
;; declare(muzzled(t)) % Shut up about closed compilation. %
|
||||
;;
|
||||
;; % GC-daemon for optimal allocation. %
|
||||
;; % Described in AI Working Paper #142. %
|
||||
;; % set "alloc-mark-ratio" to a flonum between 0.2 and 5.0. %
|
||||
;;
|
||||
;; sstatus(who1,42.,"%",118.,0.) % Set up "who" line on tv's. %
|
||||
;; sstatus(gcwho,3.)
|
||||
;; who3 := "GCDEMN"
|
||||
;;
|
||||
;; % Initialize property lists of space names. %
|
||||
;; let gc_daemon=
|
||||
;; '\spacelist;
|
||||
;; (let alloct=nil.alloc(t);
|
||||
;; for element in spacelist
|
||||
;; do (let space = car(element),
|
||||
;; freebefore = cadr(element),
|
||||
;; freeafter = caddr(element),
|
||||
;; sizebefore = cadddr(element),
|
||||
;; sizeafter = car(cddddr(element));
|
||||
;; % Initialize state of each space for gc-daemon. %
|
||||
;; accessible ofq space := sizeafter-freeafter;
|
||||
;; % Make sure that we don't get a gc-overflow interrupt. %
|
||||
;; alloc([space,[max(512.,car(space of alloct) or sizeafter),
|
||||
;; 262143.,
|
||||
;; if sizeafter>0 then 32. else 0.]])))'
|
||||
;; in gc()
|
||||
;;
|
||||
;; alloc_mark_ratio := 1.0
|
||||
;;
|
||||
;; special alloc_mark_ratio
|
||||
;;
|
||||
;; define "GC-DAEMON" (spacelist);
|
||||
;; let total_accessible = 0.0,
|
||||
;; total_consed = 0.0;
|
||||
;; % Go through spaces and accumulate consed and accessible
|
||||
;; information. %
|
||||
;; for element in spacelist % Argument is "alist" of spaces. %
|
||||
;; do (let space = car(element), % Give names to parameters. %
|
||||
;; freebefore = cadr(element),
|
||||
;; freeafter = caddr(element),
|
||||
;; sizebefore = cadddr(element),
|
||||
;; sizeafter = car(cddddr(element));
|
||||
;; % Compute consed since last gc and accessible now for this space. %
|
||||
;; consed ofq space := sizebefore-freebefore-accessible ofq space;
|
||||
;; total_consed := total_consed + consed ofq space;
|
||||
;; accessible ofq space := sizeafter-freeafter;
|
||||
;; total_accessible := total_accessible + accessible ofq space);
|
||||
;; % Store total consed, total accessible and compute total free. %
|
||||
;; consed ofq 'total_storage' := total_consed;
|
||||
;; accessible ofq 'total_storage' := total_accessible;
|
||||
;; let total_free = alloc_mark_ratio * total_accessible;
|
||||
;; free ofq 'total_storage' := total_free;
|
||||
;; % Go through spaces and re-allocate where necessary. %
|
||||
;; for element in spacelist
|
||||
;; do (let space = car element;
|
||||
;; alloc_rate ofq space := consed ofq space / total_consed;
|
||||
;; free ofq space := fix(total_free * alloc_rate ofq space);
|
||||
;; let spcsize = accessible ofq space + free ofq space + 511.;
|
||||
;; if spcsize>511. then alloc([space,[spcsize,262143.,32.]]))
|
||||
;;
|
||||
;; gc_daemon := 'gc_daemon'
|
||||
;;
|
||||
;; =exit
|
||||
|
||||
|
||||
(declare (setq USE-STRT7 T)
|
||||
(special GCDEMN-SETUP-1/|) )
|
||||
|
||||
(defvar ALLOC-MARK-RATIO 1.0)
|
||||
(defvar FILL-STORAGE-FRACTION 0.5)
|
||||
; We SYMEVAL this to see if we want to print statistics.
|
||||
(defvar GC-DAEMON-PRINT '^D)
|
||||
|
||||
(eval-when (eval compile)
|
||||
(defmacro fix-to-float (x)
|
||||
`(float (fixnum-identity ,x)))
|
||||
(defmacro float-to-fix (x)
|
||||
`(ifix (flonum-identity ,x)))
|
||||
(defmacro defmaxmin (max-name min-name type
|
||||
&aux (v1 (gensym)) (v2 (gensym)))
|
||||
|
||||
`(progn 'compile
|
||||
(defmacro ,max-name (arg1 arg2)
|
||||
(list '(lambda (,v1 ,v2)
|
||||
(declare (,type ,v1 ,v2))
|
||||
(cond ((> ,v1 ,v2) ,v1) (t ,v2)))
|
||||
arg1 arg2))
|
||||
(defmacro ,min-name (arg1 arg2)
|
||||
(list '(lambda (,v1 ,v2)
|
||||
(declare (,type ,v1 ,v2))
|
||||
(cond ((< ,v1 ,v2) ,v1) (t ,v2)))
|
||||
arg1 arg2))))
|
||||
(defmaxmin max$ min$ flonum)
|
||||
(defmaxmin max% min% fixnum)
|
||||
)
|
||||
|
||||
|
||||
(defun GC-DAEMON-PRINT (space cons-rate oldgcsize marked gcsize spcsize)
|
||||
;; We print for each non-empty space the following information:
|
||||
;; CONS-RATE The % of conses since the last GC which were for
|
||||
;; this space.
|
||||
;; OLDGCSIZE Size of the space in words before GC.
|
||||
;; MARKED Number of words marked as "in use" by GC.
|
||||
;; GCSIZE Size in words recommended by daemon.
|
||||
;; SPCSIZE (if present) Actual size of space if different from size.
|
||||
((lambda (base *nopoint f)
|
||||
(setq cons-rate (fix (*$ cons-rate 100.0)))
|
||||
(and (< (linel f)
|
||||
(+ (flatc space) (flatc cons-rate) (flatc oldgcsize)
|
||||
(flatc marked) (flatc gcsize) (flatc spcsize) 10.
|
||||
(charpos f)))
|
||||
(princ '|
|
||||
; | msgfiles))
|
||||
(princ space msgfiles)
|
||||
(princ '| | msgfiles)
|
||||
(princ cons-rate msgfiles)
|
||||
(princ '|%[| msgfiles)
|
||||
(princ oldgcsize msgfiles)
|
||||
(princ '|->| msgfiles)
|
||||
(princ marked msgfiles)
|
||||
(princ '|//| msgfiles)
|
||||
(princ gcsize msgfiles)
|
||||
(cond ((not (= spcsize gcsize))
|
||||
(princ '|//| msgfiles) (princ spcsize msgfiles)))
|
||||
(princ '|] | msgfiles))
|
||||
10. t (cond ((or (memq tyo msgfiles) (and (not ^w) (memq t msgfiles)))
|
||||
tyo)
|
||||
((car (delq t (append msgfiles nil))))
|
||||
(t tyo))))
|
||||
|
||||
|
||||
|
||||
(DEFUN BAKER-GC-DAEMON (SPACELIST)
|
||||
((LAMBDA (RUNTIME TOTAL-ACCESSIBLE TOTAL-CONSED MEMFREE)
|
||||
(declare (fixnum runtime) (flonum total-accessible total-consed))
|
||||
(MAPC
|
||||
(FUNCTION
|
||||
(LAMBDA (ELEMENT)
|
||||
((LAMBDA (SPACE FREEBEFORE FREEAFTER SIZEBEFORE SIZEAFTER)
|
||||
; No point in declarations, they only pessimize the compiler,
|
||||
; in this case.
|
||||
(PUTPROP SPACE (- SIZEBEFORE FREEBEFORE (GET SPACE 'ACCESSIBLE))
|
||||
'CONSED)
|
||||
(SETQ TOTAL-CONSED (+$ TOTAL-CONSED (fix-to-float (GET SPACE 'CONSED))))
|
||||
(PUTPROP SPACE (- SIZEAFTER FREEAFTER) 'ACCESSIBLE)
|
||||
(SETQ TOTAL-ACCESSIBLE (+$ TOTAL-ACCESSIBLE
|
||||
(fix-to-float (GET SPACE 'ACCESSIBLE)))))
|
||||
(CAR ELEMENT) (CADR ELEMENT) (CADDR ELEMENT)
|
||||
(CADDDR ELEMENT) (CAR (CDDDDR ELEMENT)))))
|
||||
SPACELIST)
|
||||
(PUTPROP 'TOTAL-STORAGE TOTAL-CONSED 'CONSED)
|
||||
(PUTPROP 'TOTAL-STORAGE TOTAL-ACCESSIBLE 'ACCESSIBLE)
|
||||
((LAMBDA (TOTAL-FREE alloct ALLOC-LIST
|
||||
ALLOC-LIST-1 SPACE-HACK SPACE-HACK-1)
|
||||
(declare (flonum total-free))
|
||||
(PUTPROP 'TOTAL-STORAGE TOTAL-FREE 'FREE)
|
||||
(and (symeval gc-daemon-print)
|
||||
((lambda (base *nopoint)
|
||||
; Kludge: if the GC printed, we do NOT want an extra newline; but
|
||||
; if it do not, we need to print one ourselves.
|
||||
(or ^d (terpri msgfiles))
|
||||
(princ '|;GC-DAEMON: cons-rate%[oldgcsize->marked//gcsize//spcsize]
|
||||
; Consed=|
|
||||
msgfiles)
|
||||
(princ (fix total-consed) msgfiles)
|
||||
(princ '|, Marked=| msgfiles)
|
||||
(princ (fix total-accessible) msgfiles)
|
||||
(princ '|, Allocated//Marked=| msgfiles)
|
||||
(princ alloc-mark-ratio msgfiles)
|
||||
(princ '|, Memfree= | msgfiles)
|
||||
(princ memfree msgfiles)
|
||||
(princ '|
|
||||
; | msgfiles))
|
||||
10. t))
|
||||
(MAPC
|
||||
(FUNCTION
|
||||
(LAMBDA (ELEMENT)
|
||||
((LAMBDA (SPACE)
|
||||
((lambda (alloc-rate)
|
||||
(declare (flonum alloc-rate))
|
||||
(putprop space alloc-rate 'alloc-rate)
|
||||
(putprop space (fix (*$ total-free alloc-rate)) 'free))
|
||||
(//$ (fix-to-float (get space 'consed)) total-consed))
|
||||
((LAMBDA (SPCSIZE)
|
||||
(declare (fixnum spcsize))
|
||||
(and (symeval gc-daemon-print)
|
||||
(get alloct space)
|
||||
(gc-daemon-print
|
||||
space
|
||||
(get space 'alloc-rate)
|
||||
(car (get alloct space))
|
||||
(get space 'accessible)
|
||||
(* 512. (// spcsize 512.))
|
||||
(status spcsize space)))
|
||||
(COND ((GREATERP SPCSIZE 511.)
|
||||
(OR ALLOC-LIST
|
||||
(SETQ ALLOC-LIST
|
||||
(LIST NIL (SETQ ALLOC-LIST-1
|
||||
(LIST NIL 262143. NIL)))
|
||||
SPACE-HACK
|
||||
(LIST 'SPCSIZE
|
||||
(CONS 'QUOTE (SETQ SPACE-HACK-1
|
||||
(LIST NIL))))))
|
||||
(rplaca space-hack-1 space)
|
||||
(RPLACA
|
||||
(CDDR (RPLACA ALLOC-LIST-1
|
||||
(max% SPCSIZE
|
||||
(apply 'status space-hack))))
|
||||
(cond ((eq space 'list) 200.) (t 32.)))
|
||||
(ALLOC (RPLACA ALLOC-LIST SPACE)))))
|
||||
(+ (GET SPACE 'ACCESSIBLE) (GET SPACE 'FREE) 511.)))
|
||||
(CAR ELEMENT))))
|
||||
SPACELIST)
|
||||
(and (symeval gc-daemon-print) (terpri msgfiles)))
|
||||
(min$ (*$ ALLOC-MARK-RATIO TOTAL-ACCESSIBLE)
|
||||
(*$ (fix-to-float memfree) fill-storage-fraction))
|
||||
(cons nil (alloc t)) NIL NIL NIL NIL)
|
||||
; Finally, add our runtime into the total gc-time.
|
||||
(setq runtime (- (status gctime) runtime))
|
||||
(sstatus gctime (+ (runtime) runtime))
|
||||
)
|
||||
(runtime) 0.0 0.0 (status memfree)))
|
||||
|
||||
|
||||
|
||||
|
||||
;; This function takes relatively little space, in comparison to all that
|
||||
;; needed for the names of the variables used. If run as expr code,
|
||||
;; these symbols would never go away.
|
||||
|
||||
(defun GCDEMN-SETUP-1/| (x)
|
||||
(let (((space freebefore freeafter sizebefore sizeafter) x))
|
||||
;;The variable GCDEMN-SETUP-1/| has been set to `(() ,.(alloc t))
|
||||
(putprop space (- sizeafter freeafter) 'ACCESSIBLE)
|
||||
(let ((spacesize (or (car (get GCDEMN-SETUP-1/| space))
|
||||
sizeafter))
|
||||
(spacemin (cond ((not (> sizeafter 0)) () )
|
||||
((eq space 'LIST) 200.)
|
||||
(32.))))
|
||||
(if (< spacesize 512.) (setq spacesize 512.))
|
||||
(alloc `(,space (,spacesize 262143. ,spacemin))))))
|
||||
|
||||
(cond
|
||||
;;If this file is loaded more than once, then don't 'push' onto
|
||||
;; the GC-DAEMON variable again.
|
||||
((or (get 'GCDEMN 'VERSION) (eq gc-daemon 'baker-gc-daemon)))
|
||||
(T (cond ((status SSTATUS GCWHO)
|
||||
(sstatus WHO1 42. '% 118. 0.)
|
||||
(sstatus GCWHO 3.)
|
||||
(sstatus WHO3 'GCDEMN) ))
|
||||
;;; Initially set things up
|
||||
(let ((GCDEMN-SETUP-1/| `(() ,.(alloc t)))
|
||||
(GC-DAEMON #'(lambda (z) (mapc #'GCDEMN-SETUP-1/| z))) )
|
||||
(gc))
|
||||
(setq GC-DAEMON
|
||||
(cond ((null GC-DAEMON) 'BAKER-GC-DAEMON)
|
||||
((let ((x (gensym)))
|
||||
`(LAMBDA (,x)
|
||||
(,.(cond ((or (symbolp gc-daemon)
|
||||
(and (not (atom gc-daemon))
|
||||
(eq (car gc-daemon) 'LAMBDA)))
|
||||
`(,gc-daemon))
|
||||
(`(FUNCALL ',gc-daemon)))
|
||||
,x)
|
||||
(BAKER-GC-DAEMON ,x)))))) ))
|
||||
|
||||
(herald GCDEMN /14)
|
||||
285
src/libdoc/genfns.71
Executable file
285
src/libdoc/genfns.71
Executable file
@@ -0,0 +1,285 @@
|
||||
;;; GENFNS -*-LISP-*-
|
||||
;;; **************************************************************
|
||||
;;; ***** MACLISP ****** LISP FUNCTIONS ENUMERATOR (GENFNS) ******
|
||||
;;; **************************************************************
|
||||
;;; ** (C) COPYRIGHT 1979 MASSACHUSETTS INSTITUTE OF TECHNOLOGY **
|
||||
;;; ****** THIS IS A READ-ONLY FILE! (ALL WRITES RESERVED) *******
|
||||
;;; **************************************************************
|
||||
|
||||
;;; To use this file, simply get a current LISP, load this file in,
|
||||
;;; and do (GENFNS). It will then produce the summary file QIOORD
|
||||
;;; Its purpose is to produce a listing of all function names and
|
||||
;;; variables in the initial LISP; for output, it will make the file
|
||||
;;; .INFO.;QIOORD verno on ITS systems
|
||||
;;; <MACLISP>QIOORD.DOC.verno on DEC20 systems
|
||||
;;; LISP:QIOORD.DOC on DEC10 systems
|
||||
;;; DSK:[MAC,LSP]QIOORD.DOC on the SAIL system
|
||||
;;; To write onto another file, do (GENFNS (DEV USR) FN1 FN2)
|
||||
|
||||
|
||||
(DECLARE (SPECIAL * + - ^R ^W BASE QUUX CHRCT OUTFILES
|
||||
UWRITE LINEL ALLSTATUSOPS)
|
||||
(*FEXPR GENFNS)
|
||||
(*EXPR *GENFNS PRINCRUFT PRINPROPS GETVALUES PRIN10 2PRIN10)
|
||||
(*LEXPR LINEL)
|
||||
(FIXNUM I J NL NC MX SP))
|
||||
|
||||
(SSTATUS FEATURE NOLDMSG)
|
||||
|
||||
(DEFUN GENFNS FEXPR (V)
|
||||
(LET ((^R 'T) (^W 'T) (DEFAULTF DEFAULTF))
|
||||
(COND (V
|
||||
(SETQ V (NAMELIST V))
|
||||
(APPLY 'UWRITE (CAR V))
|
||||
(*GENFNS)
|
||||
(APPLY 'UFILE (CDR V)))
|
||||
((STATUS FEATURE ITS)
|
||||
(UWRITE DSK /.INFO/.)
|
||||
(*GENFNS)
|
||||
(APPLY 'UFILE `(QIOORD ,(status lispversion))))
|
||||
((STATUS FEATURE DEC20)
|
||||
(UWRITE DSK MACLISP)
|
||||
(*GENFNS)
|
||||
(APPLY 'UFILE `((DSK MACLISP) QIOORD DOC ,(status lispversion))))
|
||||
((COND ((STATUS FEATURE SAIL) (UWRITE DSK (MAC LSP)) 'T)
|
||||
((STATUS FEATURE DEC10) (UWRITE LISP) 'T))
|
||||
(*GENFNS)
|
||||
(UFILE QIOORD DOC)))))
|
||||
|
||||
(MAPC (FUNCTION (LAMBDA (X) (PUTPROP X 'LAP 'FUNNYFN)))
|
||||
'(*DELQ *DELETE *APPEND *TIMES *GREAT *LESS
|
||||
*PLUS *NCONC *APPLY *EVAL *PRINT
|
||||
*PRIN1 *PRINC *TERPRI *TYO GETDDTSYM
|
||||
LAPSETUP/| TTSR/| LH/|
|
||||
SQOZ/| PUTDDTSYM GCPROTECT
|
||||
GETMIDASOP PURCOPY PURIFY
|
||||
FASLAPSETUP/| PAGEBPORG))
|
||||
|
||||
(MAPC (FUNCTION (LAMBDA (X) (PUTPROP X 'LAP 'FUNNYVAR)))
|
||||
'(*PURE PURCLOBRL PURE TTSR/| LAPSETUP/|
|
||||
PUTPROP BPORG BPEND GCPROTECT))
|
||||
|
||||
|
||||
(DEFUN INTERNAL-TEST (X)
|
||||
(COND ((GETL X '(FUNNYFN FUNNYVAR)) () )
|
||||
((GET X 'INTERNAL-TEST))
|
||||
((OR (AND (EQ (GETCHAR X 1) '+)
|
||||
(MEMQ (GETCHAR X 2) '(I /i))
|
||||
(MEMQ (GETCHAR X 3) '(N /n))
|
||||
(MEMQ (GETCHAR X 4) '(T /t))
|
||||
(MEMQ (GETCHAR X 5) '(E /e))
|
||||
(MEMQ (GETCHAR X 6) '(R /r))
|
||||
(MEMQ (GETCHAR X 7) '(N /n))
|
||||
(MEMQ (GETCHAR X 8) '(A /a))
|
||||
(MEMQ (GETCHAR X 9) '(L /l))
|
||||
(EQ (GETCHAR X 10.) '/-))
|
||||
(LET ((N (FLATC X)))
|
||||
(DO I 1 (1+ I) (> I N)
|
||||
(AND (MEMQ (GETCHAR X I) '(/| | | |`| |,|))
|
||||
(RETURN 'T)))))
|
||||
(PUTPROP X 'INTERNAL-TEST 'T)
|
||||
'T)))
|
||||
|
||||
|
||||
(SETQ ALLSTATUSOPS '(
|
||||
+ ABBREVIATE ARRAY BPSH BPSL BREAK CHTRAN CLI CRFIL
|
||||
CRUNIT DATE DAYTIME DIVOV DOW EVALHOOK FASLOAD FEATURE
|
||||
FILEMODE FLPDL FLUSH FTV FTVSIZE FTVTITLE FXPDL GCMAX
|
||||
GCMIN GCSIZE GCTIME GCWHO HACTRN HOMEDIR HSNAM ITS JCL
|
||||
JNAME JNUMBER LINMODE LISPVERSION LOSEF MACRO MAR MEMFREE
|
||||
NEWLINE NOFEATURE OSPEED PDL PDLMAX PDLNAMES PDLROOOM
|
||||
PDLSIZE PUNT PURSIZE PURSPACENAMES RANDOM SEGLOG SPCNAMES
|
||||
SPCSIZE SPDL SSTATUS STATUS SUBSYS SYNTAX SYSTEM TABSIZE
|
||||
TERPRI TOPLEVEL TTY TTYCONS TTYINT TTYREAD TTYSCAN TTYSIZE
|
||||
TTYTYPE UDIR UNAME UREAD USERI UUOLINKS UWRITE WHO1 WHO2
|
||||
WHO3 XUNAM _
|
||||
))
|
||||
|
||||
(MAPC '(LAMBDA (X) ((LAMBDA (Y) (COND ((CDDDDR Y) ;PDP-10 ONLY
|
||||
(RPLACD (CDDDDR Y) NIL)
|
||||
(PUTPROP (IMPLODE Y) X 'STATUSOP))))
|
||||
(EXPLODEN X)))
|
||||
ALLSTATUSOPS)
|
||||
|
||||
(DEFUN PRIN10 (X) ((LAMBDA (BASE *NOPOINT) (PRINC X)) 10. T))
|
||||
|
||||
(DEFUN 2PRIN10 (X)
|
||||
((LAMBDA (BASE *NOPOINT)
|
||||
(PRINC (// X 10.))
|
||||
(PRINC (\ X 10.)))
|
||||
10. T))
|
||||
|
||||
(DEFUN PHLATC (F X)
|
||||
(COND (F (FLATC X))
|
||||
((+ 2 (FLATC (CAR X))))))
|
||||
|
||||
(DEFUN PRINCRUFT (M L)
|
||||
(PROG (MX NL NC AT LL)
|
||||
(COND (L (SETQ L (COND ((SETQ AT (ATOM (CAR L)))
|
||||
(SORT L (FUNCTION ALPHALESSP)))
|
||||
((SORTCAR L (FUNCTION ALPHALESSP)))))
|
||||
(TERPRI)
|
||||
(TERPRI)
|
||||
(PRINC M)
|
||||
(TERPRI)
|
||||
(TERPRI)
|
||||
(SETQ MX (DO ((X L (CDR X))
|
||||
(I 0 (MAX I (PHLATC AT (CAR X)))))
|
||||
((NULL X) I)))
|
||||
(SETQ NL (// LINEL (+ MX 4)))
|
||||
(SETQ NC (// (+ (LENGTH L) (1- NL)) NL))
|
||||
(DO ((I NL (1- I)))
|
||||
((PROG2 (SETQ LL (CONS L LL)) (= I 1)))
|
||||
(DO ((J NC (1- J)))
|
||||
((OR (NULL L) (ZEROP J)))
|
||||
(SETQ L (CDR L))))
|
||||
(SETQ LL (NREVERSE LL))
|
||||
(DO ((I NC (1- I)) (SP 0 0))
|
||||
((ZEROP I))
|
||||
(MAP (FUNCTION (LAMBDA (X)
|
||||
(COND ((CAR X)
|
||||
(PRINC '| |)
|
||||
(DO ((J SP (1- J)))
|
||||
((ZEROP J))
|
||||
(PRINC '| |))
|
||||
(COND (AT (PRINC (CAAR X)))
|
||||
(T (PRINC (CDAAR X))
|
||||
(PRINC '| |)
|
||||
(PRINC (CAAAR X))))
|
||||
(SETQ SP (- MX (PHLATC AT (CAAR X))))
|
||||
(RPLACA X (CDAR X))))))
|
||||
LL)
|
||||
(TERPRI))))))
|
||||
|
||||
|
||||
(DEFUN *GENFNS NIL
|
||||
(PROG (DATE TIME USRSUBRS USRLSUBRS USRFSUBRS LAPFNS INTFNS STATUSOPS
|
||||
SYSVARS LAPVARS SYSARRAYS USERAUTOS SYSAUTOS PMFLAG)
|
||||
(TERPRI)
|
||||
(COND ((STATUS FEATURE ITS) (PRINC '|ITS |))
|
||||
((STATUS FEATURE DEC20) (PRINC '|TOPS-20//TENEX |))
|
||||
((STATUS FEATURE SAIL) (PRINC '|SAIL |))
|
||||
((STATUS FEATURE CMU) (PRINC '|CMU |))
|
||||
((STATUS FEATURE TOPS-10) (PRINC '|TOPS-10 |)))
|
||||
(PRINC '|MacLISP |)
|
||||
(PRINC (STATUS LISPVERSION))
|
||||
(PRINC '| Functions and Other Features|)
|
||||
(TERPRI)
|
||||
(PRINC '|This file was created by |)
|
||||
(PRINC (STATUS USERID))
|
||||
(PRINC '| on |)
|
||||
(DO ((X (EXPLODEN (STATUS DOW)) (CDR X))
|
||||
(N 0 40))
|
||||
((NULL X))
|
||||
(TYO (+ (CAR X) N)))
|
||||
(PRINC '|, |)
|
||||
(SETQ DATE (STATUS DATE))
|
||||
(PRINC (DO ((I (CADR DATE) (1- I))
|
||||
(L '(|January| |February| |March| |April| |May| |June|
|
||||
|July| |August| |September| |October|
|
||||
|November| |December|)
|
||||
(CDR L)))
|
||||
((= I 1) (CAR L))))
|
||||
(PRINC '| |)
|
||||
(PRIN10 (CADDR DATE))
|
||||
(PRINC '|, 19|)
|
||||
(PRIN10 (CAR DATE))
|
||||
(SETQ TIME (STATUS DAYTIME))
|
||||
(PRINC '| at |)
|
||||
(AND (> (CAR TIME) 11.)
|
||||
(RPLACA TIME (- (CAR TIME) 12.))
|
||||
(SETQ PMFLAG T))
|
||||
(AND (ZEROP (CAR TIME)) (RPLACA TIME '0))
|
||||
(PRIN10 (CAR TIME))
|
||||
(PRINC '|:|)
|
||||
(2PRIN10 (CADR TIME))
|
||||
(COND (PMFLAG (PRINC '| PM|))
|
||||
((PRINC '| AM|)))
|
||||
(TERPRI)
|
||||
(SETQ LINEL (LINEL (OR UWRITE TYO)))
|
||||
(MAPATOMS (FUNCTION
|
||||
(LAMBDA (QUUX)
|
||||
((LAMBDA (F V)
|
||||
(MAPCAR (FUNCTION (LAMBDA (P)
|
||||
(COND ((MEMQ P '(SUBR FSUBR LSUBR))
|
||||
(COND ((EQ F 'LAP) (PUSH QUUX LAPFNS))
|
||||
((INTERNAL-TEST QUUX) (PUSH QUUX INTFNS))
|
||||
((EQ P 'SUBR) (PUSH QUUX USRSUBRS))
|
||||
((EQ P 'FSUBR) (PUSH QUUX USRFSUBRS))
|
||||
((EQ P 'LSUBR) (PUSH QUUX USRLSUBRS)) ))
|
||||
((EQ P 'VALUE)
|
||||
(COND ((EQ V 'LAP) (PUSH QUUX LAPVARS))
|
||||
(T (PUSH QUUX SYSVARS))))
|
||||
((EQ P 'ARRAY) (PUSH QUUX SYSARRAYS))
|
||||
((EQ P 'AUTOLOAD)
|
||||
(COND ((INTERNAL-TEST QUUX)
|
||||
(PUSH QUUX SYSAUTOS))
|
||||
((PUSH QUUX USERAUTOS))) ))))
|
||||
(STATUS SYSTEM QUUX)))
|
||||
(GET QUUX 'FUNNYFN)
|
||||
(GET QUUX 'FUNNYVAR)))))
|
||||
(MAPC (FUNCTION (LAMBDA (X)
|
||||
(AND (APPLY 'STATUS (LIST 'STATUS X))
|
||||
(PUSH (CONS (OR (GET X 'STATUSOP)
|
||||
((LAMBDA (Y)
|
||||
(COND ((CDDDDR Y) ;PDP-10 ONLY
|
||||
(IMPLODE (APPEND Y '(/ ?))))
|
||||
(T X)))
|
||||
(EXPLODEN X)))
|
||||
(COND ((APPLY 'STATUS
|
||||
(LIST 'SSTATUS X))
|
||||
'*)
|
||||
(T '/ )))
|
||||
STATUSOPS))))
|
||||
(STATUS STATUS))
|
||||
(PRINCRUFT '|User SUBRs:| USRSUBRS)
|
||||
(PRINCRUFT '|User FSUBRs:| USRFSUBRS)
|
||||
(PRINCRUFT '|User LSUBRs:| USRLSUBRS)
|
||||
(PRINCRUFT '|STATUS options (* = can use with SSTATUS too):| STATUSOPS)
|
||||
(PRINCRUFT '|Initial arrays:| SYSARRAYS)
|
||||
(PRINPROPS '|Initial User AUTOLOAD properties:|
|
||||
(MAPCAR (FUNCTION (LAMBDA (X)
|
||||
(CONS X (GET X 'AUTOLOAD))))
|
||||
USERAUTOS))
|
||||
(PRINCRUFT '|LAP and FASLOAD functions:| LAPFNS)
|
||||
(PRINCRUFT '|Internal system functions:| INTFNS)
|
||||
(PRINPROPS '|Internal system AUTOLOAD properties:|
|
||||
(MAPCAR (FUNCTION (LAMBDA (X)
|
||||
(CONS X (GET X 'AUTOLOAD))))
|
||||
SYSAUTOS))
|
||||
(PRINPROPS '|System variables:| (GETVALUES SYSVARS))
|
||||
(PRINPROPS '|LAP and FASLOAD variables:| (GETVALUES LAPVARS))
|
||||
))
|
||||
|
||||
(DEFUN GETVALUES (X)
|
||||
((LAMBDA (^R ^W * + - OUTFILES DEFAULTF UREAD UWRITE)
|
||||
(MAPCAR (FUNCTION (LAMBDA (Y)
|
||||
(CONS Y
|
||||
(COND ((BOUNDP Y)
|
||||
(SYMEVAL Y))
|
||||
(T 'UNBOUND)))))
|
||||
X))
|
||||
NIL NIL '* '+ '- NIL '((DSK LOSER) @ @) NIL NIL))
|
||||
|
||||
(DEFUN PRINPROPS (M L)
|
||||
(COND (L (SETQ L (SORTCAR L (FUNCTION ALPHALESSP)))
|
||||
(TERPRI)
|
||||
(TERPRI)
|
||||
(PRINC M)
|
||||
(TERPRI)
|
||||
(TERPRI)
|
||||
(PRINC '| NAME OF ATOM INITIAL VALUE|)
|
||||
(TERPRI)
|
||||
(TERPRI)
|
||||
(DO ((X L (CDR X)))
|
||||
((NULL X))
|
||||
(PRINC '| |)
|
||||
(PRIN1 (CAAR X))
|
||||
(DO ((I (- 32. (CHARPOS (OR UWRITE T))) (1- I)))
|
||||
((NOT (PLUSP I)))
|
||||
(DECLARE (FIXNUM I))
|
||||
(PRINC '| |))
|
||||
(PRINC '| |)
|
||||
(PRIN1 (CDAR X))
|
||||
(TERPRI)))))
|
||||
|
||||
40
src/libdoc/getsyn.rlb3
Executable file
40
src/libdoc/getsyn.rlb3
Executable file
@@ -0,0 +1,40 @@
|
||||
;-*-LISP-*-
|
||||
|
||||
; getsyntax SUBR 2 args
|
||||
;
|
||||
; (getsyntax c s) returns information about the syntax of the character
|
||||
; c in the readtable. c can be a fixnum which is the Ascii code for a char,
|
||||
; or it can be a character object. s is a symbol selecting which information is
|
||||
; required.
|
||||
; SYNTAX - the syntax bits are returned as a fixnum.
|
||||
; SINGLE - if the syntax of c is that for single character objects,
|
||||
; T is returned; otherwise, NIL.
|
||||
; MACRO - if c is a macro character, the function is returned.
|
||||
; SPLICING - if c is a splicing macro character, the function is
|
||||
; returned.
|
||||
; CHTRAN - returns a character object which is the chtran of c .
|
||||
;;;This really should be in MacLISP!
|
||||
|
||||
(declare (eval (read)))
|
||||
(setsyntax '/ 'macro '(lambda () ((lambda (ibase) (read)) 8.)))
|
||||
|
||||
(defun getsyntax (c s)
|
||||
((lambda (c syn mac)
|
||||
(setq syn (status syntax (+ c 0)) mac (status macro (+ c 0)))
|
||||
(caseq s
|
||||
(syntax syn)
|
||||
(single (= syn 600500))
|
||||
(macro (and (= 0 (boole 1 40 syn)) mac))
|
||||
(splicing (and (= 40 (boole 1 40 syn)) mac))
|
||||
(chtran (ascii (status chtran (+ c 0))))
|
||||
(T (getsyntax c (error '|Bad option - GETSYNTAX| s
|
||||
'wrng-type-arg)))))
|
||||
(do c c c nil
|
||||
(caseq (typep c)
|
||||
(fixnum (return c))
|
||||
(symbol (return (getcharn c 1)))
|
||||
(T (setq c (error '|Bad character type - GETSYNTAX|
|
||||
c 'wrng-type-arg)))))
|
||||
nil nil))
|
||||
|
||||
(declare (eval (read))) (setsyntax '/ 'macro nil)
|
||||
190
src/libdoc/graph$.gjc1
Executable file
190
src/libdoc/graph$.gjc1
Executable file
@@ -0,0 +1,190 @@
|
||||
;;;-*-LISP-*-
|
||||
;;; A graphics utility package. - George Carrette.
|
||||
|
||||
;; Floating-point graphics window.
|
||||
|
||||
(eval-when (eval compile)
|
||||
(or (get 'graphm 'version)
|
||||
(load (list (car (namelist infile)) 'graphm))))
|
||||
|
||||
(graphs-module graph$)
|
||||
|
||||
;;; This is general code for dealing with floating point windows.
|
||||
;;; It will handle scaling and clipping.
|
||||
;;; ________
|
||||
;;; y1 - | |
|
||||
;;; | |
|
||||
;;; | |
|
||||
;;; y0 - --------
|
||||
;;; ' '
|
||||
;;; x0 x1
|
||||
|
||||
(defun graphics-stream NARGS
|
||||
(COMMENT (ARG 1) = GRAPHICS-STREAM
|
||||
(ARG 2) = COMMAND
|
||||
(ARG 3) = X1
|
||||
(ARG 4) = Y1
|
||||
(ARG 5) = X2
|
||||
(ARG 6) = Y2)
|
||||
(LET ((GRAPHICS-STREAM (ARG 1)))
|
||||
(LET ((WINDOW (GRAPHICS-STREAM-WINDOW))
|
||||
(VIEWPORT (GRAPHICS-STREAM-VIEWPORT))
|
||||
(SCALING-COEF (GRAPHICS-STREAM-SCALING-COEF))
|
||||
(WLAST-POS (GRAPHICS-STREAM-WLAST-POS))
|
||||
(OUT-STREAM (GRAPHICS-STREAM-OUT-STREAM)))
|
||||
(caseq (ARG 2)
|
||||
((move-pen)
|
||||
(NARG-CHECK NARGS 4 'GRAPHICS-STREAM)
|
||||
(CALL GRAPHICS-STREAM
|
||||
'draw-line
|
||||
(wlast-pos-x wlast-pos)
|
||||
(wlast-pos-y wlast-pos)
|
||||
(ARG 3) (ARG 4)))
|
||||
((draw-point)
|
||||
(NARG-CHECK NARGS 4 'GRAPHICS-STREAM)
|
||||
(UNLESS (out-of-windowp (ARG 3) (ARG 4))
|
||||
(CALL out-stream
|
||||
'draw-point
|
||||
(scale-x (ARG 3))
|
||||
(scale-y (ARG 4))))
|
||||
(update-wlast-pos (ARG 3) (ARG 4)))
|
||||
((draw-line)
|
||||
(NARG-CHECK NARGS 6 'GRAPHICS-STREAM)
|
||||
(draw-line-clip-X0 (ARG 3) (ARG 4) (ARG 5) (ARG 6))
|
||||
(update-wlast-pos (ARG 5) (ARG 6)))
|
||||
((set-pen)
|
||||
(NARG-CHECK NARGS 4 'GRAPHICS-STREAM)
|
||||
(update-wlast-pos (ARG 3) (ARG 4)))
|
||||
((tyo)
|
||||
(NARG-CHECK NARGS 3 'GRAPHICS-STREAM)
|
||||
(graphics-stream-tyo out-stream (ARG 3)))
|
||||
((init-scaling)
|
||||
(NARG-CHECK NARGS 2 'GRAPHICS-STREAM)
|
||||
(graph$-set-scaling))
|
||||
((set-window)
|
||||
(NARG-CHECK NARGS 6 'GRAPHICS-STREAM)
|
||||
(setf (window-x0 window) (float (or (ARG 3) (window-x0 window))))
|
||||
(setf (window-x1 window) (float (or (ARG 4) (window-x1 window))))
|
||||
(setf (window-y0 window) (float (or (ARG 5) (window-y0 window))))
|
||||
(setf (window-y1 window) (float (or (ARG 6) (window-y1 window))))
|
||||
(CALL GRAPHICS-STREAM 'init-scaling))
|
||||
((window)
|
||||
(NARG-CHECK NARGS 2 'GRAPHICS-STREAM)
|
||||
(list (window-x0 window)
|
||||
(window-x1 window)
|
||||
(window-y0 window)
|
||||
(window-y1 window)))
|
||||
((viewport)
|
||||
(NARG-CHECK NARGS 2 'GRAPHICS-STREAM)
|
||||
(list (viewport-x0 viewport)
|
||||
(viewport-x1 viewport)
|
||||
(viewport-y0 viewport)
|
||||
(viewport-y1 viewport)))
|
||||
((set-viewport)
|
||||
(NARG-CHECK NARGS 6 'GRAPHICS-STREAM)
|
||||
(setf (viewport-x0 viewport) (ifix (or (ARG 3) (viewport-x0 viewport))))
|
||||
(setf (viewport-x1 viewport) (ifix (or (ARG 4) (viewport-x1 viewport))))
|
||||
(setf (viewport-y0 viewport) (ifix (or (ARG 5) (viewport-y0 viewport))))
|
||||
(setf (viewport-y1 viewport) (ifix (or (ARG 6) (viewport-y1 viewport)))))
|
||||
((which-operations)
|
||||
(NARG-CHECK NARGS 2 'GRAPHICS-STREAM)
|
||||
'(tyo set-pen move-pen init-scaling window
|
||||
viewport set-window set-viewport set-clippingp break))
|
||||
((break)
|
||||
(*break t "graphics"))
|
||||
(t
|
||||
(UNKNOWN-COMMAND (ARG 2) 'GRAPHICS-STREAM))))))
|
||||
|
||||
(defun out-of-windowp (x y)
|
||||
(or (< x (window-x0 window))
|
||||
(> y (window-x1 window))
|
||||
(< x (window-y0 window))
|
||||
(> y (window-y1 window))))
|
||||
|
||||
(defun update-wlast-pos (x y)
|
||||
(setf (wlast-pos-x wlast-pos) x)
|
||||
(setf (wlast-pos-y wlast-pos) y)
|
||||
nil)
|
||||
|
||||
(declare (flonum (y-intercept flonum flonum flonum flonum flonum)))
|
||||
|
||||
;;; Y - YB YB - YA (XA - X) YB + (X - XB) YA
|
||||
;;; ------ = ------- [Y = - -------------------------]
|
||||
;;; X - XB XB - XA XB - XA
|
||||
|
||||
|
||||
(defun y-intercept (XA YA XB YB X)
|
||||
(//$ (+$ (*$ (-$ XA X) YB)
|
||||
(*$ (-$ X XB) YA))
|
||||
(-$ XA XB)))
|
||||
|
||||
|
||||
(DEFUN DRAW-LINE-CLIP-X0 (XA YA XB YB &AUX (V (WINDOW-X0 WINDOW)))
|
||||
(COND ((< XA V)
|
||||
(COND ((< XB V))
|
||||
(T
|
||||
(DRAW-LINE-CLIP-X1 V (Y-INTERCEPT XA YA XB YB V) XB YB))))
|
||||
((< XB V)
|
||||
(DRAW-LINE-CLIP-X1 XA YA V (Y-INTERCEPT XA YA XB YB V)))
|
||||
(T
|
||||
(DRAW-LINE-CLIP-X1 XA YA XB YB))))
|
||||
|
||||
(DEFUN DRAW-LINE-CLIP-X1 (XA YA XB YB &AUX (V (WINDOW-X1 WINDOW)))
|
||||
(COND ((> XA V)
|
||||
(COND ((> XB V))
|
||||
(T
|
||||
(DRAW-LINE-CLIP-Y0 V (Y-INTERCEPT XA YA XB YB V) xb yb))))
|
||||
((> XB V)
|
||||
(DRAW-LINE-CLIP-Y0 XA YA V (Y-INTERCEPT XA YA XB YB V)))
|
||||
(T
|
||||
(DRAW-LINE-CLIP-Y0 XA YA XB YB))))
|
||||
|
||||
(DEFUN DRAW-LINE-CLIP-Y0 (XA YA XB YB &AUX (V (WINDOW-Y0 WINDOW)))
|
||||
(COND ((< YA V)
|
||||
(COND ((< YB V))
|
||||
(T
|
||||
(DRAW-LINE-CLIP-Y1 (X-INTERCEPT XA YA XB YB V) V XB YB))))
|
||||
((< YB V)
|
||||
(DRAW-LINE-CLIP-Y1 XA YA (X-INTERCEPT XA YA XB YB V) V))
|
||||
(T
|
||||
(DRAW-LINE-CLIP-Y1 XA YA XB YB))))
|
||||
|
||||
(DEFUN DRAW-LINE-CLIP-Y1 (XA YA XB YB &AUX (V (WINDOW-Y1 WINDOW)))
|
||||
(COND ((> YA V)
|
||||
(COND ((> YB V))
|
||||
(T
|
||||
(DRAW-LINE-GO (X-INTERCEPT XA YA XB YB V) V XB YB))))
|
||||
((> YB V)
|
||||
(DRAW-LINE-GO XA YA (X-INTERCEPT XA YA XB YB V) V))
|
||||
(T
|
||||
(DRAW-LINE-GO XA YA XB YB))))
|
||||
|
||||
(DEFUN DRAW-LINE-GO (XA YA XB YB)
|
||||
(CALL OUT-STREAM 'DRAW-LINE (SCALE-X XA)(SCALE-Y YA)
|
||||
(SCALE-X XB)(SCALE-Y YB)))
|
||||
|
||||
(defun make-graphics-stream (out-stream)
|
||||
(let ((u (make-graphics-stream-1 out-stream out-stream)))
|
||||
(lexpr-funcall #'set-viewport u (call out-stream 'boundaries))
|
||||
u))
|
||||
|
||||
;;; V = K * W + M K=(v1-v0) / (w1-w0)
|
||||
;;; M= v0 - K * w0
|
||||
;;; the question is when to do the IFIX. For the convenience of having
|
||||
;;; all the coeff flonum I will do it at then end.
|
||||
|
||||
(defun graph$-set-scaling ()
|
||||
(setf (scaling-coef-k-x scaling-coef)
|
||||
(//$ (float (- (viewport-x1 viewport) (viewport-x0 viewport)))
|
||||
(-$ (window-x1 window) (window-x0 window))))
|
||||
(setf (scaling-coef-m-x scaling-coef)
|
||||
(-$ (float (viewport-x0 viewport))
|
||||
(*$ (scaling-coef-k-x scaling-coef) (window-x0 window))))
|
||||
(setf (scaling-coef-k-y scaling-coef)
|
||||
(//$ (float (- (viewport-y1 viewport) (viewport-y0 viewport)))
|
||||
(-$ (window-y1 window) (window-y0 window))))
|
||||
(setf (scaling-coef-m-y scaling-coef)
|
||||
(-$ (float (viewport-y0 viewport))
|
||||
(*$ (scaling-coef-k-y scaling-coef) (window-y0 window))))
|
||||
t)
|
||||
|
||||
340
src/libdoc/graph3.gjc1
Executable file
340
src/libdoc/graph3.gjc1
Executable file
@@ -0,0 +1,340 @@
|
||||
;;;-*-LISP-*-
|
||||
;;; A graphics utility package. - George Carrette.
|
||||
|
||||
;;; 3-D graphics.
|
||||
|
||||
(eval-when (eval compile)
|
||||
(or (get 'graphm 'version)
|
||||
(load (list (car (namelist infile)) 'graphm))))
|
||||
|
||||
(graphs-module graph3)
|
||||
|
||||
;;; in this stream the eye is looking down on the X-Y plane.
|
||||
;;; here is a picture where it is looking right, down on the X-axis.
|
||||
;;;
|
||||
;;; ^
|
||||
;;; | * |
|
||||
;;; | | |
|
||||
;;; | | |
|
||||
;;; | | X-AXIS
|
||||
;;; | | |
|
||||
;;; | | |
|
||||
;;; Z | | |
|
||||
;;; eye <------Z-AXIS----------------|-------------#-
|
||||
;;; | |
|
||||
;;; z-screen z-clip
|
||||
;;;
|
||||
;;;
|
||||
;;; lines are clipped at z-clip
|
||||
|
||||
|
||||
;;; V = T (V1 - V0) + V0
|
||||
;;;
|
||||
;;; [X, Y, Z] = [T (X1 - X0) + X0, Y0 + T (y1 - Y0), T (Z1 - Z0) + Z0]
|
||||
;;;
|
||||
;;; X0 (Z - Z1) + X1 (Z0 - Z) Y0 (Z - Z1) + Y1 (Z0 - Z)
|
||||
;;; X = - -------------------------, Y = - -------------------------
|
||||
;;; Z1 - Z0 Z1 - Z0
|
||||
;;;
|
||||
|
||||
|
||||
(defun z-clip-stream NARGS
|
||||
(COMMENT (ARG 1) = Z-CLIP-STREAM
|
||||
(ARG 2) = COMMAND
|
||||
(ARG 3) = X
|
||||
(ARG 4) = Y
|
||||
(ARG 5) = Z)
|
||||
(LET ((Z-CLIP-STREAM (ARG 1)))
|
||||
(LET ((OUT-STREAM (Z-CLIP-STREAM-OUT-STREAM))
|
||||
(3D-CLIP (Z-CLIP-STREAM-3D-CLIP)))
|
||||
(caseq (ARG 2)
|
||||
((move-pen)
|
||||
(NARG-CHECK NARGS 5 'Z-CLIP-STREAM)
|
||||
(let ((z0 (3d-clip-z 3d-clip))
|
||||
(x0 (3d-clip-x 3d-clip))
|
||||
(y0 (3d-clip-y 3d-clip))
|
||||
(clip (3d-clip-clip 3d-clip)))
|
||||
(cond ((> z0 clip)
|
||||
;; left point must clipped.
|
||||
(cond ((> (ARG 5) clip)
|
||||
;; whole line is clipped.
|
||||
nil)
|
||||
(t
|
||||
(CALL out-stream
|
||||
'set-pen
|
||||
(x-intercept3 z0 x0 (ARG 5) (ARG 3) clip)
|
||||
(y-intercept3 z0 y0 (ARG 5) (ARG 4) clip)
|
||||
clip)
|
||||
(CALL out-stream
|
||||
'move-pen (ARG 3)(ARG 4)(ARG 5)))))
|
||||
((> (ARG 5) clip)
|
||||
;; right point must be clipped.
|
||||
(CALL out-stream 'set-pen x0 y0 z0)
|
||||
(CALL out-stream
|
||||
'move-pen
|
||||
(x-intercept3 z0 x0 (ARG 5) (ARG 3) clip)
|
||||
(y-intercept3 z0 y0 (ARG 5) (ARG 4) clip)
|
||||
clip))
|
||||
(t
|
||||
(CALL out-stream 'set-pen x0 y0 z0)
|
||||
(CALL out-stream 'move-pen (ARG 3) (ARG 4) (ARG 5)))))
|
||||
(alter-3d-clip 3d-clip
|
||||
x (ARG 3)
|
||||
y (ARG 4)
|
||||
z (ARG 5))
|
||||
t)
|
||||
((set-pen)
|
||||
(NARG-CHECK NARGS 5 'Z-CLIP-STREAM)
|
||||
(alter-3d-clip 3d-clip
|
||||
x (ARG 3)
|
||||
y (ARG 4)
|
||||
z (ARG 5))
|
||||
t)
|
||||
((set-clip-z)
|
||||
(NARG-CHECK NARGS 3 'Z-CLIP-STREAM)
|
||||
(setf (3d-clip-clip 3d-clip) (ARG 3))
|
||||
t)
|
||||
(T
|
||||
(UNKNOWN-COMMAND (ARG 2) 'Z-CLIP-STREAM))))))
|
||||
|
||||
|
||||
(defun make-z-clip-stream (out-stream)
|
||||
(make-z-clip-stream-1 out-stream out-stream))
|
||||
|
||||
|
||||
;;; Z - Z X Z - Z
|
||||
;;; EYE SCREEN SCREEN EYE SCREEN
|
||||
;;; -------------- = ------- X = (----------------) X
|
||||
;;; Z - Z X SCREEN Z - Z
|
||||
;;; EYE EYE
|
||||
;;;
|
||||
|
||||
(declare (flonum (x-screen flonum flonum flonum flonum)))
|
||||
|
||||
(defun x-screen (z-eye z-screen z x)
|
||||
(//$ (*$ (-$ z-eye z-screen) x)
|
||||
(-$ z z-eye)))
|
||||
|
||||
(defun z-perspective-stream NARGS
|
||||
(COMMENT (ARG 1) = Z-PERSPECTIVE-STREAM
|
||||
(ARG 1) = COMMAND
|
||||
(ARG 3) = X
|
||||
(ARG 4) = Y
|
||||
(ARG 5) = Z)
|
||||
(LET ((Z-PERSPECTIVE-STREAM (ARG 1)))
|
||||
(let ((out-stream (z-perspective-stream-out-stream))
|
||||
(perspective (z-perspective-stream-perspective)))
|
||||
(caseq (ARG 2)
|
||||
((move-pen set-pen)
|
||||
(NARG-CHECK NARGS 5 'Z-PERSPECTIVE-STREAM)
|
||||
(let ((z-eye (3d-perspective-z-eye perspective))
|
||||
(z-screen (3d-perspective-z-screen perspective)))
|
||||
(CALL out-stream (ARG 2)
|
||||
(x-screen z-eye z-screen (ARG 5) (ARG 3))
|
||||
(y-screen z-eye z-screen (ARG 5) (ARG 4)))))
|
||||
((set-z-eye)
|
||||
(NARG-CHECK NARGS 3 'Z-PERSPECTIVE-STREAM)
|
||||
(setf (3d-perspective-z-eye perspective) (ARG 3))
|
||||
t)
|
||||
((set-z-screen)
|
||||
(NARG-CHECK NARGS 3 'Z-PERSPECTIVE-STREAM)
|
||||
(setf (3d-perspective-z-screen perspective) (ARG 3))
|
||||
t)
|
||||
(T
|
||||
(UNKNOWN-COMMAND (ARG 2) 'Z-PERSPECTIVE-STREAM))))))
|
||||
|
||||
(defun make-z-perspective-stream (out-stream)
|
||||
(make-z-perspective-stream-1 Out-stream out-stream))
|
||||
|
||||
|
||||
;;; orthogonal rotation by the eulerian angles. The convention
|
||||
;;; here is from Goldstein, Classical Mechanics, a worthy source.
|
||||
|
||||
;;; [ COS(PHI) SIN(PHI) 0 ]
|
||||
;;; [ ]
|
||||
;;; D = [ - SIN(PHI) COS(PHI) 0 ]
|
||||
;;; [ ]
|
||||
;;; [ 0 0 1 ]
|
||||
|
||||
|
||||
(defun phi-matrix (phi &optional
|
||||
(m (make-3matrix))
|
||||
&aux (cos-phi (cos phi)) (sin-phi (sin phi)))
|
||||
(alter-3matrix m
|
||||
x-x cos-phi x-y sin-phi x-z 0.0
|
||||
y-x (-$ sin-phi) y-y cos-phi y-z 0.0
|
||||
z-x 0.0 z-y 0.0 z-z 1.0)
|
||||
m)
|
||||
;;;
|
||||
;;; [ 1 0 0 ]
|
||||
;;; [ ]
|
||||
;;; C = [ 0 COS(THETA) SIN(THETA) ]
|
||||
;;; [ ]
|
||||
;;; [ 0 - SIN(THETA) COS(THETA) ]
|
||||
;;;
|
||||
|
||||
(defun theta-matrix (theta &optional
|
||||
(m (make-3matrix))
|
||||
&aux
|
||||
(cos-theta (cos theta))
|
||||
(sin-theta (sin theta)))
|
||||
(alter-3matrix m
|
||||
x-x 1.0 x-y 0.0 x-z 0.0
|
||||
y-x 0.0 y-y cos-theta y-z sin-theta
|
||||
z-x 0.0 z-y (-$ sin-theta) z-z cos-theta)
|
||||
m)
|
||||
;;;
|
||||
;;; [ COS(PSI) SIN(PSI) 0 ]
|
||||
;;; [ ]
|
||||
;;; B = [ - SIN(PSI) COS(PSI) 0 ]
|
||||
;;; [ ]
|
||||
;;; [ 0 0 1 ]
|
||||
|
||||
(defun psi-matrix (psi &optional
|
||||
(m (make-3matrix))
|
||||
&aux
|
||||
(cos-psi (cos psi))
|
||||
(sin-psi (sin psi)))
|
||||
(alter-3matrix m
|
||||
x-x cos-psi x-y sin-psi x-z 0.0
|
||||
y-x (-$ sin-psi) y-y cos-psi y-z 0.0
|
||||
z-x 0.0 z-y 0.0 z-z 1.0)
|
||||
m)
|
||||
|
||||
|
||||
(defun 3matrix-mult (ma mb &optional (m (make-3matrix)))
|
||||
;; this goes to 512 words of pdp10 code. gosh. well, it is fast.
|
||||
(alter-3matrix m
|
||||
x-x (3row*col x z ma mb)
|
||||
x-y (3row*col x y ma mb)
|
||||
x-z (3row*col x x ma mb)
|
||||
|
||||
y-x (3row*col y z ma mb)
|
||||
y-y (3row*col y y ma mb)
|
||||
y-z (3row*col y x ma mb)
|
||||
|
||||
z-x (3row*col z z ma mb)
|
||||
z-y (3row*col z y ma mb)
|
||||
z-z (3row*col z x ma mb))
|
||||
ma)
|
||||
|
||||
|
||||
(defun orthogonal-3d-stream NARGS
|
||||
(COMMENT (ARG 1) = orthogonal-3d-stream
|
||||
(ARG 1) = COMMAND
|
||||
(ARG 3) = X
|
||||
(ARG 4) = Y
|
||||
(ARG 5) = Z)
|
||||
(LET ((orthogonal-3d-stream (ARG 1)))
|
||||
(LET ((OUT-STREAM (orthogonal-3d-stream-OUT-STREAM))
|
||||
(EULER (orthogonal-3d-stream-EULER)))
|
||||
(caseq (ARG 2)
|
||||
((move-pen set-pen)
|
||||
(NARG-CHECK NARGS 5 'orthogonal-3d-stream)
|
||||
(let ((m (euler-rot euler)))
|
||||
(CALL out-stream
|
||||
(ARG 2)
|
||||
(+$ (*$ (ARG 3) (3matrix-x-x m))
|
||||
(*$ (ARG 4) (3matrix-x-y m))
|
||||
(*$ (ARG 5) (3matrix-x-z m)))
|
||||
|
||||
(+$ (*$ (ARG 3) (3matrix-y-x m))
|
||||
(*$ (ARG 4) (3matrix-y-y m))
|
||||
(*$ (ARG 5) (3matrix-y-z m)))
|
||||
|
||||
(+$ (*$ (ARG 3) (3matrix-z-x m))
|
||||
(*$ (ARG 4) (3matrix-z-y m))
|
||||
(*$ (ARG 5) (3matrix-z-z m))))))
|
||||
|
||||
((translate)
|
||||
(NARG-CHECK NARGS 2 'orthogonal-3d-stream)
|
||||
(3matrix-mult (euler-drot euler)
|
||||
(euler-rot euler)
|
||||
(euler-rot euler))
|
||||
t)
|
||||
((translate-psi)
|
||||
(NARG-CHECK NARGS 2 'orthogonal-3d-stream)
|
||||
(3matrix-mult (euler-dpsi euler)
|
||||
(euler-psi euler)
|
||||
(euler-psi euler))
|
||||
(setf (euler-psi-val euler)
|
||||
(+$ (euler-psi-val euler) (euler-dpsi-val euler)))
|
||||
(update-rot-matrix))
|
||||
((translate-theta)
|
||||
(NARG-CHECK NARGS 2 'orthogonal-3d-stream)
|
||||
(3matrix-mult (euler-dtheta euler)
|
||||
(euler-theta euler)
|
||||
(euler-theta euler))
|
||||
(setf (euler-theta-val euler)
|
||||
(+$ (euler-theta-val euler) (euler-dtheta-val euler)))
|
||||
(update-rot-matrix))
|
||||
((translate-phi)
|
||||
(NARG-CHECK NARGS 2 'orthogonal-3d-stream)
|
||||
(3matrix-mult (euler-dphi euler)
|
||||
(euler-phi euler)
|
||||
(euler-phi euler))
|
||||
(setf (euler-phi-val euler)
|
||||
(+$ (euler-phi-val euler) (euler-dphi-val euler)))
|
||||
(update-rot-matrix))
|
||||
((set-psi)
|
||||
(NARG-CHECK NARGS 3 'orthogonal-3d-stream)
|
||||
(alter-euler euler
|
||||
psi-val (ARG 3)
|
||||
psi (psi-matrix (ARG 3) (euler-psi euler)))
|
||||
(update-rot-matrix))
|
||||
((set-theta)
|
||||
(NARG-CHECK NARGS 3 'orthogonal-3d-stream)
|
||||
(alter-euler euler
|
||||
theta-val (ARG 3)
|
||||
theta (theta-matrix (ARG 3) (euler-theta euler)))
|
||||
(update-rot-matrix))
|
||||
((set-phi)
|
||||
(NARG-CHECK NARGS 3 'orthogonal-3d-stream)
|
||||
(alter-euler euler
|
||||
phi-val (ARG 3)
|
||||
phi (phi-matrix (ARG 3) (euler-phi euler)))
|
||||
(update-rot-matrix))
|
||||
((set-dphi)
|
||||
(NARG-CHECK NARGS 3 'orthogonal-3d-stream)
|
||||
(alter-euler euler
|
||||
dphi-val (ARG 3)
|
||||
dphi (phi-matrix (ARG 3) (euler-dphi euler)))
|
||||
(update-drot-matrix))
|
||||
((set-dpsi)
|
||||
(NARG-CHECK NARGS 3 'orthogonal-3d-stream)
|
||||
(alter-euler euler
|
||||
dpsi-val (ARG 3)
|
||||
dpsi (psi-matrix (ARG 3) (euler-dpsi euler)))
|
||||
(update-drot-matrix))
|
||||
((set-dtheta)
|
||||
(NARG-CHECK NARGS 3 'orthogonal-3d-stream)
|
||||
(alter-euler euler
|
||||
dtheta-val (ARG 3)
|
||||
dtheta (theta-matrix (ARG 3) (euler-dtheta euler)))
|
||||
(update-drot-matrix))
|
||||
((get-angles)
|
||||
(NARG-CHECK NARGS 2 'orthogonal-3d-stream)
|
||||
`((psi . ,(euler-psi-val euler))
|
||||
(theta . ,(euler-theta-val euler))
|
||||
(phi . ,(euler-phi-val euler))
|
||||
(dpsi . ,(euler-dpsi-val euler))
|
||||
(dtheta . ,(euler-dtheta-val euler))
|
||||
(dphi . ,(euler-dphi-val euler))))
|
||||
(t
|
||||
(UNKNOWN-COMMAND (ARG 2) 'orthogonal-3d-stream))))))
|
||||
|
||||
|
||||
;;; rot = psi . theta . phi
|
||||
|
||||
(defun update-rot-matrix ()
|
||||
(let ((m (3matrix-copy (euler-phi euler) (euler-rot euler))))
|
||||
(3matrix-mult (euler-theta euler) m m)
|
||||
(3matrix-mult (euler-psi euler) m m)))
|
||||
|
||||
(defun update-drot-matrix ()
|
||||
(let ((m (3matrix-copy (euler-dphi euler) (euler-drot euler))))
|
||||
(3matrix-mult (euler-dtheta euler) m m)
|
||||
(3matrix-mult (euler-dpsi euler) m m)))
|
||||
|
||||
(defun make-orthogonal-3d-stream (out-stream)
|
||||
(make-orthogonal-3d-stream-1 out-stream out-stream))
|
||||
149
src/libdoc/grapha.gjc1
Executable file
149
src/libdoc/grapha.gjc1
Executable file
@@ -0,0 +1,149 @@
|
||||
;;;-*-LISP-*-
|
||||
;;; A graphics utility package. - George Carrette.
|
||||
|
||||
;;; ARDS codes.
|
||||
|
||||
(eval-when (eval compile)
|
||||
(or (get 'graphm 'version)
|
||||
(load (list (car (namelist infile)) 'graphm))))
|
||||
|
||||
(graphs-module grapha)
|
||||
|
||||
;;; local declarations to eliminate fixnum consing.
|
||||
|
||||
(declare (fixnum (ards-basic-1 fixnum)
|
||||
(ards-basic-2 fixnum))
|
||||
(*expr (ards-mode-check-out nil fixnum)
|
||||
(ards-basic-io fixnum fixnum fixnum fixnum)
|
||||
(ards-basic-io-s fixnum fixnum)
|
||||
(ards-set-point-out fixnum fixnum)
|
||||
(ards-long-vector-out fixnum fixnum)
|
||||
(ards-short-vector-out fixnum fixnum)
|
||||
(ards-gen-vector fixnum fixnum)))
|
||||
|
||||
(defun ards-stream NARGS
|
||||
(COMMENT (ARG 1) = ARDS-STREAM
|
||||
(ARG 2) = COMMAND
|
||||
(ARG 3) = X1
|
||||
(ARG 4) = Y1
|
||||
(ARG 5) = X2
|
||||
(ARG 6) = Y2)
|
||||
(LET ((ARDS-STREAM (ARG 1)))
|
||||
(LET ((OUT-STREAM (ARDS-STREAM-OUT-STREAM))
|
||||
(GRAPHIC-MODE (ARDS-STREAM-GRAPHIC-MODE))
|
||||
(INVISIBLEP (ARDS-STREAM-INVISIBLEP))
|
||||
(DOTTEDP (ARDS-STREAM-DOTTEDP))
|
||||
(LAST-POS (ARDS-STREAM-LAST-POS)))
|
||||
(caseq (ARG 2)
|
||||
((move-pen)
|
||||
(NARG-CHECK NARGS 4 'ARDS-STREAM)
|
||||
(ards-gen-vector (- (ARG 3) (ards-last-pos-x last-pos))
|
||||
(- (ARG 4) (ards-last-pos-y last-pos)))
|
||||
(setf (ards-last-pos-x last-pos) (ARG 3))
|
||||
(setf (ards-last-pos-y last-pos) (ARG 4))
|
||||
t)
|
||||
((vector-pen)
|
||||
(NARG-CHECK NARGS 4 'ARDS-STREAM)
|
||||
(ards-gen-vector (ARG 3) (ARG 4))
|
||||
(setf (ards-last-pos-x last-pos)
|
||||
(+ (ards-last-pos-x last-pos) (ARG 3)))
|
||||
(setf (ards-last-pos-y last-pos)
|
||||
(+ (ards-last-pos-y last-pos) (ARG 4)))
|
||||
t)
|
||||
((draw-point)
|
||||
(NARG-CHECK NARGS 4 'ARDS-STREAM)
|
||||
(CALL ards-stream 'set-pen (ARG 3) (ARG 4))
|
||||
(CALL ards-stream 'vector-pen 0 0))
|
||||
((draw-line)
|
||||
(NARG-CHECK NARGS 6 'ARDS-STREAM)
|
||||
(CALL ards-stream 'set-pen (ARG 3) (ARG 4))
|
||||
(CALL ards-stream 'move-pen (ARG 5) (ARG 6)))
|
||||
((set-pen)
|
||||
(NARG-CHECK NARGS 4 'ARDS-STREAM)
|
||||
(cond ((and (= (ARG 3) (ards-last-pos-x last-pos))
|
||||
(= (ARG 4) (ards-last-pos-y last-pos))))
|
||||
(t
|
||||
(ards-mode-check-out 'set-point #/)
|
||||
(ards-set-point-out (ARG 3) (ARG 4))
|
||||
(setf (ards-last-pos-x last-pos) (ARG 3))
|
||||
(setf (ards-last-pos-y last-pos) (ARG 4))
|
||||
t)))
|
||||
((tyo)
|
||||
(NARG-CHECK NARGS 3 'ARDS-STREAM)
|
||||
(ards-gen-tyo (ARG 3)))
|
||||
((SET-DOTTEDP)
|
||||
(NARG-CHECK NARGS 3 'ARDS-STREAM)
|
||||
(setf (ards-stream-dottedp) (ARG 3)))
|
||||
((set-invisiblep)
|
||||
(NARG-CHECK NARGS 3 'ARDS-STREAM)
|
||||
(setf (ards-stream-invisiblep) (ARG 3)))
|
||||
((boundaries)
|
||||
(list (ards-stream-x-min)
|
||||
(ards-stream-x-max)
|
||||
(ards-stream-y-min)
|
||||
(ards-stream-y-max)))
|
||||
((which-operations)
|
||||
(NARG-CHECK NARGS 2 'ARDS-STREAM)
|
||||
'(tyo set-pen move-pen vector-pen draw-point
|
||||
set-dottedp set-invisiblep size))
|
||||
(t
|
||||
(UNKNOWN-COMMAND (ARG 2) 'ARDS-STREAM))))))
|
||||
|
||||
(defun make-ards-stream (s)
|
||||
(make-ards-stream-1 out-stream s))
|
||||
|
||||
(defun ards-mode-check-out (mode signal)
|
||||
(when (not (eq graphic-mode mode))
|
||||
(setq graphic-mode mode)
|
||||
(setf (ards-stream-graphic-mode) mode)
|
||||
(+tyo (+ signal #o200) OUT-STREAM)))
|
||||
|
||||
(defun ards-basic-1 (x)
|
||||
(+ (lsh (logand (abs x) #o37) 1)
|
||||
(if (minusp x) 1 0)
|
||||
#o100))
|
||||
|
||||
(defun ards-basic-2 (x)
|
||||
(+ (logand (lsh (abs x) #o-5) #o37) #o100))
|
||||
|
||||
(defun ards-basic-io (x1 x2 y1 y2)
|
||||
(+tyo x1 OUT-STREAM)
|
||||
(+tyo x2 OUT-STREAM)
|
||||
(+tyo y1 OUT-STREAM)
|
||||
(+tyo y2 OUT-STREAM))
|
||||
|
||||
(defun ards-basic-io-s (x1 y1)
|
||||
(+tyo x1 OUT-STREAM)
|
||||
(+tyo y1 OUT-STREAM))
|
||||
|
||||
|
||||
(defun ards-set-point-out (x y)
|
||||
(ards-basic-io (ards-basic-1 x)
|
||||
(ards-basic-2 x)
|
||||
(ards-basic-1 y)
|
||||
(ards-basic-2 y)))
|
||||
|
||||
|
||||
(defun ards-long-vector-out (x y)
|
||||
(ards-basic-io (ards-basic-1 x)
|
||||
(+ (ards-basic-2 x) (if invisiblep #o40 0))
|
||||
(ards-basic-1 y)
|
||||
(+ (ards-basic-2 y) (if dottedp #o40 0))))
|
||||
|
||||
(defun ards-short-vector-out (x y)
|
||||
(ards-basic-io-s (ards-basic-1 x)
|
||||
(ards-basic-1 y)))
|
||||
|
||||
(defun ards-gen-vector (x y)
|
||||
(declare (fixnum x y))
|
||||
(cond ((and (< (abs x) #o40) (< (abs y) #o40) (not invisiblep) (not dottedp))
|
||||
(ards-mode-check-out 'short-vector #/)
|
||||
(ards-short-vector-out x y))
|
||||
(t
|
||||
(ards-mode-check-out 'long-vector #/)
|
||||
(ards-long-vector-out x y))))
|
||||
|
||||
(defun ards-gen-tyo (C)
|
||||
(ards-mode-check-out nil #/)
|
||||
(tyo C OUT-STREAM))
|
||||
|
||||
280
src/libdoc/graphm.gjc1
Executable file
280
src/libdoc/graphm.gjc1
Executable file
@@ -0,0 +1,280 @@
|
||||
;;;-*-LISP-*-
|
||||
;;; A graphics utility package. - George Carrette.
|
||||
|
||||
;; Macros and compile-time environment.
|
||||
|
||||
(herald graphm)
|
||||
|
||||
;; A form to put at the begining of the modules.
|
||||
;; Works if the modules are in the same directory as
|
||||
;; this macro file.
|
||||
;;
|
||||
;;(eval-when (eval compile)
|
||||
;; (or (get 'graphm 'version)
|
||||
;; (load (list (car (namelist infile)) 'graphm))))
|
||||
;;
|
||||
;; (graphs-module <name>)
|
||||
|
||||
(eval-when (eval compile load)
|
||||
(or (get 'umlmac 'version)
|
||||
(load '((lisp)umlmac)))
|
||||
(or (fboundp 'defstruct)
|
||||
(load (caseq (status opsys)
|
||||
((tops-20)
|
||||
"<GJC>struct")
|
||||
((its)
|
||||
"liblsp;struct")
|
||||
(t
|
||||
(error "unknown opsys" (status opsys) 'fail-act))))))
|
||||
|
||||
(defmacro graphs-module (name)
|
||||
`(progn 'compile
|
||||
(herald ,name)
|
||||
(eval-when (eval)
|
||||
(or (get 'graphs 'version)
|
||||
(load (list (car (namelist infile)) 'graphs))))
|
||||
(eval-when (load)
|
||||
(or (get 'graphs 'version)
|
||||
(load (list (car (namelist (status fasload))) 'graphs))))))
|
||||
|
||||
(defmacro defstream (name &rest slots)
|
||||
`(defstruct (,name named conc-name default-pointer
|
||||
(constructor ,(symbolconc 'make- name '-1)))
|
||||
,@slots))
|
||||
|
||||
;; For GRAPHS module:
|
||||
|
||||
(when (status feature complr)
|
||||
(*expr set-pen move-pen vector-pen draw-point
|
||||
draw-frame NARG-CHECK NARG-ERROR
|
||||
UNKNOWN-COMMAND
|
||||
set-viewport get-viewport set-window get-window
|
||||
call0 call1 call2 call3 call4 call5
|
||||
graphics-stream-tyo
|
||||
)
|
||||
(*lexpr graphics-stream-close graphics-stream-open call
|
||||
make-broadcast-stream
|
||||
make-broadcast-sfa
|
||||
))
|
||||
|
||||
(defstream broadcast-stream
|
||||
out-streams)
|
||||
|
||||
(defstruct (graphics-sfa sfa conc-name
|
||||
(constructor make-graphics-sfa-1))
|
||||
out-stream)
|
||||
|
||||
(defstruct (broadcast-sfa sfa default-pointer conc-name
|
||||
(constructor make-broadcast-sfa-1))
|
||||
l)
|
||||
|
||||
;; For GRAPHA module.
|
||||
|
||||
(WHEN (STATUS FEATURE COMPLR)
|
||||
(*expr make-ards-stream)
|
||||
(special out-stream graphic-mode invisiblep
|
||||
dottedp last-pos
|
||||
ards-stream))
|
||||
|
||||
(defstream ards-stream
|
||||
(out-stream nil)
|
||||
(graphic-mode nil)
|
||||
(invisiblep nil)
|
||||
(dottedp nil)
|
||||
(last-pos (make-ards-last-pos))
|
||||
;; default information for GRAPH$
|
||||
(X-MIN -400.)
|
||||
(X-MAX 400.)
|
||||
(Y-MIN -400.)
|
||||
(Y-MAX 400.)
|
||||
)
|
||||
|
||||
(defstruct (ards-last-pos fixnum-array conc-name) x y)
|
||||
|
||||
;; For GRAPH$ module:
|
||||
|
||||
(WHEN (STATUS FEATURE COMPLR)
|
||||
(SPECIAL GRAPHICS-STREAM WINDOW VIEWPORT SCALING-COEF WLAST-POS
|
||||
OUT-STREAM)
|
||||
(flonum (y-intercept flonum flonum flonum flonum flonum))
|
||||
(*expr y-intercept make-graphics-stream))
|
||||
|
||||
|
||||
(defstream GRAPHICS-STREAM
|
||||
(window (make-window))
|
||||
(viewport (make-viewport))
|
||||
(scaling-coef (make-scaling-coef))
|
||||
(wlast-pos (make-wlast-pos))
|
||||
out-stream
|
||||
)
|
||||
|
||||
(defstruct (window flonum-array conc-name)
|
||||
(x0 -1.0)
|
||||
(x1 +1.0)
|
||||
(y0 -1.0)
|
||||
(y1 +1.0))
|
||||
|
||||
(defstruct (viewport fixnum-array conc-name)
|
||||
(x0 0)
|
||||
(x1 100)
|
||||
(y0 0)
|
||||
(y1 100))
|
||||
|
||||
(defstruct (scaling-coef flonum-array conc-name)
|
||||
k-x k-y m-x m-y)
|
||||
|
||||
(defstruct (wlast-pos flonum-array conc-name)
|
||||
x y)
|
||||
|
||||
(defmacro scale (k w m)
|
||||
`(ifix (+$ (*$ ,k ,w) ,m)))
|
||||
|
||||
(defmacro scale-x (x)
|
||||
`(scale (scaling-coef-k-x scaling-coef)
|
||||
,x
|
||||
(scaling-coef-m-x scaling-coef)))
|
||||
|
||||
(defmacro scale-y (y)
|
||||
`(scale (scaling-coef-k-y scaling-coef)
|
||||
,y
|
||||
(scaling-coef-m-y scaling-coef)))
|
||||
|
||||
|
||||
(DEFMACRO X-INTERCEPT (A B C D E)
|
||||
`(Y-INTERCEPT ,B ,A ,D ,C ,E))
|
||||
|
||||
;; For GRAPH3 module:
|
||||
|
||||
(WHEN (STATUS FEATURE COMPLR)
|
||||
(SPECIAL Z-CLIP-STREAM OUT-STREAM 3D-CLIP
|
||||
Z-PERSPECTIVE-STREAM PERSPECTIVE
|
||||
ORTHOGONAL-3D-STREAM EULER
|
||||
))
|
||||
|
||||
|
||||
(defstream Z-CLIP-STREAM
|
||||
out-stream
|
||||
(3d-clip (make-3d-clip)))
|
||||
|
||||
|
||||
(defstruct (3d-perspective conc-name flonum-array)
|
||||
z-eye z-screen)
|
||||
|
||||
(defstruct (3d-clip conc-name flonum-array)
|
||||
x y z clip)
|
||||
|
||||
|
||||
(defstream Z-PERSPECTIVE-STREAM
|
||||
out-stream
|
||||
(perspective (make-3d-perspective)))
|
||||
|
||||
(defmacro x-intercept3 (z0 x0 z1 x1 z)
|
||||
;; this is not scewed as is the 2-dim case.
|
||||
`(y-intercept ,z0 ,x0 ,z1 ,x1 ,z))
|
||||
|
||||
(defmacro y-intercept3 (z0 y0 z1 y1 z)
|
||||
`(y-intercept ,z0 ,y0 ,z1 ,y1 ,z))
|
||||
|
||||
(defmacro y-screen (z-eye z-screen z y)
|
||||
`(x-screen ,z-eye ,z-screen ,z ,y)))
|
||||
|
||||
(defstruct (3matrix conc-name flonum-array
|
||||
size-macro)
|
||||
x-x x-y x-z
|
||||
y-x y-y y-z
|
||||
z-x z-y z-z)
|
||||
|
||||
(defmacro 3row*col (row col m1 m2)
|
||||
`(+$ (*$ (,(symbolconc '3matrix- row '-x) ,m1)
|
||||
(,(symbolconc '3matrix-x- col) ,m2))
|
||||
(*$ (,(symbolconc '3matrix- row '-y) ,m1)
|
||||
(,(symbolconc '3matrix-y- col) ,m2))
|
||||
(*$ (,(symbolconc '3matrix- row '-z) ,m1)
|
||||
(,(symbolconc '3matrix-z- col) ,m2))))
|
||||
|
||||
(defmacro 3matrix-copy (m1 &optional (m2 (make-3matrix)))
|
||||
`(fillarray ,m2 ,m1))
|
||||
|
||||
;; The euler matrix will keep various matricies around so that
|
||||
;; certain kinds of updates will be efficient.
|
||||
|
||||
(defstruct (euler conc-name)
|
||||
;; matrix used in transformations.
|
||||
(rot (phi-matrix 0.0))
|
||||
;; for differential updates of rot.
|
||||
(drot (phi-matrix 0.0))
|
||||
; for reference.
|
||||
(ident (phi-matrix 0.0))
|
||||
(phi (phi-matrix 0.0))
|
||||
(phi-val 0.0)
|
||||
(dphi (phi-matrix 0.0))
|
||||
(dphi-val 0.0)
|
||||
(theta (theta-matrix 0.0))
|
||||
(theta-val 0.0)
|
||||
(dtheta (theta-matrix 0.0))
|
||||
(dtheta-val 0.0)
|
||||
(psi (psi-matrix 0.0))
|
||||
(psi-val 0.0)
|
||||
(dpsi (psi-matrix 0.0))
|
||||
(dpsi-val 0.0))
|
||||
|
||||
(defstream orthogonal-3d-stream
|
||||
out-stream
|
||||
(euler (make-euler)))
|
||||
|
||||
|
||||
;; For GRAPHT module:
|
||||
|
||||
(WHEN (STATUS FEATURE COMPLR)
|
||||
(*expr make-tek-stream)
|
||||
(SPECIAL tek-stream VIEWPORT GRAPHIC-OUTPUT))
|
||||
|
||||
(defstruct (tek conc-name fixnum-array (default-pointer viewport))
|
||||
(x-min 0)
|
||||
(x-max #o1777)
|
||||
(y-min 0)
|
||||
(y-max #o1377)
|
||||
(x-pen 0)
|
||||
(y-pen 0)
|
||||
(graphic-mode TEK-GRAPHMODE)
|
||||
(high-y 0)
|
||||
(low-y 0)
|
||||
(high-x 0)
|
||||
(low-x 0))
|
||||
|
||||
(defstream tek-stream
|
||||
(viewport (make-tek))
|
||||
(graphic-output))
|
||||
|
||||
|
||||
;; Optimizations.
|
||||
|
||||
(DEFPROP CALL (CALL-ST) SOURCE-TRANS)
|
||||
(DEFUN CALL-ST (FORM)
|
||||
(LET ((ARG-N (LENGTH (CDDR FORM))))
|
||||
(IF (> ARG-N 5)
|
||||
(VALUES FORM NIL)
|
||||
(VALUES (CONS (CDR (ASSOC ARG-N '((0 . CALL0)
|
||||
(1 . CALL1)
|
||||
(2 . CALL2)
|
||||
(3 . CALL3)
|
||||
(4 . CALL4)
|
||||
(5 . CALL5))))
|
||||
(CDR FORM))
|
||||
T))))
|
||||
|
||||
(DEFPROP NARG-CHECK (NARG-CHECK-ST) SOURCE-TRANS)
|
||||
(DEFUN NARG-CHECK-ST (FORM)
|
||||
(IF (TRIVIAL-ARG-LIST? (CDR FORM))
|
||||
(VALUES `(OR (= ,(CADR FORM) ,(CADDR FORM))
|
||||
(NARG-ERROR ,@(CDR FORM)))
|
||||
T)
|
||||
(VALUES FORM NIL)))
|
||||
|
||||
(DEFUN TRIVIAL-ARG-LIST? (L)
|
||||
(DO ()
|
||||
((NULL L) T)
|
||||
(LET ((FORM (POP L)))
|
||||
(IF (NOT (ATOM FORM))
|
||||
(IF (NOT (EQ (CAR FORM) 'QUOTE))
|
||||
(RETURN NIL))))))
|
||||
314
src/libdoc/graphs.gjc1
Executable file
314
src/libdoc/graphs.gjc1
Executable file
@@ -0,0 +1,314 @@
|
||||
;;;-*-LISP-*-
|
||||
;;; A graphics utility package. - George Carrette.
|
||||
|
||||
;;; Reorganized 3:26pm Thursday, 9 July 1981 -GJC
|
||||
|
||||
(eval-when (eval compile)
|
||||
(or (get 'graphm 'version)
|
||||
(load (list (car (namelist infile)) 'graphm))))
|
||||
|
||||
(herald graphs)
|
||||
|
||||
;; Autoload definitions:
|
||||
;; Go to some hair to make sure these are in the directory from
|
||||
;; which this file is being loaded.
|
||||
|
||||
(PUTPROP 'GRAPHS
|
||||
'(LAMBDA (GRAPHS)
|
||||
(PUTPROP 'MAKE-ARDS-STREAM (LIST GRAPHS 'GRAPHA)'AUTOLOAD)
|
||||
(PUTPROP 'MAKE-TEK-STREAM (LIST GRAPHS 'GRAPHT)'AUTOLOAD)
|
||||
(PUTPROP 'MAKE-GRAPHICS-STREAM (LIST GRAPHS 'GRAPH$)'AUTOLOAD)
|
||||
(PUTPROP 'MAKE-Z-CLIP-STREAM (LIST GRAPHS 'GRAPH3)'AUTOLOAD)
|
||||
(PUTPROP 'MAKE-Z-PERSPECTIVE-STREAM (LIST GRAPHS 'GRAPH3)'AUTOLOAD)
|
||||
)
|
||||
'GRAPHS)
|
||||
|
||||
(EVAL-WHEN (LOAD)
|
||||
(FUNCALL (GET 'GRAPHS 'GRAPHS) (CAR (NAMELIST (STATUS FASLOAD)))))
|
||||
(EVAL-WHEN (EVAL)
|
||||
(FUNCALL (GET 'GRAPHS 'GRAPHS) (CAR (NAMELIST INFILE))))
|
||||
(REMPROP 'GRAPHS 'GRAPHS)
|
||||
|
||||
;; Runtime primitives:
|
||||
|
||||
(DEFUN CALL N
|
||||
(LEXPR-FUNCALL (CAR (ARG 1)) (ARG 1) (LISTIFY (- 1 N))))
|
||||
|
||||
(DEFUN NARG-ERROR (N-ACTUAL N-NEEDED THE-FUNCTION)
|
||||
(ERROR (LIST "wanted" N-NEEDED "arguments but got" N-ACTUAL)
|
||||
THE-FUNCTION
|
||||
'FAIL-ACT))
|
||||
|
||||
(DEFUN NARG-CHECK (N-ACTUAL N-NEEDED THE-FUNCTION)
|
||||
(UNLESS (= N-ACTUAL N-NEEDED)
|
||||
(NARG-ERROR N-ACTUAL N-NEEDED THE-FUNCTION)))
|
||||
|
||||
(DEFUN UNKNOWN-COMMAND (COMMAND THE-FUNCTION)
|
||||
(ERROR (LIST "Unknown command to" THE-FUNCTION) COMMAND
|
||||
'FAIL-ACT))
|
||||
|
||||
;; the generic graphics functions.
|
||||
|
||||
(DEFUN SET-PEN (F X Y)
|
||||
(CALL F 'SET-PEN X Y))
|
||||
|
||||
(DEFUN MOVE-PEN (F X Y)
|
||||
(CALL3-MAP2-DISPATCH F 'MOVE-PEN X Y))
|
||||
|
||||
(DEFUN VECTOR-PEN (F X Y)
|
||||
(CALL3-MAP2-DISPATCH F 'VECTOR-PEN X Y))
|
||||
|
||||
(DEFUN DRAW-POINT (F X Y)
|
||||
(CALL3-MAP2-DISPATCH F 'DRAW-POINT X Y))
|
||||
|
||||
(DEFUN DRAW-LINE (F X1 Y1 X2 Y2)
|
||||
(CALL5-MAP2-DISPATCH F 'DRAW-LINE X1 Y1 X2 Y2))
|
||||
|
||||
(DEFUN GRAPHICS-STREAM-TYO (F ARG) (CALL F 'TYO ARG))
|
||||
|
||||
(DEFUN SET-VIEWPORT (F X0 X1 Y0 Y1)
|
||||
(CALL F 'SET-VIEWPORT X0 X1 Y0 Y1))
|
||||
|
||||
(DEFUN GET-VIEWPORT (F)
|
||||
(CALL F 'VIEWPORT))
|
||||
|
||||
(DEFUN SET-WINDOW (F X0 X1 Y0 Y1)
|
||||
(CALL F 'SET-WINDOW X0 X1 Y0 Y1))
|
||||
|
||||
(DEFUN GET-WINDOW (F)
|
||||
(CALL F 'WINDOW))
|
||||
|
||||
(DEFUN SET-INVISIBLEP (F FLAG)
|
||||
(CALL F 'SET-INVISIBLEP FLAG))
|
||||
|
||||
(DEFUN SET-DOTTEP (F FLAG)
|
||||
(CALL F 'SET-DOTTEP FLAG))
|
||||
|
||||
(DEFUN DRAW-FRAME (S)
|
||||
(LET (((X0 X1 Y0 Y1) (GET-WINDOW S)))
|
||||
(SET-PEN S X0 Y0)
|
||||
(MOVE-PEN S X1 Y0)
|
||||
(MOVE-PEN S X1 Y1)
|
||||
(MOVE-PEN S X0 Y1)
|
||||
(MOVE-PEN S X0 Y0)))
|
||||
|
||||
;; Splitting interface
|
||||
|
||||
(defun broadcast-stream n
|
||||
(let* ((broadcast-stream (arg 1))
|
||||
(l (broadcast-stream-out-streams)))
|
||||
(caseq n
|
||||
((1)
|
||||
(do ()((null l))
|
||||
(call (pop l))))
|
||||
((2)
|
||||
(do ()((null l))
|
||||
(call (pop l) (arg 2))))
|
||||
((3)
|
||||
(do ()((null l))
|
||||
(call (pop l) (arg 2) (arg 3))))
|
||||
((4)
|
||||
(do ()((null l))
|
||||
(call (pop l) (arg 2) (arg 3) (arg 4))))
|
||||
((5)
|
||||
(do ()((null l))
|
||||
(call (pop l) (arg 2) (arg 3) (arg 4) (arg 5))))
|
||||
((6)
|
||||
(do ()((null l))
|
||||
(call (pop l) (arg 2) (arg 3) (arg 4) (arg 5) (arg 6))))
|
||||
(t
|
||||
(do ((rest (listify (- 6 n))))
|
||||
((null l))
|
||||
(lexpr-funcall #'call (pop l)
|
||||
(arg 2) (arg 3) (arg 4) (arg 5) (arg 6)
|
||||
rest))))))
|
||||
|
||||
(defun make-broadcast-stream (&rest l)
|
||||
(make-broadcast-stream-1 out-streams l))
|
||||
|
||||
;; SFA Interface.
|
||||
|
||||
(defun make-graphics-sfa (out-stream)
|
||||
(make-graphics-sfa-1 out-stream out-stream))
|
||||
|
||||
(defun graphics-sfa (sfa command arg)
|
||||
(caseq command
|
||||
((tyo)
|
||||
(CALL (graphics-sfa-out-stream sfa) 'tyo arg))
|
||||
((which-operations)
|
||||
'(tyo))
|
||||
(t
|
||||
(unknown-command command 'graphics-sfa))))
|
||||
|
||||
(defun make-broadcast-sfa (&rest l)
|
||||
(make-broadcast-sfa-1 l l))
|
||||
|
||||
(defun broadcast-sfa (broadcast-sfa command arg)
|
||||
(caseq command
|
||||
((tyo)
|
||||
(do ((l (broadcast-sfa-l)))
|
||||
((null l))
|
||||
(+tyo arg (pop l))))
|
||||
((print)
|
||||
(do ((l (broadcast-sfa-l)))
|
||||
((null l))
|
||||
(print arg (pop l))))
|
||||
((princ)
|
||||
(do ((l (broadcast-sfa-l)))
|
||||
((null l))
|
||||
(princ arg (pop l))))
|
||||
((prin1)
|
||||
(do ((l (broadcast-sfa-l)))
|
||||
((null l))
|
||||
(prin1 arg (pop l))))
|
||||
((open)
|
||||
(do ((l (broadcast-sfa-l)))
|
||||
((null l))
|
||||
(open (pop l)))
|
||||
broadcast-sfa)
|
||||
((close)
|
||||
(do ((l (broadcast-sfa-l)))
|
||||
((null l))
|
||||
(close (pop l))))
|
||||
((which-operations)
|
||||
'(tyo print princ prin1 open close))
|
||||
(t
|
||||
(unknown-command command 'broadcast-sfa))))
|
||||
|
||||
|
||||
;; Optimizations.
|
||||
|
||||
(DEFUN CALL0 (F)
|
||||
(FUNCALL (CAR F) F))
|
||||
(DEFUN CALL1 (F A)
|
||||
(FUNCALL (CAR F) F A))
|
||||
(DEFUN CALL2 (F A B)
|
||||
(FUNCALL (CAR F) F A B))
|
||||
(DEFUN CALL3 (F A B C)
|
||||
(FUNCALL (CAR F) F A B C))
|
||||
(DEFUN CALL4 (F A B C D)
|
||||
(FUNCALL (CAR F) F A B C D))
|
||||
(DEFUN CALL5 (F A B C D E)
|
||||
(FUNCALL (CAR F) F A B C D E))
|
||||
|
||||
;; Specialized mapping functions
|
||||
;; CALL3 version.
|
||||
|
||||
(DEFUN CALL3-MAP2L (F A B C)
|
||||
(DO ()
|
||||
((NULL B))
|
||||
(CALL F A (POP B) (POP C))))
|
||||
|
||||
(DEFUN CALL3-MAP2A (F A B C)
|
||||
(DO ((J 0 (1+ J))
|
||||
(N (ARRAY-DIMENSION-N 1 B)))
|
||||
((= J N))
|
||||
(DECLARE (FIXNUM J N))
|
||||
(CALL F A (ARRAYCALL T B J) (ARRAYCALL T C J))))
|
||||
|
||||
(DEFUN CALL3-MAP2A$ (F A B C)
|
||||
(DO ((J 0 (1+ J))
|
||||
(N (ARRAY-DIMENSION-N 1 B)))
|
||||
((= J N))
|
||||
(DECLARE (FIXNUM J N))
|
||||
(CALL F A (ARRAYCALL FLONUM B J) (ARRAYCALL FLONUM C J))))
|
||||
|
||||
(DEFUN CALL3-MAP2A% (F A B C)
|
||||
(DO ((J 0 (1+ J))
|
||||
(N (ARRAY-DIMENSION-N 1 B)))
|
||||
((= J N))
|
||||
(DECLARE (FIXNUM J N))
|
||||
(CALL F A (ARRAYCALL FIXNUM B J) (ARRAYCALL FIXNUM C J))))
|
||||
|
||||
(DEFUN CALL3-MAP2-DISPATCH-WTA (M F A B C)
|
||||
(CALL3-MAP2-DISPATCH F A
|
||||
(ERROR M B 'WRNG-TYPE-ARG)
|
||||
C))
|
||||
|
||||
(DEFUN CALL3-MAP2-DISPATCH (F A B C)
|
||||
(IF (NOT (NULL B)) ; Stupid NIL is a SYMBOL.
|
||||
(CASEQ (TYPEP B)
|
||||
((FIXNUM FLONUM)
|
||||
(CALL F A B C))
|
||||
((LIST)
|
||||
(CALL3-MAP2L F A B C))
|
||||
((ARRAY)
|
||||
(CASEQ (ARRAY-TYPE B)
|
||||
((T NIL)
|
||||
(CALL3-MAP2A F A B C))
|
||||
((FLONUM)
|
||||
(CALL3-MAP2A$ F A B C))
|
||||
((FIXNUM)
|
||||
(CALL3-MAP2A% F A B C))
|
||||
(T
|
||||
(CALL3-MAP2-DISPATCH-WTA "Bad type of array to map over"
|
||||
F A B C))))
|
||||
(T
|
||||
(CALL3-MAP2-DISPATCH-WTA "Unknown type to MAP over" F A B C)))))
|
||||
|
||||
;; CALL5 version.
|
||||
|
||||
(DEFUN CALL5-MAP2L (F A B C D E)
|
||||
(DO ()
|
||||
((NULL B))
|
||||
(CALL F A (POP B) (POP C) (POP D) (POP E))))
|
||||
|
||||
(DEFUN CALL5-MAP2A (F A B C D E)
|
||||
(DO ((J 0 (1+ J))
|
||||
(N (ARRAY-DIMENSION-N 1 B)))
|
||||
((= J N))
|
||||
(DECLARE (FIXNUM J N))
|
||||
(CALL F A
|
||||
(ARRAYCALL T B J)
|
||||
(ARRAYCALL T C J)
|
||||
(ARRAYCALL T D J)
|
||||
(ARRAYCALL T E J))))
|
||||
|
||||
(DEFUN CALL5-MAP2A$ (F A B C D E)
|
||||
(DO ((J 0 (1+ J))
|
||||
(N (ARRAY-DIMENSION-N 1 B)))
|
||||
((= J N))
|
||||
(DECLARE (FIXNUM J N))
|
||||
(CALL F A
|
||||
(ARRAYCALL FLONUM B J)
|
||||
(ARRAYCALL FLONUM C J)
|
||||
(ARRAYCALL FLONUM D J)
|
||||
(ARRAYCALL FLONUM E J))))
|
||||
|
||||
(DEFUN CALL5-MAP2A% (F A B C D E)
|
||||
(DO ((J 0 (1+ J))
|
||||
(N (ARRAY-DIMENSION-N 1 B)))
|
||||
((= J N))
|
||||
(DECLARE (FIXNUM J N))
|
||||
(CALL F A
|
||||
(ARRAYCALL FIXNUM B J)
|
||||
(ARRAYCALL FIXNUM C J)
|
||||
(ARRAYCALL FIXNUM D J)
|
||||
(ARRAYCALL FIXNUM E J))))
|
||||
|
||||
(DEFUN CALL5-MAP2-DISPATCH-WTA (M F A B C D E)
|
||||
(CALL5-MAP2-DISPATCH F A
|
||||
(ERROR M B 'WRNG-TYPE-ARG)
|
||||
C D E))
|
||||
|
||||
(DEFUN CALL5-MAP2-DISPATCH (F A B C D E)
|
||||
(IF (NOT (NULL B)) ; Stupid NIL is a SYMBOL.
|
||||
(CASEQ (TYPEP B)
|
||||
((FIXNUM FLONUM)
|
||||
(CALL F A B C D E))
|
||||
((LIST)
|
||||
(CALL5-MAP2L F A B C D E))
|
||||
((ARRAY)
|
||||
(CASEQ (ARRAY-TYPE B)
|
||||
((T NIL)
|
||||
(CALL5-MAP2A F A B C D E))
|
||||
((FLONUM)
|
||||
(CALL5-MAP2A$ F A B C D E))
|
||||
((FIXNUM)
|
||||
(CALL5-MAP2A% F A B C D E))
|
||||
(T
|
||||
(CALL5-MAP2-DISPATCH-WTA "Bad type of array to map over"
|
||||
F A B C D E))))
|
||||
(T
|
||||
(CALL5-MAP2-DISPATCH-WTA "Unknown type to MAP over" F A B C D E)))))
|
||||
|
||||
74
src/libdoc/graphs.usage
Executable file
74
src/libdoc/graphs.usage
Executable file
@@ -0,0 +1,74 @@
|
||||
|
||||
This is an archive of graphics utilities written sometime
|
||||
during 1980 by George Carrette. Files marked with a "*"
|
||||
are used by the CONSTANCE II mirror-confined plasma experiment
|
||||
data-analysis system written by Michael Mauel.
|
||||
|
||||
* GRAPH$ Floating-point graphics.
|
||||
GRAPH3 3-d graphics.
|
||||
* GRAPHA Ards hardware support.
|
||||
GRAPHM Declarations and Macro support for package.
|
||||
* GRAPHS Generic runtime support and autoload defs.
|
||||
GRAPHT Tektronics 4010 hardware support.
|
||||
PLOT 2-d plotting examples.
|
||||
PLOT3 3-d plotting examples.
|
||||
|
||||
Summary of graphics package. -George Carrette.
|
||||
|
||||
Load the GRAPHM module at compile-time to get all
|
||||
the needed declarations.
|
||||
|
||||
Load the GRAPHS module at runtime to get the basic entry
|
||||
points and autoload definitions.
|
||||
|
||||
(MAKE-ARDS-STREAM <SFA-OR-FILE-OBJECT>) ; Return a STREAM taking FIXNUMS
|
||||
(MAKE-TEK-STREAM <SFA-OR-FILE-OBJECT>) ; Return a STREAM taking FIXNUMS
|
||||
|
||||
[Both give streams, which are implemented using hunks or lists
|
||||
depending upon what the compile-time setting in GRAPHM was.]
|
||||
|
||||
(MAKE-GRAPHICS-STREAM <STREAM>)
|
||||
|
||||
Gives a floating-point stream, complete with windows and
|
||||
viewports.
|
||||
|
||||
Operations on all streams:
|
||||
|
||||
(SET-PEN <STREAM> X Y) ; Sets the pen.
|
||||
(MOVE-PEN <STREAM> X Y) ; Draws a line from last setting.
|
||||
(VECTOR-PEN <STREAM> X Y) ; Relative MOVE-PEN
|
||||
(DRAW-POINT <STREAM> X Y) ; Draw a line of zero length.
|
||||
|
||||
(DRAW-LINE <STREAM> X0 Y0 X1 Y1) ; Most popular operation.
|
||||
|
||||
The above all do mapping if X and Y are both lists or arrays.
|
||||
|
||||
Operations specific to GRAPHICS-STREAM:
|
||||
|
||||
(SET-VIEWPORT <STREAM> X0 X1 Y0 Y1) ; FIXNUM range to feed to ARDS or TEK.
|
||||
(SET-WINDOW <STREAM> X0 X1 Y0 Y1) ; FLONUM domain of stream.
|
||||
(GET-WINDOW <STREAM>)
|
||||
(DRAW-FRAME <STREAM>) ; Calls GET-WINDOW to do the obvious thing.
|
||||
|
||||
Operations specific to the low-level ARDS and TEK streams.
|
||||
|
||||
(CALL <STREAM> 'BOUNDARIES) ; returns maximum allowed for SET-VIEWPORT
|
||||
|
||||
Utilities:
|
||||
|
||||
(MAKE-BROADCAST-SFA <SFA-OR-FILE-OBJECT1> <SFA-OR-FILE-OBJECT2> ...)
|
||||
(MAKE-BROADCAST-STREAM <STREAM1> <STREAM2> ...)
|
||||
|
||||
|
||||
3d-Graphics:
|
||||
|
||||
(MAKE-Z-PERSPECTIVE-STREAM <GRAPHICS-STREAM>) ; 3d=>2d mapping.
|
||||
(MAKE-Z-CLIP-STREAM <3D-STREAM>) ; 3d=>3d plane clipping.
|
||||
(MAKE-ORTHOGONAL-3D-STREAM <3D-STREAM>) ; 3d=>3d rotation.
|
||||
|
||||
Other:
|
||||
|
||||
(PLOTF '(<f1> <f2> ...) X0 X1 N) ; plots some functions.
|
||||
|
||||
The plot functions are meant to serve as example usage.
|
||||
|
||||
147
src/libdoc/grapht.gjc1
Executable file
147
src/libdoc/grapht.gjc1
Executable file
@@ -0,0 +1,147 @@
|
||||
;;;-*-LISP-*-
|
||||
;;; A graphics utility package. - George Carrette.
|
||||
|
||||
;;; Tektronix graphics.
|
||||
|
||||
(eval-when (eval compile)
|
||||
(or (get 'graphm 'version)
|
||||
(load (list (car (namelist infile)) 'graphm))))
|
||||
|
||||
(graphs-module grapht)
|
||||
|
||||
;; For info on Tek graphic protocol see .INFO.;TEK INFO
|
||||
;; This code was nabbed from JGA.
|
||||
|
||||
(DEFVAR TEK-PRINTMODE #o37)
|
||||
(DEFVAR TEK-GRAPHMODE #o35)
|
||||
|
||||
;; TEK Primitives
|
||||
|
||||
(defun tek-stream NARGS
|
||||
(COMMENT (ARG 1) = TEK-STREAM
|
||||
(ARG 2) = COMMAND
|
||||
(ARG 3) = X1
|
||||
(ARG 4) = Y1
|
||||
(ARG 5) = X2
|
||||
(ARG 6) = Y2)
|
||||
(LET ((TEK-STREAM (ARG 1)))
|
||||
(LET ((VIEWPORT (TEK-STREAM-VIEWPORT))
|
||||
(GRAPHIC-OUTPUT (TEK-STREAM-GRAPHIC-OUTPUT)))
|
||||
(caseq (ARG 2)
|
||||
((SET-PEN)
|
||||
(NARG-CHECK NARGS 4 'TEK-STREAM)
|
||||
(TEK-SET-PEN (ARG 3) (ARG 4)))
|
||||
((MOVE-PEN)
|
||||
(NARG-CHECK NARGS 4 'TEK-STREAM)
|
||||
(TEK-MOVE-PEN (ARG 3) (ARG 4)))
|
||||
(VECTOR-PEN
|
||||
(NARG-CHECK NARGS 4 'TEK-STREAM)
|
||||
(TEK-VECTOR-PEN (ARG 3) (ARG 4)))
|
||||
(DRAW-POINT
|
||||
(NARG-CHECK NARGS 4 'TEK-STREAM)
|
||||
(TEK-SET-PEN (ARG 3) (ARG 4))
|
||||
(TEK-VECTOR-PEN 0 0))
|
||||
(DRAW-LINE
|
||||
(NARG-CHECK NARGS 6 'TEK-STREAM)
|
||||
(TEK-SET-PEN (ARG 3) (ARG 4))
|
||||
(TEK-MOVE-PEN (ARG 5) (ARG 6)))
|
||||
((print-text)
|
||||
(NARG-CHECK NARGS 3 'TEK-STREAM)
|
||||
(tek-print-text (ARG 3)))
|
||||
((tyo)
|
||||
(NARG-CHECK NARGS 3 'TEK-STREAM)
|
||||
(tek-tyo (ARG 3)))
|
||||
((boundaries)
|
||||
(list (tek-x-min)
|
||||
(tek-x-max)
|
||||
(tek-y-min)
|
||||
(tek-y-max)))
|
||||
((which-operations)
|
||||
(NARG-CHECK NARGS 2 'TEK-STREAM)
|
||||
'(SET-PEN MOVE-PEN VECTOR-PEN
|
||||
DRAW-POINT DRAW-LINE TYO
|
||||
print-text))
|
||||
(t
|
||||
(UNKNOWN-COMMAND (ARG 2) 'TEK-STREAM))))))
|
||||
|
||||
;; These are the basic graphic operations in fixnum (viewport) coordinates.
|
||||
;; No attempt is made to clip lines for the viewport here, nor check for
|
||||
;; out-of-range arguments which will fold over mod #o2000.
|
||||
|
||||
(defun tek-tyo (c)
|
||||
(unless (= (tek-graphic-mode) TEK-PRINTMODE)
|
||||
(+tyo TEK-PRINTMODE graphic-output)
|
||||
(setf (tek-graphic-mode) TEK-PRINTMODE))
|
||||
(tyo c graphic-output))
|
||||
|
||||
(defun tek-print-text (text)
|
||||
(unless (= (tek-graphic-mode) TEK-PRINTMODE)
|
||||
(+tyo TEK-PRINTMODE graphic-output)
|
||||
(setf (tek-graphic-mode) TEK-PRINTMODE))
|
||||
(princ text graphic-output))
|
||||
|
||||
;; tekout does the basic encoding of all coordinates into Tek format
|
||||
;; Note that it does the storage of high-y, low-y, etc., but not x or y.
|
||||
|
||||
(DEFUN tekout (x y)
|
||||
(let ((high-y (lsh (logand y #o1740) -5))
|
||||
(low-y (logand y #o37))
|
||||
(high-x (lsh (logand x #o1740) -5))
|
||||
(low-x (logand x #o37))
|
||||
(old-high-y (tek-high-y))
|
||||
(old-low-y (tek-low-y))
|
||||
(old-high-x (tek-high-x)))
|
||||
(declare (fixnum high-y low-y high-x low-x
|
||||
old-high-y old-low-y old-high-x))
|
||||
(unless (= high-y old-high-y)
|
||||
(+tyo (+ high-y #o40) graphic-output)
|
||||
(setf (tek-high-y) high-y))
|
||||
(unless (and (= low-y old-low-y) (= high-x old-high-x))
|
||||
(+tyo (+ low-y #o140) graphic-output)
|
||||
(setf (tek-low-y) low-y)
|
||||
(unless (= high-x old-high-x)
|
||||
(+tyo (+ high-x #o40) graphic-output)
|
||||
(setf (tek-high-x) high-x)))
|
||||
(+tyo (+ low-x #o100) graphic-output)
|
||||
(setf (tek-low-x) low-x))
|
||||
nil)
|
||||
|
||||
(defun tek-set-pen (x y)
|
||||
(declare (fixnum x y)
|
||||
(special viewport))
|
||||
(+tyo TEK-GRAPHMODE graphic-output)
|
||||
(setf (tek-graphic-mode) TEK-GRAPHMODE)
|
||||
(tekout x y)
|
||||
(setf (tek-x-pen) x)
|
||||
(setf (tek-y-pen) y)
|
||||
nil)
|
||||
|
||||
(defun tek-move-pen (x y)
|
||||
(declare (fixnum x y))
|
||||
(unless (= (tek-graphic-mode) TEK-GRAPHMODE)
|
||||
(+tyo TEK-GRAPHMODE graphic-output)
|
||||
(tekout (tek-x-pen)
|
||||
(tek-y-pen))
|
||||
(setf (tek-graphic-mode) TEK-GRAPHMODE))
|
||||
(tekout x y)
|
||||
(setf (tek-x-pen) x)
|
||||
(setf (tek-y-pen) y)
|
||||
nil)
|
||||
|
||||
(defun tek-vector-pen (dx dy)
|
||||
(declare (fixnum dx dy))
|
||||
(unless (= (tek-graphic-mode) TEK-GRAPHMODE)
|
||||
(+tyo TEK-GRAPHMODE graphic-output)
|
||||
(tekout (tek-x-pen)
|
||||
(tek-y-pen))
|
||||
(setf (tek-graphic-mode) TEK-GRAPHMODE))
|
||||
(let ((x (+ dx (tek-x-pen)))
|
||||
(y (+ dy (tek-y-pen))))
|
||||
(declare (fixnum x y))
|
||||
(tekout x y)
|
||||
(setf (tek-x-pen) x)
|
||||
(setf (tek-y-pen) y))
|
||||
nil)
|
||||
|
||||
(defun make-tek-stream (s)
|
||||
(make-tek-stream-1 graphic-output s))
|
||||
53
src/libdoc/impdef.kmp15
Executable file
53
src/libdoc/impdef.kmp15
Executable file
@@ -0,0 +1,53 @@
|
||||
;;; -*- Mode:LISP; IBase:10.; -*-
|
||||
;;;
|
||||
;;; IMPDEF: A library for selectively including a definition from a file of definitions
|
||||
|
||||
(HERALD IMPDEF /15)
|
||||
|
||||
(EVAL-WHEN (EVAL COMPILE)
|
||||
(COND ((NOT (STATUS FEATURE IOTA))
|
||||
(LOAD '((DSK LIBLSP) IOTA FASL)))))
|
||||
|
||||
;;; (IMPORT-DEFINITION function filename)
|
||||
;;; Gets the definition of the function from filename and includes just
|
||||
;;; that one function in current file.
|
||||
;;;
|
||||
;;; Works for DEFUNs, DEFMACROs, DEFUN&s, and recursive IMPORT-DEFINITIONs.
|
||||
|
||||
(DEFMACRO IMPORT-DEFINITION (NAME FILE)
|
||||
(TERPRI MSGFILES)
|
||||
(PRINC '|;IMPORT-DEFINITION looking for | MSGFILES)
|
||||
(PRIN1 NAME MSGFILES)
|
||||
(PRINC '| in /"| MSGFILES)
|
||||
(PRINC (NAMESTRING FILE) MSGFILES)
|
||||
(PRINC '/" MSGFILES)
|
||||
(COND ((NOT (PROBEF FILE))
|
||||
(TERPRI MSGFILES)
|
||||
(PRINC '|;File not found. -- IMPORT-DEFINITION| MSGFILES)
|
||||
'`(FILE ,FILE NOT FOUND WHEN LOOKING FOR DEFINITION
|
||||
OF ,NAME))
|
||||
(T
|
||||
(IOTA ((STREAM FILE 'IN))
|
||||
(DO ((FORM (READ STREAM STREAM)
|
||||
(READ STREAM STREAM)))
|
||||
((EQ FORM STREAM)
|
||||
(TERPRI MSGFILES)
|
||||
(PRINC '|;Definition of function | MSGFILES)
|
||||
(PRIN1 NAME MSGFILES)
|
||||
(PRINC '| not found. -- IMPORT-DEFINITION|
|
||||
MSGFILES)
|
||||
`'(FUNCTION ,NAME NOT FOUND IN ,FILE))
|
||||
(COND ((AND (NOT (ATOM FORM))
|
||||
(MEMQ (CAR FORM)
|
||||
'(DEFUN DEFMACRO MACRO DEFUN/&
|
||||
IMPORT-DEFINITION))
|
||||
(OR (AND (ATOM (CADR FORM))
|
||||
(EQ (CADR FORM) NAME))
|
||||
(AND (NOT (ATOM (CADR FORM)))
|
||||
(EQ (CAADR FORM) NAME))))
|
||||
(TERPRI MSGFILES)
|
||||
(PRINC '|;Using | MSGFILES)
|
||||
((LAMBDA (PRINLENGTH)
|
||||
(PRIN1 FORM MSGFILES)) 2.)
|
||||
(PRINC '| -- IMPORT-DEFINITION| MSGFILES)
|
||||
(RETURN FORM))))))))
|
||||
53
src/libdoc/laugh.gsb3
Executable file
53
src/libdoc/laugh.gsb3
Executable file
@@ -0,0 +1,53 @@
|
||||
; Friü˜| ASept 8,1978 22:14 NM+6D.17H.53M.39S. -*- Lisp -*-
|
||||
(declare (array* (notype (laughs ?)))
|
||||
(special *laughs-dimension)
|
||||
(fixnum *laughs-dimension))
|
||||
|
||||
(defun one-laugh1 (phrase output-file)
|
||||
(or (and (eq output-file t) (setq output-file tyo) (not (null ^w)))
|
||||
((lambda (pos)
|
||||
(declare (fixnum pos))
|
||||
(cond ((> (+ (flatc phrase) 1 pos) (linel output-file))
|
||||
(terpri output-file))
|
||||
((not (= pos 0)) (princ '| | output-file)))
|
||||
(and (eq output-file tyo) (+tyo 7. output-file))
|
||||
(princ phrase output-file))
|
||||
(charpos output-file))))
|
||||
|
||||
(defun one-laugh2 (phrase list)
|
||||
(mapc '(lambda (f) (one-laugh1 phrase f)) list)
|
||||
t)
|
||||
|
||||
(defun one-laugh (output-file)
|
||||
((lambda (phrase)
|
||||
(cond ((null output-file)
|
||||
(one-laugh1 phrase t)
|
||||
(and ^r (one-laugh2 phrase outfiles)))
|
||||
((atom output-file) (one-laugh1 phrase output-file))
|
||||
(t (one-laugh2 phrase output-file))))
|
||||
(laughs (random *laughs-dimension))))
|
||||
|
||||
(defun laugh (arg output-filespec)
|
||||
(prog (i no-sleep-p)
|
||||
(declare (fixnum i))
|
||||
(setq no-sleep-p (and (filep output-filespec)
|
||||
(eq (caar (namelist output-filespec)) 'cli)))
|
||||
error-return-loop
|
||||
(cond ((null arg) (setq i 1))
|
||||
((eq arg 'uncontrollably) (setq i 1_34.))
|
||||
((eq (typep arg) 'fixnum) (setq i arg))
|
||||
(t (setq arg (error '|Bad arg - LAUGH| arg 'wrng-type-arg))
|
||||
(go error-return-loop)))
|
||||
(terpri output-filespec)
|
||||
super-hackish-losing-loop
|
||||
(one-laugh output-filespec)
|
||||
(and (not (plusp (setq i (1- i)))) (return 'hic))
|
||||
(and (null no-sleep-p)
|
||||
(sleep (+$ (//$ (float (random 20.)) 30.0) 0.05)))
|
||||
(go super-hackish-losing-loop)))
|
||||
|
||||
((lambda (l)
|
||||
(fillarray (array laughs t (setq *laughs-dimension (length l))) l))
|
||||
'(|Ha Ha| |Snort| |Chortle| |Ha| |He| |He He| |He He He| |Chortle|
|
||||
|Ho| |Ho Ho| |Ho Ho Ho| |Snicker| |Ha Ha Ha| |Giggle| |Chuckle|
|
||||
|Guffaw|))
|
||||
345
src/libdoc/lchstr.jlk24
Executable file
345
src/libdoc/lchstr.jlk24
Executable file
@@ -0,0 +1,345 @@
|
||||
;;; Chaosnet Streams for Maclisp
|
||||
|
||||
;;; todo: variable byte sizes for IN & OUT
|
||||
;;; improve efficiency of ARRAY-IN, ARRAY-OUT
|
||||
;;; make LSN's work
|
||||
;;; flush sfa-get/store in favor of SETF and ...?
|
||||
|
||||
;;; To generate a Chaosnet stream do (MAKE-CHAOSNET-STREAM). Then do
|
||||
;;; (OPEN <stream> '(HOST <host-address> CONTACT <contact-name>)).
|
||||
;;; Then use standard operations like TYI, UNTYI, TYO, IN, OUT, CLOSE, etc
|
||||
;;; or non-standard operations PACKET-IN, PACKET-OUT, ARRAY-IN, ARRAY-OUT
|
||||
;;; More documentation can be found before each operation handler (e.g. OPEN).
|
||||
|
||||
;;; Note: If you want reasonable error handling when running in a bare
|
||||
;;; LISP, you need a package like the one in MACSYMA (LIBMAX;MDEBUG >).
|
||||
|
||||
;;; Standard compile-time environment
|
||||
(include |mc:libmax;gprelud >|)
|
||||
|
||||
(herald lchstr)
|
||||
|
||||
(eval-when (compile) (setq defmacro-for-compiling nil))
|
||||
|
||||
(eval-when (eval compile)
|
||||
(if (not (fboundp 'loop)) (load "dsk:liblsp;loop fasl")))
|
||||
|
||||
;;; Load the Chaosnet support package, if not already loaded
|
||||
(eval-when (load eval)
|
||||
(or (get 'lchnsp 'version) (load "dsk:lisp;lchnsp fasl")))
|
||||
|
||||
(defvar chaos-stream-id 0)
|
||||
(defvar default-window-size 10.)
|
||||
(defvar default-timeout 60.)
|
||||
|
||||
;;; See the file L;LCHNSP > for the %chaos routines
|
||||
|
||||
(declare (special chaos-internal-pkt-buffer)
|
||||
(*expr %chaos-open-channels %chaos-close-channels
|
||||
%chaos-request-connection %chaos-eof %chaos-allocate-buffer
|
||||
%chaos-pktiot %chaos-get-byte %chaos-put-byte
|
||||
%chaos-set-pkt-length %chaos-set-pkt-opcode
|
||||
%chaos-get-pkt-length %chaos-get-pkt-opcode))
|
||||
|
||||
;;; Compile time constants
|
||||
|
||||
(eval-when (eval compile)
|
||||
;;; Connection state symbols
|
||||
(setq %cscls 0 %csrfs 3 %csopn 4 %cslos 5 %csinc 6
|
||||
;;; Packet Opcode definitions
|
||||
%codat 200 %coeof 14 %cocls 3
|
||||
;;; Other constants
|
||||
max-connect-tries 5
|
||||
max-pkt-size-bytes 488.)
|
||||
;;; Stream slot indices (should be done as a structure, but sfa's don't win...)
|
||||
(let ((slot-index 0)) ;crock...
|
||||
(mapc #'(lambda(slot) (set slot (setq slot-index (1+ slot-index))))
|
||||
'(connection host-address contact-name request-or-listen
|
||||
byte-size window-size timeout
|
||||
untyi-list in-buffer out-buffer in-count out-count
|
||||
max-chaosnet-stream-slot)))) ;this must be last
|
||||
|
||||
;;; Generate a bare chaosnet-stream object
|
||||
(defun make-chaosnet-stream ()
|
||||
(let ((stream (sfa-create #'chaosnet-stream-function
|
||||
#.max-chaosnet-stream-slot
|
||||
(format nil "chaos-stream-object-~A"
|
||||
(setq chaos-stream-id (1+ chaos-stream-id))))))
|
||||
(sfa-store stream #.host-address nil)
|
||||
(sfa-store stream #.contact-name nil)
|
||||
(sfa-store stream #.request-or-listen t) ;default to RFC
|
||||
(sfa-store stream #.byte-size 8)
|
||||
(sfa-store stream #.window-size default-window-size)
|
||||
(sfa-store stream #.timeout default-timeout)
|
||||
(sfa-store stream #.in-count -1)
|
||||
(sfa-store stream #.out-count 0)
|
||||
(sfa-store stream #.in-buffer (%chaos-allocate-buffer))
|
||||
(sfa-store stream #.out-buffer (%chaos-allocate-buffer))
|
||||
stream))
|
||||
|
||||
;;; chaosnet-stream-function is at the end of the file because it depends on
|
||||
;;; the following macros.
|
||||
|
||||
|
||||
;;; These macros are only to be expanded inside chaosnet-stream-function
|
||||
|
||||
;;; OPEN msg handler. Format is (OPEN <stream> <option-list>) where
|
||||
;;; <stream> is a chaosnet stream as returned by (MAKE-CHAOSNET-STREAM) and
|
||||
;;; <option-list> is a list of keywords and values (keywd1 val1 keywd2 val2 ..)
|
||||
;;; Known options are: HOST (or ADDRESS or HOST-ADDRESS) - Chaosnet host addr
|
||||
;;; CONTACT-NAME (or CONTACT or NAME) - Contact name + JCL
|
||||
;;; REQUEST or LISTEN - same as CONTACT
|
||||
;;; BYTE-SIZE (or BYTE) - byte size (8)
|
||||
;;; WINDOW-SIZE (or WINDOW) - xmt window size
|
||||
;;; Note: HOST-ADDRESS and CONTACT-NAME are required.
|
||||
;;; [Should OPEN errors here be signaled in a special way to be compatible?]
|
||||
|
||||
;;; Map keywords into slot indices with an occassional side-effect.
|
||||
(defmacro chaosnet-stream-keyword-decode (stream keyword)
|
||||
`(caseq ,keyword
|
||||
((host address host-address host-number)
|
||||
#.host-address)
|
||||
((contact name contact-name request)
|
||||
(sfa-store ,stream #.request-or-listen T)
|
||||
#.contact-name)
|
||||
(listen
|
||||
(sfa-store ,stream #.request-or-listen NIL)
|
||||
#.contact-name)
|
||||
((byte byte-size) #.byte-size)
|
||||
((window window-size) #.window-size)
|
||||
(timeout #.timeout)
|
||||
(T (ferror nil "Unknown keyword in OPEN for ~A - ~A"
|
||||
,stream keyword))))
|
||||
|
||||
(defmacro chaosnet-stream-open (stream args)
|
||||
`(progn
|
||||
(loop for (keyword value) on ,args by #'cddr
|
||||
for index = (chaosnet-stream-keyword-decode ,stream keyword)
|
||||
do (sfa-store ,stream index value))
|
||||
(sfa-call ,stream 'close nil) ;make sure its closed
|
||||
(if (null (sfa-get ,stream #.host-address))
|
||||
(ferror nil
|
||||
"Error handling OPEN for ~A: No host address specified."
|
||||
,stream))
|
||||
(if (null (sfa-get ,stream #.contact-name))
|
||||
(ferror nil
|
||||
"Error handling OPEN for ~A: No contact name specified."
|
||||
,stream))
|
||||
(if (null (sfa-get ,stream #.connection)) ;create a connection,
|
||||
(sfa-store ,stream #.connection ;if needed
|
||||
(%chaos-open-channels (sfa-get ,stream #.window-size))))
|
||||
(loop ;repeat #.max-connect-tries ; would be nicer...
|
||||
for connect-tries from 1 to #.max-connect-tries and
|
||||
state =
|
||||
(*catch 'chaos-pktiot-error ;catch IOC errors
|
||||
(%chaos-request-connection
|
||||
(sfa-get ,stream #.connection)
|
||||
(sfa-get ,stream #.host-address)
|
||||
(sfa-get ,stream #.contact-name)
|
||||
(sfa-get ,stream #.request-or-listen)
|
||||
(sfa-get ,stream #.timeout)))
|
||||
until (= #.%csopn state)
|
||||
finally
|
||||
(if (not (= #.%csopn state))
|
||||
(error (get-chaosnet-error-msg ,stream)
|
||||
"some error from chaos site")))
|
||||
(sfa-call ,stream 'clear-input nil)
|
||||
(sfa-call ,stream 'clear-output nil)
|
||||
,stream))
|
||||
|
||||
;;; CLOSE msg handler. Shuts down the connection and frees up the channels.
|
||||
|
||||
(defmacro chaosnet-stream-close (stream)
|
||||
`(let ((conn (sfa-get ,stream #.connection)))
|
||||
(sfa-store ,stream #.connection nil)
|
||||
(unless (null conn)
|
||||
(*catch 'chaos-pktiot-error (%chaos-eof conn))
|
||||
(%chaos-close-channels conn))))
|
||||
|
||||
;;; Standard stream operations
|
||||
|
||||
;;; Define a wrapper to catch IOC errors and handle them nicely
|
||||
(defmacro chaosnet-op (stream &rest body)
|
||||
`(if (null (*catch 'chaos-pktiot-error ,@ body))
|
||||
(error (get-chaosnet-error-msg ,stream) "some error from chaos site"
|
||||
'fail-act
|
||||
)))
|
||||
|
||||
;;; TYI and TYO ignore BYTE-SIZE and always return/take 8-bit bytes.
|
||||
;;; UNTYI can take anything (and TYI after UNTYI will return anything).
|
||||
|
||||
(defmacro chaosnet-stream-tyi (stream eof)
|
||||
`(let ((utl (sfa-get ,stream #.untyi-list)))
|
||||
(if utl (prog1 (car utl) (sfa-store ,stream #.untyi-list (cdr utl)))
|
||||
(let ((ibuf (sfa-get ,stream #.in-buffer))
|
||||
(cnt (sfa-get ,stream #.in-count)))
|
||||
(when (<= cnt 0)
|
||||
(chaosnet-op ,stream
|
||||
(%chaos-pktiot
|
||||
(car (sfa-get ,stream #.connection))
|
||||
ibuf))
|
||||
(sfa-store ,stream #.in-count
|
||||
(setq cnt (%chaos-get-pkt-length ibuf))))
|
||||
(cond ((= #.%coeof (%chaos-get-pkt-opcode ibuf))
|
||||
(sfa-call ,stream 'clear-input nil)
|
||||
,eof)
|
||||
((= #.%cocls (%chaos-get-pkt-opcode ibuf))
|
||||
(error (get-chaosnet-error-msg ,stream T))) ;cls-flag
|
||||
((= 0 cnt) (sfa-call ,stream 'tyi ,eof))
|
||||
(T (sfa-store ,stream #.in-count (1- cnt))
|
||||
(%chaos-get-byte
|
||||
ibuf
|
||||
(- (%chaos-get-pkt-length ibuf) cnt))))))))
|
||||
|
||||
(defmacro chaosnet-stream-untyi (stream byte)
|
||||
`(sfa-store ,stream #.untyi-list
|
||||
(push ,byte (sfa-get ,stream #.untyi-list))))
|
||||
|
||||
(defmacro chaosnet-stream-tyo (stream byte)
|
||||
`(let ((cnt (sfa-get ,stream #.out-count)))
|
||||
(%chaos-put-byte (sfa-get ,stream #.out-buffer) ,byte)
|
||||
(setq cnt (1+ cnt))
|
||||
(if (> cnt #.(1- max-pkt-size-bytes)) (sfa-call ,stream 'force-output
|
||||
nil)
|
||||
(sfa-store ,stream #.out-count cnt))
|
||||
T))
|
||||
|
||||
;;; what should IN and OUT do? (pack arbitrary byte sizes into 16 bit words?)
|
||||
|
||||
(defmacro chaosnet-stream-in (stream eof)
|
||||
`(sfa-call ,stream 'tyi ,eof)) ;should do something better..
|
||||
|
||||
(defmacro chaosnet-stream-out (stream word)
|
||||
`(sfa-call ,stream 'tyo ,word))
|
||||
|
||||
(defmacro chaosnet-stream-force-output (stream)
|
||||
`(when (> (sfa-get ,stream #.out-count) 0)
|
||||
(chaosnet-op ,stream
|
||||
(%chaos-pktiot (cdr (sfa-get ,stream #.connection))
|
||||
(sfa-get ,stream #.out-buffer)))
|
||||
(sfa-call ,stream 'clear-output nil)))
|
||||
|
||||
(defmacro chaosnet-stream-clear-input (stream)
|
||||
`(loop with ary = chaos-internal-pkt-buffer and
|
||||
ichan = (car (sfa-get ,stream #.connection))
|
||||
for count = (lsh (nth 2 (syscall 3 'whyint ichan)) -18.)
|
||||
while (and (> count 0)
|
||||
(*catch 'chaos-pktiot-error (%chaos-pktiot ichan ary)))
|
||||
finally (sfa-store ,stream #.in-count -1) ;no packet
|
||||
(sfa-store ,stream #.untyi-list nil)
|
||||
(return T)))
|
||||
|
||||
(defmacro chaosnet-stream-clear-output (stream)
|
||||
`(let ((obuf (sfa-get ,stream #.out-buffer)))
|
||||
(sfa-store ,stream #.out-count 0)
|
||||
(%chaos-set-pkt-length obuf 0)
|
||||
(%chaos-set-pkt-opcode obuf #.%codat))) ;data opcode
|
||||
|
||||
;;; Non-standard stream operations
|
||||
|
||||
;;; Input a packet into an array
|
||||
(defmacro chaosnet-stream-packet-in (stream array)
|
||||
`(let ((ibuf (sfa-get ,stream #.in-buffer)))
|
||||
(chaosnet-op ,stream
|
||||
(%chaos-pktiot (car (sfa-get ,stream #.connection))
|
||||
ibuf)
|
||||
(fillarray ,array ibuf))
|
||||
T))
|
||||
|
||||
(defmacro chaosnet-stream-packet-out (stream array)
|
||||
`(let ((obuf (sfa-get ,stream #.out-buffer)))
|
||||
(chaosnet-op ,stream
|
||||
(fillarray obuf ,array) ;how big is obuf?
|
||||
(%chaos-pktiot (cdr (sfa-get ,stream #.connection))
|
||||
obuf))))
|
||||
|
||||
;;; These should probably be made more efficient someday...
|
||||
|
||||
(defmacro chaosnet-stream-array-in (stream array count)
|
||||
`(progn
|
||||
(dotimes (i ,count)
|
||||
(setf (arraycall fixnum ,array i) (sfa-call ,stream 'tyi 0)))
|
||||
T))
|
||||
|
||||
(defmacro chaosnet-stream-array-out (stream array count)
|
||||
`(progn
|
||||
(dotimes (i ,count)
|
||||
(sfa-call ,stream 'out (arraycall fixnum ,array i)))
|
||||
T))
|
||||
|
||||
(defmacro chaosnet-stream-eof (stream msg) ;hack the msg someday
|
||||
`(progn (sfa-call ,stream 'force-output nil)
|
||||
(chaosnet-op ,stream (%chaos-eof (sfa-get ,stream #.connection)))
|
||||
(sfa-call ,stream 'clear-output nil)))
|
||||
|
||||
;;; Dispatching function for Chaosnet streams
|
||||
(declare (*lexpr get-chaosnet-error-msg))
|
||||
|
||||
(defun chaosnet-stream-function (stream msg arg)
|
||||
(caseq msg
|
||||
(which-operations '(open close untyi tyi tyo in out force-output eof
|
||||
clear-input clear-output
|
||||
packet-in packet-out
|
||||
array-in array-out))
|
||||
;standard operations
|
||||
(open (chaosnet-stream-open stream arg))
|
||||
(close (chaosnet-stream-close stream))
|
||||
(untyi (chaosnet-stream-untyi stream arg))
|
||||
(tyi (chaosnet-stream-tyi stream arg))
|
||||
(tyo (chaosnet-stream-tyo stream arg))
|
||||
(in (chaosnet-stream-in stream arg))
|
||||
(out (chaosnet-stream-out stream arg))
|
||||
(force-output (chaosnet-stream-force-output stream))
|
||||
(clear-input (chaosnet-stream-clear-input stream))
|
||||
(clear-output (chaosnet-stream-clear-output stream))
|
||||
;non-standard operations
|
||||
(packet-in (chaosnet-stream-packet-in stream arg))
|
||||
(packet-out (chaosnet-stream-packet-out stream arg))
|
||||
(array-in (chaosnet-stream-array-in stream (car arg) (cadr arg)))
|
||||
(array-out (chaosnet-stream-array-out stream (car arg) (cadr arg)))
|
||||
(eof (chaosnet-stream-eof stream arg))
|
||||
(T (ferror nil "Unknown stream operation - ~A" msg))))
|
||||
|
||||
;;; Function forms of non-standard stream operations
|
||||
|
||||
;;; packet-in/out reads/writes a packet to/from a fixnum array
|
||||
;;; data is packed 32-bit to a word, left adjusted.
|
||||
|
||||
(defun packet-in (stream array)
|
||||
(sfa-call stream 'packet-in array))
|
||||
|
||||
(defun packet-out (stream array)
|
||||
(sfa-call stream 'packet-out array))
|
||||
|
||||
;;; Engorge or disgorge <n> numbers into or out of an array.
|
||||
;;; Packing is either 8,16, or 32 bit, depending on the mode of the OPEN.
|
||||
|
||||
(defun array-in (stream array count)
|
||||
(sfa-call stream 'array-in (list array count)))
|
||||
|
||||
(defun array-out (stream array count)
|
||||
(sfa-call stream 'array-out (list array count)))
|
||||
|
||||
;;; Read and stringify a message about why a connection is losing
|
||||
|
||||
(defun get-chaosnet-error-msg (stream &optional (cls-flag nil)
|
||||
&aux (ichan (car (sfa-get stream #.connection)))
|
||||
(ary (sfa-get stream #.in-buffer)))
|
||||
(let ((count (lsh (nth 2 (syscall 3 'whyint ichan)) -18.)))
|
||||
(if (not (or cls-flag
|
||||
(and (> count 0)
|
||||
(*catch 'chaos-pktiot-error (%chaos-pktiot ichan ary)))))
|
||||
"Chaosnet Lossage - cause undetermined."
|
||||
(maknam (loop for i from 4
|
||||
for word = (arraycall fixnum ary i)
|
||||
until (= 0 word)
|
||||
collect (load-byte word 28. 8)
|
||||
collect (load-byte word 20. 8)
|
||||
collect (load-byte word 12. 8)
|
||||
collect (load-byte word 4. 8))))))
|
||||
|
||||
|
||||
;; Local Modes:
|
||||
;; Mode: LISP
|
||||
;; Comment Col:40
|
||||
;; END:
|
||||
345
src/libdoc/lchstr.jlk25
Normal file
345
src/libdoc/lchstr.jlk25
Normal file
@@ -0,0 +1,345 @@
|
||||
;;; Chaosnet Streams for Maclisp
|
||||
|
||||
;;; todo: variable byte sizes for IN & OUT
|
||||
;;; improve efficiency of ARRAY-IN, ARRAY-OUT
|
||||
;;; make LSN's work
|
||||
;;; flush sfa-get/store in favor of SETF and ...?
|
||||
|
||||
;;; To generate a Chaosnet stream do (MAKE-CHAOSNET-STREAM). Then do
|
||||
;;; (OPEN <stream> '(HOST <host-address> CONTACT <contact-name>)).
|
||||
;;; Then use standard operations like TYI, UNTYI, TYO, IN, OUT, CLOSE, etc
|
||||
;;; or non-standard operations PACKET-IN, PACKET-OUT, ARRAY-IN, ARRAY-OUT
|
||||
;;; More documentation can be found before each operation handler (e.g. OPEN).
|
||||
|
||||
;;; Note: If you want reasonable error handling when running in a bare
|
||||
;;; LISP, you need a package like the one in MACSYMA (LIBMAX;MDEBUG >).
|
||||
|
||||
;;; Standard compile-time environment
|
||||
(include |dsk:libmax;gprelud >|)
|
||||
|
||||
(herald lchstr)
|
||||
|
||||
(eval-when (compile) (setq defmacro-for-compiling nil))
|
||||
|
||||
(eval-when (eval compile)
|
||||
(if (not (fboundp 'loop)) (load "dsk:liblsp;loop fasl")))
|
||||
|
||||
;;; Load the Chaosnet support package, if not already loaded
|
||||
(eval-when (load eval)
|
||||
(or (get 'lchnsp 'version) (load "dsk:lisp;lchnsp fasl")))
|
||||
|
||||
(defvar chaos-stream-id 0)
|
||||
(defvar default-window-size 10.)
|
||||
(defvar default-timeout 60.)
|
||||
|
||||
;;; See the file L;LCHNSP > for the %chaos routines
|
||||
|
||||
(declare (special chaos-internal-pkt-buffer)
|
||||
(*expr %chaos-open-channels %chaos-close-channels
|
||||
%chaos-request-connection %chaos-eof %chaos-allocate-buffer
|
||||
%chaos-pktiot %chaos-get-byte %chaos-put-byte
|
||||
%chaos-set-pkt-length %chaos-set-pkt-opcode
|
||||
%chaos-get-pkt-length %chaos-get-pkt-opcode))
|
||||
|
||||
;;; Compile time constants
|
||||
|
||||
(eval-when (eval compile)
|
||||
;;; Connection state symbols
|
||||
(setq %cscls 0 %csrfs 3 %csopn 4 %cslos 5 %csinc 6
|
||||
;;; Packet Opcode definitions
|
||||
%codat 200 %coeof 14 %cocls 3
|
||||
;;; Other constants
|
||||
max-connect-tries 5
|
||||
max-pkt-size-bytes 488.)
|
||||
;;; Stream slot indices (should be done as a structure, but sfa's don't win...)
|
||||
(let ((slot-index 0)) ;crock...
|
||||
(mapc #'(lambda(slot) (set slot (setq slot-index (1+ slot-index))))
|
||||
'(connection host-address contact-name request-or-listen
|
||||
byte-size window-size timeout
|
||||
untyi-list in-buffer out-buffer in-count out-count
|
||||
max-chaosnet-stream-slot)))) ;this must be last
|
||||
|
||||
;;; Generate a bare chaosnet-stream object
|
||||
(defun make-chaosnet-stream ()
|
||||
(let ((stream (sfa-create #'chaosnet-stream-function
|
||||
#.max-chaosnet-stream-slot
|
||||
(format nil "chaos-stream-object-~A"
|
||||
(setq chaos-stream-id (1+ chaos-stream-id))))))
|
||||
(sfa-store stream #.host-address nil)
|
||||
(sfa-store stream #.contact-name nil)
|
||||
(sfa-store stream #.request-or-listen t) ;default to RFC
|
||||
(sfa-store stream #.byte-size 8)
|
||||
(sfa-store stream #.window-size default-window-size)
|
||||
(sfa-store stream #.timeout default-timeout)
|
||||
(sfa-store stream #.in-count -1)
|
||||
(sfa-store stream #.out-count 0)
|
||||
(sfa-store stream #.in-buffer (%chaos-allocate-buffer))
|
||||
(sfa-store stream #.out-buffer (%chaos-allocate-buffer))
|
||||
stream))
|
||||
|
||||
;;; chaosnet-stream-function is at the end of the file because it depends on
|
||||
;;; the following macros.
|
||||
|
||||
|
||||
;;; These macros are only to be expanded inside chaosnet-stream-function
|
||||
|
||||
;;; OPEN msg handler. Format is (OPEN <stream> <option-list>) where
|
||||
;;; <stream> is a chaosnet stream as returned by (MAKE-CHAOSNET-STREAM) and
|
||||
;;; <option-list> is a list of keywords and values (keywd1 val1 keywd2 val2 ..)
|
||||
;;; Known options are: HOST (or ADDRESS or HOST-ADDRESS) - Chaosnet host addr
|
||||
;;; CONTACT-NAME (or CONTACT or NAME) - Contact name + JCL
|
||||
;;; REQUEST or LISTEN - same as CONTACT
|
||||
;;; BYTE-SIZE (or BYTE) - byte size (8)
|
||||
;;; WINDOW-SIZE (or WINDOW) - xmt window size
|
||||
;;; Note: HOST-ADDRESS and CONTACT-NAME are required.
|
||||
;;; [Should OPEN errors here be signaled in a special way to be compatible?]
|
||||
|
||||
;;; Map keywords into slot indices with an occassional side-effect.
|
||||
(defmacro chaosnet-stream-keyword-decode (stream keyword)
|
||||
`(caseq ,keyword
|
||||
((host address host-address host-number)
|
||||
#.host-address)
|
||||
((contact name contact-name request)
|
||||
(sfa-store ,stream #.request-or-listen T)
|
||||
#.contact-name)
|
||||
(listen
|
||||
(sfa-store ,stream #.request-or-listen NIL)
|
||||
#.contact-name)
|
||||
((byte byte-size) #.byte-size)
|
||||
((window window-size) #.window-size)
|
||||
(timeout #.timeout)
|
||||
(T (ferror nil "Unknown keyword in OPEN for ~A - ~A"
|
||||
,stream keyword))))
|
||||
|
||||
(defmacro chaosnet-stream-open (stream args)
|
||||
`(progn
|
||||
(loop for (keyword value) on ,args by #'cddr
|
||||
for index = (chaosnet-stream-keyword-decode ,stream keyword)
|
||||
do (sfa-store ,stream index value))
|
||||
(sfa-call ,stream 'close nil) ;make sure its closed
|
||||
(if (null (sfa-get ,stream #.host-address))
|
||||
(ferror nil
|
||||
"Error handling OPEN for ~A: No host address specified."
|
||||
,stream))
|
||||
(if (null (sfa-get ,stream #.contact-name))
|
||||
(ferror nil
|
||||
"Error handling OPEN for ~A: No contact name specified."
|
||||
,stream))
|
||||
(if (null (sfa-get ,stream #.connection)) ;create a connection,
|
||||
(sfa-store ,stream #.connection ;if needed
|
||||
(%chaos-open-channels (sfa-get ,stream #.window-size))))
|
||||
(loop ;repeat #.max-connect-tries ; would be nicer...
|
||||
for connect-tries from 1 to #.max-connect-tries and
|
||||
state =
|
||||
(*catch 'chaos-pktiot-error ;catch IOC errors
|
||||
(%chaos-request-connection
|
||||
(sfa-get ,stream #.connection)
|
||||
(sfa-get ,stream #.host-address)
|
||||
(sfa-get ,stream #.contact-name)
|
||||
(sfa-get ,stream #.request-or-listen)
|
||||
(sfa-get ,stream #.timeout)))
|
||||
until (= #.%csopn state)
|
||||
finally
|
||||
(if (not (= #.%csopn state))
|
||||
(error (get-chaosnet-error-msg ,stream)
|
||||
"some error from chaos site")))
|
||||
(sfa-call ,stream 'clear-input nil)
|
||||
(sfa-call ,stream 'clear-output nil)
|
||||
,stream))
|
||||
|
||||
;;; CLOSE msg handler. Shuts down the connection and frees up the channels.
|
||||
|
||||
(defmacro chaosnet-stream-close (stream)
|
||||
`(let ((conn (sfa-get ,stream #.connection)))
|
||||
(sfa-store ,stream #.connection nil)
|
||||
(unless (null conn)
|
||||
(*catch 'chaos-pktiot-error (%chaos-eof conn))
|
||||
(%chaos-close-channels conn))))
|
||||
|
||||
;;; Standard stream operations
|
||||
|
||||
;;; Define a wrapper to catch IOC errors and handle them nicely
|
||||
(defmacro chaosnet-op (stream &rest body)
|
||||
`(if (null (*catch 'chaos-pktiot-error ,@ body))
|
||||
(error (get-chaosnet-error-msg ,stream) "some error from chaos site"
|
||||
'fail-act
|
||||
)))
|
||||
|
||||
;;; TYI and TYO ignore BYTE-SIZE and always return/take 8-bit bytes.
|
||||
;;; UNTYI can take anything (and TYI after UNTYI will return anything).
|
||||
|
||||
(defmacro chaosnet-stream-tyi (stream eof)
|
||||
`(let ((utl (sfa-get ,stream #.untyi-list)))
|
||||
(if utl (prog1 (car utl) (sfa-store ,stream #.untyi-list (cdr utl)))
|
||||
(let ((ibuf (sfa-get ,stream #.in-buffer))
|
||||
(cnt (sfa-get ,stream #.in-count)))
|
||||
(when (<= cnt 0)
|
||||
(chaosnet-op ,stream
|
||||
(%chaos-pktiot
|
||||
(car (sfa-get ,stream #.connection))
|
||||
ibuf))
|
||||
(sfa-store ,stream #.in-count
|
||||
(setq cnt (%chaos-get-pkt-length ibuf))))
|
||||
(cond ((= #.%coeof (%chaos-get-pkt-opcode ibuf))
|
||||
(sfa-call ,stream 'clear-input nil)
|
||||
,eof)
|
||||
((= #.%cocls (%chaos-get-pkt-opcode ibuf))
|
||||
(error (get-chaosnet-error-msg ,stream T))) ;cls-flag
|
||||
((= 0 cnt) (sfa-call ,stream 'tyi ,eof))
|
||||
(T (sfa-store ,stream #.in-count (1- cnt))
|
||||
(%chaos-get-byte
|
||||
ibuf
|
||||
(- (%chaos-get-pkt-length ibuf) cnt))))))))
|
||||
|
||||
(defmacro chaosnet-stream-untyi (stream byte)
|
||||
`(sfa-store ,stream #.untyi-list
|
||||
(push ,byte (sfa-get ,stream #.untyi-list))))
|
||||
|
||||
(defmacro chaosnet-stream-tyo (stream byte)
|
||||
`(let ((cnt (sfa-get ,stream #.out-count)))
|
||||
(%chaos-put-byte (sfa-get ,stream #.out-buffer) ,byte)
|
||||
(setq cnt (1+ cnt))
|
||||
(if (> cnt #.(1- max-pkt-size-bytes)) (sfa-call ,stream 'force-output
|
||||
nil)
|
||||
(sfa-store ,stream #.out-count cnt))
|
||||
T))
|
||||
|
||||
;;; what should IN and OUT do? (pack arbitrary byte sizes into 16 bit words?)
|
||||
|
||||
(defmacro chaosnet-stream-in (stream eof)
|
||||
`(sfa-call ,stream 'tyi ,eof)) ;should do something better..
|
||||
|
||||
(defmacro chaosnet-stream-out (stream word)
|
||||
`(sfa-call ,stream 'tyo ,word))
|
||||
|
||||
(defmacro chaosnet-stream-force-output (stream)
|
||||
`(when (> (sfa-get ,stream #.out-count) 0)
|
||||
(chaosnet-op ,stream
|
||||
(%chaos-pktiot (cdr (sfa-get ,stream #.connection))
|
||||
(sfa-get ,stream #.out-buffer)))
|
||||
(sfa-call ,stream 'clear-output nil)))
|
||||
|
||||
(defmacro chaosnet-stream-clear-input (stream)
|
||||
`(loop with ary = chaos-internal-pkt-buffer and
|
||||
ichan = (car (sfa-get ,stream #.connection))
|
||||
for count = (lsh (nth 2 (syscall 3 'whyint ichan)) -18.)
|
||||
while (and (> count 0)
|
||||
(*catch 'chaos-pktiot-error (%chaos-pktiot ichan ary)))
|
||||
finally (sfa-store ,stream #.in-count -1) ;no packet
|
||||
(sfa-store ,stream #.untyi-list nil)
|
||||
(return T)))
|
||||
|
||||
(defmacro chaosnet-stream-clear-output (stream)
|
||||
`(let ((obuf (sfa-get ,stream #.out-buffer)))
|
||||
(sfa-store ,stream #.out-count 0)
|
||||
(%chaos-set-pkt-length obuf 0)
|
||||
(%chaos-set-pkt-opcode obuf #.%codat))) ;data opcode
|
||||
|
||||
;;; Non-standard stream operations
|
||||
|
||||
;;; Input a packet into an array
|
||||
(defmacro chaosnet-stream-packet-in (stream array)
|
||||
`(let ((ibuf (sfa-get ,stream #.in-buffer)))
|
||||
(chaosnet-op ,stream
|
||||
(%chaos-pktiot (car (sfa-get ,stream #.connection))
|
||||
ibuf)
|
||||
(fillarray ,array ibuf))
|
||||
T))
|
||||
|
||||
(defmacro chaosnet-stream-packet-out (stream array)
|
||||
`(let ((obuf (sfa-get ,stream #.out-buffer)))
|
||||
(chaosnet-op ,stream
|
||||
(fillarray obuf ,array) ;how big is obuf?
|
||||
(%chaos-pktiot (cdr (sfa-get ,stream #.connection))
|
||||
obuf))))
|
||||
|
||||
;;; These should probably be made more efficient someday...
|
||||
|
||||
(defmacro chaosnet-stream-array-in (stream array count)
|
||||
`(progn
|
||||
(dotimes (i ,count)
|
||||
(setf (arraycall fixnum ,array i) (sfa-call ,stream 'tyi 0)))
|
||||
T))
|
||||
|
||||
(defmacro chaosnet-stream-array-out (stream array count)
|
||||
`(progn
|
||||
(dotimes (i ,count)
|
||||
(sfa-call ,stream 'out (arraycall fixnum ,array i)))
|
||||
T))
|
||||
|
||||
(defmacro chaosnet-stream-eof (stream msg) ;hack the msg someday
|
||||
`(progn (sfa-call ,stream 'force-output nil)
|
||||
(chaosnet-op ,stream (%chaos-eof (sfa-get ,stream #.connection)))
|
||||
(sfa-call ,stream 'clear-output nil)))
|
||||
|
||||
;;; Dispatching function for Chaosnet streams
|
||||
(declare (*lexpr get-chaosnet-error-msg))
|
||||
|
||||
(defun chaosnet-stream-function (stream msg arg)
|
||||
(caseq msg
|
||||
(which-operations '(open close untyi tyi tyo in out force-output eof
|
||||
clear-input clear-output
|
||||
packet-in packet-out
|
||||
array-in array-out))
|
||||
;standard operations
|
||||
(open (chaosnet-stream-open stream arg))
|
||||
(close (chaosnet-stream-close stream))
|
||||
(untyi (chaosnet-stream-untyi stream arg))
|
||||
(tyi (chaosnet-stream-tyi stream arg))
|
||||
(tyo (chaosnet-stream-tyo stream arg))
|
||||
(in (chaosnet-stream-in stream arg))
|
||||
(out (chaosnet-stream-out stream arg))
|
||||
(force-output (chaosnet-stream-force-output stream))
|
||||
(clear-input (chaosnet-stream-clear-input stream))
|
||||
(clear-output (chaosnet-stream-clear-output stream))
|
||||
;non-standard operations
|
||||
(packet-in (chaosnet-stream-packet-in stream arg))
|
||||
(packet-out (chaosnet-stream-packet-out stream arg))
|
||||
(array-in (chaosnet-stream-array-in stream (car arg) (cadr arg)))
|
||||
(array-out (chaosnet-stream-array-out stream (car arg) (cadr arg)))
|
||||
(eof (chaosnet-stream-eof stream arg))
|
||||
(T (ferror nil "Unknown stream operation - ~A" msg))))
|
||||
|
||||
;;; Function forms of non-standard stream operations
|
||||
|
||||
;;; packet-in/out reads/writes a packet to/from a fixnum array
|
||||
;;; data is packed 32-bit to a word, left adjusted.
|
||||
|
||||
(defun packet-in (stream array)
|
||||
(sfa-call stream 'packet-in array))
|
||||
|
||||
(defun packet-out (stream array)
|
||||
(sfa-call stream 'packet-out array))
|
||||
|
||||
;;; Engorge or disgorge <n> numbers into or out of an array.
|
||||
;;; Packing is either 8,16, or 32 bit, depending on the mode of the OPEN.
|
||||
|
||||
(defun array-in (stream array count)
|
||||
(sfa-call stream 'array-in (list array count)))
|
||||
|
||||
(defun array-out (stream array count)
|
||||
(sfa-call stream 'array-out (list array count)))
|
||||
|
||||
;;; Read and stringify a message about why a connection is losing
|
||||
|
||||
(defun get-chaosnet-error-msg (stream &optional (cls-flag nil)
|
||||
&aux (ichan (car (sfa-get stream #.connection)))
|
||||
(ary (sfa-get stream #.in-buffer)))
|
||||
(let ((count (lsh (nth 2 (syscall 3 'whyint ichan)) -18.)))
|
||||
(if (not (or cls-flag
|
||||
(and (> count 0)
|
||||
(*catch 'chaos-pktiot-error (%chaos-pktiot ichan ary)))))
|
||||
"Chaosnet Lossage - cause undetermined."
|
||||
(maknam (loop for i from 4
|
||||
for word = (arraycall fixnum ary i)
|
||||
until (= 0 word)
|
||||
collect (load-byte word 28. 8)
|
||||
collect (load-byte word 20. 8)
|
||||
collect (load-byte word 12. 8)
|
||||
collect (load-byte word 4. 8))))))
|
||||
|
||||
|
||||
;; Local Modes:
|
||||
;; Mode: LISP
|
||||
;; Comment Col:40
|
||||
;; END:
|
||||
1378
src/libdoc/lets.rcw1
Executable file
1378
src/libdoc/lets.rcw1
Executable file
File diff suppressed because it is too large
Load Diff
79
src/libdoc/linere.jonl2
Executable file
79
src/libdoc/linere.jonl2
Executable file
@@ -0,0 +1,79 @@
|
||||
;;; -*-LISP-*-
|
||||
|
||||
;;; This function acts like READLINE, except instead of returning
|
||||
;;; a "compressed" symbol, it "reads" each s-expression in the
|
||||
;;; line, and returns a list of these s-expressions.
|
||||
;;; Arguments: 0 to 2, just like READLINE, an optional EOF value,
|
||||
;;; and an optional input file. Default is () for EOF value, and
|
||||
;;; TYI for input file.
|
||||
|
||||
(herald LINEREAD /2)
|
||||
|
||||
(declare (setq defmacro-for-compiling () defmacro-displace-call () ))
|
||||
(defmacro SQUIDIFY (x)
|
||||
(COND ((MEMQ COMPILER-STATE '(COMPILE MAKLAP DECLARE))
|
||||
`(,squid (LIST ',x)))
|
||||
(`(QUOTE ,(list x)))) )
|
||||
|
||||
|
||||
(defun LINEREAD n
|
||||
(and (> n 2) (error '|Too many args - LINEREAD| (listify n)))
|
||||
(LET ((OLD-CR-SYNTAX (STATUS SYNTAX 13.))
|
||||
(OLD-TTYREAD (STATUS TTYREAD))
|
||||
(UNIQUE (SQUIDIFY LINEREAD))
|
||||
FILE EOFFL EOFVAL
|
||||
TTYFL OLD-ITS-TTYVARS TEM)
|
||||
(SETQ FILE (COND ((= N 0) TYI)
|
||||
((COND ((FILEP (SETQ TEM (ARG 1))))
|
||||
((MEMQ TEM '(T NIL))
|
||||
(SETQ TEM TYI)
|
||||
'T))
|
||||
(AND (> N 1) (SETQ EOFFL 'T EOFVAL (ARG 2)))
|
||||
TEM)
|
||||
((= N 1)
|
||||
(SETQ EOFFL 'T EOFVAL (ARG 1))
|
||||
TYI)
|
||||
((COND ((FILEP (SETQ TEM (ARG 2))))
|
||||
((MEMQ TEM '(T NIL))
|
||||
(SETQ TEM TYI)
|
||||
'T))
|
||||
(SETQ EOFFL 'T EOFVAL (ARG 1))
|
||||
TEM)))
|
||||
(COND ((AND (STATUS FEATURE ITS)
|
||||
(MEMQ 'TTY (CAR (STATUS FILEMODE FILE))))
|
||||
(SETQ TTYFL 'T)
|
||||
(SETQ OLD-ITS-TTYVARS (STATUS TTY))))
|
||||
(UNWIND-PROTECT
|
||||
(PROG (LIST-OF-FORMS START-CHAR)
|
||||
(SETSYNTAX 13. 197472. ()) ;Make <cr> both a "Force-feed"
|
||||
;601540 ; and a "single" char object.
|
||||
(SSTATUS TTYREAD ())
|
||||
(COND (TTYFL
|
||||
;TURN OFF ITS ACTIVATION CHARS EXCEPT FOR <bs> and <cr>
|
||||
(SSTATUS TTY (BOOLE 6 34087042. (CAR OLD-ITS-TTYVARS))
|
||||
;000202020202
|
||||
(BOOLE 7 (BOOLE 6 2181570560.
|
||||
;020202020000
|
||||
(CADR OLD-ITS-TTYVARS))
|
||||
8320.))
|
||||
;000000020200
|
||||
))
|
||||
LP (SETQ START-CHAR (TYIPEEK 'T FILE))
|
||||
(SETQ TEM (COND ((= START-CHAR 13.)
|
||||
(TYI FILE) ;Flush worthless <cr>
|
||||
(RETURN (NREVERSE LIST-OF-FORMS)))
|
||||
((= START-CHAR 41.)
|
||||
(PROG2 (SETSYNTAX 13. OLD-CR-SYNTAX () )
|
||||
(READ UNIQUE FILE)
|
||||
(SETSYNTAX 13. 197472. ())
|
||||
;601540
|
||||
))
|
||||
((READ UNIQUE FILE))))
|
||||
(AND (EQ TEM UNIQUE) (RETURN (AND EOFFL EOFVAL)))
|
||||
(PUSH TEM LIST-OF-FORMS)
|
||||
(GO LP))
|
||||
(AND OLD-TTYREAD (SSTATUS TTYREAD T))
|
||||
(SETSYNTAX 13. OLD-CR-SYNTAX ())
|
||||
(COND (TTYFL (SSTATUS TTY (CAR OLD-ITS-TTYVARS) (CADR OLD-ITS-TTYVARS))
|
||||
(SSTATUS TTYREAD T))))))
|
||||
|
||||
34
src/libdoc/link.gls
Executable file
34
src/libdoc/link.gls
Executable file
@@ -0,0 +1,34 @@
|
||||
TITLE LINK FUNCTION FOR LISP NEWIO (ITS)
|
||||
|
||||
.FASL
|
||||
.INSRT SYS:.FASL DEFS
|
||||
|
||||
.ENTRY LINK SUBR 000003 ;SUBR 2
|
||||
PUSHJ P,2MERGE ;GET MERGED FILE SPECS
|
||||
.CALL LINK9 ;LINK 'EM UP
|
||||
IOJRST 0,LINK1 ;LOSE LOSE
|
||||
PUSHJ P,6BTNML ;IF WIN, RETURN TO FILE NAMES
|
||||
SUB FXP,[4,,4]
|
||||
POPJ P,
|
||||
|
||||
LINK1: PUSHJ P,6BTNML
|
||||
CALL 1,.FUNCTION NCONS
|
||||
PUSH P,A
|
||||
PUSHJ P,6BTNML
|
||||
POP P,B
|
||||
CALL 2,.FUNCTION CONS
|
||||
MOVEI B,.ATOM LINK
|
||||
JRST XCIOL
|
||||
|
||||
LINK9: SETZ
|
||||
SIXBIT \MLINK\ ;MAKE LINK
|
||||
,,-7(FXP) ;FROM DEVICE
|
||||
,,-5(FXP) ;FROM FILE NAME 1
|
||||
,,-4(FXP) ;FROM FILE NAME 2
|
||||
,,-6(FXP) ;FROM SNAME
|
||||
,,-1(FXP) ;TO FILE NAME 1
|
||||
,,0(FXP) ;TO FILE NAME 2
|
||||
400000,,-2(FXP) ;TO SNAME
|
||||
|
||||
FASEND
|
||||
|
||||
798
src/libdoc/lispt.jlk708
Executable file
798
src/libdoc/lispt.jlk708
Executable file
@@ -0,0 +1,798 @@
|
||||
;;; LISP Inferior-job Editing Package
|
||||
|
||||
(comment declarations and special variables)
|
||||
|
||||
(declare (special editor-jname editor-job null editor-usr-input editor-usr-output
|
||||
lispt-read-loop crlf lispt-jname lispt-file
|
||||
lispt-file-forced lispt-protect tty-return-prompt?
|
||||
lispt-initial-sname lispt-text-string lispt-prompter
|
||||
lispt-tty-to-ddt-msg lispt-tty-passing-msg tty-verbose
|
||||
current-job tty-return-list default-tty-return-list
|
||||
tty-passing-msg current-editor-buffer current-teco-buffer-block
|
||||
roving-editor?)
|
||||
(fixnum (examine-job fixnum))
|
||||
(notype (deposit-job fixnum fixnum))
|
||||
(*expr make-job load-job start-job job-returned-tty wait-for-job
|
||||
deposit-job examine-job job-uset-write job-uset-read
|
||||
set-job-start-adr usr-open-fix return-to-ddt
|
||||
kill-job disown-job job-start-adr continue-job select-job
|
||||
clear-tty-return set-jcl)
|
||||
(genprefix /|lt))
|
||||
|
||||
(eval-when (eval compile)
|
||||
(setq ibase 8)
|
||||
(cond ((not (get '*uset 'macro))
|
||||
(fasload lusets fasl dsk liblsp)))
|
||||
(cond ((not (status feature lspmac))
|
||||
(fasload lspmac fasl dsk liblsp)))
|
||||
(setsyntax '/# 'macro '/#macro) ;enable #
|
||||
(defun 6bit macro (x) (list 'car (list 'pnget (cadr x) 6)))
|
||||
|
||||
; TECO Buffer Block symbols and other things (.OPTION bits)
|
||||
|
||||
(setq beg 0 begv 1 pt 2 gpt 3 zv 4 z 5 extrac 6 crlf '|/
|
||||
| null (ascii 0) bufblk 2 suparg 8 supcmd 7 read-jcl 1 edit-text 2
|
||||
select-buffer 3 optddt 1_36))
|
||||
|
||||
; insert the kludgey LISP patch
|
||||
(include |dsk:libdoc;lispt patch|)
|
||||
|
||||
(sstatus feature lispt) ; this comes after the patch
|
||||
|
||||
; LISP EXTERNAL REFERENCES FOR JOB MANIPULATION
|
||||
|
||||
(mapc '(lambda(x) (cond ((not (getl x '(subr expr autoload)))
|
||||
(putprop x '(lddt fasl dsk liblsp) 'autoload))))
|
||||
'(start-job set-job-start-adr continue-job wait-for-job make-job
|
||||
set-job-start-adr disown-job job-start-adr))
|
||||
|
||||
(mapc '(lambda(x) (cond ((not (getl x '(subr autoload)))
|
||||
(putprop x '(humble fasl dsk liblsp) 'autoload))))
|
||||
'(select-job load-job kill-job examine-job deposit-job
|
||||
job-uset-read job-uset-write))
|
||||
|
||||
;;; GLOBAL VARIABLES
|
||||
|
||||
(setq editor-job nil editor-usr-input nil editor-usr-output nil
|
||||
editor-jname nil lispt-file-forced nil)
|
||||
|
||||
;;; These symbols may have previous definitions by the user
|
||||
(special-init lispt-file '((dsk sys2) ts lispt))
|
||||
(special-init lispt-initial-sname (status udir))
|
||||
(special-init lispt-jname (cond ((status feature macsyma) 'macst) (t 'lispt)))
|
||||
(special-init lispt-protect nil)
|
||||
(special-init lispt-prompter (cond ((status feature macsyma) 'ttyretfun)
|
||||
(t 'lisp-prompt)))
|
||||
(special-init lispt-tty-passing-msg '|(Console Passing to the Editor)|)
|
||||
(special-init lispt-tty-to-ddt-msg '|(Console Passing to DDT)|)
|
||||
(special-init roving-editor? t)
|
||||
|
||||
(cond ((status feature macsyma)
|
||||
(defprop $edprotect lispt-protect alias)
|
||||
(defprop lispt-protect edprotect reversealias)
|
||||
(defprop $rover roving-editor? alias)
|
||||
(defprop roving-editor? rover reversealias)))
|
||||
|
||||
(COMMENT INTERRUPT HANDLER FOR /.BREAK 16 FROM TECO)
|
||||
|
||||
;;; THE .BREAK 16, CONVENTION FOR COMMUNICATING WITH AN INFERIOR TECO
|
||||
;;; 100000 IS DECODED BY THE REMAINING BITS:
|
||||
;;; 1 - DO A READ-EVAL-PRIN1 LOOP OVER THE WHOLE BUFFER.
|
||||
;;; 2 - TRY ZAPPING MACSYMA CODE IF IN A MACSYMA
|
||||
;;; 4 - random text
|
||||
;;; 10 - return to DDT, and upon return, directly back to the editor
|
||||
;;; 20 - return to DDT
|
||||
;;; 40
|
||||
;;; 100 - silent return (i.e. tty wasn't used by TECO
|
||||
;;; 200
|
||||
;;; 400
|
||||
;;; 1000 - error return. Encountered errors while executing
|
||||
;;; TECO commands requested by the superior. The
|
||||
;;; error message is left in a buffer for the superior
|
||||
;;; to read. After doing that, the superior should
|
||||
;;; continue the teco to allow it to clean up, and then
|
||||
;;; the teco will return silently.
|
||||
;;; OTHERWISE JUST GENTLY RETURN
|
||||
|
||||
|
||||
(SETQ *BREAK16-FUNCTION '*BREAK-TECO)
|
||||
|
||||
(defun *break-teco (eff)
|
||||
(caseq (boole 1 7777 eff)
|
||||
(1 (load-from-teco editor-job))
|
||||
(2 (batch-from-teco editor-job))
|
||||
(4 (lispt-read-text editor-job))
|
||||
(10 (lispt-return-to-ddt t))
|
||||
(20 (lispt-return-to-ddt nil))
|
||||
(100 (clear-tty-return)) ; silent return
|
||||
(1000 (lispt-teco-error editor-job)))
|
||||
null)
|
||||
|
||||
(COMMENT LOAD AND START EDITOR)
|
||||
|
||||
|
||||
(DEFUN MAKE-EDITOR NIL
|
||||
(LET ((FILE LISPT-FILE-FORCED)
|
||||
(JOB-ORIGIN) (JNAME-TAIL)
|
||||
(JNAME-LIST (EXPLODEN LISPT-JNAME))
|
||||
(FILE-LIST `(((DSK ,(STATUS hsname)) ,(status xuname) LISPT)
|
||||
((DSK ,(STATUS hsname)) ,(status xuname) EDIT)
|
||||
,LISPT-FILE)))
|
||||
|
||||
(IF (AND FILE (ATOM FILE)) (SETQ FILE `(TS ,FILE)))
|
||||
(IF FILE (SETQ FILE-LIST
|
||||
(NCONC (LIST (MERGEF FILE `((DSK ,(STATUS UDIR))))
|
||||
(MERGEF FILE `((DSK ,(STATUS hsname))))
|
||||
(MERGEF FILE `((DSK SYS)))
|
||||
(MERGEF FILE `((DSK SYS1)))
|
||||
(MERGEF FILE `((DSK SYS2))))
|
||||
FILE-LIST)))
|
||||
|
||||
(DO ((FL FILE-LIST (CDR FL)))
|
||||
((NULL FL) (ERROR '|Can't find editor on disk! |))
|
||||
(IF (PROBEF (CAR FL)) (RETURN (SETQ FILE (CAR FL)))))
|
||||
|
||||
(IF (> (LENGTH JNAME-LIST) 6)
|
||||
(DO ((L (NREVERSE JNAME-LIST) (CDR L)))
|
||||
((NOT (> (LENGTH L) 6)) (SETQ JNAME-LIST (NREVERSE L)))))
|
||||
|
||||
|
||||
(DO ((JNAME (PROG2 NIL (IMPLODE JNAME-LIST)
|
||||
(SETQ JNAME-LIST (NREVERSE JNAME-LIST)
|
||||
JNAME-TAIL
|
||||
(IF (= 6 (LENGTH JNAME-LIST)) (RPLACA JNAME-LIST 0)
|
||||
(CONS 0 JNAME-LIST))
|
||||
JNAME-LIST (NREVERSE JNAME-TAIL)))
|
||||
(PROG2 (RPLACA JNAME-TAIL (+ I 60)) (IMPLODE JNAME-LIST)))
|
||||
(I 0 (1+ I)) (JOB))
|
||||
((> I 7) (ERROR '|Can't create LISPT job |))
|
||||
(SETQ JOB (MAKE-JOB JNAME)
|
||||
JOB-ORIGIN (CAR JOB)
|
||||
JOB (CADR JOB))
|
||||
(IF (NULL JOB-ORIGIN) (ERROR '|Can't Create job (system full?) |))
|
||||
(IF (NOT (EQ 'FOREIGN JOB-ORIGIN))
|
||||
(RETURN (SETQ EDITOR-JNAME JNAME EDITOR-JOB JOB))))
|
||||
|
||||
(IF (NOT (GETL 'START-JOB '(EXPR SUBR))) ; need LDDT below
|
||||
(LET ((^W T) (DEFAULTF))
|
||||
(APPLY 'FASLOAD (GET 'START-JOB 'AUTOLOAD))))
|
||||
|
||||
(IF (NOT (EQ 'REOWNED JOB-ORIGIN))
|
||||
(PROGN (IF (LOAD-JOB FILE) (ERROR '|Can't load LISPT job |))
|
||||
(COND (TTY-VERBOSE
|
||||
(IF (NOT (= 0 (CDR (CURSORPOS)))) (TERPRI))
|
||||
(MAPC 'PRINC `(|; Editor job "| ,EDITOR-JNAME
|
||||
|" Created | ,CRLF))))
|
||||
(SET-JOB-START-ADR EDITOR-JOB (+ 2 (JOB-START-ADR EDITOR-JOB)))
|
||||
(*USET *SSNAM (6BIT LISPT-INITIAL-SNAME)))
|
||||
(IF (NOT (= 0 (CDR (CURSORPOS)))) (TERPRI))
|
||||
(MAPC 'PRINC `(|; Editor job "| ,EDITOR-JNAME |" Reowned | ,CRLF))
|
||||
(SET-JOB-START-ADR EDITOR-JOB 4002)) ; MAY NOT WIN. FOR $G RECOVERY.
|
||||
|
||||
(IF LISPT-PROTECT (VALRET* '|/..SAFE//1/î:VP |))
|
||||
|
||||
JOB-ORIGIN))
|
||||
|
||||
(defun start-editor nil
|
||||
(if (not (inf-editor-test)) (make-editor))
|
||||
(continue-editor t))
|
||||
|
||||
(defun GZP-editor nil
|
||||
(if (not (inf-editor-test)) (make-editor))
|
||||
(set-jcl '|100100. FS EXIT|)
|
||||
(select-job editor-job)
|
||||
(continue-job t)
|
||||
(wait-for-editor)
|
||||
T)
|
||||
|
||||
(defun continue-editor (tty-flag)
|
||||
(setq tty-passing-msg lispt-tty-passing-msg)
|
||||
(select-job editor-job)
|
||||
(continue-job tty-flag))
|
||||
|
||||
(defun wait-for-editor nil (wait-for-job editor-job))
|
||||
|
||||
|
||||
(COMMENT EDITOR JOB CONTROL)
|
||||
|
||||
(DEFUN KILL-EDITOR NIL
|
||||
(IF EDITOR-JOB (PROGN (CLEAN-UP-EDITOR)
|
||||
(SELECT-JOB EDITOR-JOB)
|
||||
(KILL-JOB)
|
||||
(PRINC0 '|; Job "|) (PRINC EDITOR-JNAME)
|
||||
(PRINC '|" killed|) (TERPRI)
|
||||
(SETQ EDITOR-JOB NIL EDITOR-JNAME NIL))
|
||||
(PRINC0 '|; No editor job? |) (TERPRI))
|
||||
'DONE)
|
||||
|
||||
(DEFUN $KILLEDITOR NIL (KILL-EDITOR) '$DONE)
|
||||
|
||||
(DEFUN DISOWN-EDITOR NIL
|
||||
(IF EDITOR-JOB (PROG2 (CLEAN-UP-EDITOR)
|
||||
(DISOWN-JOB EDITOR-JOB)
|
||||
(PRINC0 '|; Job "|) (PRINC EDITOR-JNAME)
|
||||
(PRINC '|" disowned |) (TERPRI)
|
||||
(SETQ EDITOR-JOB NIL EDITOR-JNAME NIL))
|
||||
(PRINC0 '|; No editor job? |) (TERPRI) NIL))
|
||||
|
||||
(DEFUN $DISOWNEDITOR NIL (IF (DISOWN-EDITOR) '$DONE))
|
||||
|
||||
(DEFUN REOWN-EDITOR (X)
|
||||
(PROG NIL
|
||||
(SETQ X (IF (NULL X) 'LISPT X))
|
||||
(COND ((AND EDITOR-JOB (EQ EDITOR-JNAME X))
|
||||
(PRINC0 '|; Editor already owned |)
|
||||
(RETURN '*))
|
||||
(EDITOR-JOB (CLOBBER-EDITOR?)))
|
||||
(LET ((JOB (MAKE-JOB X)))
|
||||
(COND ((EQ 'REOWNED (CAR JOB))
|
||||
(SETQ EDITOR-JNAME X EDITOR-JOB (CADR JOB))
|
||||
(SET-JOB-START-ADR EDITOR-JOB 4000)
|
||||
(RETURN T))
|
||||
(T (KILL-JOB)
|
||||
(PRINC0 '|; Job "|) (PRINC X)
|
||||
(IF (EQ 'FOREIGN (CAR JOB))
|
||||
(PRINC '|" is owned by another job|)
|
||||
(PRINC '|" not found |))
|
||||
(TERPRI))))
|
||||
(IF LISPT-PROTECT (VALRET* '|/..SAFE//1/î:VP |))))
|
||||
|
||||
(DEFUN $REOWNEDITOR MACRO (X)
|
||||
`(PROGN (REOWN-EDITOR .,(IF X (MAPCAR 'STRIPDOLLAR X)))
|
||||
'$DONE))
|
||||
|
||||
(DEFUN CLEAN-UP-EDITOR NIL
|
||||
(IF EDITOR-USR-OUTPUT (CLOSE-EDITOR EDITOR-USR-OUTPUT))
|
||||
(IF EDITOR-USR-INPUT (CLOSE-EDITOR EDITOR-USR-INPUT)))
|
||||
|
||||
|
||||
(COMMENT Open and Closing files to Editor Buffers)
|
||||
|
||||
(DECLARE (SPECIAL TECO-PC))
|
||||
(DEFUN OPEN-EDITOR (JOB MODE)
|
||||
(COND ((EQ 'INPUT MODE)
|
||||
(SETQ EDITOR-USR-INPUT (OPEN JOB '(IN ASCII)))
|
||||
(USR-OPEN-FIX EDITOR-USR-INPUT (TECO-V #,ZV))
|
||||
(FILEPOS EDITOR-USR-INPUT (TECO-V #,BEGV))
|
||||
EDITOR-USR-INPUT)
|
||||
(T (SETQ EDITOR-USR-OUTPUT (OPEN JOB '(OUT ASCII)))
|
||||
(USR-OPEN-FIX EDITOR-USR-OUTPUT (TECO-V #,ZV))
|
||||
(FILEPOS EDITOR-USR-OUTPUT (TECO-V #,PT))
|
||||
EDITOR-USR-OUTPUT)))
|
||||
|
||||
(DEFUN CLOSE-EDITOR (FILE) ; not too exciting for now
|
||||
(CLOSE FILE)
|
||||
(SET (IF (EQ EDITOR-USR-INPUT FILE) 'EDITOR-USR-INPUT 'EDITOR-USR-OUTPUT)
|
||||
NIL)
|
||||
T)
|
||||
|
||||
(DEFUN TECO-V (X)
|
||||
(LET ((BUFBLK (EXAMINE-JOB #,BUFBLK)))
|
||||
(LET ((VX (EXAMINE-JOB (+ BUFBLK X))))
|
||||
(COND ((NOT (< VX (EXAMINE-JOB (+ BUFBLK #,GPT))))
|
||||
(+ VX (EXAMINE-JOB (+ BUFBLK #,EXTRAC))))
|
||||
(T VX)))))
|
||||
|
||||
(setq current-editor-buffer nil)
|
||||
(declare (*lexpr run-teco))
|
||||
|
||||
; Crufty TECO code below is for editor independence (ugh). It simply runs
|
||||
; MM & LISPT SELECT WRITE BUFFER
|
||||
|
||||
(defun select-buffer (buffer)
|
||||
(let ((tty-return))
|
||||
(if (not (inf-editor-test))
|
||||
(error '|Can't select buffer - No editor job.|))
|
||||
(if (not (atom buffer))
|
||||
(error '|Buffer names must be atoms.|))
|
||||
(if editor-usr-output (close-editor editor-usr-output))
|
||||
(setq current-editor-buffer buffer)
|
||||
(select-job editor-job)
|
||||
(set-jcl buffer)
|
||||
(let ((save-pc (*uset *rupc)) (bb (examine-job #,bufblk)))
|
||||
(declare (fixnum bb save-pc))
|
||||
(deposit-job (+ bb #,suparg) #,select-buffer)
|
||||
(*uset *supc (+ bb #,supcmd))
|
||||
(continue-job T) ; JCL hacker gives tty back too
|
||||
(wait-for-editor)
|
||||
(setq current-teco-buffer-block (examine-job #,bufblk))
|
||||
(continue-job T)
|
||||
(wait-for-job editor-job)
|
||||
(*uset *supc save-pc))
|
||||
(open-editor editor-job 'output)
|
||||
T))
|
||||
|
||||
(defun run-teco-command (cmd)
|
||||
(select-job editor-job)
|
||||
(let ((save-pc (*uset *rupc)) (bb (examine-job #,bufblk)) (TTY-RETURN))
|
||||
(declare (fixnum bb save-pc))
|
||||
(deposit-job (+ bb #,suparg) cmd)
|
||||
(*uset *supc (+ bb #,supcmd))
|
||||
(continue-job T) ; JCL hacker gives tty back too
|
||||
(wait-for-editor)
|
||||
(*uset *supc save-pc))
|
||||
t)
|
||||
|
||||
(defun run-teco n
|
||||
(select-job editor-job)
|
||||
(apply 'set-jcl (listify n))
|
||||
(let ((save-pc (*uset *rupc)) (bb (examine-job #,bufblk)))
|
||||
(declare (fixnum bb save-pc))
|
||||
(deposit-job (+ bb #,suparg) #,read-jcl)
|
||||
(*uset *supc (+ bb #,supcmd))
|
||||
(let ((tty-return))
|
||||
(continue-job T)
|
||||
(wait-for-job editor-job))
|
||||
(*uset *supc save-pc))
|
||||
t)
|
||||
|
||||
; ERROR Handling for Errors in TECO while executing JCL commands
|
||||
; assumes that TECO has closed the gap in the current buffer
|
||||
|
||||
(defun lispt-teco-error (job)
|
||||
(clear-tty-return)
|
||||
(let ((editor-usr-input) (lispt-text-string))
|
||||
(princ0 '|; Error while editor executing commands requested by LISP:|)
|
||||
(terpri) (princ (lispt-read-text job)) (terpri)
|
||||
(nointerrupt nil)
|
||||
(select-job job)
|
||||
(let ((tty-return))
|
||||
(continue-job T)
|
||||
(wait-for-job job))
|
||||
(tyipeek nil tyi)))
|
||||
|
||||
|
||||
(COMMENT READ-EVAL ROUTINE)
|
||||
|
||||
(special-init lispt-read-loop 'default-lispt-read-eval-print-loop)
|
||||
(special-init lispt-readtable readtable)
|
||||
|
||||
(defun load-from-teco (job)
|
||||
(let ((prompt? tty-return-prompt?))
|
||||
(clear-tty-return)
|
||||
(open-editor job 'input)
|
||||
(funcall lispt-read-loop)
|
||||
(close-editor editor-usr-input)
|
||||
(if prompt? (funcall lispt-prompter nil))))
|
||||
|
||||
(defun default-lispt-read-eval-print-loop nil
|
||||
(let ((errlist '((princ '|; Reading from the editor aborted|) (terpri))))
|
||||
(cursorpos 'c) ; start with a fresh screen
|
||||
(princ0 '|; Reading from the editor |) (terpri)
|
||||
(do ((infile editor-usr-input) (^Q T) (expr))
|
||||
(NIL)
|
||||
(setq expr (funcall (or read 'read) 'LISPT-EOF))
|
||||
(IF (EQ 'LISPT-EOF EXPR) (RETURN NIL))
|
||||
(setq + expr)
|
||||
(if (and (not (atom expr)) (eq 'INCLUDE (car expr)))
|
||||
(let ((file (cadr expr)))
|
||||
(princ0 '|; Including File |) (princ file)
|
||||
(funcall 'load file)
|
||||
(terpri) (princ '|; End of File |)
|
||||
(princ file)))
|
||||
(terpri) (funcall (or prin1 'prin1) (setq * (eval expr)))))
|
||||
(terpri) (terpri) (princ '|; Finished reading |))
|
||||
|
||||
|
||||
(COMMENT OUTPUT TO EDITOR BUFFERS)
|
||||
|
||||
(defun eprinc n ; doesn't force output
|
||||
(if (and (> n 1) (not (eq (arg 2) current-editor-buffer)))
|
||||
(select-buffer (arg 2)))
|
||||
(princ (if (> n 0) (arg 1)) editor-usr-output)
|
||||
T)
|
||||
|
||||
(defun eprint n
|
||||
(if (and (> n 1) (not (eq (arg 2) current-editor-buffer)))
|
||||
(select-buffer (arg 2)))
|
||||
(print (if (> n 0) (arg 1)) editor-usr-output)
|
||||
(eforce-output)
|
||||
T)
|
||||
|
||||
(defun eprin1 n
|
||||
(if (and (> n 1) (not (eq (arg 2) current-editor-buffer)))
|
||||
(select-buffer (arg 2)))
|
||||
(prin1 (if (> n 0) (arg 1)) editor-usr-output)
|
||||
(eforce-output)
|
||||
T)
|
||||
|
||||
(defun eterpri n
|
||||
(if (and (> n 0) (not (eq (arg 1) current-editor-buffer)))
|
||||
(select-buffer (arg 1)))
|
||||
(terpri editor-usr-output)
|
||||
(eforce-output)
|
||||
T)
|
||||
|
||||
(defun esprinter n (editor-output 'sprinter (listify n)))
|
||||
|
||||
(defun egrindef fexpr (x) (editor-output 'grindef x))
|
||||
|
||||
(defun etyo n
|
||||
(if (and (> n 1) (not (eq (arg 2) current-editor-buffer)))
|
||||
(select-buffer (arg 2)))
|
||||
(tyo (if (> n 0) (arg 1) 0) editor-usr-output)
|
||||
t)
|
||||
|
||||
(defun eforce-output nil (force-output editor-usr-output))
|
||||
|
||||
(defun eclose nil (close-editor editor-usr-output))
|
||||
|
||||
(declare (macros t))
|
||||
(defun editt macro (form)
|
||||
(if (null (inf-editor-test)) (GZP-EDITOR))
|
||||
(select-buffer 'LISP-EDIT)
|
||||
(mapc '(lambda (x) (editor-output 'grindef x)) (cdr form))
|
||||
(run-teco-command #,edit-text)
|
||||
T)
|
||||
(declare (macros nil))
|
||||
|
||||
(defun editor-output (op x)
|
||||
(if (not (inf-editor-test)) (error '|No editor job|))
|
||||
(if (= 2 (length x)) (select-buffer (cadr x)))
|
||||
(if (null (and editor-usr-output current-editor-buffer))
|
||||
(error '|No channel open to the editor or no buffer selected.|))
|
||||
|
||||
(if (null (getl 'grindef '(fsubr fexpr))) (grindef))
|
||||
(let ((^w t) (^d nil) (outfiles (list editor-usr-output)) (^r t))
|
||||
(apply op (list (car x))))
|
||||
(eforce-output)
|
||||
'*)
|
||||
|
||||
(COMMENT BATCH MACSYMA COMMAND FROM TECO)
|
||||
|
||||
(DECLARE (SPECIAL $DEMOMODE $TRANSLMODE $BATCHKILL $LINENUM CR LF TAB ST FF SP
|
||||
$INCHAR $OUTCHAR REPHRASE $% $NOLABELS LINELABLE $LASTTIME
|
||||
UPCASEP $CURSOR POS $DISPFLAG $FUNCTIONS $ARRAYS $ALL $INPUT
|
||||
$STRDISP OLDST THISTIME IMAGE-STRING $ERRORFUN)
|
||||
(*LEXPR PRINT-CONSOLE-MSG)
|
||||
(*EXPR KILL1 STRIPDOLLAR TYI* PARSE1 CONTINUE1 TRANSLATE-MACEXPR
|
||||
PRINTLABEL DISPLAY* MAKELABEL $RESET MAKSTRING GETLABELS
|
||||
STRMEVAL GETLABELS* CONSFUNDEF MGET LISTARGP ERLIST REPRINT
|
||||
CHECKLABEL))
|
||||
|
||||
(SETQ $DEMOMODE NIL $TRANSLMODE NIL)
|
||||
|
||||
(DEFUN BATCH-FROM-TECO (JOB)
|
||||
(LET ((PROMPT? TTY-RETURN-PROMPT?))
|
||||
(IF (NOT (STATUS FEATURE MACSYMA))
|
||||
(ERROR '|Zapping MACSYMA code into a LISP without MACSYMA? |))
|
||||
(CLEAR-TTY-RETURN)
|
||||
(CURSORPOS 'C)
|
||||
(PRINT-CONSOLE-MSG '|(Reading Commands from the Editor)|)
|
||||
(OPEN-EDITOR JOB 'INPUT)
|
||||
(COND ((PROG2 NIL (TECO-BATCH)
|
||||
(CLOSE-EDITOR EDITOR-USR-INPUT))
|
||||
(PRINT-CONSOLE-MSG '|(Finished)|)))
|
||||
(IF PROMPT? (FUNCALL lispt-prompter NIL))
|
||||
NULL))
|
||||
|
||||
(DEFUN TECO-BATCH NIL
|
||||
(LET (($DISPFLAG) (ST) ($ERRORFUN 'TECO-BATCH-ERROR)
|
||||
(ERRLIST '((TECO-BATCH-ERROR))))
|
||||
(COND ($BATCHKILL (KILL1 $BATCHKILL)
|
||||
(COND ((EQ $BATCHKILL T) ($RESET))) (GCTWA)))
|
||||
(COND ((NOT (CHECKLABEL $INCHAR)) (SETQ $LINENUM (1+ $LINENUM))))
|
||||
(MAKELABEL $INCHAR)
|
||||
(DO ((COMMAND-STRING) (TERMINATOR) (COMMAND) (RESULT))
|
||||
((EQ 'EOF/# TERMINATOR))
|
||||
(SETQ IMAGE-STRING NIL
|
||||
COMMAND-STRING (GET-COMMAND-STRING)
|
||||
TERMINATOR (CAR COMMAND-STRING)
|
||||
$DISPFLAG (EQ '/; TERMINATOR)
|
||||
ST (mapcar '(lambda (x) (getcharn x 1)) (CDR COMMAND-STRING)))
|
||||
(COND ((EQ 'EOF/# TERMINATOR) (RETURN T)))
|
||||
(REPRINT IMAGE-STRING T)
|
||||
(SETQ OLDST ST)
|
||||
(SETQ COMMAND (COND ($TRANSLMODE ((LAMBDA (^W) (PARSE1)) NIL))
|
||||
(T (PARSE1))))
|
||||
(COND ((NULL COMMAND) (TERPRI)
|
||||
(PRINC '|Syntax error occurred in reading commands from the editor.|)
|
||||
(TERPRI) (RETURN NIL))
|
||||
($TRANSLMODE (TRANSLATE-MACEXPR (CAR COMMAND)))
|
||||
(T (SETQ RESULT (CONTINUE1 (CAR COMMAND)))))
|
||||
(COND ((NULL RESULT) (TERPRI)
|
||||
(PRINC '|Error occurred while executing commands from the editor.|)
|
||||
(TERPRI) (RETURN NIL)))
|
||||
(SETQ $% (CAR RESULT)) (MAKELABEL $OUTCHAR)
|
||||
(COND ((NOT $NOLABELS) (SET LINELABLE $%)
|
||||
(PUTPROP LINELABLE (CONS (CADR $LASTTIME) (CADDR $LASTTIME)) 'TIME)))
|
||||
(COND ($DISPFLAG (REMPROP LINELABLE 'NODISP) (DISPLAY*))
|
||||
(T (PUTPROP LINELABLE T 'NODISP)))
|
||||
(SETQ $LINENUM (1+ $LINENUM)) (MAKELABEL $INCHAR)
|
||||
(COND ($DEMOMODE (PRINC (STRIPDOLLAR $CURSOR))
|
||||
(COND ((NOT (= (TYI*) 32.))
|
||||
(TERPRI) (PRINC '|DEMO TERMINATED|)
|
||||
(TERPRI) (SETQ ST NIL)
|
||||
(RETURN nil))))))))
|
||||
|
||||
(DEFUN TECO-BATCH-ERROR NIL
|
||||
(PRINC0 '| (Command reading from the Editor aborted)|)
|
||||
(TERPRI))
|
||||
|
||||
(DEFUN GET-COMMAND-STRING NIL
|
||||
(LET ((CH-STRING))
|
||||
(DO ((CH) (STARTING T (AND STARTING (NULL CH-STRING)))
|
||||
(CTRL-LIST (LIST CR LF FF TAB)))
|
||||
((MEMQ CH '( | ||||