/* >>>>> start of cc3 <<<<<<<<< */ /* 3/3/88 */ /* */ /* Perform a function call */ /* */ /* called from heir11, this routine will either call */ /* the named function, or if the supplied ptr is */ /* zero, will call the contents of BX */ callfunction(ptr) char *ptr; /* symbol table entry (or 0) */ { int nargs; nargs=0; blanks(); /* already saw open paren */ if(ptr==0)zpush(); /* calling BX */ while(streq(line+lptr,")")==0) {if(endst())break; expression(); /* get an argument */ if(ptr==0)swapstk(); /* don't push addr */ zpush(); /* push argument */ nargs=nargs+4; /* count args*4 */ if (match(",")==0) break; } needbrack(")"); if(ptr)zcall(ptr); else callstk(); Zsp=modstk(Zsp+nargs); /* clean up arguments */ } junk() { if(an(inbyte())) while(an(ch()))gch(); else while(an(ch())==0) {if(ch()==0)break; gch(); } blanks(); } endst() { blanks(); return ((streq(line+lptr,";")|(ch()==0))); } illname() { error("illegal symbol name");junk();} multidef(sname) char *sname; { error("already defined"); comment(); outstr(sname);nl(); } needbrack(str) char *str; { if(match(str)==0) { error("missing bracket"); comment();outstr(str);nl(); } } needlval() { error("must be lvalue"); } findglb(sname) char *sname; { char *ptr; ptr=startglb; while(ptr!=glbptr) {if(astreq(sname,ptr,namemax))return ptr; ptr=ptr+symsiz; } return 0; } findloc(sname) char *sname; { char *ptr; ptr=startloc; while(ptr!=locptr) {if(astreq(sname,ptr,namemax))return ptr; ptr=ptr+symsiz; } return 0; } addglb(sname, class, typ, value) char *sname, class, typ; int value; { char *ptr; if(cptr=findglb(sname)) return cptr; if(glbptr>=endglb) { error("global symbol table overflow"); return 0; } cptr=ptr=glbptr; while (an(*ptr++ = *sname++)); /* copy name */ cptr[ident]=class; cptr[type]=typ; cptr[storage]=statik; cptr[offset]=value; cptr[offset+1]=value>>8; glbptr=glbptr+symsiz; return cptr; } addloc(sname, class, typ, value) char *sname, class, typ; int value; { char *ptr; if(cptr=findloc(sname)) return cptr; if(locptr>=endloc) { error("local symbol table overflow"); return 0; } cptr=ptr=locptr; while(an(*ptr++ = *sname++)); /* copy name */ cptr[ident]=class; cptr[type]=typ; cptr[storage]=stkloc; cptr[offset]=value; cptr[offset+1]=value>>8; locptr=locptr+symsiz; return cptr; } addext(sname, id) char *sname, id; { char *ptr; if(cptr=findext(sname)) return cptr; if(extptr>=endextrn) {error("external symbol table overflow"); return 0;} cptr=ptr=extptr; while(an(*ptr++=*sname++)); /* copy name */ /* type stored in byte following zero terminating name */ *ptr++=id; extptr=ptr; return cptr; } findext(sname) char *sname; { char *ptr; ptr=startextrn; while(ptr='a')&(c<='z')) | ((c>='A')&(c<='Z')) | (c=='_')); } /* Test if given character is numeric */ numeric(c) char c; { c=c&127; return ((c>='0') & (c<='9')); } /* Test if given character is alphanumeric */ an(c) char c; { return ((alpha(c)) | (numeric(c))); } /* Print a carriage return and a string only to console */ pl(str) char *str; { int k; k=0; putchar(hosteol); while (str[k]) putchar(str[k++]); } addwhile(ptr) int ptr[]; { int k; if (wqptr==wqmax) { error("too many active whiles"); return; } k=0; while (k0) { if((k==hosteol) | (lptr>=linemax)) break; line[lptr++]=k; } line[lptr]=0; /* append null */ lineno++; /* read one more line gtf 7/2/80 */ if(k<=0) { fclose(unit); if(input2) endinclude(); /* gtf 7/16/80 */ else input=0; } if(lptr) { if((ctext) & (cmode)) { comment(); outstr(line); nl(); } lptr=0; return; } } } /* >>>>>> start of cc4 <<<<<<< */ preprocess() { int k; char c, sname[namesize]; if(cmode==0) return; mptr=lptr=0; while(ch()) { if((ch()==' ') | (ch()==9)) predel(); else if(ch()=='"') prequote(); else if(ch()==39) preapos(); else if((ch()=='/') & (nch()=='*')) precomm(); else if(alpha(ch())) /* from an(): 9/22/80 gtf */ { k=0; while(an(ch())) { if(k=mpmax) error("line too long"); lptr=mptr=0; while (line[lptr++]=mline[mptr++]); lptr=0; } keepch(c) char c; { mline[mptr]=c; if(mptr=macmax) error("macro table full"); } putmac(c) char c; { macq[macptr]=c; if(macptr=1) { c=number/k + '0'; if ((c!='0') | (k==1) | (zs)) { zs=1; outbyte(c); } number=number%k; k=k/10; } } /* return the length of a string */ /* gtf 4/8/80 */ strlen(s) char *s; { char *t; t = s; while(*s) s++; return (s-t); } /* convert lower case to upper */ /* gtf 6/26/80 */ raise(c) char c; { if((c>='a') & (c<='z')) c = c - 'a' + 'A'; return (c); }