Some bug fixes and minor extensions
This commit is contained in:
parent
382c88eb17
commit
45238eea0f
9 changed files with 140 additions and 41 deletions
|
@ -3,23 +3,25 @@
|
||||||
CFILES=cgg.c subr.c main.c coerc.c enterkeyw.c error.c emlookup.c expr.c instruct.c iocc.c lookup.c output.c set.c strlookup.c var.c hall.c
|
CFILES=cgg.c subr.c main.c coerc.c enterkeyw.c error.c emlookup.c expr.c instruct.c iocc.c lookup.c output.c set.c strlookup.c var.c hall.c
|
||||||
OFILES=cgg.o subr.o main.o coerc.o enterkeyw.o error.o emlookup.o expr.o instruct.o iocc.o lookup.o set.o strlookup.o var.o hall.o
|
OFILES=cgg.o subr.o main.o coerc.o enterkeyw.o error.o emlookup.o expr.o instruct.o iocc.o lookup.o set.o strlookup.o var.o hall.o
|
||||||
SOURCES=*.h cgg.y scan.l cvtkeywords keywords coerc.c emlookup.c error.c expr.c hall.c instruct.c iocc.c lookup.c main.c output.c set.c strlookup.c subr.c var.c
|
SOURCES=*.h cgg.y scan.l cvtkeywords keywords coerc.c emlookup.c error.c expr.c hall.c instruct.c iocc.c lookup.c main.c output.c set.c strlookup.c subr.c var.c
|
||||||
EMH=../../h
|
EMHOME=../..
|
||||||
CFLAGS=-I$(EMH)
|
EMH=$(EMHOME)/h
|
||||||
|
CFLAGS=-O -I$(EMH)
|
||||||
YFLAGS=-v -d
|
YFLAGS=-v -d
|
||||||
LDFLAGS=-i
|
LDFLAGS=-i
|
||||||
|
|
||||||
|
|
||||||
cgg: cgg.o $(OFILES) output.o
|
cgg: cgg.o $(OFILES) output.o
|
||||||
cc $(LDFLAGS) $(OFILES) output.o ../../lib/em_data.a -ll -o cgg
|
cc $(LDFLAGS) $(OFILES) output.o $(EMHOME)/lib/em_data.a -ll -o cgg
|
||||||
|
|
||||||
install: cgg
|
install: cgg
|
||||||
cp cgg ../../lib/ncgg
|
rm -f $(EMHOME)/lib/ncgg
|
||||||
|
cp cgg $(EMHOME)/lib/ncgg
|
||||||
|
|
||||||
cmp: cgg
|
cmp: cgg
|
||||||
cmp cgg ../../lib/ncgg
|
cmp cgg $(EMHOME)/lib/ncgg
|
||||||
|
|
||||||
debugcgg: cgg.o $(OFILES) debugoutput.o
|
debugcgg: cgg.o $(OFILES) debugoutput.o
|
||||||
cc $(LDFLAGS) $(OFILES) debugoutput.o ../../lib/em_data.a -ll -o cgg
|
cc $(LDFLAGS) $(OFILES) debugoutput.o $(EMHOME)/lib/em_data.a -ll -o cgg
|
||||||
|
|
||||||
cgg.o: scan.c
|
cgg.o: scan.c
|
||||||
|
|
||||||
|
@ -43,8 +45,8 @@ clean:
|
||||||
pr:
|
pr:
|
||||||
pr $(SOURCES)
|
pr $(SOURCES)
|
||||||
|
|
||||||
lpr:
|
opr:
|
||||||
make pr|lpr
|
-make pr|opr
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
makedepend
|
makedepend
|
||||||
|
|
102
util/ncgg/cgg.y
102
util/ncgg/cgg.y
|
@ -18,6 +18,7 @@ extern int lineno;
|
||||||
int instline,saveline;
|
int instline,saveline;
|
||||||
int startline;
|
int startline;
|
||||||
int npatterns;
|
int npatterns;
|
||||||
|
int att_type;
|
||||||
int patindex[MAXPATTERNS];
|
int patindex[MAXPATTERNS];
|
||||||
|
|
||||||
int emhere=0; /* lexical analyzer flag */
|
int emhere=0; /* lexical analyzer flag */
|
||||||
|
@ -27,6 +28,9 @@ int saferulefound=0;
|
||||||
int maxempatlen=0;
|
int maxempatlen=0;
|
||||||
int maxrule=0;
|
int maxrule=0;
|
||||||
struct varinfo *defcost;
|
struct varinfo *defcost;
|
||||||
|
int Xstackflag=0; /* set in coercions, moves, and tests. %1 means something
|
||||||
|
different then.
|
||||||
|
*/
|
||||||
|
|
||||||
struct varinfo *gen_inst(),*gen_move(),*gen_test(),*gen_preturn(),*gen_tlab();
|
struct varinfo *gen_inst(),*gen_move(),*gen_test(),*gen_preturn(),*gen_tlab();
|
||||||
struct varinfo *make_erase();
|
struct varinfo *make_erase();
|
||||||
|
@ -35,7 +39,7 @@ expr_t perc_ident_expr(),sum_expr(),regvar_expr();
|
||||||
|
|
||||||
set_t ident_to_set(),setproduct(),setsum(),setdiff();
|
set_t ident_to_set(),setproduct(),setsum(),setdiff();
|
||||||
|
|
||||||
iocc_t subr_iocc(),tokm_iocc(),ident_iocc(),all_iocc(),descr_iocc();
|
iocc_t subr_iocc(),tokm_iocc(),ident_iocc(),all_iocc(),percident_iocc(), descr_iocc();
|
||||||
|
|
||||||
extern int narexpr;
|
extern int narexpr;
|
||||||
extern expr_t arexp[];
|
extern expr_t arexp[];
|
||||||
|
@ -81,7 +85,7 @@ iocc_t iops[20];
|
||||||
%token TIMEFACTOR SIZEFACTOR
|
%token TIMEFACTOR SIZEFACTOR
|
||||||
%token COST
|
%token COST
|
||||||
%type <yy_varinfo> prop_list property ident_list ident_list_el
|
%type <yy_varinfo> prop_list property ident_list ident_list_el
|
||||||
%type <yy_varinfo> att_list att_list_el structdecl optcost optformat
|
%type <yy_varinfo> att_list att_list_el att_list_el_list structdecl optcost optformat
|
||||||
%type <yy_varinfo> kills allocates yields leaving
|
%type <yy_varinfo> kills allocates yields leaving
|
||||||
%type <yy_varinfo> generates kill_list kill_list_el uselist uselist_el genlist yieldlist
|
%type <yy_varinfo> generates kill_list kill_list_el uselist uselist_el genlist yieldlist
|
||||||
%type <yy_varinfo> leavelist leavelist_el gen_instruction
|
%type <yy_varinfo> leavelist leavelist_el gen_instruction
|
||||||
|
@ -300,10 +304,24 @@ att_list
|
||||||
{ $1->vi_next = $2; $$ = $1; }
|
{ $1->vi_next = $2; $$ = $1; }
|
||||||
;
|
;
|
||||||
att_list_el
|
att_list_el
|
||||||
: att_list_el_type IDENT ';'
|
: att_list_el_type IDENT
|
||||||
|
{ NEW ($<yy_varinfo>$,struct varinfo);
|
||||||
|
$<yy_varinfo>$->vi_int[0] = $1;
|
||||||
|
$<yy_varinfo>$->vi_str[0] = $2;
|
||||||
|
att_type = $1;
|
||||||
|
}
|
||||||
|
att_list_el_list ';'
|
||||||
|
{ $<yy_varinfo>3->vi_next = $4;
|
||||||
|
$$ = $<yy_varinfo>3;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
att_list_el_list
|
||||||
|
: /* empty */
|
||||||
|
{ $$ = 0; }
|
||||||
|
| ',' IDENT att_list_el_list
|
||||||
{ NEW($$, struct varinfo);
|
{ NEW($$, struct varinfo);
|
||||||
$$->vi_next = 0;
|
$$->vi_next = $3;
|
||||||
$$->vi_int[0] = $1;
|
$$->vi_int[0] = att_type;
|
||||||
$$->vi_str[0] = $2;
|
$$->vi_str[0] = $2;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -446,7 +464,8 @@ erase_list_el
|
||||||
/* Now the moves */
|
/* Now the moves */
|
||||||
|
|
||||||
moves
|
moves
|
||||||
: MOVES movedeflist
|
: MOVES
|
||||||
|
movedeflist
|
||||||
| /* empty */
|
| /* empty */
|
||||||
;
|
;
|
||||||
movedeflist
|
movedeflist
|
||||||
|
@ -457,19 +476,30 @@ movedeflist_el
|
||||||
: FROM
|
: FROM
|
||||||
{startline = lineno; }
|
{startline = lineno; }
|
||||||
tokenset_no
|
tokenset_no
|
||||||
{ cursetno = $3; }
|
{ Xstackflag = 1;
|
||||||
optexpr TO tokenset_no
|
cursetno = $3;
|
||||||
{ cursetno = $7;
|
}
|
||||||
|
optexpr
|
||||||
|
{ Xstackflag = 0;
|
||||||
|
cursetno = -1;
|
||||||
|
}
|
||||||
|
TO tokenset_no
|
||||||
|
{ cursetno = $8;
|
||||||
tokpatlen=2;
|
tokpatlen=2;
|
||||||
tokpatset[0] = $3;
|
tokpatset[0] = $3;
|
||||||
tokpatset[1] = $7;
|
tokpatset[1] = $8;
|
||||||
tokpatro[0] = 1;
|
tokpatro[0] = 1;
|
||||||
|
Xstackflag = 1;
|
||||||
}
|
}
|
||||||
optexpr GEN genlist
|
optexpr
|
||||||
|
{ Xstackflag = 0;
|
||||||
|
cursetno = -1;
|
||||||
|
}
|
||||||
|
GEN genlist
|
||||||
{ tokpatlen=0;
|
{ tokpatlen=0;
|
||||||
tokpatro[0]=0;
|
tokpatro[0]=0;
|
||||||
n_move($3,$5,$7,$9,$11);
|
n_move($3,$5,$8,$10,$13);
|
||||||
freevi($11);
|
freevi($13);
|
||||||
}
|
}
|
||||||
| error
|
| error
|
||||||
;
|
;
|
||||||
|
@ -477,7 +507,10 @@ movedeflist_el
|
||||||
/* Now the test part */
|
/* Now the test part */
|
||||||
|
|
||||||
tests
|
tests
|
||||||
: TESTS testdeflist
|
: TESTS
|
||||||
|
{ Xstackflag = 1; }
|
||||||
|
testdeflist
|
||||||
|
{ Xstackflag = 0; }
|
||||||
| /* empty */
|
| /* empty */
|
||||||
;
|
;
|
||||||
testdeflist
|
testdeflist
|
||||||
|
@ -498,6 +531,7 @@ testdeflist_el
|
||||||
tokpatro[0] = 0;
|
tokpatro[0] = 0;
|
||||||
n_test($4,$6,$8);
|
n_test($4,$6,$8);
|
||||||
freevi($8);
|
freevi($8);
|
||||||
|
cursetno = -1;
|
||||||
}
|
}
|
||||||
| error
|
| error
|
||||||
;
|
;
|
||||||
|
@ -505,7 +539,10 @@ testdeflist_el
|
||||||
/* Now the stacks */
|
/* Now the stacks */
|
||||||
|
|
||||||
stacks
|
stacks
|
||||||
: STACKINGRULES stackdeflist
|
: STACKINGRULES
|
||||||
|
{ Xstackflag = 1; }
|
||||||
|
stackdeflist
|
||||||
|
{ Xstackflag = 0; }
|
||||||
;
|
;
|
||||||
stackdeflist
|
stackdeflist
|
||||||
: stackdeflist_el
|
: stackdeflist_el
|
||||||
|
@ -524,6 +561,7 @@ stackdeflist_el
|
||||||
{ tokpatro[0] = 0;
|
{ tokpatro[0] = 0;
|
||||||
n_stack($3,$5,$8,$10);
|
n_stack($3,$5,$8,$10);
|
||||||
freevi($10);
|
freevi($10);
|
||||||
|
cursetno = -1;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
optuses
|
optuses
|
||||||
|
@ -536,7 +574,10 @@ optuses
|
||||||
/* Now the one-to-one coercion rules */
|
/* Now the one-to-one coercion rules */
|
||||||
|
|
||||||
coercs
|
coercs
|
||||||
: COERCIONS coercdeflist
|
: COERCIONS
|
||||||
|
{ Xstackflag = 1; }
|
||||||
|
coercdeflist
|
||||||
|
{ Xstackflag = 0; }
|
||||||
;
|
;
|
||||||
coercdeflist
|
coercdeflist
|
||||||
: coercdeflist_el
|
: coercdeflist_el
|
||||||
|
@ -566,6 +607,7 @@ coercdeflist_el
|
||||||
n_coerc($3,$5,$6,$7,$8);
|
n_coerc($3,$5,$6,$7,$8);
|
||||||
freevi($6);
|
freevi($6);
|
||||||
freevi($7);
|
freevi($7);
|
||||||
|
cursetno = -1;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -722,6 +764,7 @@ kill_list_el
|
||||||
$$->vi_next = 0;
|
$$->vi_next = 0;
|
||||||
$$->vi_int[0]=$1;
|
$$->vi_int[0]=$1;
|
||||||
$$->vi_int[1]=$3;
|
$$->vi_int[1]=$3;
|
||||||
|
cursetno = -1;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
allocates
|
allocates
|
||||||
|
@ -864,6 +907,13 @@ tokeninstance
|
||||||
{ $$ = ident_iocc($1); free($1);}
|
{ $$ = ident_iocc($1); free($1);}
|
||||||
| allreg subreg
|
| allreg subreg
|
||||||
{ $$ = all_iocc($1,$2); }
|
{ $$ = all_iocc($1,$2); }
|
||||||
|
| PERC_IDENT
|
||||||
|
{ if (cursetno < 0) {
|
||||||
|
error("%%<ident> not allowed here");
|
||||||
|
}
|
||||||
|
$$ = percident_iocc($1);
|
||||||
|
free($1);
|
||||||
|
}
|
||||||
| '{' IDENT attlist '}'
|
| '{' IDENT attlist '}'
|
||||||
{ $$ = descr_iocc($2); free($2); }
|
{ $$ = descr_iocc($2); free($2); }
|
||||||
;
|
;
|
||||||
|
@ -883,12 +933,12 @@ emarg
|
||||||
;
|
;
|
||||||
tokarg
|
tokarg
|
||||||
: PERCENT
|
: PERCENT
|
||||||
{ if ($1<1 || $1>tokpatlen) {
|
{ $$ = $1;
|
||||||
|
if ($1<1 || $1>tokpatlen) {
|
||||||
error("Only %d tokens in stackpattern",tokpatlen);
|
error("Only %d tokens in stackpattern",tokpatlen);
|
||||||
$$ =1;
|
$$ =1;
|
||||||
} else {
|
|
||||||
$$ = $1;
|
|
||||||
}
|
}
|
||||||
|
if (Xstackflag) $$ = 0;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
subreg
|
subreg
|
||||||
|
@ -928,7 +978,12 @@ expr
|
||||||
| allreg subreg
|
| allreg subreg
|
||||||
{ $$ = all_expr($1,$2); }
|
{ $$ = all_expr($1,$2); }
|
||||||
| PERC_IDENT
|
| PERC_IDENT
|
||||||
{ $$ = perc_ident_expr($1); free($1); }
|
{ if (cursetno < 0) {
|
||||||
|
error("%%<ident> not allowed here");
|
||||||
|
}
|
||||||
|
$$ = perc_ident_expr($1);
|
||||||
|
free($1);
|
||||||
|
}
|
||||||
| DEFINED '(' expr ')'
|
| DEFINED '(' expr ')'
|
||||||
{ $$ = make_expr(TYPBOOL,EX_DEFINED,i_expr($3),0); }
|
{ $$ = make_expr(TYPBOOL,EX_DEFINED,i_expr($3),0); }
|
||||||
| SAMESIGN '(' expr ',' expr ')'
|
| SAMESIGN '(' expr ',' expr ')'
|
||||||
|
@ -943,6 +998,13 @@ expr
|
||||||
{ $$ = make_expr(TYPINT,EX_LOWW,$3-1,0); }
|
{ $$ = make_expr(TYPINT,EX_LOWW,$3-1,0); }
|
||||||
| HIGHW '(' emarg ')'
|
| HIGHW '(' emarg ')'
|
||||||
{ $$ = make_expr(TYPINT,EX_HIGHW,$3-1,0); }
|
{ $$ = make_expr(TYPINT,EX_HIGHW,$3-1,0); }
|
||||||
|
/* Excluded, because it causes a shift-reduce conflict
|
||||||
|
(problems with a tokenset_no followed by an optexpr)
|
||||||
|
| '-' expr %prec UMINUS
|
||||||
|
{ $$ = make_expr(TYPINT,EX_CON, 0, 0);
|
||||||
|
$$ = make_expr(TYPINT,EX_MINUS,i_expr($$),i_expr($2));
|
||||||
|
}
|
||||||
|
*/
|
||||||
| '(' expr ')'
|
| '(' expr ')'
|
||||||
{ $$ = $2; }
|
{ $$ = $2; }
|
||||||
| expr CMPEQ expr
|
| expr CMPEQ expr
|
||||||
|
|
|
@ -68,7 +68,8 @@ expr_t subreg_expr(tokarg,subreg) {
|
||||||
expr_t result;
|
expr_t result;
|
||||||
|
|
||||||
result.ex_typ = TYPREG;
|
result.ex_typ = TYPREG;
|
||||||
subregset(l_sets[tokpatset[tokarg-1]].set_val,subreg,result.ex_regset);
|
subregset(l_sets[tokpatset[tokarg > 0 ? tokarg-1 : tokarg]].set_val,
|
||||||
|
subreg,result.ex_regset);
|
||||||
result.ex_index = ex_lookup(EX_SUBREG,tokarg,subreg);
|
result.ex_index = ex_lookup(EX_SUBREG,tokarg,subreg);
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
@ -106,6 +107,7 @@ int *typp;
|
||||||
int typesdiffer=0;
|
int typesdiffer=0;
|
||||||
int res_j= -1;
|
int res_j= -1;
|
||||||
|
|
||||||
|
if (setno < 0) return 0;
|
||||||
sp = l_sets[setno].set_val;
|
sp = l_sets[setno].set_val;
|
||||||
for (i=1;i<nregs;i++) if (BIT(sp,i)) {
|
for (i=1;i<nregs;i++) if (BIT(sp,i)) {
|
||||||
error("Set in %s contains %s, which is not a token",
|
error("Set in %s contains %s, which is not a token",
|
||||||
|
@ -167,9 +169,10 @@ expr_t memb_expr(setno,name,appearance,tokarg) char *name,*appearance; {
|
||||||
|
|
||||||
expr_t tokm_expr(tokarg,name) char *name; {
|
expr_t tokm_expr(tokarg,name) char *name; {
|
||||||
char app[100];
|
char app[100];
|
||||||
|
int tokarg1 = tokarg > 0 ? tokarg : 1;
|
||||||
|
|
||||||
sprintf(app,"%%%d.%s",tokarg,name);
|
sprintf(app,"%%%d.%s",tokarg1,name);
|
||||||
return(memb_expr(tokpatset[tokarg-1],name,app,tokarg));
|
return(memb_expr(tokpatset[tokarg1-1],name,app,tokarg));
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t perc_ident_expr(name) char *name; {
|
expr_t perc_ident_expr(name) char *name; {
|
||||||
|
|
|
@ -55,6 +55,7 @@ onlyreg(argno) {
|
||||||
register bitno;
|
register bitno;
|
||||||
register short *sp;
|
register short *sp;
|
||||||
|
|
||||||
|
if (! argno) argno++;
|
||||||
sp = l_sets[tokpatset[argno-1]].set_val;
|
sp = l_sets[tokpatset[argno-1]].set_val;
|
||||||
for(bitno=nregs;bitno<nregs+ntokens;bitno++)
|
for(bitno=nregs;bitno<nregs+ntokens;bitno++)
|
||||||
if (BIT(sp,bitno))
|
if (BIT(sp,bitno))
|
||||||
|
@ -65,6 +66,7 @@ onlyreg(argno) {
|
||||||
makescratch(argno) {
|
makescratch(argno) {
|
||||||
set_t s;
|
set_t s;
|
||||||
|
|
||||||
|
if (! argno) argno++;
|
||||||
if (tokpatro[argno-1])
|
if (tokpatro[argno-1])
|
||||||
error("Instruction destroys %%%d, not allowed here",argno);
|
error("Instruction destroys %%%d, not allowed here",argno);
|
||||||
s = l_sets[tokpatset[argno-1]];
|
s = l_sets[tokpatset[argno-1]];
|
||||||
|
|
|
@ -30,6 +30,7 @@ iocc_t subr_iocc(tokarg,subreg) {
|
||||||
insta.in_info[0] = tokarg;
|
insta.in_info[0] = tokarg;
|
||||||
insta.in_info[1] = subreg;
|
insta.in_info[1] = subreg;
|
||||||
result.in_index = instalookup(insta,2);
|
result.in_index = instalookup(insta,2);
|
||||||
|
if (tokarg < 1) tokarg = 1;
|
||||||
if (subreg==0)
|
if (subreg==0)
|
||||||
for (i=0;i<SETSIZE;i++)
|
for (i=0;i<SETSIZE;i++)
|
||||||
result.in_set[i] = l_sets[tokpatset[tokarg-1]].set_val[i];
|
result.in_set[i] = l_sets[tokpatset[tokarg-1]].set_val[i];
|
||||||
|
@ -48,17 +49,36 @@ iocc_t tokm_iocc(tokarg,ident) char *ident; {
|
||||||
char app[100];
|
char app[100];
|
||||||
int dummy;
|
int dummy;
|
||||||
|
|
||||||
sprintf(app,"%%%d.%s",tokarg,ident);
|
|
||||||
for(i=0;i<SETSIZE;i++)
|
for(i=0;i<SETSIZE;i++)
|
||||||
result.in_set[i] = 0;
|
result.in_set[i] = 0;
|
||||||
insta.in_which = IN_MEMB;
|
insta.in_which = IN_MEMB;
|
||||||
insta.in_info[0] = tokarg;
|
insta.in_info[0] = tokarg;
|
||||||
|
if (tokarg < 1) tokarg = 1;
|
||||||
|
sprintf(app,"%%%d.%s",tokarg,ident);
|
||||||
insta.in_info[1] = 1+membset(tokpatset[tokarg-1],ident,result.in_set,
|
insta.in_info[1] = 1+membset(tokpatset[tokarg-1],ident,result.in_set,
|
||||||
app,TYPREG,&dummy);
|
app,TYPREG,&dummy);
|
||||||
result.in_index = instalookup(insta,2);
|
result.in_index = instalookup(insta,2);
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iocc_t percident_iocc(ident) char *ident; {
|
||||||
|
iocc_t result;
|
||||||
|
inst_t insta;
|
||||||
|
register i;
|
||||||
|
char app[100];
|
||||||
|
int dummy;
|
||||||
|
|
||||||
|
for(i=0;i<SETSIZE;i++)
|
||||||
|
result.in_set[i] = 0;
|
||||||
|
insta.in_which = IN_MEMB;
|
||||||
|
insta.in_info[0] = 0;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
iocc_t ident_iocc(ident) char *ident; {
|
iocc_t ident_iocc(ident) char *ident; {
|
||||||
iocc_t result;
|
iocc_t result;
|
||||||
inst_t insta;
|
inst_t insta;
|
||||||
|
|
|
@ -155,7 +155,7 @@ codenl() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
int prevind=0;
|
int prevind=0;
|
||||||
int npatbytes=0;
|
int npatbytes= -1;
|
||||||
char pattern[MAXPATBYTES];
|
char pattern[MAXPATBYTES];
|
||||||
int pathash[256];
|
int pathash[256];
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ outpatterns() {
|
||||||
if (!inproc) {
|
if (!inproc) {
|
||||||
patbyte(0);
|
patbyte(0);
|
||||||
patshort(prevind);
|
patshort(prevind);
|
||||||
prevind = npatbytes-3;
|
prevind = npatbytes-2;
|
||||||
patbyte(empatlen);
|
patbyte(empatlen);
|
||||||
for(i=0;i<empatlen;i++)
|
for(i=0;i<empatlen;i++)
|
||||||
patbyte(emmnem[i]);
|
patbyte(emmnem[i]);
|
||||||
|
@ -207,7 +207,8 @@ patshort(n) {
|
||||||
|
|
||||||
patbyte(n) {
|
patbyte(n) {
|
||||||
|
|
||||||
pattern[npatbytes++]=n;
|
NEXT(npatbytes, MAXPATBYTES, "Pattern bytes");
|
||||||
|
pattern[npatbytes]=n;
|
||||||
}
|
}
|
||||||
|
|
||||||
hashpatterns() {
|
hashpatterns() {
|
||||||
|
@ -572,8 +573,8 @@ outars() {
|
||||||
fprintf(ctable,"char coderules[%d];\n",codeindex);
|
fprintf(ctable,"char coderules[%d];\n",codeindex);
|
||||||
fprintf(ctable,"int ncodebytes=%d;\n",codeindex);
|
fprintf(ctable,"int ncodebytes=%d;\n",codeindex);
|
||||||
}
|
}
|
||||||
fprintf(ctable,"char pattern[%d]={\n",npatbytes);
|
fprintf(ctable,"char pattern[%d]={\n",npatbytes+1);
|
||||||
for(i=0;i<npatbytes;i++) {
|
for(i=0;i<=npatbytes;i++) {
|
||||||
fprintf(ctable,"%d,%c",pattern[i]&BMASK,i%16==15 ? '\n' : ' ');
|
fprintf(ctable,"%d,%c",pattern[i]&BMASK,i%16==15 ? '\n' : ' ');
|
||||||
}
|
}
|
||||||
fprintf(ctable,"};\n\n");
|
fprintf(ctable,"};\n\n");
|
||||||
|
@ -851,7 +852,7 @@ statistics() {
|
||||||
used("1->1 Coercions",ncoercs,MAXCOERCS);
|
used("1->1 Coercions",ncoercs,MAXCOERCS);
|
||||||
used("Splitting coercions",nsplit,MAXSPLCOERC);
|
used("Splitting coercions",nsplit,MAXSPLCOERC);
|
||||||
used("Register variables",maxregvars,MAXREGVAR);
|
used("Register variables",maxregvars,MAXREGVAR);
|
||||||
used("Pat bytes",npatbytes,MAXPATBYTES);
|
used("Pat bytes",npatbytes+1,MAXPATBYTES);
|
||||||
if (tabledebug)
|
if (tabledebug)
|
||||||
used("Source lines",maxline,MAXSOURCELINES);
|
used("Source lines",maxline,MAXSOURCELINES);
|
||||||
fprintf(stderr,"%ldK heap used\n",((long) (sbrk(0)-end+1023))/1024);
|
fprintf(stderr,"%ldK heap used\n",((long) (sbrk(0)-end+1023))/1024);
|
||||||
|
|
|
@ -114,5 +114,14 @@ set_t setdiff(s1,s2) set_t s1,s2; {
|
||||||
result.set_size = 0;
|
result.set_size = 0;
|
||||||
for(i=0;i<SETSIZE;i++)
|
for(i=0;i<SETSIZE;i++)
|
||||||
result.set_val[i] = s1.set_val[i] & ~ s2.set_val[i];
|
result.set_val[i] = s1.set_val[i] & ~ s2.set_val[i];
|
||||||
|
/* make sure that we don't loose the lowest bit of the set, which
|
||||||
|
indicates that it contains registers
|
||||||
|
*/
|
||||||
|
for (i=1;i <= nregs; i++) {
|
||||||
|
if (BIT(result.set_val, i)) {
|
||||||
|
BIS(result.set_val,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ n_proc(name) char *name; {
|
||||||
extern int npatbytes;
|
extern int npatbytes;
|
||||||
|
|
||||||
sy_p = lookup(name,symproc,newsymbol);
|
sy_p = lookup(name,symproc,newsymbol);
|
||||||
sy_p->sy_value.syv_procoff = npatbytes;
|
sy_p->sy_value.syv_procoff = npatbytes + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct varinfo *
|
struct varinfo *
|
||||||
|
|
|
@ -23,7 +23,7 @@ int empatlen,emmnem[EMPATMAX];
|
||||||
int empatexpr;
|
int empatexpr;
|
||||||
int tokpatlen,tokpatset[TOKPATMAX],tokpatro[TOKPATMAX];
|
int tokpatlen,tokpatset[TOKPATMAX],tokpatro[TOKPATMAX];
|
||||||
int nallreg,allreg[MAXALLREG];
|
int nallreg,allreg[MAXALLREG];
|
||||||
int cursetno;
|
int cursetno = -1;
|
||||||
int allsetno;
|
int allsetno;
|
||||||
int inproc=0; /* scanning "procedure" */
|
int inproc=0; /* scanning "procedure" */
|
||||||
int callproc=0;
|
int callproc=0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue