{$M-,X+}
program hash;

include {NOLIST} 'domain:mdep.def';
include {NOLIST} 'domain:master.def';
include {NOLIST} 'domain:msub.hdr';
include {NOLIST} 'domain:eutil.hdr';

{	This file contains the hash functions used by the domain server
}
function hashlabel(var x:exp_label):integer;

begin
with x
do	if labinfo[0]=0
	then	hashlabel:=0
	else	hashlabel:=band(0377b,bshift(labinfo[0],6)+
				      labinfo[1]+
				      labinfo[labinfo[0]])
end;

function hashchunk(var x:exp_chunk):integer;

var	i,sum:integer;

begin
with x
do	if ckind=name_chunk
	then	hashchunk:=hashlabel(rrname.dlabels[1])
	else	begin
		sum:=0;
		for i:=1 to min(3,lit_data_count)
		do	sum:=bshift(sum,2)+lit_data[i];
		hashchunk:=band(0377b,sum)
		end
end. { hashchunk }
