1987-03-09 19:15:41 +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".
|
|
|
|
*/
|
1985-01-08 09:59:28 +00:00
|
|
|
#ifndef NORCSID
|
2019-05-10 17:17:24 +00:00
|
|
|
static char rcsid[] = "$Id$";
|
1985-01-08 09:59:28 +00:00
|
|
|
#endif
|
|
|
|
|
2017-11-10 03:22:13 +00:00
|
|
|
#include <assert.h>
|
2006-07-18 17:18:42 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2017-11-14 22:04:01 +00:00
|
|
|
#include <string.h>
|
1985-01-08 09:59:28 +00:00
|
|
|
#include "param.h"
|
|
|
|
#include "set.h"
|
|
|
|
#include "expr.h"
|
|
|
|
#include "lookup.h"
|
2019-05-10 17:17:24 +00:00
|
|
|
#include "subr.h"
|
1985-01-08 09:59:28 +00:00
|
|
|
#include "token.h"
|
|
|
|
#include "property.h"
|
|
|
|
#include "iocc.h"
|
|
|
|
#include <cgg_cg.h>
|
|
|
|
#include "regvar.h"
|
|
|
|
#include "extern.h"
|
|
|
|
|
|
|
|
extern set_t l_sets[];
|
|
|
|
|
|
|
|
int narexpr;
|
|
|
|
expr_t arexp[MAXATT];
|
|
|
|
|
|
|
|
expr_t iextoaddr();
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
/* Forward declarations */
|
|
|
|
static int instalookup(inst_t, int);
|
|
|
|
|
|
|
|
iocc_t subr_iocc(int tokarg, int subreg)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
inst_t insta;
|
2019-05-10 17:17:24 +00:00
|
|
|
iocc_t result;
|
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
|
|
|
|
insta.in_which = IN_COPY;
|
|
|
|
insta.in_info[0] = tokarg;
|
|
|
|
insta.in_info[1] = subreg;
|
2019-05-10 17:17:24 +00:00
|
|
|
result.in_index = instalookup(insta, 2);
|
|
|
|
if (tokarg < 1)
|
|
|
|
tokarg = 1;
|
|
|
|
if (subreg == 0)
|
|
|
|
for (i = 0; i < SETSIZE; i++)
|
|
|
|
result.in_set[i] = l_sets[tokpatset[tokarg - 1]].set_val[i];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < SETSIZE; i++)
|
1985-01-08 09:59:28 +00:00
|
|
|
result.in_set[i] = 0;
|
2019-05-10 17:17:24 +00:00
|
|
|
subregset(l_sets[tokpatset[tokarg - 1]].set_val, subreg, result.in_set);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
2019-05-10 17:17:24 +00:00
|
|
|
return (result);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
iocc_t tokm_iocc(int tokarg, char *ident)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
iocc_t result;
|
|
|
|
inst_t insta;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
char app[100];
|
|
|
|
int dummy;
|
2019-05-10 17:17:24 +00:00
|
|
|
|
|
|
|
for (i = 0; i < SETSIZE; i++)
|
1985-01-08 09:59:28 +00:00
|
|
|
result.in_set[i] = 0;
|
|
|
|
insta.in_which = IN_MEMB;
|
|
|
|
insta.in_info[0] = tokarg;
|
2019-05-10 17:17:24 +00:00
|
|
|
if (tokarg < 1)
|
|
|
|
tokarg = 1;
|
|
|
|
sprintf(app, "%%%d.%s", tokarg, ident);
|
|
|
|
insta.in_info[1] = 1
|
|
|
|
+ membset(tokpatset[tokarg - 1], ident, result.in_set, app, TYPREG,
|
|
|
|
&dummy);
|
|
|
|
result.in_index = instalookup(insta, 2);
|
|
|
|
return (result);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
1987-01-16 13:51:42 +00:00
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
iocc_t percident_iocc(char *ident)
|
|
|
|
{
|
1987-01-16 13:51:42 +00:00
|
|
|
iocc_t result;
|
|
|
|
inst_t insta;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1987-01-16 13:51:42 +00:00
|
|
|
char app[100];
|
|
|
|
int dummy;
|
2019-05-10 17:17:24 +00:00
|
|
|
|
|
|
|
for (i = 0; i < SETSIZE; i++)
|
1987-01-16 13:51:42 +00:00
|
|
|
result.in_set[i] = 0;
|
|
|
|
insta.in_which = IN_MEMB;
|
|
|
|
insta.in_info[0] = 0;
|
2019-05-10 17:17:24 +00:00
|
|
|
sprintf(app, "%%%s", ident);
|
|
|
|
insta.in_info[1] = 1
|
|
|
|
+ membset(cursetno, ident, result.in_set, app, TYPREG, &dummy);
|
|
|
|
result.in_index = instalookup(insta, 2);
|
|
|
|
return (result);
|
1987-01-16 13:51:42 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
iocc_t ident_iocc(char *ident)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
iocc_t result;
|
|
|
|
inst_t insta;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
register symbol *sy_p;
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 0; i < SETSIZE; i++)
|
1985-01-08 09:59:28 +00:00
|
|
|
result.in_set[i] = 0;
|
|
|
|
insta.in_which = IN_RIDENT;
|
2019-05-10 17:17:24 +00:00
|
|
|
sy_p = lookup(ident, symreg, mustexist);
|
1985-01-08 09:59:28 +00:00
|
|
|
insta.in_info[0] = sy_p->sy_value.syv_regno;
|
2019-05-10 17:17:24 +00:00
|
|
|
result.in_index = instalookup(insta, 1);
|
|
|
|
BIS(result.in_set, sy_p->sy_value.syv_regno);
|
|
|
|
return (result);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
iocc_t all_iocc(int all_no, int subreg)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
iocc_t result;
|
|
|
|
inst_t insta;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
set_t localset;
|
|
|
|
register short *sp;
|
|
|
|
|
|
|
|
sp = l_props[allreg[all_no]].pr_regset;
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 0; i < SETSIZE; i++)
|
|
|
|
localset.set_val[i] = i < SZOFSET(MAXREGS) ? sp[i] : 0;
|
|
|
|
for (i = 0; i < SETSIZE; i++)
|
1985-01-08 09:59:28 +00:00
|
|
|
result.in_set[i] = 0;
|
|
|
|
insta.in_which = IN_ALLOC;
|
|
|
|
insta.in_info[0] = all_no;
|
|
|
|
insta.in_info[1] = subreg;
|
2019-05-10 17:17:24 +00:00
|
|
|
subregset(localset.set_val, subreg, result.in_set);
|
|
|
|
result.in_index = instalookup(insta, 2);
|
|
|
|
return (result);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
iocc_t descr_iocc(char *ident)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
iocc_t result;
|
|
|
|
inst_t insta;
|
|
|
|
register symbol *sy_p;
|
|
|
|
register token_p tp;
|
2019-05-10 17:17:24 +00:00
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
int typerr;
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 0; i < SETSIZE; i++)
|
1985-01-08 09:59:28 +00:00
|
|
|
result.in_set[i] = 0;
|
2019-05-10 17:17:24 +00:00
|
|
|
sy_p = lookup(ident, symtok, mustexist);
|
1985-01-08 09:59:28 +00:00
|
|
|
tp = l_tokens[sy_p->sy_value.syv_tokno];
|
2019-05-10 17:17:24 +00:00
|
|
|
BIS(result.in_set, sy_p->sy_value.syv_tokno + nregs);
|
1985-01-08 09:59:28 +00:00
|
|
|
insta.in_which = IN_DESCR;
|
2019-05-10 17:17:24 +00:00
|
|
|
if (rvused & SL_REGVAR && strcmp(ident, "LOCAL") == 0)
|
1985-01-08 09:59:28 +00:00
|
|
|
insta.in_which = IN_S_DESCR;
|
2019-05-10 17:17:24 +00:00
|
|
|
else if (rvused & DL_REGVAR && strcmp(ident, "DLOCAL") == 0)
|
1985-01-08 09:59:28 +00:00
|
|
|
insta.in_which = IN_D_DESCR;
|
|
|
|
insta.in_info[0] = sy_p->sy_value.syv_tokno;
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 0; i < MAXATT; i++)
|
|
|
|
{
|
|
|
|
if (tp->tk_att[i].ta_type == -3)
|
|
|
|
{
|
|
|
|
if (narexpr > i)
|
|
|
|
error("token %s initialized with too many attributes", ident);
|
1985-01-08 09:59:28 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-05-10 17:17:24 +00:00
|
|
|
if (i >= narexpr)
|
|
|
|
{
|
|
|
|
error("token %s initialized with too few attributes", ident);
|
1985-01-08 09:59:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
typerr = 0;
|
2019-05-10 17:17:24 +00:00
|
|
|
switch (arexp[i].ex_typ)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
case TYPINT:
|
|
|
|
if (tp->tk_att[i].ta_type != -1)
|
|
|
|
if (tp->tk_att[i].ta_type == -2)
|
|
|
|
arexp[i] = iextoaddr(arexp[i]);
|
|
|
|
else
|
|
|
|
typerr++;
|
|
|
|
break;
|
|
|
|
case TYPBOOL:
|
1985-01-08 09:59:28 +00:00
|
|
|
typerr++;
|
2019-05-10 17:17:24 +00:00
|
|
|
break;
|
|
|
|
case TYPADDR:
|
|
|
|
if (tp->tk_att[i].ta_type != -2)
|
|
|
|
typerr++;
|
|
|
|
break;
|
|
|
|
case TYPREG:
|
|
|
|
if (tp->tk_att[i].ta_type < 0)
|
|
|
|
typerr++;
|
|
|
|
else if (!subset(arexp[i].ex_regset,
|
|
|
|
l_props[tp->tk_att[i].ta_type].pr_regset,
|
|
|
|
SZOFSET(MAXREGS)))
|
|
|
|
typerr++;
|
|
|
|
break;
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
if (typerr)
|
2019-05-10 17:17:24 +00:00
|
|
|
error("Attribute %s.%s given wrong type of value", ident,
|
|
|
|
tp->tk_att[i].ta_name);
|
|
|
|
insta.in_info[i + 1] = arexp[i].ex_index;
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
2019-05-10 17:17:24 +00:00
|
|
|
result.in_index = instalookup(insta, i + 1);
|
|
|
|
return (result);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* low level instance package */
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
int ninstances = 1;
|
1985-01-08 09:59:28 +00:00
|
|
|
inst_t l_instances[MAXINSTANCES];
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
static int instalookup(inst_t insta, int filled)
|
|
|
|
{
|
|
|
|
register int i, j;
|
1985-01-08 09:59:28 +00:00
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
for (j = filled; j <= MAXATT; j++)
|
1985-01-08 09:59:28 +00:00
|
|
|
insta.in_info[j] = 0;
|
2019-05-10 17:17:24 +00:00
|
|
|
for (i = 0; i < ninstances; i++)
|
|
|
|
{
|
1985-01-08 09:59:28 +00:00
|
|
|
if (insta.in_which != l_instances[i].in_which)
|
|
|
|
continue;
|
2019-05-10 17:17:24 +00:00
|
|
|
for (j = 0; j <= MAXATT; j++)
|
|
|
|
if (insta.in_info[j] != l_instances[i].in_info[j])
|
1985-01-08 09:59:28 +00:00
|
|
|
goto cont;
|
2019-05-10 17:17:24 +00:00
|
|
|
return (i);
|
|
|
|
cont: ;
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|
2019-05-10 17:17:24 +00:00
|
|
|
NEXT(ninstances, MAXINSTANCES, "Instances");
|
1985-01-08 09:59:28 +00:00
|
|
|
l_instances[i] = insta;
|
2019-05-10 17:17:24 +00:00
|
|
|
return (i);
|
1985-01-08 09:59:28 +00:00
|
|
|
}
|