2019-05-10 17:17:40 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*
|
|
|
|
* Author: Hans van Staveren
|
|
|
|
*/
|
2006-07-20 23:04:15 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1984-05-17 13:42:36 +00:00
|
|
|
#include "param.h"
|
|
|
|
#include "types.h"
|
1990-09-04 16:42:43 +00:00
|
|
|
#include "tes.h"
|
1984-05-17 13:42:36 +00:00
|
|
|
#include "lookup.h"
|
|
|
|
#include "alloc.h"
|
|
|
|
#include "proinf.h"
|
2019-05-10 17:17:40 +00:00
|
|
|
#include "util.h"
|
1984-05-17 13:42:36 +00:00
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
unsigned hash(char *string)
|
|
|
|
{
|
1984-05-17 13:42:36 +00:00
|
|
|
register char *p;
|
2019-05-10 17:17:40 +00:00
|
|
|
register unsigned i, sum;
|
1984-05-17 13:42:36 +00:00
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
for (sum = i = 0, p = string; *p; i += 3)
|
|
|
|
sum ^= (*p++) << (i & 07);
|
|
|
|
return (sum);
|
1984-05-17 13:42:36 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
sym_p symlookup(char *name, int status, int flags)
|
|
|
|
{
|
|
|
|
register sym_p *spp, sp;
|
|
|
|
register int i;
|
1984-05-17 13:42:36 +00:00
|
|
|
static short genfrag = 32767;
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
spp = &symhash[hash(name) % NSYMHASH];
|
1984-05-17 13:42:36 +00:00
|
|
|
while (*spp != (sym_p) 0)
|
2019-05-10 17:17:40 +00:00
|
|
|
if (strncmp((*spp)->s_name, name, IDL) == 0)
|
|
|
|
{
|
1984-05-17 13:42:36 +00:00
|
|
|
sp = *spp;
|
2019-05-10 17:17:40 +00:00
|
|
|
if ((sp->s_flags ^ flags) & SYMPRO)
|
|
|
|
error("%s is both proc and datalabel", name);
|
|
|
|
if (status == DEFINING)
|
|
|
|
{
|
|
|
|
if (sp->s_flags & SYMDEF)
|
|
|
|
error("redefined symbol %s", name);
|
1984-05-17 13:42:36 +00:00
|
|
|
sp->s_flags |= SYMDEF;
|
|
|
|
}
|
2019-05-10 17:17:40 +00:00
|
|
|
return (sp);
|
|
|
|
}
|
|
|
|
else
|
1984-05-17 13:42:36 +00:00
|
|
|
spp = &(*spp)->s_next;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* symbol not found, enter in table
|
|
|
|
*/
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
i = strlen(name) + 1;
|
|
|
|
if (i & 1)
|
|
|
|
i++;
|
|
|
|
if (i > IDL)
|
|
|
|
i = IDL;
|
|
|
|
*spp = sp = newsym(i);
|
|
|
|
strncpy(sp->s_name, name, i);
|
1984-05-17 13:42:36 +00:00
|
|
|
sp->s_flags = flags;
|
|
|
|
if (status == DEFINING)
|
|
|
|
sp->s_flags |= SYMDEF;
|
|
|
|
sp->s_frag = genfrag--;
|
2019-05-10 17:17:40 +00:00
|
|
|
return (sp);
|
1984-05-17 13:42:36 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
num_p numlookup(unsigned number)
|
|
|
|
{
|
1984-05-17 13:42:36 +00:00
|
|
|
register num_p *npp, np;
|
|
|
|
|
2019-05-10 17:17:40 +00:00
|
|
|
npp = &curpro.numhash[number % NNUMHASH];
|
1984-05-17 13:42:36 +00:00
|
|
|
while (*npp != (num_p) 0)
|
|
|
|
if ((*npp)->n_number == number)
|
2019-05-10 17:17:40 +00:00
|
|
|
return (*npp);
|
1984-05-17 13:42:36 +00:00
|
|
|
else
|
|
|
|
npp = &(*npp)->n_next;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* local label not found, enter in tabel
|
|
|
|
*/
|
|
|
|
|
|
|
|
*npp = np = newnum();
|
|
|
|
np->n_number = number;
|
|
|
|
np->n_repl = np;
|
2019-05-10 17:17:40 +00:00
|
|
|
return (np);
|
1984-05-17 13:42:36 +00:00
|
|
|
}
|