2 static char rcsid[] = "$Id: nextem.c,v 2.4 1994/06/24 13:23:56 ceriel Exp $";
11 #include <cg_pattern.h>
17 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
18 * See the copyright notice in the ACK home directory, in the file "Copyright".
20 * Author: Hans van Staveren
25 extern char em_mnem[][4];
28 byte *trypat(bp,len) register byte *bp; {
41 if (emp[i].em_instr != (*bp++&BMASK))
43 for (i=0;i<patlen;i++)
44 if (emp[i].em_optyp==OPNO)
45 dollar[i].e_typ=EV_UNDEF;
46 else if ((dollar[i].e_typ=argtyp(emp[i].em_instr))==EV_INT)
47 dollar[i].e_v.e_con=emp[i].em_u.em_ioper;
49 dollar[i].e_v.e_str=emp[i].em_soper;
52 struct emline *svp = saveemp;
55 result = compute(&enodes[i]);
56 if (result.e_typ != EV_INT || result.e_v.e_con == 0) {
63 fprintf(stderr,"Matched:");
64 for (i=0;i<patlen;i++)
65 fprintf(stderr," %3.3s",em_mnem[emp[i].em_instr-sp_fmnem]);
74 extern char em_flag[];
78 switch(em_flag[mn-sp_fmnem]&EM_PAR) {
94 byte *nextem(toplevel) {
100 register struct emline *ep;
103 if (nemlines && emp>emlines) {
104 nemlines -= emp-emlines;
105 for (i=0,ep=emlines;i<nemlines;i++)
111 hash[0] = emp[0].em_instr;
112 hash[1] = (hash[0]<<4) ^ emp[1].em_instr;
113 hash[2] = (hash[1]<<4) ^ emp[2].em_instr;
115 index = pathash[hash[i]&BMASK];
117 bp = &pattern[index];
118 if ( bp[PO_HASH] == (hash[i]>>8))
119 if ((cp=trypat(&bp[PO_MATCH],i+1)) != 0)
121 index = (bp[PO_NEXT]&BMASK) | (bp[PO_NEXT+1]<<8);