Checking in Martin's changes.

This commit is contained in:
em 1985-01-17 14:10:27 +00:00
parent e75b8772ca
commit 6512a304a0
8 changed files with 39 additions and 31 deletions

View file

@ -87,6 +87,7 @@ int chann; /* input/output channel */
char *formatstring; /* formatstring used for printing */ char *formatstring; /* formatstring used for printing */
Symbol *s; /* Symbol dummy */ Symbol *s; /* Symbol dummy */
%} %}
/* We need to type things properly to limit complaints of lint*/
%% %%
programline : INTVALUE {newblock(ival); newemblock(ival);} stmts EOLN programline : INTVALUE {newblock(ival); newemblock(ival);} stmts EOLN
| '#' INTVALUE STRVALUE EOLN | '#' INTVALUE STRVALUE EOLN
@ -417,8 +418,8 @@ factor : INTVALUE {$$=loadint(ival);}
| '(' expression ')' {$$=$2;} | '(' expression ')' {$$=$2;}
| '-' factor { $$=negate($2);} | '-' factor { $$=negate($2);}
| FLTVALUE {$$=loaddbl(dval);} | FLTVALUE {$$=loaddbl(dval);}
| STRVALUE {$$=loadstr($1);} | STRVALUE {$$= STRINGTYPE; loadstr($1);}
| variable {$$=loadvar($1);} | variable {$$=$1; loadvar($1);}
| INKEYSYM '$' { emcode("cal","$_inkey"); | INKEYSYM '$' { emcode("cal","$_inkey");
emcode("lfr",EMPTRSIZE); emcode("lfr",EMPTRSIZE);
$$= STRINGTYPE; $$= STRINGTYPE;
@ -426,8 +427,8 @@ factor : INTVALUE {$$=loadint(ival);}
| VARPTR '(' '#' intvalue ')' { warning("Not supported"); $$=INTTYPE;} | VARPTR '(' '#' intvalue ')' { warning("Not supported"); $$=INTTYPE;}
| FUNCTION {$$= callfcn($1,0);} | FUNCTION {$$= callfcn($1,0);}
| FUNCTION '(' cross exprlist')' {$$=callfcn($1,$4);} | FUNCTION '(' cross exprlist')' {$$=callfcn($1,$4);}
| funcname { $$=fcnend($1);} | funcname { $$=fcnend(0);}
| funcname funccall ')' { $$=fcnend($1,$2);} | funcname funccall ')' { $$=fcnend($2);}
| MIDSYM '$' midparms | MIDSYM '$' midparms
{ emcode("cal","$_mid"); { emcode("cal","$_mid");
emcode("asp",itoa($3)); emcode("asp",itoa($3));
@ -460,4 +461,4 @@ exprlist: expression { typetable[0]= $1; $$=1;}
#ifndef NORCSID #ifndef NORCSID
static char rcs_id[] = "$Header$" ; static char rcs_id[] = "$Header$" ;
#endif #endif
#include "lex.c" #include "basic.lex"

View file

@ -61,3 +61,5 @@ extern char *itoa();
extern char *datalabel(); extern char *datalabel();
extern char *instrlabel(); extern char *instrlabel();
extern char *typesize(); extern char *typesize();
extern char *typestring();
extern void sprintf();

View file

@ -6,13 +6,15 @@ static char rcs_id[] = "$Header$" ;
/* compile the next program in the list */ /* compile the next program in the list */
/* Here we should open the input file. (for the future) */
FILE *yyin; FILE *yyin;
compileprogram() compileprogram(dummyprog)
char *dummyprog;
{ {
while( getline()) while( getline())
yyparse(); (void) yyparse();
fclose(yyin); (void) fclose(yyin);
} }

View file

@ -321,7 +321,6 @@ int type;
{ {
/* load a simple variable its address is on the stack*/ /* load a simple variable its address is on the stack*/
emcode("loi",typestring(type)); emcode("loi",typestring(type));
return(type);
} }
loadint(value) loadint(value)
int value; int value;
@ -343,7 +342,6 @@ loadstr(value)
int value; int value;
{ {
emcode("lae",datalabel(value)); emcode("lae",datalabel(value));
return(STRINGTYPE);
} }
loadaddr(s) loadaddr(s)
Symbol *s; Symbol *s;

View file

@ -11,6 +11,13 @@ Linerecord *firstline,
*currline, *currline,
*lastline; *lastline;
List *newlist()
{
List *l;
l= (List *) salloc(sizeof(List));
return(l);
}
/* Line management is handled here */ /* Line management is handled here */
Linerecord *srchline(nr) Linerecord *srchline(nr)
@ -94,7 +101,7 @@ int nr;
if(debug) printf("goto label %d\n",nr); if(debug) printf("goto label %d\n",nr);
/* update currline */ /* update currline */
ll= (List *) salloc( sizeof(*ll)); ll= newlist();
ll-> linenr=nr; ll-> linenr=nr;
ll-> nextlist= currline->gotos; ll-> nextlist= currline->gotos;
currline->gotos= ll; currline->gotos= ll;
@ -108,7 +115,7 @@ int nr;
{ {
/* declare forward label */ /* declare forward label */
if(debug) printf("declare forward %d\n",nr); if(debug) printf("declare forward %d\n",nr);
ll= (List *) salloc( sizeof(*ll)); ll= newlist();
ll->emlabel= genlabel(); ll->emlabel= genlabel();
ll-> linenr=nr; ll-> linenr=nr;
ll->nextlist= forwardlabel; ll->nextlist= forwardlabel;
@ -132,9 +139,8 @@ int gosubcnt=1;
List *gosublabel() List *gosublabel()
{ {
List *l; List *l;
int n;
l= (List *) salloc(sizeof(List)); l= newlist();
l->nextlist=0; l->nextlist=0;
l->emlabel=genlabel(); l->emlabel=genlabel();
if( gotail){ if( gotail){
@ -192,7 +198,7 @@ int nr;
{ {
List *l; List *l;
l= (List *) salloc(sizeof(List)); l= newlist();
l->emlabel= gotolabel(nr); l->emlabel= gotolabel(nr);
l->nextlist=0; l->nextlist=0;
if( jumphead==0) jumphead= jumptail= l; if( jumphead==0) jumphead= jumptail= l;
@ -247,7 +253,7 @@ int type;
} }
jumphead= jumptail=0; jumpcnt=0; jumphead= jumptail=0; jumpcnt=0;
l= (List *) salloc(sizeof(List)); l= newlist();
l->nextlist=0; l->nextlist=0;
l->emlabel=firstlabel; l->emlabel=firstlabel;
if( gotail){ if( gotail){
@ -277,12 +283,12 @@ simpleprogram()
/* a small EM programs has been found */ /* a small EM programs has been found */
prologcode(); prologcode();
prolog2(); prolog2();
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)
fwrite(buf,1,length,emfile); (void) fwrite(buf,1,length,emfile);
epilogcode(); epilogcode();
unlink(tmpfname); (void) unlink(tmpfname);
} }

View file

@ -15,10 +15,9 @@ parseparams(argc,argv)
int argc; int argc;
char **argv; char **argv;
{ {
int i,j,k; int i;
char *ext; char *ext;
j=k=0;
if(argc< 4) if(argc< 4)
{ {
fprintf(stderr,"usage %s <flags> <file>.i <file>.e <source>\n", argv[0]); fprintf(stderr,"usage %s <flags> <file>.i <file>.e <source>\n", argv[0]);
@ -32,7 +31,7 @@ char **argv;
case 't': traceflag++; break; /* line tracing */ case 't': traceflag++; break; /* line tracing */
case 'h':/* split EM file */ case 'h':/* split EM file */
hflag=0; hflag=0;
threshold= (long) atol(argv[i][2]); threshold= atoi(argv[i][2]);
if( threshold==0) if( threshold==0)
threshold= THRESHOLD; threshold= THRESHOLD;
break; break;

View file

@ -41,8 +41,8 @@ List *l;
phase1() phase1()
{ {
/* copy all offloaded blocks */ /* copy all offloaded blocks */
Linerecord *lr, *lf,*lr2; Linerecord *lr, *lf;
int blksize; long blksize;
lf= lr= firstline; lf= lr= firstline;
blksize= lr->codelines; blksize= lr->codelines;

View file

@ -191,8 +191,7 @@ heading( )
if( fcn->symtype== DEFAULTTYPE) if( fcn->symtype== DEFAULTTYPE)
fcn->symtype= DOUBLETYPE; fcn->symtype= DOUBLETYPE;
} }
fcnsize(s) fcnsize()
Symbol *s;
{ {
/* generate portable function size */ /* generate portable function size */
int i; int i;
@ -210,7 +209,7 @@ int type;
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(fcn); fcnsize();
s= firstsym; s= firstsym;
while(s) while(s)
{ {
@ -226,7 +225,7 @@ int type;
dclparm(s) dclparm(s)
Symbol *s; Symbol *s;
{ {
int i,size=0; int size=0;
if( s->symtype== DEFAULTTYPE) if( s->symtype== DEFAULTTYPE)
s->symtype= DOUBLETYPE; s->symtype= DOUBLETYPE;
s->isparam=1; s->isparam=1;
@ -257,9 +256,10 @@ Symbol *s;
fcnindex++; fcnindex++;
fcntable[fcnindex]=s; fcntable[fcnindex]=s;
} }
return(s->symtype);
} }
fcnend(fcntype, parmcount) fcnend(parmcount)
int fcntype, parmcount; int parmcount;
{ {
int type; int type;
/* check number of arguments */ /* check number of arguments */
@ -270,7 +270,7 @@ int fcntype, parmcount;
fprintf(tmpfile," cal $_%s\n",fcn->symname); fprintf(tmpfile," cal $_%s\n",fcn->symname);
emlinecount++; emlinecount++;
fprintf(tmpfile," asp "); fprintf(tmpfile," asp ");
fcnsize(fcn); fcnsize();
emcode("lfr",typestring(fcn->symtype)); emcode("lfr",typestring(fcn->symtype));
type= fcn->symtype; type= fcn->symtype;
fcnindex--; fcnindex--;