ANSI C compilation fixes

This commit is contained in:
carl 2019-05-14 23:22:38 +08:00
parent 9bb69bbb98
commit b1f6d5d827
11 changed files with 1075 additions and 1013 deletions

View file

@ -6,30 +6,30 @@ static char rcsidp3[] = "$Id$";
#define UPDATEWORST(backups) if(backups>mostbackups) mostbackups = backups;
PRIVATE int leftmatch();
PRIVATE int rightmatch();
PRIVATE int rightmatch(struct mnems,struct mnems,int, int);
PRIVATE int leftmatch(struct mnems, struct mnems, int, int);
findworst(patt,repl)
struct mnems patt,repl;
void findworst(struct mnems patt,struct mnems repl)
{
/*
/* Find the pattern that requires the most backup of output queue.
/* Let repl be r1 r2 ... rn. All these are already on the output queue.
/* Possibilities in order of most backup first are:
/* a) pattern of form: p1 .... pb r1 r2 .... rn pc ... pd
/* i.e. <repl> completely in pattern.
/* requires a backup of b+n instructions
/* and a goto to state 0.
/* b) pattern of form: p1 .... pb r1 r2 .... ri
/* i.e. a prefix of <repl> ends a pattern.
/* requires a backup of b+n instructions
/* and a goto to state 0.
/* c) pattern of form: ri ri+1 ... rn pc ... pd
/* i.e. a suffix of <repl> starts a pattern.
/* requires a backup of j-i+1 instructions and a goto to state 0.
/* d) pattern of the form: ri ri+1 ... rj
/* i.e. a substring of <repl> is a complete pattern
/* requires a backup of j-i+1 instructions and a goto to state 0.
/ Find the pattern that requires the most backup of output queue.
/ Let repl be r1 r2 ... rn. All these are already on the output queue.
/ Possibilities in order of most backup first are:
/ a) pattern of form: p1 .... pb r1 r2 .... rn pc ... pd
/ i.e. <repl> completely in pattern.
/ requires a backup of b+n instructions
/ and a goto to state 0.
/ b) pattern of form: p1 .... pb r1 r2 .... ri
/ i.e. a prefix of <repl> ends a pattern.
/ requires a backup of b+n instructions
/ and a goto to state 0.
/ c) pattern of form: ri ri+1 ... rn pc ... pd
/ i.e. a suffix of <repl> starts a pattern.
/ requires a backup of j-i+1 instructions and a goto to state 0.
/ d) pattern of the form: ri ri+1 ... rj
/ i.e. a substring of <repl> is a complete pattern
/ requires a backup of j-i+1 instructions and a goto to state 0.
*/
int n = repl.m_len;
int diff = patt.m_len - repl.m_len;
@ -45,7 +45,7 @@ findworst(patt,repl)
if(actions[s]==(struct action *)NULL)
continue;
/* look for case a */
if(first=rightmatch(patterns[s],repl,1,n)) {
if( (first=rightmatch(patterns[s],repl,1,n))) {
UPDATEWORST(first-1+n);
}
/* look for case b */
@ -76,16 +76,14 @@ findworst(patt,repl)
fprintf(ofile,"\t\tOO_mkrepl(%d,%d,%d);\n",n,diff,mostbackups);
}
findfail(state,resout,rescpy,resgto)
int state;
int *resout, *rescpy, *resgto;
void findfail(int state, int *resout, int *rescpy, int *resgto)
{
/*
/* If pattern matching fails in 'state', how many outputs and how many
/* push backs are requires. If pattern is of the form p1 p2 .... pn
/* look for patterns of the form p2 p3 ... pn; then p3 p4 ... pn; etc.
/* The first such match of the form pi pi+1 ... pn requires an output
/* of p1 p2 ... pi-1 and a push back of pn pn-1 ... pi.
/ If pattern matching fails in 'state', how many outputs and how many
/ push backs are requires. If pattern is of the form p1 p2 .... pn
/ look for patterns of the form p2 p3 ... pn; then p3 p4 ... pn; etc.
/ The first such match of the form pi pi+1 ... pn requires an output
/ of p1 p2 ... pi-1 and a push back of pn pn-1 ... pi.
*/
int s,i;
struct state *p;
@ -114,15 +112,12 @@ findfail(state,resout,rescpy,resgto)
*resgto = 0;
}
PRIVATE int
leftmatch(patt,repl,i,j)
struct mnems patt,repl;
int i,j;
PRIVATE int leftmatch(struct mnems patt,struct mnems repl,int i,int j)
{
/*
/* Return the first complete match of the mnems <ri,ri+1,..,rj> of
/* 'repl' in the mnems of 'patt'. Find the leftmost match.
/* Return 0 if fails.
/ Return the first complete match of the mnems <ri,ri+1,..,rj> of
/ 'repl' in the mnems of 'patt'. Find the leftmost match.
/ Return 0 if fails.
*/
int lenrij = j-i+1;
int lastpos = patt.m_len - lenrij + 1;
@ -139,15 +134,12 @@ leftmatch(patt,repl,i,j)
return(0);
}
PRIVATE int
rightmatch(patt,repl,i,j)
struct mnems patt,repl;
int i,j;
PRIVATE int rightmatch(struct mnems patt,struct mnems repl,int i,int j)
{
/*
/* Return the first complete match of the mnems <ri,ri+1,..,rj> of
/* 'repl' in the mnems of 'patt'. Find the rightmost match.
/* Return 0 if fails.
/ Return the first complete match of the mnems <ri,ri+1,..,rj> of
/ 'repl' in the mnems of 'patt'. Find the rightmost match.
/ Return 0 if fails.
*/
int lenrij = j-i+1;
int lastpos = patt.m_len - lenrij + 1;

View file

@ -13,9 +13,9 @@ static char rcsidp2[] = "$Id$";
extern char em_flag[];
extern char em_mnem[][4];
PRIVATE idinit();
PRIVATE void idinit(char *, int, int);
initlex()
void initlex(void)
{
register int i,j;
init_idf();
@ -47,11 +47,8 @@ initlex()
}
}
PRIVATE
idinit(tag,opcode,argfmt)
char *tag;
int opcode;
int argfmt;
PRIVATE void idinit(char *tag, int opcode, int argfmt)
{
struct idf *p;
p = str2idf(tag,0);

View file

@ -3,49 +3,66 @@ BEGIN {
seenproc = 0;
CC="${CMD}"
if (prototypes == "") prototypes = "prototypes"
print "#include \"nopt.h\""
}
/^%/ {}
/^$/ {}
/^[a-z]/ && $3 !~ /.*NOTIMPLEMENTED.*/ {
if(seenproc) {
print "}"
print "--EOF--"
printf "if %s O_%s.c\n",CC,nam
printf "then :\nelse exit 1\nfi\n"
printf "rm -f O_%s.c\n",nam
}
seenproc = 1
$1 = substr($1,1,index($1,"\t")-1);
nam = $1
printf "cat > O_%s.c << '--EOF--'\n",$1
print "#include \"nopt.h\""
print ""
printf "void O_%s(",$1
prototype = "_PROTOTYPE(void O_" $1 ", ("
nparms = split($2,parms,":");
for(p=1;p<nparms;p++) {
if(p!=1) {
printf ","
}
split(parms[p+1],a," ")
printf a[1]
paramstr = $2
gsub(/\t/,"",paramstr)
gsub(/^[ \t]+/,"",paramstr)
gsub(/[ \t]+$/,"",paramstr)
gsub(/:([A-Za-z0-9]+[ ])/,"&!",paramstr)
count = split(paramstr,p2,"!");
paramstr = ""
if (count == 0)
{
printf "void"
paramstr = paramstr "void"
}
printf ")\n"
if(nparms > 1) {
prototype = prototype parms[1]
printf "\t%s",parms[1]
}
else {
prototype = prototype "void"
}
for(p=1;p<nparms;p++) {
split(parms[p+1],a," ")
prototype = prototype " " a[1]
printf " %s;\n",a[1]
if(a[2]) {
prototype = prototype ", " a[2] a[3] a[4]
printf "\t%s%s%s",a[2],a[3],a[4]
else
{
for (i=1;i<=count;i++)
{
if (length(p2[i]) > 0)
{
nparms = split(p2[i],params,":");
if (nparms >0 )
{
gsub(/^[ \t]+/,"",params[1])
gsub(/[ \t]+$/,"",params[1])
gsub(/^[ \t]+/,"",params[2])
gsub(/[ \t]+$/,"",params[2])
paramstr = paramstr params[1] " " params[2]
printf "%s %s",params[1],params[2]
if(count!=i)
{
paramstr = paramstr ", "
printf ", "
}
} else
{
printf "void"
paramstr = paramstr "void"
}
}
}
}
prototype = prototype paramstr
print ")"
print prototype "));" >> prototypes
if($3) {
printf "{\n\t%s\n",$3
@ -60,9 +77,6 @@ BEGIN {
END {
if(seenproc) {
print "}"
print "--EOF--"
printf "if %s O_%s.c\n",CC,nam
printf "then :\nelse exit 1\nfi\n"
printf "rm -f O_%s.c\n",nam
print ""
}
}

View file

@ -4,20 +4,16 @@ static char rcsid3[] = "$Id$";
#include "nopt.h"
void
EM_mkop(p,opcode)
register p_instr p;
int opcode;
void EM_mkop(p, opcode)
register p_instr p;int opcode;
{
p->em_type = EM_MNEM;
p->em_opcode = opcode;
p->em_argtype = 0;
}
void
EM_mknarg(p,opcode)
register p_instr p;
int opcode;
void EM_mknarg(p, opcode)
register p_instr p;int opcode;
{
p->em_type = EM_MNEM;
p->em_opcode = opcode;
@ -25,11 +21,8 @@ EM_mknarg(p,opcode)
p->em_cst = 0;
}
void
EM_mkilb(p,opcode,lab)
register p_instr p;
int opcode;
label lab;
void EM_mkilb(p, opcode, lab)
register p_instr p;int opcode;label lab;
{
p->em_type = EM_MNEM;
p->em_argtype = ilb_ptyp;
@ -37,11 +30,8 @@ EM_mkilb(p,opcode,lab)
p->em_ilb = lab;
}
void
EM_mknof(p,opcode,lab,off)
register p_instr p;
int opcode;
label lab;
void EM_mknof(p, opcode, lab, off)
register p_instr p;int opcode;label lab;
arith off;
{
p->em_type = EM_MNEM;
@ -51,24 +41,19 @@ EM_mknof(p,opcode,lab,off)
p->em_off = off;
}
void
EM_mksof(p,opcode,name,off)
register p_instr p;
int opcode;
char *name;
void EM_mksof(p, opcode, name, off)
register p_instr p;int opcode;char *name;
arith off;
{
p->em_type = EM_MNEM;
p->em_argtype = sof_ptyp;
p->em_opcode = opcode;
p->em_dnam = OO_freestr(name);
p->em_dnam = OO_freestr(name);
p->em_off = off;
}
void
EM_mkcst(p,opcode,cst)
register p_instr p;
int opcode;
void EM_mkcst(p, opcode, cst)
register p_instr p;int opcode;
arith cst;
{
p->em_type = EM_MNEM;
@ -77,11 +62,8 @@ EM_mkcst(p,opcode,cst)
p->em_cst = cst;
}
void
EM_mkpro(p,opcode,pnam)
register p_instr p;
int opcode;
char *pnam;
void EM_mkpro(p, opcode, pnam)
register p_instr p;int opcode;char *pnam;
{
p->em_type = EM_MNEM;
p->em_argtype = pro_ptyp;
@ -89,11 +71,8 @@ EM_mkpro(p,opcode,pnam)
p->em_pnam = OO_freestr(pnam);
}
void
EM_mkdefilb(p,opcode,deflb)
register p_instr p;
int opcode;
label deflb;
void EM_mkdefilb(p, opcode, deflb)
register p_instr p;int opcode;label deflb;
{
p->em_type = EM_DEFILB;
p->em_opcode = opcode;
@ -101,8 +80,7 @@ EM_mkdefilb(p,opcode,deflb)
p->em_ilb = deflb;
}
void
EM_Nop(opcode)
void EM_Nop(opcode)
int opcode;
{
register p_instr p = GETNXTPATT();
@ -111,8 +89,7 @@ EM_Nop(opcode)
p->em_argtype = 0;
}
void
EM_Nnarg(opcode)
void EM_Nnarg(opcode)
int opcode;
{
register p_instr p = GETNXTPATT();
@ -122,10 +99,8 @@ EM_Nnarg(opcode)
p->em_cst = 0;
}
void
EM_Nilb(opcode,lab)
int opcode;
label lab;
void EM_Nilb(opcode, lab)
int opcode;label lab;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_MNEM;
@ -134,10 +109,8 @@ EM_Nilb(opcode,lab)
p->em_ilb = lab;
}
void
EM_Nnof(opcode,lab,off)
int opcode;
label lab;
void EM_Nnof(opcode, lab, off)
int opcode;label lab;
arith off;
{
register p_instr p = GETNXTPATT();
@ -148,22 +121,19 @@ EM_Nnof(opcode,lab,off)
p->em_off = off;
}
void
EM_Nsof(opcode,name,off)
int opcode;
char *name;
void EM_Nsof(opcode, name, off)
int opcode;char *name;
arith off;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_MNEM;
p->em_argtype = sof_ptyp;
p->em_opcode = opcode;
p->em_dnam = OO_freestr(name);
p->em_dnam = OO_freestr(name);
p->em_off = off;
}
void
EM_Ncst(opcode,cst)
void EM_Ncst(opcode, cst)
int opcode;
arith cst;
{
@ -174,10 +144,8 @@ EM_Ncst(opcode,cst)
p->em_cst = cst;
}
void
EM_Npro(opcode,pnam)
int opcode;
char *pnam;
void EM_Npro(opcode, pnam)
int opcode;char *pnam;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_MNEM;
@ -186,10 +154,8 @@ EM_Npro(opcode,pnam)
p->em_pnam = OO_freestr(pnam);
}
void
EM_Ndefilb(opcode,deflb)
int opcode;
label deflb;
void EM_Ndefilb(opcode, deflb)
int opcode;label deflb;
{
register p_instr p = GETNXTPATT();
p->em_type = EM_DEFILB;
@ -198,8 +164,7 @@ EM_Ndefilb(opcode,deflb)
p->em_ilb = deflb;
}
void
EM_Rop(opcode)
void EM_Rop(opcode)
int opcode;
{
register p_instr p = GETNXTREPL();
@ -208,8 +173,7 @@ EM_Rop(opcode)
p->em_argtype = 0;
}
void
EM_Rnarg(opcode)
void EM_Rnarg(opcode)
int opcode;
{
register p_instr p = GETNXTREPL();
@ -219,10 +183,8 @@ EM_Rnarg(opcode)
p->em_cst = 0;
}
void
EM_Rilb(opcode,lab)
int opcode;
label lab;
void EM_Rilb(opcode, lab)
int opcode;label lab;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_MNEM;
@ -231,10 +193,8 @@ EM_Rilb(opcode,lab)
p->em_ilb = lab;
}
void
EM_Rnof(opcode,lab,off)
int opcode;
label lab;
void EM_Rnof(opcode, lab, off)
int opcode;label lab;
arith off;
{
register p_instr p = GETNXTREPL();
@ -245,22 +205,19 @@ EM_Rnof(opcode,lab,off)
p->em_off = off;
}
void
EM_Rsof(opcode,name,off)
int opcode;
char *name;
void EM_Rsof(opcode, name, off)
int opcode;char *name;
arith off;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_MNEM;
p->em_argtype = sof_ptyp;
p->em_opcode = opcode;
p->em_dnam = OO_freestr(name);
p->em_dnam = OO_freestr(name);
p->em_off = off;
}
void
EM_Rcst(opcode,cst)
void EM_Rcst(opcode, cst)
int opcode;
arith cst;
{
@ -271,10 +228,8 @@ EM_Rcst(opcode,cst)
p->em_cst = cst;
}
void
EM_Rpro(opcode,pnam)
int opcode;
char *pnam;
void EM_Rpro(opcode, pnam)
int opcode;char *pnam;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_MNEM;
@ -283,10 +238,8 @@ EM_Rpro(opcode,pnam)
p->em_pnam = OO_freestr(pnam);
}
void
EM_Rdefilb(opcode,deflb)
int opcode;
label deflb;
void EM_Rdefilb(opcode, deflb)
int opcode;label deflb;
{
register p_instr p = GETNXTREPL();
p->em_type = EM_DEFILB;

View file

@ -4,36 +4,36 @@ static char rcsid2[] = "$Id$";
#include "nopt.h"
extern struct dfa OO_checknext[]; /* Initialized in dfa.c */
extern struct dfa *OO_base[]; /* Initialized in dfa.c */
extern struct dodefault OO_default[]; /* Initialized in dfa.c */
extern int OO_maxpattern; /* Initialized in dfa.c */
extern int OO_maxreplacement; /* Initialized in dfa.c */
extern int (*OO_ftrans[])(); /* Initialized in trans.c */
extern struct dfa OO_checknext[]; /* Initialized in dfa.c */
extern struct dfa *OO_base[]; /* Initialized in dfa.c */
extern struct dodefault OO_default[]; /* Initialized in dfa.c */
extern int OO_maxpattern; /* Initialized in dfa.c */
extern int OO_maxreplacement; /* Initialized in dfa.c */
extern int (*OO_ftrans[])(); /* Initialized in trans.c */
extern char em_mnem[][4];
extern char em_pseu[][4];
extern char em_mnem[][4];
extern char em_pseu[][4];
int OO_state = 0;
p_instr OO_buffer;
p_instr OO_patternqueue;
p_instr OO_nxtpatt;
p_instr OO_endbackup;
p_instr OO_nxtrepl;
static p_instr OO_replqueue;
p_instr OO_buffer;
p_instr OO_patternqueue;
p_instr OO_nxtpatt;
p_instr OO_endbackup;
p_instr OO_nxtrepl;
static p_instr OO_replqueue;
static char *filename;
static char *strqueue;
static char *nextstr;
static char *laststr;
static char *filename;
static char *strqueue;
static char *nextstr;
static char *laststr;
arith OO_WSIZE; /* wordlength */
arith OO_DWSIZE; /* 2*wordlength */
arith OO_PSIZE; /* pointer length */
arith OO_WSIZE; /* wordlength */
arith OO_DWSIZE; /* 2*wordlength */
arith OO_PSIZE; /* pointer length */
#ifdef STATS
int OO_wrstats = 1; /* pattern statistics output */
int OO_wrstats = 1; /* pattern statistics output */
#endif
#ifdef DEBUG
#define printstate(s) dumpstate(s)
@ -42,108 +42,103 @@ int OO_wrstats = 1; /* pattern statistics output */
#endif /* DEBUG */
/**** WHICH IS FASTER? ****
#define BTSCPY(pp,qq,i,p,q,n) btscpy(p,q,(n)*sizeof(struct e_instr))
#define BTSCPY(pp,qq,i,p,q,n) btscpy(p,q,(n)*sizeof(struct e_instr))
**************************/
#define BTSCPY(pp,qq,i,p,q,n) for(pp=(p),qq=(q),i=(n);i--;*pp++ = *qq++)
PRIVATE void allocmem();
PRIVATE void allocmem(void);
void
O_init(wsize,psize)
arith wsize, psize;
void O_init(arith wsize, arith psize)
{
allocmem();
C_init(wsize,psize);
C_init(wsize, psize);
OO_WSIZE = wsize;
OO_DWSIZE = 2*wsize;
OO_DWSIZE = 2 * wsize;
OO_PSIZE = psize;
}
int
O_open(fname)
char *fname;
int O_open(char *fname)
{
filename = fname;
return(C_open(fname));
return (C_open(fname));
}
void
O_magic()
void O_magic(void)
{
C_magic();
}
void
O_close()
void O_close(void)
{
C_close();
}
void
OO_dfa(last)
register int last;
void OO_dfa(register int last)
{
register struct dfa *b;
register struct dodefault *d;
register int (*f)();
for(;;) {
for (;;)
{
printstate("OO_dfa");
if((b=OO_base[OO_state]) && ((b += last)->check==OO_state)) {
if(f=OO_ftrans[OO_state = b->next]) (*f)();
if ((b = OO_base[OO_state]) && ((b += last)->check == OO_state))
{
if ((f = OO_ftrans[OO_state = b->next]))
(*f)();
}
else if (OO_state) {
else if (OO_state)
{
/* consult default entry */
d = &OO_default[OO_state];
if(!OO_endbackup) OO_endbackup = OO_nxtpatt;
if (!OO_endbackup)
OO_endbackup = OO_nxtpatt;
OO_nxtpatt--;
OO_patternqueue += d->numout;
if(f=OO_ftrans[OO_state = d->next]) (*f)();
if ((f = OO_ftrans[OO_state = d->next]))
(*f)();
}
else OO_flush();
if (!OO_endbackup) return;
else
OO_flush();
if (!OO_endbackup)
return;
last = (OO_nxtpatt++)->em_opcode;
if (OO_nxtpatt >= OO_endbackup)
OO_endbackup = 0;
}
}
PRIVATE void
fatal(s,a)
char *s;
int a;
PRIVATE void fatal(s, a)
char *s;int a;
{
fprint(STDERR, "%s: ", filename ? filename : "standard input");
fprint(STDERR,s,a);
fprint(STDERR,"\n");
fprint(STDERR, s, a);
fprint(STDERR, "\n");
sys_stop(S_EXIT);
}
PRIVATE void
allocmem()
PRIVATE void allocmem(void)
{
/* Allocate memory for queues on heap */
OO_buffer = (p_instr)
Malloc((unsigned)(MAXBUFFER*sizeof(struct e_instr)));
OO_buffer = (p_instr) Malloc(
(unsigned) (MAXBUFFER * sizeof(struct e_instr)));
OO_patternqueue = OO_nxtpatt = OO_buffer;
OO_replqueue = (p_instr)
Malloc((unsigned)OO_maxreplacement*sizeof(struct e_instr));
OO_replqueue = (p_instr) Malloc(
(unsigned) OO_maxreplacement * sizeof(struct e_instr));
OO_nxtrepl = OO_replqueue;
nextstr = strqueue =
(char *)Malloc(MAXSTRING*sizeof(char));
nextstr = strqueue = (char *) Malloc(MAXSTRING * sizeof(char));
laststr = strqueue + MAXSTRING - 1;
}
char *
OO_freestr(str)
char *str;
char * OO_freestr(char *str)
{
register char *s = str;
register char *res;
while (*s++);
again:
if ((s-str) > (laststr-nextstr)) {
unsigned newsize = (laststr - strqueue + 1)*2;
res = Realloc(strqueue,newsize);
while (*s++)
;
again: if ((s - str) > (laststr - nextstr))
{
unsigned newsize = (laststr - strqueue + 1) * 2;
res = Realloc(strqueue, newsize);
laststr = res + newsize - 1;
nextstr = res + (nextstr - strqueue);
strqueue = res;
@ -153,201 +148,202 @@ OO_freestr(str)
#endif
goto again;
}
res=nextstr;
for(s=str;*nextstr++ = *s++;);
return(res);
res = nextstr;
for (s = str; (*nextstr++ = *s++);)
;
return (res);
}
void
OO_flush()
void OO_flush(void)
{
/*
/* Output all instructions waiting in the output queue and free their
/* storage including the saved strings.
*/
register p_instr p,q;
register int i,n;
Output all instructions waiting in the output queue and free their
storage including the saved strings.
*/
register p_instr p, q;
register int i, n;
printstate("Flush");
for(p=OO_buffer;p<OO_patternqueue;p++)
for (p = OO_buffer; p < OO_patternqueue; p++)
C_out(p);
if(p->em_opcode!=OTHER)
if (p->em_opcode != OTHER)
C_out(p);
if(OO_endbackup) {
n = OO_endbackup-OO_nxtpatt;
BTSCPY(p,q,i,OO_buffer,OO_nxtpatt,n);
if (OO_endbackup)
{
n = OO_endbackup - OO_nxtpatt;
BTSCPY(p, q, i, OO_buffer, OO_nxtpatt, n);
OO_endbackup = OO_buffer + n;
}
else nextstr = strqueue;
else
nextstr = strqueue;
OO_patternqueue = OO_nxtpatt = OO_buffer;
}
p_instr
OO_halfflush()
p_instr OO_halfflush(void)
{
/*
/* Called when buffer full, flush half the buffer and move the
/* the pattern pointers to the new positions. Return a pointer
/* to the new nxtpatt position and increment it.
/* Note that OO_endbackup is always NIL (i.e. there are no
/* instructions on the backup queue) when this is invoked.
*/
register int i,n;
register p_instr p,q;
Called when buffer full, flush half the buffer and move the
the pattern pointers to the new positions. Return a pointer
to the new nxtpatt position and increment it.
Note that OO_endbackup is always NIL (i.e. there are no
instructions on the backup queue) when this is invoked.
*/
register int i, n;
register p_instr p, q;
printstate("Half flush");
n = MAXBUFFER / 2;
for(p=OO_buffer,i=n;i--;)
for (p = OO_buffer, i = n; i--;)
C_out(p++);
/* now copy the rest of buffer and pattern back */
BTSCPY(p,q,i,OO_buffer,OO_buffer+n,(OO_nxtpatt-OO_buffer)-n);
BTSCPY(p, q, i, OO_buffer, OO_buffer + n, (OO_nxtpatt - OO_buffer) - n);
OO_patternqueue -= n;
OO_nxtpatt -= n;
printstate("after Half flush");
return (OO_nxtpatt++);
}
void
OO_mkext(p,opcode,arg,off)
register p_instr p;
int opcode;
p_instr arg;
arith off;
void OO_mkext(register p_instr p, int opcode, p_instr arg, arith off)
{
switch(arg->em_argtype) {
case cst_ptyp:
EM_mkcst(p,opcode,off);
break;
case sof_ptyp:
EM_mksof(p,opcode,arg->em_dnam,off);
break;
case nof_ptyp:
EM_mknof(p,opcode,arg->em_dlb,off);
break;
default:
fatal("Unexpected type %d in outext",arg->em_argtype);
switch (arg->em_argtype)
{
case cst_ptyp:
EM_mkcst(p, opcode, off);
break;
case sof_ptyp:
EM_mksof(p, opcode, arg->em_dnam, off);
break;
case nof_ptyp:
EM_mknof(p, opcode, arg->em_dlb, off);
break;
default:
fatal("Unexpected type %d in outext", arg->em_argtype);
}
}
void
OO_mkrepl(lrepl,diff,numbkup)
int lrepl,diff,numbkup;
void OO_mkrepl(int lrepl, int diff, int numbkup)
{
/* copy the replacement queue into the buffer queue */
/* then move the pattern queue back n places */
register p_instr p,q;
register p_instr p, q;
register int i;
printstate("Before backup");
if(OO_endbackup) {
if (OO_endbackup)
{
/* move the region between OO_nxtpatt and OO_endbackup */
if (diff > 0) {
if (diff > 0)
{
/* move left by diff */
BTSCPY(p,q,i,OO_nxtpatt-diff,OO_nxtpatt,OO_endbackup-OO_nxtpatt);
BTSCPY(p, q, i, OO_nxtpatt - diff, OO_nxtpatt,
OO_endbackup - OO_nxtpatt);
OO_nxtpatt -= diff;
OO_endbackup -= diff;
}
else if (diff < 0) {
else if (diff < 0)
{
/* move right by diff */
/* careful of overflowing buffer!! */
if ((OO_nxtpatt-diff)> (OO_buffer+MAXBUFFER) )
if ((OO_nxtpatt - diff) > (OO_buffer + MAXBUFFER))
OO_halfflush();
/* cannot use btscpy as strings may overlap */
p = (q=OO_endbackup-1) - diff;
while(q>=OO_nxtpatt)
p = (q = OO_endbackup - 1) - diff;
while (q >= OO_nxtpatt)
*p-- = *q--;
OO_nxtpatt -= diff;
OO_endbackup -= diff;
}
}
/* copy the replacement */
if (lrepl) {
BTSCPY(p,q,i,OO_patternqueue,OO_replqueue,lrepl);
if (lrepl)
{
BTSCPY(p, q, i, OO_patternqueue, OO_replqueue, lrepl);
OO_nxtrepl = OO_replqueue;
OO_patternqueue += lrepl;
}
/* now move the position of interest back nunbkup instructions */
if ((OO_patternqueue-OO_buffer) < numbkup)
numbkup = (OO_patternqueue-OO_buffer);
if ((OO_patternqueue - OO_buffer) < numbkup)
numbkup = (OO_patternqueue - OO_buffer);
OO_nxtpatt = OO_patternqueue -= numbkup;
if(!OO_endbackup && numbkup)
OO_endbackup = OO_patternqueue+numbkup;
if (!OO_endbackup && numbkup)
OO_endbackup = OO_patternqueue + numbkup;
OO_state = 0;
printstate("After backup");
}
#ifdef DEBUG
void
dumpstate(mess)
char *mess;
dumpstate(char *mess)
{
p_instr p;
p_instr p;
fprintf(stderr,"%s - state(%d): ",mess,OO_state);
p = OO_buffer;
while(p<OO_patternqueue)
prtinst(p++);
prtinst(p++);
fprintf(stderr," |==| ");
while(p<OO_nxtpatt)
prtinst(p++);
prtinst(p++);
fprintf(stderr," |==| ");
if(OO_endbackup) {
if(OO_endbackup)
{
while(p<OO_endbackup)
prtinst(p++);
prtinst(p++);
}
fprintf(stderr,"\n");
}
void
prtinst(p)
p_instr p;
prtinst(p_instr p)
{
switch(p->em_type) {
case EM_MNEM:
switch(p->em_type)
{
case EM_MNEM:
fprintf(stderr,"%s ",em_mnem[p->em_opcode-sp_fmnem]);
break;
case EM_PSEU:
case EM_PSEU:
fprintf(stderr,"%s ",em_pseu[p->em_opcode-sp_fpseu]);
break;
case EM_STARTMES:
case EM_MESARG:
case EM_ENDMES:
case EM_STARTMES:
case EM_MESARG:
case EM_ENDMES:
fprintf(stderr,"MES ");
break;
case EM_DEFILB:
case EM_DEFILB:
fprintf(stderr,"%ld ", (long)p->em_ilb);
return;
case EM_DEFDLB:
case EM_DEFDLB:
fprintf(stderr,"%ld ", (long)p->em_dlb);
return;
case EM_DEFDNAM:
case EM_DEFDNAM:
fprintf(stderr,"%d ", p->em_dnam);
return;
case EM_ERROR:
case EM_FATAL:
case EM_EOF:
case EM_ERROR:
case EM_FATAL:
case EM_EOF:
return;
}
switch(p->em_argtype) {
case 0:
switch(p->em_argtype)
{
case 0:
break;
case cst_ptyp:
case cst_ptyp:
fprintf(stderr,"%d ",p->em_cst);
break;
case nof_ptyp:
case nof_ptyp:
fprintf(stderr,".%d+%d ",p->em_dlb,p->em_off);
break;
case sof_ptyp:
case sof_ptyp:
fprintf(stderr,"%s+%d ",p->em_dnam,p->em_off);
break;
case ilb_ptyp:
case ilb_ptyp:
fprintf(stderr,"*%d ",p->em_ilb);
break;
case pro_ptyp:
case pro_ptyp:
fprintf(stderr,"$%s ",p->em_pnam);
break;
case str_ptyp:
case ico_ptyp:
case uco_ptyp:
case str_ptyp:
case ico_ptyp:
case uco_ptyp:
fprintf(stderr,"\"%s\"",p->em_string);
break;
default:
default:
fatal(" prtinst - Unregognized arg %d ",p->em_argtype);
}
}

View file

@ -4,108 +4,128 @@ static char rcsidp4[] = "$Id$";
#include "parser.h"
outputincalls()
void outputincalls(void)
{
struct idf *op;
char *s;
for(op=ops;op!=(struct idf *)NULL;op=op->id_nextidf) {
for (op = ops; op != (struct idf *) NULL; op = op->id_nextidf)
{
s = op->id_text;
switch(op->id_argfmt) {
case NOARG:
fprintf(ofile,"%s\t|\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_Nop(op_%s);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
fprintf(ofile,"\tFLUSHDFA();\n");
fprintf(ofile,"\tC_%s();\n",s);
}
break;
case CSTOPT:
fprintf(ofile,"%s_narg\t|\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_Nnarg(op_%s);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
fprintf(ofile,"\tFLUSHDFA();\n");
fprintf(ofile,"\tC_%s_narg();\n",s);
}
/* fall thru */
case CST:
fprintf(ofile,"%s\t| arith:n\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_Ncst(op_%s,n);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
fprintf(ofile,"\tFLUSHDFA();\n");
fprintf(ofile,"\tC_%s(n);\n",s);
}
break;
case DEFILB:
fprintf(ofile,"df_ilb\t| label:l\t|\n");
if(op->id_used) {
fprintf(ofile,"\tEM_Ndefilb(op_%s,l);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
fprintf(ofile,"\tFLUSHDFA();\n");
fprintf(ofile,"\tC_df_ilb(l);\n",s);
}
break;
case PNAM:
fprintf(ofile,"%s\t| char *:s\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_Npro(op_%s,s);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
fprintf(ofile,"\tFLUSHDFA();\n");
fprintf(ofile,"\tC_%s(s);\n",s);
}
break;
case LAB:
fprintf(ofile,"%s\t| label:l\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_Nilb(op_%s,l);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
fprintf(ofile,"\tFLUSHDFA();\n");
fprintf(ofile,"\tC_%s(l);\n",s);
}
break;
case EXT:
fprintf(ofile,"%s\t| arith:n\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_Ncst(op_%s,n);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
fprintf(ofile,"\tFLUSHDFA();\n");
fprintf(ofile,"\tC_%s(n);\n",s);
}
fprintf(ofile,"%s_dnam\t| char *:s arith:n\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_Nsof(op_%s,s,n);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
fprintf(ofile,"\tFLUSHDFA();\n");
fprintf(ofile,"\tC_%s_dnam(s,n);\n",s);
}
fprintf(ofile,"%s_dlb\t| label:l arith:n\t|\n",s);
if(op->id_used) {
fprintf(ofile,"\tEM_Nnof(op_%s,l,n);\n",s);
fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
}
else {
fprintf(ofile,"\tFLUSHDFA();\n");
fprintf(ofile,"\tC_%s_dlb(l,n);\n",s);
}
break;
switch (op->id_argfmt)
{
case NOARG:
fprintf(ofile, "%s\t|\t|\n", s);
if (op->id_used)
{
fprintf(ofile, "\tEM_Nop(op_%s);\n", s);
fprintf(ofile, "\tOO_dfa(op_%s);\n", s);
}
else
{
fprintf(ofile, "\tFLUSHDFA();\n");
fprintf(ofile, "\tC_%s();\n", s);
}
break;
case CSTOPT:
fprintf(ofile, "%s_narg\t|\t|\n", s);
if (op->id_used)
{
fprintf(ofile, "\tEM_Nnarg(op_%s);\n", s);
fprintf(ofile, "\tOO_dfa(op_%s);\n", s);
}
else
{
fprintf(ofile, "\tFLUSHDFA();\n");
fprintf(ofile, "\tC_%s_narg();\n", s);
}
/* fall thru */
case CST:
fprintf(ofile, "%s\t| arith:n\t|\n", s);
if (op->id_used)
{
fprintf(ofile, "\tEM_Ncst(op_%s,n);\n", s);
fprintf(ofile, "\tOO_dfa(op_%s);\n", s);
}
else
{
fprintf(ofile, "\tFLUSHDFA();\n");
fprintf(ofile, "\tC_%s(n);\n", s);
}
break;
case DEFILB:
fprintf(ofile, "df_ilb\t| label:l\t|\n");
if (op->id_used)
{
fprintf(ofile, "\tEM_Ndefilb(op_%s,l);\n", s);
fprintf(ofile, "\tOO_dfa(op_%s);\n", s);
}
else
{
fprintf(ofile, "\tFLUSHDFA();\n");
fprintf(ofile, "\tC_df_ilb(l);\n", s);
}
break;
case PNAM:
fprintf(ofile, "%s\t| char *:s\t|\n", s);
if (op->id_used)
{
fprintf(ofile, "\tEM_Npro(op_%s,s);\n", s);
fprintf(ofile, "\tOO_dfa(op_%s);\n", s);
}
else
{
fprintf(ofile, "\tFLUSHDFA();\n");
fprintf(ofile, "\tC_%s(s);\n", s);
}
break;
case LAB:
fprintf(ofile, "%s\t| label:l\t|\n", s);
if (op->id_used)
{
fprintf(ofile, "\tEM_Nilb(op_%s,l);\n", s);
fprintf(ofile, "\tOO_dfa(op_%s);\n", s);
}
else
{
fprintf(ofile, "\tFLUSHDFA();\n");
fprintf(ofile, "\tC_%s(l);\n", s);
}
break;
case EXT:
fprintf(ofile, "%s\t| arith:n\t|\n", s);
if (op->id_used)
{
fprintf(ofile, "\tEM_Ncst(op_%s,n);\n", s);
fprintf(ofile, "\tOO_dfa(op_%s);\n", s);
}
else
{
fprintf(ofile, "\tFLUSHDFA();\n");
fprintf(ofile, "\tC_%s(n);\n", s);
}
fprintf(ofile, "%s_dnam\t| char *:s arith:n\t|\n", s);
if (op->id_used)
{
fprintf(ofile, "\tEM_Nsof(op_%s,s,n);\n", s);
fprintf(ofile, "\tOO_dfa(op_%s);\n", s);
}
else
{
fprintf(ofile, "\tFLUSHDFA();\n");
fprintf(ofile, "\tC_%s_dnam(s,n);\n", s);
}
fprintf(ofile, "%s_dlb\t| label:l arith:n\t|\n", s);
if (op->id_used)
{
fprintf(ofile, "\tEM_Nnof(op_%s,l,n);\n", s);
fprintf(ofile, "\tOO_dfa(op_%s);\n", s);
}
else
{
fprintf(ofile, "\tFLUSHDFA();\n");
fprintf(ofile, "\tC_%s_dlb(l,n);\n", s);
}
break;
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -17,6 +17,7 @@ static char rcsidp1[] = "$Id$";
#endif
#include "parser.h"
#include "alloc.h"
#define MAXPRIO 11
@ -33,6 +34,20 @@ int nerrors = 0;
static int lencurrpatt;
static int lenthisrepl;
static int currentstate; /* Current state of dfa */
extern void back_token(void);
extern void parser(void);
/* Forward declarations */
void addaction(int, int, struct exp_node *,struct exp_node *,
struct mnem_list *);
struct mnem_elem **constructlist(struct mnem_list *, int);
struct mnem_list *addelem(struct mnem_list *, struct idf *,
struct exp_node *);
int dotransition(int, struct idf *, struct mnem_list *, int);
int priority(int);
void LLmessage(int);
}
input : /* empty */
@ -326,11 +341,8 @@ binop : LOGAND
%lexical yylex;
{
addaction(startline, state, restrictions, finaltest, repllist)
int startline;
int state;
struct exp_node *restrictions, *finaltest;
struct mnem_list *repllist;
void addaction(int startline, int state, struct exp_node *restrictions,
struct exp_node *finaltest, struct mnem_list *repllist)
{
struct action *p, *q;
p=(struct action *)Malloc(sizeof(struct action));
@ -349,10 +361,7 @@ addaction(startline, state, restrictions, finaltest, repllist)
}
}
struct mnem_elem **
constructlist(list,len)
struct mnem_list *list;
int len;
struct mnem_elem **constructlist(struct mnem_list *list, int len)
{
struct mnem_elem **p;
p = (struct mnem_elem **)
@ -364,11 +373,9 @@ constructlist(list,len)
return(p);
}
struct mnem_list *
addelem(oldlist, mnem, test)
struct mnem_list *oldlist;
struct idf *mnem;
struct exp_node *test;
struct mnem_list *addelem(struct mnem_list *oldlist,
struct idf *mnem,
struct exp_node *test)
{
struct mnem_list *reslist;
struct mnem_elem *element;
@ -381,12 +388,11 @@ addelem(oldlist, mnem, test)
return(reslist);
}
int
dotransition(state, mnem, mnem_list, lenlist)
int state;
struct idf *mnem;
struct mnem_list *mnem_list;
int lenlist;
int dotransition(
int state,
struct idf *mnem,
struct mnem_list *mnem_list,
int lenlist)
{
struct state *p;
/* look for existing transition */
@ -399,7 +405,7 @@ dotransition(state, mnem, mnem_list, lenlist)
p=(struct state *)Malloc(sizeof(struct state));
p->op=mnem;
if(++higheststate>MAXSTATES) {
fprintf(stderr,"Parser: More than %s states\n",MAXSTATES);
fprintf(stderr,"Parser: More than %d states\n",MAXSTATES);
sys_stop(S_EXIT);
}
p->goto_state= higheststate;
@ -427,7 +433,7 @@ combinetests(test1, test2)
return(mknode(LOGAND,test1,test2));
}
priority(op) int op; {
int priority(int op) {
switch (op) {
case LOGOR: return(1);
case LOGAND: return(2);
@ -456,10 +462,8 @@ priority(op) int op; {
return(0);
}
struct exp_node *
mknode(op,left,right)
int op;
struct exp_node *left,*right;
struct exp_node *mknode(int op, struct exp_node *left,
struct exp_node *right)
{
struct exp_node *p;
p = (struct exp_node *)Malloc(sizeof(struct exp_node));
@ -469,9 +473,7 @@ mknode(op,left,right)
return(p);
}
struct exp_node *
mkleaf(op,val)
int op,val;
struct exp_node *mkleaf(int op, int val)
{
struct exp_node *p;
p = (struct exp_node *)Malloc(sizeof(struct exp_node));
@ -480,8 +482,7 @@ mkleaf(op,val)
return(p);
}
LLmessage(insertedtok)
int insertedtok;
void LLmessage(int insertedtok)
{
nerrors++;
fprintf(stderr,"parser: syntax error on line %d: ",linenum);
@ -492,7 +493,8 @@ LLmessage(insertedtok)
else fprintf(stderr,"Deleted token %d\n",LLsymb);
}
main() {
int main(int argc, char **argv)
{
initlex();
states[0] = (struct state *)NULL;
patterns[0].m_len = 0;

View file

@ -1,4 +1,7 @@
/* $Id$ */
#ifndef PARSER_H_
#define PARSER_H_
#include <stdio.h>
#include <system.h>
@ -88,10 +91,17 @@ extern struct idf *opval; /* opcode of returned OPCODE*/
extern int lastintval; /* value of last integer seen */
extern int linenum; /*line number of input file*/
/* Functions not returning int */
char *Malloc();
struct exp_node *mknode();
struct exp_node *mkleaf();
struct exp_node *combinetests();
struct mnem_list *addelem();
struct mnem_elem **constructlist();
struct exp_node *mknode(int, struct exp_node *, struct exp_node *);
struct exp_node *mkleaf(int, int);
struct exp_node *combinetests(struct exp_node *, struct exp_node *);
struct mnem_list *addelem(struct mnem_list *, struct idf *, struct exp_node *);
struct mnem_elem **constructlist(struct mnem_list *, int);
void findworst(struct mnems,struct mnems);
void outputincalls(void);
void outputnopt(void);
void initlex(void);
void findfail(int, int *, int *, int *);
#endif /* PARSER_H_ */

View file

@ -3,6 +3,7 @@
#include "Lpars.h"
#include "parser.h"
struct idf *opval; /* opcode of returned OPCODE*/
int lastintval; /* value of last integer seen */
int linenum = 1; /*current line number of input file*/
@ -59,7 +60,12 @@ offset return(OFFSET);
. return(yytext[0]);
%%
back_token()
int yywrap(void)
{
return 1;
}
void back_token(void)
{
yyless(0);
}

View file

@ -2,97 +2,88 @@
static char rcsid4[] = "$Id$";
#endif
#include <string.h>
#include "nopt.h"
arith
OO_rotate(w,amount)
arith w, amount;
arith OO_rotate(arith w, arith amount)
{
long highmask, lowmask;
highmask = (long)(-1) << amount;
highmask = (long) (-1) << amount;
lowmask = ~highmask;
if(OO_WSIZE!=4)
highmask &= (OO_WSIZE==2)?0xFFFF:0xFF;
return(((w<<amount)&highmask) | ((w >> (8*OO_WSIZE-amount))&lowmask));
if (OO_WSIZE != 4)
highmask &= (OO_WSIZE == 2) ? 0xFFFF : 0xFF;
return (((w << amount) & highmask)
| ((w >> (8 * OO_WSIZE - amount)) & lowmask));
}
int
OO_signsame(a,b)
arith a, b;
int OO_signsame(arith a, arith b)
{
return( (a ^ b) >= 0);
return ((a ^ b) >= 0);
}
int
OO_sfit(val,nbits)
arith val, nbits;
int OO_sfit(arith val, arith nbits)
{
register long mask = ~((1L << (nbits - 1)) - 1);
return(((val&mask) == 0) | (val&mask)==mask);
return (((val & mask) == 0) | ((val & mask) == mask));
}
int
OO_ufit(val, nbits)
arith val, nbits;
int OO_ufit(arith val, arith nbits)
{
return((val&(~((1L << (nbits - 1)) - 1))) == 0);
return ((val & (~((1L << (nbits - 1)) - 1))) == 0);
}
int
OO_extsame(a1,a2)
register p_instr a1, a2;
int OO_extsame(register p_instr a1, register p_instr a2)
{
if (a1->em_argtype != a2->em_argtype)
return(0);
switch(a1->em_argtype) {
case cst_ptyp:
return (a1->em_cst == a2->em_cst);
case sof_ptyp:
if(a1->em_off != a2->em_off)
return(0);
return (strcmp(a1->em_dnam,a2->em_dnam)==0);
case nof_ptyp:
if (a1->em_off != a2->em_off)
return(0);
return (a1->em_dlb == a2->em_dlb);
default:
fatal("illegal type (%d) to sameext!",a1->em_argtype);
/*NOTREACHED*/
return (0);
switch (a1->em_argtype)
{
case cst_ptyp:
return (a1->em_cst == a2->em_cst);
case sof_ptyp:
if (a1->em_off != a2->em_off)
return (0);
return (strcmp(a1->em_dnam, a2->em_dnam) == 0);
case nof_ptyp:
if (a1->em_off != a2->em_off)
return (0);
return (a1->em_dlb == a2->em_dlb);
default:
fatal("illegal type (%d) to sameext!", a1->em_argtype);
/*NOTREACHED*/
}
}
int
OO_namsame(a1,a2)
register p_instr a1, a2;
int OO_namsame(register p_instr a1, register p_instr a2)
{
if (a1->em_argtype != a2->em_argtype)
return(0);
switch(a1->em_argtype) {
case cst_ptyp:
return 1;
case sof_ptyp:
return (strcmp(a1->em_dnam,a2->em_dnam)==0);
case nof_ptyp:
return (a1->em_dlb == a2->em_dlb);
default:
fatal("illegal type (%d) to samenam!",a1->em_argtype);
/*NOTREACHED*/
return (0);
switch (a1->em_argtype)
{
case cst_ptyp:
return 1;
case sof_ptyp:
return (strcmp(a1->em_dnam, a2->em_dnam) == 0);
case nof_ptyp:
return (a1->em_dlb == a2->em_dlb);
default:
fatal("illegal type (%d) to samenam!", a1->em_argtype);
/*NOTREACHED*/
}
}
arith
OO_offset(a)
register p_instr a;
arith OO_offset(register p_instr a)
{
switch(a->em_argtype) {
case cst_ptyp:
return a->em_cst;
case sof_ptyp:
return a->em_off;
case nof_ptyp:
return a->em_off;
default:
fatal("illegal type (%d) to offset!",a->em_argtype);
/*NOTREACHED*/
switch (a->em_argtype)
{
case cst_ptyp:
return a->em_cst;
case sof_ptyp:
return a->em_off;
case nof_ptyp:
return a->em_off;
default:
fatal("illegal type (%d) to offset!", a->em_argtype);
/*NOTREACHED*/
}
}