Sun defines tmpfile in stdio.h. Renamed Tmpfile
This commit is contained in:
parent
1e10c0cf98
commit
f1fc51c85c
6 changed files with 50 additions and 50 deletions
|
@ -36,7 +36,7 @@ extern char tmpfname[MAXFILENAME]; /* temporary statements file */
|
||||||
|
|
||||||
extern FILE *emfile; /* EM output file */
|
extern FILE *emfile; /* EM output file */
|
||||||
extern FILE *datfile; /* data file */
|
extern FILE *datfile; /* data file */
|
||||||
extern FILE *tmpfile; /* compiler temporary */
|
extern FILE *Tmpfile; /* compiler temporary */
|
||||||
extern FILE *yyin; /* Compiler input */
|
extern FILE *yyin; /* Compiler input */
|
||||||
|
|
||||||
extern int endofinput;
|
extern int endofinput;
|
||||||
|
@ -51,7 +51,7 @@ extern int threshold;
|
||||||
extern int debug;
|
extern int debug;
|
||||||
extern int tronoff;
|
extern int tronoff;
|
||||||
|
|
||||||
extern int emlinecount; /* counts lines on tmpfile */
|
extern int emlinecount; /* counts lines on Tmpfile */
|
||||||
extern int dataused;
|
extern int dataused;
|
||||||
extern int typetable[10]; /* parameters to standard functions */
|
extern int typetable[10]; /* parameters to standard functions */
|
||||||
|
|
||||||
|
|
|
@ -136,9 +136,9 @@ char *opcode;
|
||||||
emcode(opcode,instrlabel(l1));
|
emcode(opcode,instrlabel(l1));
|
||||||
emcode("loc",itoa(0));
|
emcode("loc",itoa(0));
|
||||||
emcode("bra",instrlabel(l2));
|
emcode("bra",instrlabel(l2));
|
||||||
fprintf(tmpfile,"%d\n",l1); emlinecount++;
|
fprintf(Tmpfile,"%d\n",l1); emlinecount++;
|
||||||
emcode("loc",itoa(-1));
|
emcode("loc",itoa(-1));
|
||||||
fprintf(tmpfile,"%d\n",l2); emlinecount++;
|
fprintf(Tmpfile,"%d\n",l2); emlinecount++;
|
||||||
}
|
}
|
||||||
relop( ltype,rtype,operator)
|
relop( ltype,rtype,operator)
|
||||||
int ltype,rtype,operator;
|
int ltype,rtype,operator;
|
||||||
|
@ -292,10 +292,10 @@ loadptr(s)
|
||||||
Symbol *s;
|
Symbol *s;
|
||||||
{
|
{
|
||||||
if( POINTERSIZE==WORDSIZE)
|
if( POINTERSIZE==WORDSIZE)
|
||||||
fprintf(tmpfile," loe l%d\n",s->symalias);
|
fprintf(Tmpfile," loe l%d\n",s->symalias);
|
||||||
else
|
else
|
||||||
if( POINTERSIZE== 2*WORDSIZE)
|
if( POINTERSIZE== 2*WORDSIZE)
|
||||||
fprintf(tmpfile," lde l%d\n",s->symalias);
|
fprintf(Tmpfile," lde l%d\n",s->symalias);
|
||||||
else error("loadptr:unexpected pointersize");
|
else error("loadptr:unexpected pointersize");
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -355,10 +355,10 @@ Symbol *s;
|
||||||
else{
|
else{
|
||||||
j= -s->symalias;
|
j= -s->symalias;
|
||||||
if(debug) printf("load parm %d\n",j);
|
if(debug) printf("load parm %d\n",j);
|
||||||
fprintf(tmpfile," lal ");
|
fprintf(Tmpfile," lal ");
|
||||||
for(i=fcn->dimensions;i>j;i--)
|
for(i=fcn->dimensions;i>j;i--)
|
||||||
fprintf(tmpfile,"%s+",typesize(fcn->dimlimit[i-1]));
|
fprintf(Tmpfile,"%s+",typesize(fcn->dimlimit[i-1]));
|
||||||
fprintf(tmpfile,"0\n");
|
fprintf(Tmpfile,"0\n");
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
/*
|
/*
|
||||||
emcode("lal",datalabel(fcn->dimalias[-s->symalias]));
|
emcode("lal",datalabel(fcn->dimalias[-s->symalias]));
|
||||||
|
@ -424,7 +424,7 @@ int type;
|
||||||
conversion(type,INTTYPE);
|
conversion(type,INTTYPE);
|
||||||
dim--;
|
dim--;
|
||||||
/* first check index range */
|
/* first check index range */
|
||||||
fprintf(tmpfile," lae r%d\n",s->dimalias[dim]);
|
fprintf(Tmpfile," lae r%d\n",s->dimalias[dim]);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
emcode("rck",EMINTSIZE);
|
emcode("rck",EMINTSIZE);
|
||||||
emcode("lae",datalabel(s->dimalias[dim]));
|
emcode("lae",datalabel(s->dimalias[dim]));
|
||||||
|
|
|
@ -36,23 +36,23 @@ int blk1,blk2;
|
||||||
{
|
{
|
||||||
/* exchange assembler blocks */
|
/* exchange assembler blocks */
|
||||||
if(debug) printf("exchange %d %d %d\n",blk1,blk2,emlinecount);
|
if(debug) printf("exchange %d %d %d\n",blk1,blk2,emlinecount);
|
||||||
fprintf(tmpfile," exc %d,%d\n",blk2-blk1,emlinecount-blk2);
|
fprintf(Tmpfile," exc %d,%d\n",blk2-blk1,emlinecount-blk2);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* routines to manipulate the tmpfile */
|
/* routines to manipulate the Tmpfile */
|
||||||
int emlinecount; /* count number of lines generated */
|
int emlinecount; /* count number of lines generated */
|
||||||
/* this value can be used to generate EXC */
|
/* this value can be used to generate EXC */
|
||||||
int tronoff=0;
|
int tronoff=0;
|
||||||
newemblock(nr)
|
newemblock(nr)
|
||||||
int nr;
|
int nr;
|
||||||
{
|
{
|
||||||
/* save location on tmpfile */
|
/* save location on Tmpfile */
|
||||||
currline->offset= ftell(tmpfile);
|
currline->offset= ftell(Tmpfile);
|
||||||
fprintf(tmpfile,"%d\n",currline->emlabel);
|
fprintf(Tmpfile,"%d\n",currline->emlabel);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
if (! nolins) {
|
if (! nolins) {
|
||||||
fprintf(tmpfile," lin %d\n",nr);
|
fprintf(Tmpfile," lin %d\n",nr);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
}
|
}
|
||||||
if( tronoff || traceflag) {
|
if( tronoff || traceflag) {
|
||||||
|
@ -65,7 +65,7 @@ int nr;
|
||||||
emcode(operation,params)
|
emcode(operation,params)
|
||||||
char *operation,*params;
|
char *operation,*params;
|
||||||
{
|
{
|
||||||
fprintf(tmpfile," %s %s\n",operation,params);
|
fprintf(Tmpfile," %s %s\n",operation,params);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
}
|
}
|
||||||
/* Handle data statements */
|
/* Handle data statements */
|
||||||
|
@ -304,13 +304,13 @@ int elselab;
|
||||||
|
|
||||||
nr=genlabel();
|
nr=genlabel();
|
||||||
emcode("bra",instrlabel(nr));
|
emcode("bra",instrlabel(nr));
|
||||||
fprintf(tmpfile,"%d\n",elselab);
|
fprintf(Tmpfile,"%d\n",elselab);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
return(nr);
|
return(nr);
|
||||||
}
|
}
|
||||||
elsepart(lab)int lab;
|
elsepart(lab)int lab;
|
||||||
{
|
{
|
||||||
fprintf(tmpfile,"%d\n",lab); emlinecount++;
|
fprintf(Tmpfile,"%d\n",lab); emlinecount++;
|
||||||
}
|
}
|
||||||
/* generate code for the for-statement */
|
/* generate code for the for-statement */
|
||||||
#define MAXFORDEPTH 20
|
#define MAXFORDEPTH 20
|
||||||
|
@ -425,7 +425,7 @@ int type;
|
||||||
emcode("sti",typestring(result));
|
emcode("sti",typestring(result));
|
||||||
emcode("bra",instrlabel(f->fortst));
|
emcode("bra",instrlabel(f->fortst));
|
||||||
/* increment loop variable */
|
/* increment loop variable */
|
||||||
fprintf(tmpfile,"%d\n",f->forinc);
|
fprintf(Tmpfile,"%d\n",f->forinc);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
emcode("lae",datalabel(varaddress));
|
emcode("lae",datalabel(varaddress));
|
||||||
loadvar(result);
|
loadvar(result);
|
||||||
|
@ -437,7 +437,7 @@ int type;
|
||||||
emcode("lae",datalabel(varaddress));
|
emcode("lae",datalabel(varaddress));
|
||||||
emcode("sti",typestring(result));
|
emcode("sti",typestring(result));
|
||||||
/* test boundary */
|
/* test boundary */
|
||||||
fprintf(tmpfile,"%d\n",f->fortst);
|
fprintf(Tmpfile,"%d\n",f->fortst);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
emcode("lae",datalabel(varaddress));
|
emcode("lae",datalabel(varaddress));
|
||||||
loadvar(result);
|
loadvar(result);
|
||||||
|
@ -457,7 +457,7 @@ Symbol *s;
|
||||||
else{
|
else{
|
||||||
/* address of variable is on top of stack ! */
|
/* address of variable is on top of stack ! */
|
||||||
emcode("bra",instrlabel(fortable[forcnt].forinc));
|
emcode("bra",instrlabel(fortable[forcnt].forinc));
|
||||||
fprintf(tmpfile,"%d\n",fortable[forcnt].forout);
|
fprintf(Tmpfile,"%d\n",fortable[forcnt].forout);
|
||||||
forcnt--;
|
forcnt--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ whilestart()
|
||||||
newblock(-1);
|
newblock(-1);
|
||||||
whilelabels[whilecnt][0]= currline->emlabel;
|
whilelabels[whilecnt][0]= currline->emlabel;
|
||||||
whilelabels[whilecnt][1]= genlabel();
|
whilelabels[whilecnt][1]= genlabel();
|
||||||
fprintf(tmpfile,"%d\n", whilelabels[whilecnt][0]);
|
fprintf(Tmpfile,"%d\n", whilelabels[whilecnt][0]);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
}
|
}
|
||||||
whiletst(exprtype)
|
whiletst(exprtype)
|
||||||
|
@ -494,7 +494,7 @@ int exprtype;
|
||||||
{
|
{
|
||||||
/* test expression type */
|
/* test expression type */
|
||||||
conversion(exprtype,INTTYPE);
|
conversion(exprtype,INTTYPE);
|
||||||
fprintf(tmpfile," zeq *%d\n",whilelabels[whilecnt][1]);
|
fprintf(Tmpfile," zeq *%d\n",whilelabels[whilecnt][1]);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
}
|
}
|
||||||
wend()
|
wend()
|
||||||
|
@ -502,8 +502,8 @@ wend()
|
||||||
if( whilecnt<1)
|
if( whilecnt<1)
|
||||||
error("not part of while statement");
|
error("not part of while statement");
|
||||||
else{
|
else{
|
||||||
fprintf(tmpfile," bra *%d\n",whilelabels[whilecnt][0]);
|
fprintf(Tmpfile," bra *%d\n",whilelabels[whilecnt][0]);
|
||||||
fprintf(tmpfile,"%d\n",whilelabels[whilecnt][1]);
|
fprintf(Tmpfile,"%d\n",whilelabels[whilecnt][1]);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
whilecnt--;
|
whilecnt--;
|
||||||
|
|
|
@ -78,8 +78,8 @@ int nr;
|
||||||
/*NOSTRICT*/ l= (Linerecord *) salloc(sizeof(*l));
|
/*NOSTRICT*/ l= (Linerecord *) salloc(sizeof(*l));
|
||||||
l->emlabel= frwrd? frwrd->emlabel: genlabel();
|
l->emlabel= frwrd? frwrd->emlabel: genlabel();
|
||||||
l->linenr= nr;
|
l->linenr= nr;
|
||||||
/* save offset into tmpfile too */
|
/* save offset into Tmpfile too */
|
||||||
l->offset = (long) ftell(tmpfile);
|
l->offset = (long) ftell(Tmpfile);
|
||||||
l->codelines= emlinecount;
|
l->codelines= emlinecount;
|
||||||
|
|
||||||
/* insert this record */
|
/* insert this record */
|
||||||
|
@ -163,7 +163,7 @@ int lab;
|
||||||
emcode("cal","$_gosub"); /* administer legal return */
|
emcode("cal","$_gosub"); /* administer legal return */
|
||||||
emcode("asp",EMINTSIZE);
|
emcode("asp",EMINTSIZE);
|
||||||
emcode("bra",instrlabel(nr));
|
emcode("bra",instrlabel(nr));
|
||||||
fprintf(tmpfile,"%d\n",l->emlabel);
|
fprintf(Tmpfile,"%d\n",l->emlabel);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
}
|
}
|
||||||
genreturns()
|
genreturns()
|
||||||
|
@ -185,7 +185,7 @@ returnstmt()
|
||||||
{
|
{
|
||||||
emcode("cal","$_retstmt"); /* ensure legal return*/
|
emcode("cal","$_retstmt"); /* ensure legal return*/
|
||||||
emcode("lfr",EMINTSIZE);
|
emcode("lfr",EMINTSIZE);
|
||||||
fprintf(tmpfile," lae returns\n");
|
fprintf(Tmpfile," lae returns\n");
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
emcode("csa",EMINTSIZE);
|
emcode("csa",EMINTSIZE);
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,12 @@ int type;
|
||||||
/* create descriptor first */
|
/* create descriptor first */
|
||||||
descr= genlabel();
|
descr= genlabel();
|
||||||
firstlabel=genlabel();
|
firstlabel=genlabel();
|
||||||
fprintf(tmpfile,"l%d\n",descr); emlinecount++;
|
fprintf(Tmpfile,"l%d\n",descr); emlinecount++;
|
||||||
fprintf(tmpfile," rom *%d,1,%d\n",firstlabel,jumpcnt-1); emlinecount++;
|
fprintf(Tmpfile," rom *%d,1,%d\n",firstlabel,jumpcnt-1); emlinecount++;
|
||||||
l= jumphead;
|
l= jumphead;
|
||||||
while( l)
|
while( l)
|
||||||
{
|
{
|
||||||
fprintf(tmpfile," rom *%d\n",l->emlabel); emlinecount++;
|
fprintf(Tmpfile," rom *%d\n",l->emlabel); emlinecount++;
|
||||||
l= l->nextlist;
|
l= l->nextlist;
|
||||||
}
|
}
|
||||||
jumphead= jumptail=0; jumpcnt=0;
|
jumphead= jumptail=0; jumpcnt=0;
|
||||||
|
@ -232,7 +232,7 @@ int type;
|
||||||
conversion(type,INTTYPE);
|
conversion(type,INTTYPE);
|
||||||
emcode("lae",datalabel(descr));
|
emcode("lae",datalabel(descr));
|
||||||
emcode("csa",EMINTSIZE);
|
emcode("csa",EMINTSIZE);
|
||||||
fprintf(tmpfile,"%d\n",firstlabel); emlinecount++;
|
fprintf(Tmpfile,"%d\n",firstlabel); emlinecount++;
|
||||||
}
|
}
|
||||||
ongosubstmt(type)
|
ongosubstmt(type)
|
||||||
int type;
|
int type;
|
||||||
|
@ -243,12 +243,12 @@ int type;
|
||||||
/* create descriptor first */
|
/* create descriptor first */
|
||||||
descr= genlabel();
|
descr= genlabel();
|
||||||
firstlabel=genlabel();
|
firstlabel=genlabel();
|
||||||
fprintf(tmpfile,"l%d\n",descr); emlinecount++;
|
fprintf(Tmpfile,"l%d\n",descr); emlinecount++;
|
||||||
fprintf(tmpfile," rom *%d,1,%d\n",firstlabel,jumpcnt-1); emlinecount++;
|
fprintf(Tmpfile," rom *%d,1,%d\n",firstlabel,jumpcnt-1); emlinecount++;
|
||||||
l= jumphead;
|
l= jumphead;
|
||||||
while( l)
|
while( l)
|
||||||
{
|
{
|
||||||
fprintf(tmpfile," rom *%d\n",l->emlabel); emlinecount++;
|
fprintf(Tmpfile," rom *%d\n",l->emlabel); emlinecount++;
|
||||||
l= l->nextlist;
|
l= l->nextlist;
|
||||||
}
|
}
|
||||||
jumphead= jumptail=0; jumpcnt=0;
|
jumphead= jumptail=0; jumpcnt=0;
|
||||||
|
@ -269,7 +269,7 @@ int type;
|
||||||
conversion(type,INTTYPE);
|
conversion(type,INTTYPE);
|
||||||
emcode("lae",datalabel(descr));
|
emcode("lae",datalabel(descr));
|
||||||
emcode("csa",EMINTSIZE);
|
emcode("csa",EMINTSIZE);
|
||||||
fprintf(tmpfile,"%d\n",firstlabel);
|
fprintf(Tmpfile,"%d\n",firstlabel);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,11 +283,11 @@ simpleprogram()
|
||||||
/* a small EM programs has been found */
|
/* a small EM programs has been found */
|
||||||
prologcode();
|
prologcode();
|
||||||
prolog2();
|
prolog2();
|
||||||
(void) fclose(tmpfile);
|
(void) fclose(Tmpfile);
|
||||||
tmpfile= fopen(tmpfname,"r");
|
Tmpfile= fopen(tmpfname,"r");
|
||||||
if( tmpfile==NULL)
|
if( Tmpfile==NULL)
|
||||||
fatal("tmp file disappeared");
|
fatal("tmp file disappeared");
|
||||||
while( (length=fread(buf,1,512,tmpfile)) != 0)
|
while( (length=fread(buf,1,512,Tmpfile)) != 0)
|
||||||
(void) fwrite(buf,1,length,emfile);
|
(void) fwrite(buf,1,length,emfile);
|
||||||
epilogcode();
|
epilogcode();
|
||||||
(void) unlink(tmpfname);
|
(void) unlink(tmpfname);
|
||||||
|
|
|
@ -8,7 +8,7 @@ static char rcs_id[] = "$Header$" ;
|
||||||
/* generate temporary files etc */
|
/* generate temporary files etc */
|
||||||
|
|
||||||
FILE *emfile;
|
FILE *emfile;
|
||||||
FILE *tmpfile;
|
FILE *Tmpfile;
|
||||||
FILE *datfile;
|
FILE *datfile;
|
||||||
|
|
||||||
initialize()
|
initialize()
|
||||||
|
@ -35,8 +35,8 @@ initialize()
|
||||||
strcat(datfname,".d");
|
strcat(datfname,".d");
|
||||||
yyin= fopen(inpfile,"r");
|
yyin= fopen(inpfile,"r");
|
||||||
emfile= fopen(outfile,"w");
|
emfile= fopen(outfile,"w");
|
||||||
tmpfile= fopen(tmpfname,"w");
|
Tmpfile= fopen(tmpfname,"w");
|
||||||
if( yyin==NULL || emfile== NULL || tmpfile== NULL )
|
if( yyin==NULL || emfile== NULL || Tmpfile== NULL )
|
||||||
fatal("Improper file permissions");
|
fatal("Improper file permissions");
|
||||||
fillkex(); /* initialize symbol table */
|
fillkex(); /* initialize symbol table */
|
||||||
fprintf(emfile,"#\n");
|
fprintf(emfile,"#\n");
|
||||||
|
|
|
@ -196,8 +196,8 @@ fcnsize()
|
||||||
/* generate portable function size */
|
/* generate portable function size */
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<fcn->dimensions;i++)
|
for(i=0;i<fcn->dimensions;i++)
|
||||||
fprintf(tmpfile,"%s+",typesize(fcn->dimlimit[i]));
|
fprintf(Tmpfile,"%s+",typesize(fcn->dimlimit[i]));
|
||||||
fprintf(tmpfile,"0\n"); emlinecount++;
|
fprintf(Tmpfile,"0\n"); emlinecount++;
|
||||||
}
|
}
|
||||||
endscope(type)
|
endscope(type)
|
||||||
int type;
|
int type;
|
||||||
|
@ -208,7 +208,7 @@ int type;
|
||||||
conversion(type,fcn->symtype);
|
conversion(type,fcn->symtype);
|
||||||
emcode("ret", typestring(fcn->symtype));
|
emcode("ret", typestring(fcn->symtype));
|
||||||
/* generate portable EM code */
|
/* generate portable EM code */
|
||||||
fprintf(tmpfile," end ");
|
fprintf(Tmpfile," end ");
|
||||||
fcnsize();
|
fcnsize();
|
||||||
s= firstsym;
|
s= firstsym;
|
||||||
while(s)
|
while(s)
|
||||||
|
@ -267,9 +267,9 @@ int parmcount;
|
||||||
error("not enough parameters");
|
error("not enough parameters");
|
||||||
if( parmcount >fcn->dimensions)
|
if( parmcount >fcn->dimensions)
|
||||||
error("too many parameters");
|
error("too many parameters");
|
||||||
fprintf(tmpfile," cal $_%s\n",fcn->symname);
|
fprintf(Tmpfile," cal $_%s\n",fcn->symname);
|
||||||
emlinecount++;
|
emlinecount++;
|
||||||
fprintf(tmpfile," asp ");
|
fprintf(Tmpfile," asp ");
|
||||||
fcnsize();
|
fcnsize();
|
||||||
emcode("lfr",typestring(fcn->symtype));
|
emcode("lfr",typestring(fcn->symtype));
|
||||||
type= fcn->symtype;
|
type= fcn->symtype;
|
||||||
|
|
Loading…
Reference in a new issue