;;;;	TYPES	;;;;

if1,[
typlo=:400
refbit=:400000
relbit=:200000
repbit=:200000
gcbit=: 100000
typmsk=:(07777)

;	offsets for blocks used in the CLU support system.

;	arep,array_rep
ar.cod==: 0	; tarep+low_bound
ar.rel==: 1	; [rsb,,rel] -size,,rel to usable stuff in vector
ar.vec==: 2	; [rsb,,ref] predict,,ref to real vector

;	crep,call_block_rep
pc.cod==: 0	; tcrep+size (in words)
pc.set==: 1	; [rsb] the setup for the procedure (pc.set=en.set !!)
pc.num==: 2	; [rsb] the number of arguments given in the call
pc.str==: 3	; [ref] the external name (or operation name)
pc.typ==: 4	; [ref] the cluster type (if an operation)
pc.par==: 5	; [ref] parms given for the procedure
pc.dat==: 6	; any more words are refs

;	drep,descriptor_rep
td.cod==: 0	; [rsb] code for type desc & length
td.fix==: 1	; [ref] the fixed up value for the descriptor (init 0)
td.opt==: 2	; [rsb] the variety of type desc
td.nam==: 3	; [ref] string ref for external name (or 0)
td.arg==: 4	; [ref] to parms or arguments (td,sd,pt,it,ed,zd)
		; [ref] to cluster desc (rt,xr)
		; [0,,rsb] position of parm (pa)
td.rtn==: 5	; [ref] to return types (for pt,it)
		; [ref] to proc parms (rt,xr)
td.sig==: 6	; [ref] to signal types (for pt,it)

;	option codes in td.opt (must be single bits)
tdc.td==:1	; simple type desc
tdc.sd==:2	; selected type desc
tdc.pa==:4	; cluster/proc parm
tdc.rt==:10	; return type desc
tdc.pt==:20	; proc type desc
tdc.it==:40	; iterator type desc
tdc.ed==:100	; exception desc
tdc.xr==:200	; external proc desc
tdc.pp==:400	; proc parm dependent
tdc.cp==:1000	; cluster parm dependent
tdc.zd==:2000	; zdesc (for records/oneofs)

;	erep,entry_rep
en.cod==: 0	; terep+size (in words)
en.set==: 1	; [rsb,,rel] the setup instruction to XCT (en.set=pc.set !!)
en.lpr==: 2	; [ref,,ref] the (lr,,pr) pair
en.vi==: 3	; [ref+1,,rsb] the variable init pair (ref+1,,len)
en.par==: 4	; [ref,,ref] the (proc parm,,cluster parm) pair
en.tr==: 5	; [rsb,,ref] the trace info (if any)
en.typ==: 6	; [ref] the type (or type desc) for this entry
en.nxt==: 7	; [ref] the chain of entry blocks (for parameters)
en.dat==: 8.	; any more words are refs
en.odv==: 8.	; [ref] optional vector to own data

;	prep,pure_part_rep
pr.cod==: 0	; tprep+size (in words)
pr.err==: 1	; [rsb,,rsb] LH has prc codes, RH has disp to error info
pr.cut==: 2	; [rsb] stack cutback on exit
pr.nam==: 3	; [rsb] disp to names in pr block
pr.go==:  4	; [rsb] first word of code here
		; further words are [rsb], except that
		; [ref]'s start where pr.err is an offset to

; prc codes
prc.ni==: 1	; no interrupts while this proc is current
prc.cp==: 2	; this proc is dependent on cluster parms
prc.na==: 4	; no array chopping while in this procedure
prc.pp==: 10	; this proc is dependent on proc parms
prc.it==: 20	; this proc is really an iterator
prc.ma==: 40	; this proc is multi-argument (top one gives #)

;	orep,oneof_rep
on.cod==: 0	; torep+tag
on.ref==: 1	; [ref] info part

;	srep,string_rep
st.cod==: 0	; tsrep+number_of_chars
st.dat==: 1	; [rsb] characters immediately follow

;	vec,vector
ve.cod==: 0	; tvec+size (in words)
ve.dat==: 1	; [ref] references follow

;	wvec,word_vector
wv.cod==: 0	; twvec+size (in words)
wv.dat==: 1	; [rsb] words of raw seething bits follow

;	xvec,ref_vector
xv.cod==: 0	; txvec+size (in words)
xv.dat==: 1	; [rsb,,ref] words in remainder

fb.cod==0
fb.dev==1
fb.nm1==2
fb.nm2==3
fb.usr==4
fb..==5

;	deft is used to define types
define	deft	name,xname
if1	[t!name=:(.+typbit)
	 t%!name=:.+typbit
	 typnum==typnum+1]
ife	usrflg,[
	if1	[ [0 ? ascii	"xname"]
		]
	if2	[strlit xname
		]
	]
ifn	usrflg,[.=.+1]
termin
typnum==0

]	; end of first pass cond

;	Fake a vector for the type codes.
typlen==:100
loc	typlo-2
types$:	ife	usrflg,[tvec+typlen ? ttype+typusr-1 ]
loc	typlo
;	The most basic type codes to occur as LH of references
typbit==refbit
deft	ref,ref
deft	xref,?ref
typbit==refbit+relbit
deft	rel,rel
deft	xrel,?rel
typrep==:.
typbit==repbit
;	The most basic type codes to appear as LH of 1st words
deft	arep,arep
deft	crep,crep
deft	drep,drep
deft	erep,erep
deft	prep,prep
deft	orep,orep
deft	srep,srep
deft	vec,vec
deft	wvec,wvec
deft	xrep,xvec
typbit==0
typrsb==:.
deft	int,int
deft	bool,bool
deft	char,char
deft	type,type
deft	mrtn,mrtn
deft	chan,chan
typref==:.
deft	str,str
deft	real,real
typbit==refbit
deft	pcb,pcb		; procedure call block
deft	td,tdesc	; normal-type descriptor
deft	ppd,ppdesc	; proc parm desc
deft	cpd,cpdesc	; cluster parm desc
typbit==0
deft	null,null
deft	none,none	; type of return obj from procs that don't have any
deft	any,any		; type any
typusr==:.	; User-defined types from here on
%str=:refbit(tstr)
