(include-if (null (get 'chead 'version)) "../chead.l")
"$Header: datab.l,v 1.6 87/12/15 16:59:55 sklower Exp $")
;;; ---- d a t a b data base
;;; -[Sat Aug 6 23:59:11 1983 by layer]-
;--- d-tranloc :: locate a function in the transfer table
; return the offset we should use for this function call
(cond ((get fname g-tranloc))
(let ((newval (* 8 g-trancnt)))
(putprop fname newval g-tranloc)
;--- d-loc :: return the location of the variable or value in IADR form
; - form : form whose value we are to locate
; if we are given a xxx as form, we check yyy;
; nil Nil is always returned
; symbol return the location of the symbols value, first looking
; in the registers, then on the stack, then the bind list.
; If g-ingorereg is t then we don't check the registers.
; We would want to do this if we were interested in storing
; something in the symbol's value location.
; number always return the location of the number on the bind
; other always return the location of the other on the bind
(if (null form) then 'Nil
elseif (numberp form) then
(if (and (fixp form) (greaterp form -1025) (lessp form 1024))
then `(fixnum ,form) ; small fixnum
else (d-loclit form nil))
then (if (and (null g-ignorereg) (car (d-bestreg form nil))) thenret
else (if (d-specialp form) then (d-loclit form t)
else (do ((ll g-locs (cdr ll)) ; check stack
" declared special by compiler")
then (if (eq form (car ll))
then (return `(stack ,n))
else (setq n (1- n)))))))
else (d-loclit form nil)))
;--- d-loclit :: locate or add litteral to bind list
; - form : form to check for and add if not present
; - flag : if t then if we are given a symbol, return the location of
; its value, else return the location of the symbol itself
; scheme: we share the locations of atom (symbols,numbers,string) but always
; create a fresh copy of anything else.
(defun d-loclit (form flag)
(prog (loc onplist symboltype)
(cond ((setq loc (get form g-bindloc))
then (do ((ll g-lits (cdr ll)) ; search for atom on list
then (setq loc n) ; found it
(setq g-litcnt (1+ g-litcnt)
(cond ((and symboltype (null onplist))
(putprop form loc g-bindloc))))
(return (if (and flag symboltype) then `(bind ,loc)
;--- d-locv :: find the location of a value cell, and dont return a register
;--- d-simple :: see of arg can be addresses in one instruction
; we define simple and really simple as follows
(if (d-rsimple arg) thenret
elseif (atom arg) then (d-loc arg)
elseif (and (memq (car arg) '(cdr car cddr cdar))
(setq tmp (d-rsimple (cadr arg))))
then (if (eq 'Nil tmp) then tmp
then #+(or for-vax for-tahoe)
elseif (eq 'cdr (car arg))
elseif (eq 'cddr (car arg))
elseif (eq 'cdar (car arg))
elseif (eq 'cdr (car arg))
elseif (not (eq 'cdr (car arg)))
elseif (eq 'lbind (car tmp))
elseif (eq 'stack (car tmp))
then `(vstack ,(cadr tmp))
elseif (eq 'fixnum (car tmp))
then `(immed ,(cadr tmp))
else (comp-err "bad arg to d-simple: " (or arg))))))
elseif (eq t arg) then 'T
else (car (d-bestreg arg nil)))
elseif (eq 'quote (car arg)) then (d-loclit (cadr arg) nil)))
;--- d-specialp :: check if a variable is special
; a varible is special if it has been declared as such, or if
; the variable special is t
(eq 'special (d-findfirstprop vrb 'bindtype)) ; local special decl
(eq 'special (get vrb g-bindtype))))
(or (eq 'fixnum (d-findfirstprop vrb 'vartype))
(eq 'fixnum (get vrb g-vartype)))))
;--- d-functyp :: return the type of function
; If name had a macro function definition, we return `macro'. Otherwise
; we see if name as a declared type, if so we return that. Otherwise
; we see if name is defined and we return that if so, and finally if
; we have no idea what this function is, we return lambda.
; This is not really satisfactory, but will handle most cases.
; If macrochk is nil then we don't check for the macro case. This
; is important to prevent recursive macroexpansion.
(defun d-functyp (name macrochk)
(setq ftyp (if (and macrochk (get name 'cmacro)) ;compiler macro
then (let ((type (getdisc func)))
(if (memq type '(lambda nlambda macro))
then 'lambda ; foreign function
" has a strange discipline "
elseif (and macrochk (get name 'macro-autoload))
(if (memq ftyp '(macro cmacro)) then ftyp
elseif (d-findfirstprop name 'functype) thenret
elseif (get name g-functype) thenret ; check if declared first
else 'lambda))) ; default is lambda
;--- d-allfixnumargs :: check if all forms are fixnums
; make sure all forms are fixnums or symbols whose declared type are fixnums
(defun d-allfixnumargs (forms)
(cond ((and (fixp (setq arg (car xx))) (not (bigp arg))))
(defun d-findfirstprop (name type)
(do ((xx g-decls (cdr xx))
(if (and (eq name (caar xx))
(get (setq rcd (cdar xx)) type))