home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-07-27 | 43.9 KB | 1,001 lines |
- e(dput)) {
- (void)fprintf(output.fp, "/*\n"), Putl(output, 1);
- (void)fprintf(output.fp, "** Definitions for i/o\n"), Putl(output, 1);
- (void)fprintf(output.fp, "*/\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%s<stdio.h>\n", C24_include), Putl(output, 1);
- }
- if (use(dinput) || use(doutput) || use(dtext)) {
- etextdef();
- if (use(dinput)) {
- if (tp->U.V13.tsubid == (struct S61 *)NIL)
- (void)fprintf(output.fp, "%s", xtern), Putl(output, 0);
- (void)fprintf(output.fp, "text%c", tab1), Putl(output, 0);
- printid(defnams.A[(int)(dinput)]->U.V6.lid);
- if (tp->U.V13.tsubid != (struct S61 *)NIL)
- (void)fprintf(output.fp, " = { stdin, 0, 0 }"), Putl(output, 0);
- Putchr(';', output),Putchr('\n', output);
- }
- if (use(doutput)) {
- if (tp->U.V13.tsubid == (struct S61 *)NIL)
- (void)fprintf(output.fp, "%s", xtern), Putl(output, 0);
- (void)fprintf(output.fp, "text%c", tab1), Putl(output, 0);
- printid(defnams.A[(int)(doutput)]->U.V6.lid);
- if (tp->U.V13.tsubid != (struct S61 *)NIL)
- (void)fprintf(output.fp, " = { stdout, 0, 0 }"), Putl(output, 0);
- Putchr(';', output),Putchr('\n', output);
- }
- }
- if (use(dinput) || use(dget) || use(dread) || use(dreadln) || use(deof) || use(deoln) || use(dreset) || use(drewrite)) {
- (void)fprintf(output.fp, "%sFread(x, f) fread((char *)&x, sizeof(x), 1, f)\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%sGet(f) Fread((f).buf, (f).fp)\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%sGetx(f) (f).init = 1, (f).eoln = (((f).buf = fgetc((f).fp)) == %s) ? (((f).buf = %s), 1) : 0\n", C4_define, nlchr, spchr), Putl(output, 1);
- (void)fprintf(output.fp, "%sGetchr(f) (f).buf, Getx(f)\n", C4_define), Putl(output, 1);
- }
- if (use(dread) || use(dreadln)) {
- (void)fprintf(output.fp, "%sFILE%c*Tmpfil;\n", C50_static, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%slong%cTmplng;\n", C50_static, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sdouble%cTmpdbl;\n", C50_static, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sFscan(f) (f).init ? ungetc((f).buf, (f).fp) : 0, Tmpfil = (f).fp\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%sScan(p, a) Scanck(fscanf(Tmpfil, p, a))\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%s%cScanck();\n", voidtyp, tab1), Putl(output, 1);
- if (use(dreadln))
- (void)fprintf(output.fp, "%s%cGetl();\n", voidtyp, tab1), Putl(output, 1);
- }
- if (use(deoln))
- (void)fprintf(output.fp, "%sEoln(f) ((f).eoln ? true : false)\n", C4_define), Putl(output, 1);
- if (use(deof))
- (void)fprintf(output.fp, "%sEof(f) ((((f).init == 0) ? (Get(f)) : 0, ((f).eof ? 1 : feof((f).fp))) ? true : false)\n", C4_define), Putl(output, 1);
- if (use(doutput) || use(dput) || use(dwrite) || use(dwriteln) || use(dreset) || use(drewrite) || use(dclose)) {
- (void)fprintf(output.fp, "%sFwrite(x, f) fwrite((char *)&x, sizeof(x), 1, f)\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%sPut(f) Fwrite((f).buf, (f).fp)\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%sPutx(f) (f).eoln = ((f).buf == %s), %sfputc((f).buf, (f).fp)\n", C4_define, nlchr, voidcast), Putl(output, 1);
- (void)fprintf(output.fp, "%sPutchr(c, f) (f).buf = (c), Putx(f)\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%sPutl(f, v) (f).eoln = v\n", C4_define), Putl(output, 1);
- }
- if (use(dreset) || use(drewrite) || use(dclose))
- (void)fprintf(output.fp, "%sFinish(f) ((f).out && !(f).eoln) ? (Putchr(%s, f), 0) : 0, rewind((f).fp)\n", C4_define, nlchr), Putl(output, 1);
- if (use(dclose)) {
- (void)fprintf(output.fp, "%sClose(f) (f).init = ((f).init ? (fclose((f).fp), 0) : 0), (f).fp = NULL\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%sClosex(f) (f).init = ((f).init ? (Finish(f), fclose((f).fp), 0) : 0), (f).fp = NULL\n", C4_define), Putl(output, 1);
- }
- if (use(dreset)) {
- (void)fprintf(output.fp, "%sREADONLY\n", ifdef), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s%cRmode[] = \"r\";\n", C50_static, chartyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s\n", elsif), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s%cRmode[] = \"r+\";\n", C50_static, chartyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s\n", endif), Putl(output, 1);
- (void)fprintf(output.fp, "%sReset(f, n) (f).init = (f).init ? rewind((f).fp) : (((f).fp = Fopen(n, Rmode)), 1), (f).eof = (f).out = 0, Get(f)\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%sResetx(f, n) (f).init = (f).init ? (Finish(f)) : (((f).fp = Fopen(n, Rmode)), 1), (f).eof = (f).out = 0, Getx(f)\n", C4_define), Putl(output, 1);
- usefopn = true;
- }
- if (use(drewrite)) {
- (void)fprintf(output.fp, "%sWRITEONLY\n", ifdef), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s%cWmode[] = \"w\";\n", C50_static, chartyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s\n", elsif), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s%cWmode[] = \"w+\";\n", C50_static, chartyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s\n", endif), Putl(output, 1);
- (void)fprintf(output.fp, "%sRewrite(f, n) (f).init = (f).init ? rewind((f).fp) : (((f).fp = Fopen(n, Wmode)), 1), (f).out = (f).eof = 1\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%sRewritex(f, n) (f).init = (f).init ? (Finish(f)) : (((f).fp = Fopen(n, Wmode)), 1), (f).out = (f).eof = (f).eoln = 1\n", C4_define), Putl(output, 1);
- usefopn = true;
- }
- if (usefopn) {
- (void)fprintf(output.fp, "FILE *Fopen();\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%sMAXFILENAME 256\n", C4_define), Putl(output, 1);
- }
- if (usecase || usejmps) {
- (void)fprintf(output.fp, "/*\n"), Putl(output, 1);
- (void)fprintf(output.fp, "** Definitions for case-statements\n"), Putl(output, 1);
- (void)fprintf(output.fp, "** and for non-local gotos\n"), Putl(output, 1);
- (void)fprintf(output.fp, "*/\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%sLine __LINE__\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%s%cCaseerror();\n", voidtyp, tab1), Putl(output, 1);
- }
- if (usejmps) {
- (void)fprintf(output.fp, "%s<setjmp.h>\n", C24_include), Putl(output, 1);
- (void)fprintf(output.fp, "%sstruct Jb { jmp_buf%cjb; } J[%1d];\n", C50_static, tab1, (maxlevel + 1)), Putl(output, 1);
- }
- if (use(dinteger) || use(dmaxint) || use(dboolean) || use(dfalse) || use(dtrue) || use(deof) || use(deoln) || use(dexp) || use(dln) || use(dsqr) || use(dsin) || use(dcos) || use(dtan) || use(darctan) || use(dsqrt) || use(dreal)) {
- (void)fprintf(output.fp, "/*\n"), Putl(output, 1);
- (void)fprintf(output.fp, "** Definitions for standard types\n"), Putl(output, 1);
- (void)fprintf(output.fp, "*/\n"), Putl(output, 1);
- }
- if (usecomp) {
- (void)fprintf(output.fp, "%s%s strncmp();\n", xtern, inttyp), Putl(output, 1);
- (void)fprintf(output.fp, "%sCmpstr(x, y) strncmp((x), (y), sizeof(x))\n", C4_define), Putl(output, 1);
- }
- if (use(dboolean) || use(dfalse) || use(dtrue) || use(deof) || use(deoln) || usesets) {
- capital(defnams.A[(int)(dboolean)]);
- (void)fprintf(output.fp, "%s%s%c", typdef, chartyp, tab1), Putl(output, 0);
- printid(defnams.A[(int)(dboolean)]->U.V6.lid);
- Putchr(';', output),Putchr('\n', output);
- capital(defnams.A[(int)(dfalse)]);
- (void)fprintf(output.fp, "%s", C4_define), Putl(output, 0);
- printid(defnams.A[(int)(dfalse)]->U.V6.lid);
- (void)fprintf(output.fp, " ("), Putl(output, 0);
- printid(defnams.A[(int)(dboolean)]->U.V6.lid);
- (void)fprintf(output.fp, ")0\n"), Putl(output, 1);
- capital(defnams.A[(int)(dtrue)]);
- (void)fprintf(output.fp, "%s", C4_define), Putl(output, 0);
- printid(defnams.A[(int)(dtrue)]->U.V6.lid);
- (void)fprintf(output.fp, " ("), Putl(output, 0);
- printid(defnams.A[(int)(dboolean)]->U.V6.lid);
- (void)fprintf(output.fp, ")1\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s%c*Bools[];\n", xtern, chartyp, tab1), Putl(output, 1);
- }
- capital(defnams.A[(int)(dinteger)]);
- if (use(dinteger)) {
- (void)fprintf(output.fp, "%s%s%c", typdef, inttyp, tab1), Putl(output, 0);
- printid(defnams.A[(int)(dinteger)]->U.V6.lid);
- Putchr(';', output),Putchr('\n', output);
- }
- if (use(dmaxint))
- (void)fprintf(output.fp, "%smaxint%c%1d\n", C4_define, tab1, maxint), Putl(output, 1);
- capital(defnams.A[(int)(dreal)]);
- if (use(dreal)) {
- (void)fprintf(output.fp, "%s%s%c", typdef, realtyp, tab1), Putl(output, 0);
- printid(defnams.A[(int)(dreal)]->U.V6.lid);
- Putchr(';', output),Putchr('\n', output);
- }
- if (use(dexp))
- (void)fprintf(output.fp, "%s%s exp();\n", xtern, doubletyp), Putl(output, 1);
- if (use(dln))
- (void)fprintf(output.fp, "%s%s log();\n", xtern, doubletyp), Putl(output, 1);
- if (use(dsqr))
- (void)fprintf(output.fp, "%s%s pow();\n", xtern, doubletyp), Putl(output, 1);
- if (use(dsin))
- (void)fprintf(output.fp, "%s%s sin();\n", xtern, doubletyp), Putl(output, 1);
- if (use(dcos))
- (void)fprintf(output.fp, "%s%s cos();\n", xtern, doubletyp), Putl(output, 1);
- if (use(dtan))
- (void)fprintf(output.fp, "%s%s tan();\n", xtern, doubletyp), Putl(output, 1);
- if (use(darctan))
- (void)fprintf(output.fp, "%s%s atan();\n", xtern, doubletyp), Putl(output, 1);
- if (use(dsqrt))
- (void)fprintf(output.fp, "%s%s sqrt();\n", xtern, doubletyp), Putl(output, 1);
- if (use(dabs) && use(dreal))
- (void)fprintf(output.fp, "%s%s fabs();\n", xtern, doubletyp), Putl(output, 1);
- if (use(dhalt))
- (void)fprintf(output.fp, "%s%s abort();\n", xtern, voidtyp), Putl(output, 1);
- if (use(dnew) || usenilp) {
- (void)fprintf(output.fp, "/*\n"), Putl(output, 1);
- (void)fprintf(output.fp, "** Definitions for pointers\n"), Putl(output, 1);
- (void)fprintf(output.fp, "*/\n"), Putl(output, 1);
- }
- if (use(dnew)) {
- (void)fprintf(output.fp, "%sUnionoffs\n", ifndef), Putl(output, 1);
- (void)fprintf(output.fp, "%sUnionoffs(p, m) (((long)(&(p)->m))-((long)(p)))\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%s\n", endif), Putl(output, 1);
- }
- if (usenilp)
- (void)fprintf(output.fp, "%sNIL 0\n", C4_define), Putl(output, 1);
- if (use(dnew))
- (void)fprintf(output.fp, "%s%s *malloc();\n", xtern, chartyp), Putl(output, 1);
- if (use(ddispose))
- (void)fprintf(output.fp, "%s%s free();\n", xtern, voidtyp), Putl(output, 1);
- if (usesets) {
- (void)fprintf(output.fp, "/*\n"), Putl(output, 1);
- (void)fprintf(output.fp, "** Definitions for set-operations\n"), Putl(output, 1);
- (void)fprintf(output.fp, "*/\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%sClaimset() %sCurrset(0, (%s)0)\n", C4_define, voidcast, setptyp), Putl(output, 1);
- (void)fprintf(output.fp, "%sNewset() Currset(1, (%s)0)\n", C4_define, setptyp), Putl(output, 1);
- (void)fprintf(output.fp, "%sSaveset(s) Currset(2, s)\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%ssetbits %1d\n", C4_define, C37_setbits), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s%c%s;\n", typdef, wordtype, tab1, setwtyp), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s *%c%s;\n", typdef, setwtyp, tab1, setptyp), Putl(output, 1);
- printid(defnams.A[(int)(dboolean)]->U.V6.lid);
- (void)fprintf(output.fp, "%cMember(), Le(), Ge(), Eq(), Ne();\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%cUnion(), Diff();\n", setptyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%cInsmem(), Mksubr();\n", setptyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%cCurrset(), Inter();\n", setptyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s%cTmpset;\n", C50_static, setptyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s%cConset[];\n", xtern, setptyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%cSetncpy();\n", voidtyp, tab1), Putl(output, 1);
- }
- (void)fprintf(output.fp, "%s%s *strncpy();\n", xtern, chartyp), Putl(output, 1);
- if (use(dargc) || use(dargv)) {
- (void)fprintf(output.fp, "/*\n"), Putl(output, 1);
- (void)fprintf(output.fp, "** Definitions for argv-operations\n"), Putl(output, 1);
- (void)fprintf(output.fp, "*/\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%s%cargc;\n", inttyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%c**argv;\n", chartyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, " void\n"), Putl(output, 1);
- (void)fprintf(output.fp, "Argvgt(n, cp, l)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%s%cn;\n", inttyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s%cl;\n", registr, inttyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s%c*cp;\n", registr, chartyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%c*sp;\n", tab1, registr, chartyp, tab1), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cfor (sp = argv[n]; l > 0 && *sp; l--)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*cp++ = *sp++;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (l-- > 0)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*cp++ = %s;\n", tab2, spchr), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if ((tp->U.V13.tsubconst != (struct S61 *)NIL) || (tp->U.V13.tsubtype != (struct S61 *)NIL) || (tp->U.V13.tsubvar != (struct S61 *)NIL) || (tp->U.V13.tsubsub != (struct S61 *)NIL)) {
- (void)fprintf(output.fp, "/*\n"), Putl(output, 1);
- (void)fprintf(output.fp, "** Start of program definitions\n"), Putl(output, 1);
- (void)fprintf(output.fp, "*/\n"), Putl(output, 1);
- }
- econst(tp->U.V13.tsubconst);
- etype(tp->U.V13.tsubtype);
- evar(tp->U.V13.tsubvar);
- if (tp->U.V13.tsubsub != (struct S61 *)NIL)
- Putchr('\n', output);
- esubr(tp->U.V13.tsubsub);
- if (tp->U.V13.tsubid != (struct S61 *)NIL) {
- (void)fprintf(output.fp, "/*\n"), Putl(output, 1);
- (void)fprintf(output.fp, "** Start of program code\n"), Putl(output, 1);
- (void)fprintf(output.fp, "*/\n"), Putl(output, 1);
- if (use(dargc) || use(dargv)) {
- (void)fprintf(output.fp, "main(_ac, _av)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%s%c_ac;\n", inttyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%c*_av[];\n", chartyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cargc = _ac;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cargv = _av;\n", tab1), Putl(output, 1);
- } else {
- (void)fprintf(output.fp, "main()\n"), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- }
- increment();
- elabel(tp);
- estmt(tp->U.V13.tsubstmt);
- indent();
- (void)fprintf(output.fp, "exit(0);\n"), Putl(output, 1);
- decrement();
- Putchr('}', output),Putchr('\n', output);
- (void)fprintf(output.fp, "/*\n"), Putl(output, 1);
- (void)fprintf(output.fp, "** End of program code\n"), Putl(output, 1);
- (void)fprintf(output.fp, "*/\n"), Putl(output, 1);
- }
- }
-
- void econset();
-
- integer
- size(tp)
- treeptr tp;
- {
- register integer R175;
- integer r, x;
-
- r = 0;
- while (tp != (struct S61 *)NIL) {
- if (tp->tt == nrange)
- x = cvalof(tp->U.V41.texpr);
- else
- if (tp->tt == nempty)
- x = 0;
- else
- x = cvalof(tp);
- if (x > r)
- r = x;
- tp = tp->tnext;
- }
- R175 = csetwords(r + 1);
- return R175;
- }
-
- void ebits();
-
- void
- eword(s)
- bitset s;
- {
- # define bitshex 4
- integer n;
- register integer i;
- unsigned char x;
-
- n = 0;
- while (n <= C37_setbits)
- n = n + bitshex;
- n = n - bitshex;
- while (n >= 0) {
- x = 0;
- {
- integer B57 = 0,
- B58 = bitshex - 1;
-
- if (B57 <= B58)
- for (i = B57; ; i++) {
- if (Member((unsigned)((n + i)), s.S))
- switch (i) {
- case 0:
- x = x + 1;
- break ;
- case 1:
- x = x + 2;
- break ;
- case 2:
- x = x + 4;
- break ;
- case 3:
- x = x + 8;
- break ;
- default:
- Caseerror(Line);
- }
- if (i == B58) break;
- }
- }
- Putchr(hexdig.A[x], output);
- n = n - bitshex;
- }
- }
-
- void
- ebits(tp)
- treeptr tp;
- {
- typedef struct { bitset A[maxsetrange + 1]; } T74;
- T74 sets;
- integer s;
- register integer m;
- register integer n;
-
- s = size(tp);
- {
- integer B59 = 0,
- B60 = s - 1;
-
- if (B59 <= B60)
- for (n = B59; ; n++) {
- Setncpy(sets.A[n].S, Conset[161], sizeof(sets.A[n].S));
- if (n == B60) break;
- }
- }
- while (tp != (struct S61 *)NIL) {
- if (tp->tt == nrange)
- {
- integer B61 = cvalof(tp->U.V41.texpl),
- B62 = cvalof(tp->U.V41.texpr);
-
- if (B61 <= B62)
- for (m = B61; ; m++) {
- n = m / (C37_setbits + 1);
- Setncpy(sets.A[n].S, Union(sets.A[n].S, Saveset((Tmpset = Newset(), (void)Insmem((unsigned)(m % (C37_setbits + 1)), Tmpset), Tmpset))), sizeof(sets.A[n].S));
- Claimset();
- if (m == B62) break;
- }
- }
- else
- if (tp->tt != nempty) {
- m = cvalof(tp);
- n = m / (C37_setbits + 1);
- Setncpy(sets.A[n].S, Union(sets.A[n].S, Saveset((Tmpset = Newset(), (void)Insmem((unsigned)(m % (C37_setbits + 1)), Tmpset), Tmpset))), sizeof(sets.A[n].S));
- Claimset();
- }
- tp = tp->tnext;
- }
- (void)fprintf(output.fp, "%c%1d", tab1, s), Putl(output, 0);
- {
- integer B63 = 0,
- B64 = s - 1;
-
- if (B63 <= B64)
- for (n = B63; ; n++) {
- Putchr(',', output);
- if (n % 6 == 0)
- Putchr('\n', output);
- (void)fprintf(output.fp, "%c0x", tab1), Putl(output, 0);
- eword(sets.A[n]);
- if (n == B64) break;
- }
- }
- Putchr('\n', output);
- }
-
- void
- econset(tp, len)
- treeptr tp;
- integer len;
- {
- register integer i;
-
- i = 0;
- while (tp != (struct S61 *)NIL) {
- (void)fprintf(output.fp, "%s%s%cQ%1d[] = {\n", C50_static, setwtyp, tab1, i), Putl(output, 1);
- ebits(tp->U.V42.texps);
- (void)fprintf(output.fp, "};\n"), Putl(output, 1);
- i = i + 1;
- tp = tp->tnext;
- }
- (void)fprintf(output.fp, "%s%s%c*Conset[] = {\n", C50_static, setwtyp, tab1), Putl(output, 1);
- {
- integer B65 = len - 1,
- B66 = 1;
-
- if (B65 >= B66)
- for (i = B65; ; i--) {
- (void)fprintf(output.fp, "%cQ%1d,", tab1, i), Putl(output, 0);
- if (i % 6 == 5)
- Putchr('\n', output);
- if (i == B66) break;
- }
- }
- (void)fprintf(output.fp, "%cQ0\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "};\n"), Putl(output, 1);
- }
-
- void
- emit()
- {
- static char usigned[] = "unsigned ";
- boolean conflag, setused, dropset, donearr;
- integer doarrow, indnt;
- boolean *F195;
- boolean *F197;
- boolean *F199;
- boolean *F201;
- integer *F203;
- integer *F205;
-
- F205 = G204_indnt;
- G204_indnt = &indnt;
- F203 = G202_doarrow;
- G202_doarrow = &doarrow;
- F201 = G200_donearr;
- G200_donearr = &donearr;
- F199 = G198_dropset;
- G198_dropset = &dropset;
- F197 = G196_setused;
- G196_setused = &setused;
- F195 = G194_conflag;
- G194_conflag = &conflag;
- (*G204_indnt) = 0;
- varno = 0;
- (*G194_conflag) = false;
- (*G196_setused) = false;
- (*G198_dropset) = false;
- (*G202_doarrow) = 0;
- eprogram(top);
- if (usebool)
- (void)fprintf(output.fp, "%s%c*Bools[] = { \"false\", \"true\" };\n", chartyp, tab1), Putl(output, 1);
- if (usescan) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s\n", C50_static, voidtyp), Putl(output, 1);
- (void)fprintf(output.fp, "Scanck(n)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%s%cn;\n", inttyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%cif (n != 1) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%sfprintf(stderr, \"Bad input\\n\");\n", tab2, voidcast), Putl(output, 1);
- (void)fprintf(output.fp, "%sexit(1);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usegetl) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s\n", C50_static, voidtyp), Putl(output, 1);
- (void)fprintf(output.fp, "Getl(f)\n"), Putl(output, 1);
- (void)fprintf(output.fp, " text%c*f;\n", tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%cwhile (f->eoln == 0)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sGetx(*f);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%cGetx(*f);\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usefopn) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%sFILE *\n", C50_static), Putl(output, 1);
- (void)fprintf(output.fp, "Fopen(n, m)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%s%c*n, *m;\n", chartyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%cFILE%s*f;\n", tab1, tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%c*s;\n", tab1, registr, chartyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cch = %cA%c;\n", tab1, C50_static, chartyp, tab1, quote, quote), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%ctmp[MAXFILENAME];\n", tab1, C50_static, chartyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cunlink();\n", tab1, xtern, inttyp, tab1), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cif (n == NULL)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%ssprintf(tmp, %sch++);\n", tab2, tmpfilename), Putl(output, 1);
- (void)fprintf(output.fp, "%celse {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sstrncpy(tmp, n, sizeof(tmp));\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sfor (s = &tmp[sizeof(tmp)-1]; *s == %s || *s == %s; )\n", tab2, spchr, nulchr), Putl(output, 1);
- (void)fprintf(output.fp, "%s*s-- = %s;\n", tab3, nulchr), Putl(output, 1);
- (void)fprintf(output.fp, "%sif (tmp[sizeof(tmp)-1]) {\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%s%sfprintf(stderr, \"Too long filename %c%%s%c\\n\", n);\n", tab3, voidcast, quote, quote), Putl(output, 1);
- (void)fprintf(output.fp, "%sexit(1);\n", tab3), Putl(output, 1);
- (void)fprintf(output.fp, "%s}\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cs = tmp;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cif ((f = fopen(s, m)) == NULL) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%sfprintf(stderr, \"Cannot open: %%s\\n\", s);\n", tab2, voidcast), Putl(output, 1);
- (void)fprintf(output.fp, "%sexit(1);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cif (n == NULL)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sunlink(tmp);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (f);\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s%crewind();\n", xtern, inttyp, tab1), Putl(output, 1);
- }
- if (setcnt > 0)
- econset(setlst, setcnt);
- if (useunion) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s\n", C50_static, setptyp), Putl(output, 1);
- (void)fprintf(output.fp, "Union(p1, p2)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cp1, p2;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%si, j, k;\n", tab1, registr, inttyp, tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%ssp = Newset(),\n", tab1, registr, setptyp, tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sp3 = sp;\n", tab4), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cj = *p1;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c*p3 = j;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cif (j > *p2)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sj = *p2;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%celse\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*p3 = *p2;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%ck = *p1 - *p2;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cp1++, p2++, p3++;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cfor (i = 0; i < j; i++)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*p3++ = (*p1++ | *p2++);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (k > 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*p3++ = *p1++;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sk--;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (k < 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*p3++ = *p2++;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sk++;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (Saveset(sp));\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usediff) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s\n", C50_static, setptyp), Putl(output, 1);
- (void)fprintf(output.fp, "Diff(p1, p2)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cp1, p2;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%si, j, k;\n", tab1, registr, inttyp, tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%ssp = Newset(),\n", tab1, registr, setptyp, tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sp3 = sp;\n", tab4), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cj = *p1;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c*p3 = j;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cif (j > *p2)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sj = *p2;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%ck = *p1 - *p2;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cp1++, p2++, p3++;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cfor (i = 0; i < j; i++)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*p3++ = (*p1++ & ~ (*p2++));\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (k > 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*p3++ = *p1++;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sk--;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (Saveset(sp));\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (useintr) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s\n", C50_static, setptyp), Putl(output, 1);
- (void)fprintf(output.fp, "Inter(p1, p2)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cp1, p2;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%si, j, k;\n", tab1, registr, inttyp, tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%ssp = Newset(),\n", tab1, registr, setptyp, tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sp3 = sp;\n", tab4), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cif ((j = *p1) > *p2)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sj = *p2;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c*p3 = j;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cp1++, p2++, p3++;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cfor (i = 0; i < j; i++)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*p3++ = (*p1++ & *p2++);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (Saveset(sp));\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usememb) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s", C50_static), Putl(output, 0);
- printid(defnams.A[(int)(dboolean)]->U.V6.lid);
- Putchr('\n', output);
- (void)fprintf(output.fp, "Member(m, sp)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%s%cm;\n", tab1, registr, usigned, inttyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%csp;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%s%ci = m / (setbits+1) + 1;\n", tab1, registr, usigned, inttyp, tab1), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cif ((i <= *sp) && (sp[i] & (1 << (m %% (setbits+1)))))\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (", tab2), Putl(output, 0);
- printid(defnams.A[(int)(dtrue)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (", tab1), Putl(output, 0);
- printid(defnams.A[(int)(dfalse)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (useseq || usesne) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s", C50_static), Putl(output, 0);
- printid(defnams.A[(int)(dboolean)]->U.V6.lid);
- Putchr('\n', output);
- (void)fprintf(output.fp, "Eq(p1, p2)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cp1, p2;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%ci, j;\n", tab1, registr, inttyp, tab1), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%ci = *p1++;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cj = *p2++;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (i != 0 && j != 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sif (*p1++ != *p2++)\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (", tab3), Putl(output, 0);
- printid(defnams.A[(int)(dfalse)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%si--, j--;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (i != 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sif (*p1++ != 0)\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (", tab3), Putl(output, 0);
- printid(defnams.A[(int)(dfalse)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%si--;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (j != 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sif (*p2++ != 0)\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (", tab3), Putl(output, 0);
- printid(defnams.A[(int)(dfalse)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%sj--;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (", tab1), Putl(output, 0);
- printid(defnams.A[(int)(dtrue)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usesne) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s", C50_static), Putl(output, 0);
- printid(defnams.A[(int)(dboolean)]->U.V6.lid);
- Putchr('\n', output);
- (void)fprintf(output.fp, "Ne(p1, p2)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cp1, p2;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%creturn (!Eq(p1, p2));", tab1), Putl(output, 0);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usesle) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s", C50_static), Putl(output, 0);
- printid(defnams.A[(int)(dboolean)]->U.V6.lid);
- Putchr('\n', output);
- (void)fprintf(output.fp, "Le(p1, p2)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cp1, p2;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%ci, j;\n", tab1, registr, inttyp, tab1), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%ci = *p1++;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cj = *p2++;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (i != 0 && j != 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sif ((*p1++ & ~ *p2++) != 0)\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (", tab3), Putl(output, 0);
- printid(defnams.A[(int)(dfalse)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%si--, j--;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (i != 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sif (*p1++ != 0)\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (", tab3), Putl(output, 0);
- printid(defnams.A[(int)(dfalse)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%si--;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (", tab1), Putl(output, 0);
- printid(defnams.A[(int)(dtrue)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usesge) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s", C50_static), Putl(output, 0);
- printid(defnams.A[(int)(dboolean)]->U.V6.lid);
- Putchr('\n', output);
- (void)fprintf(output.fp, "Ge(p1, p2)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cp1, p2;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%ci, j;\n", tab1, registr, inttyp, tab1), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%ci = *p1++;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cj = *p2++;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (i != 0 && j != 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sif ((*p2++ & ~ *p1++) != 0)\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (false);\n", tab3), Putl(output, 1);
- (void)fprintf(output.fp, "%si--, j--;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (j != 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sif (*p2++ != 0)\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (", tab3), Putl(output, 0);
- printid(defnams.A[(int)(dfalse)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%sj--;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (", tab1), Putl(output, 0);
- printid(defnams.A[(int)(dtrue)]->U.V6.lid);
- (void)fprintf(output.fp, ");\n"), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usemksub) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s\n", C50_static, setptyp), Putl(output, 1);
- (void)fprintf(output.fp, "Mksubr(lo, hi, sp)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%s%clo, hi;\n", tab1, registr, usigned, inttyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%csp;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%ci, k;\n", tab1, registr, inttyp, tab1), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cif (hi < lo)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (sp);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%ci = hi / (setbits+1) + 1;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cfor (k = *sp + 1; k <= i; k++)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%ssp[k] = 0;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%cif (*sp < i)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*sp = i;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%cfor (k = lo; k <= hi; k++)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%ssp[k / (setbits+1) + 1] |= (1 << (k %% (setbits+1)));\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (sp);\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (useins) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s\n", C50_static, setptyp), Putl(output, 1);
- (void)fprintf(output.fp, "Insmem(m, sp)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%s%cm;\n", tab1, registr, usigned, inttyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%csp;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%ci,\n", tab1, registr, inttyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s%cj = m / (setbits+1) + 1;\n", tab3, tab1), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cif (*sp < j)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sfor (i = *sp + 1, *sp = j; i <= *sp; i++)\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%ssp[i] = 0;\n", tab3), Putl(output, 1);
- (void)fprintf(output.fp, "%csp[j] |= (1 << (m %% (setbits+1)));\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (sp);\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usesets) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%sSETSPACE\n", ifndef), Putl(output, 1);
- (void)fprintf(output.fp, "%sSETSPACE 256\n", C4_define), Putl(output, 1);
- (void)fprintf(output.fp, "%s\n", endif), Putl(output, 1);
- (void)fprintf(output.fp, "%s%s\n", C50_static, setptyp), Putl(output, 1);
- (void)fprintf(output.fp, "Currset(n,sp)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%cn;\n", tab1, inttyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%csp;\n", tab1, setptyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%cSpace[SETSPACE];\n", tab1, C50_static, setwtyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cTop = Space;\n", tab1, C50_static, setptyp, tab1), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cswitch (n) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c case 0:\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sTop = Space;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (0);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c case 1:\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sif (&Space[SETSPACE] - Top <= %1d) {\n", tab2, maxsetrange), Putl(output, 1);
- (void)fprintf(output.fp, "%s%sfprintf(stderr, \"Set-space exhausted\\n\");\n", tab3, voidcast), Putl(output, 1);
- (void)fprintf(output.fp, "%sexit(1);\n", tab3), Putl(output, 1);
- (void)fprintf(output.fp, "%s}\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%s*Top = 0;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (Top);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c case 2:\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sif (Top <= &sp[*sp])\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%sTop = &sp[*sp + 1];\n", tab3), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (sp);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c/* NOTREACHED */\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usescpy) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s\n", C50_static, voidtyp), Putl(output, 1);
- (void)fprintf(output.fp, "Setncpy(S1, S2, N)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%cS1, S2;\n", tab1, registr, setptyp, tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%s%s%cN;\n", tab1, registr, usigned, inttyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s%s%cm;\n", tab1, registr, usigned, inttyp, tab1), Putl(output, 1);
- Putchr('\n', output);
- (void)fprintf(output.fp, "%cN /= sizeof(%s);\n", tab1, setwtyp), Putl(output, 1);
- (void)fprintf(output.fp, "%c*S1++ = --N;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cm = *S2++;\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (m != 0 && N != 0) {\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*S1++ = *S2++;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%s--N;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%s--m;\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%c}\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%cwhile (N-- != 0)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%s*S1++ = 0;\n", tab2), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usecase) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s\n", C50_static, voidtyp), Putl(output, 1);
- (void)fprintf(output.fp, "Caseerror(n)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%cn;\n", tab1, inttyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%sfprintf(stderr, \"Missing case limb: line %%d\\n\", n);\n", tab1, voidcast), Putl(output, 1);
- (void)fprintf(output.fp, "%cexit(1);\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (usemax) {
- Putchr('\n', output);
- (void)fprintf(output.fp, "%s%s\n", C50_static, inttyp), Putl(output, 1);
- (void)fprintf(output.fp, "Max(m, n)\n"), Putl(output, 1);
- (void)fprintf(output.fp, "%c%s%cm, n;\n", tab1, inttyp, tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%cif (m > n)\n", tab1), Putl(output, 1);
- (void)fprintf(output.fp, "%sreturn (m);\n", tab2), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn (n);\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (use(dtrunc)) {
- (void)fprintf(output.fp, "%s%s\n", C50_static, inttyp), Putl(output, 1);
- (void)fprintf(output.fp, "Trunc(f)\n"), Putl(output, 1);
- printid(defnams.A[(int)(dreal)]->U.V6.lid);
- (void)fprintf(output.fp, "%cf;\n", tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%creturn f;\n", tab1), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- if (use(dround)) {
- (void)fprintf(output.fp, "%s%s\n", C50_static, inttyp), Putl(output, 1);
- (void)fprintf(output.fp, "Round(f)\n"), Putl(output, 1);
- printid(defnams.A[(int)(dreal)]->U.V6.lid);
- (void)fprintf(output.fp, "%cf;\n", tab1), Putl(output, 1);
- Putchr('{', output),Putchr('\n', output);
- (void)fprintf(output.fp, "%c%s%s floor();\n", tab1, xtern, doubletyp), Putl(output, 1);
- (void)fprintf(output.fp, "%creturn floor(%s(0.5+f));\n", tab1, dblcast), Putl(output, 1);
- Putchr('}', output),Putchr('\n', output);
- }
- G194_conflag = F195;
- G196_setused = F197;
- G198_dropset = F199;
- G200_donearr = F201;
- G202_doarrow = F203;
- G204_indnt = F205;
- }
-
- void initialize();
-
- void
- defname(cn, str)
- cnames cn;
- keyword str;
- {
- toknbuf w;
- register toknidx i;
-
- { register int _j, _i = 1 - 1;
- for (_j = 0; _j < 10; )
- w.A[_i++] = str.A[_j++];
- }
- {
- toknidx B67 = 1,
- B68 = keywordlen;
-
- if (B67 <= B68)
- for (i = B67; ; i++) {
- if (w.A[i - 1] == space) {
- w.A[i - 1] = null;
- goto L999;
- }
- if (i == B68) break;
- }
- }
- w.A[keywordlen + 1 - 1] = null;
- L999:
- ctable.A[(int)(cn)] = saveid(&w);
- }
-
- void
- defid(nt, did, str)
- treetyp nt;
- predefs did;
- keyword str;
- {
- toknbuf w;
- register toknidx i;
- treeptr tp, tq, tv;
-
- {
- toknidx B69 = 1,
- B70 = keywordlen;
-
- if (B69 <= B70)
- for (i = B69; ; i++) {
- if (str.A[i - 1] == space) {
- w.A[i - 1] = null;
- goto L999;
- } else
- w.A[i - 1] = str.A[i - 1];
- if (i == B70) break;
- }
- }
- w.A[keywordlen + 1 - 1] = null;
- L999:
- tp = newid(saveid(&w));
- defnams.A[(int)(did)] = tp->U.V43.tsym;
- if (Member((unsigned)(nt), Conset[162])) {
- tv = mknode(npredef);
- tv->U.V12.tdef = did;
- tv->U.V12.tobtyp = tnone;
- } else
- tv = (struct S61 *)NIL;
- switch (nt) {
- case nscalar:
- tv = mknode(nscalar);
- tv->U.V17.tscalid = (struct S61 *)NIL;
- tq = mknode(ntype);
- tq->U.V14.tbind = tv;
- tq->U.V14.tidl = tp;
- tp = tq;
- break ;
- case nconst: case ntype: case nfield: case nvar:
- tq = mknode(nt);
- tq->U.V14.tbind = tv;
- tq->U.V14.tidl = tp;
- tq->U.V14.tattr = anone;
- tp = tq;
- break ;
- case nfunc: case nproc:
- tq = mknode(nt);
- tq->U.V13.tsubid = tp;
- tq->U.V13.tsubstmt = tv;
- tq->U.V13.tfuntyp = (struct S61 *)NIL;
- tq->U.V13.tsubpar = (struct S61 *)NIL;
- tq->U.V13.tsublab = (struct S61 *)NIL;
- tq->U.V13.tsubconst = (struct S61 *)NIL;
- tq->U.V13.tsubtype = (struct S61 *)NIL;
- tq->U.V13.tsubvar = (struct S61 *)NIL;
- tq->U.V13.tsubsub = (struct S61 *)NIL;
- tq->U.V13.tscope = (struct S60 *)NIL;
- tq->U.V13.tstat = 0;
- tp = tq;
- break ;
- case nid:
- break ;
- default:
- Caseerror(Line);
- }
- deftab.A[(int)(did)] = tp;
- }
-
- void
- defkey(s, w)
- symtyp s;
- keyword w;
- {
- register unsigned char i;
-
- {
- unsigned char B71 = 1,
- B72 = keywordlen;
-
- if (B71 <= B72)
- for (i = B71; ; i++) {
- if (w.A[i - 1] == space)
- w.A[i - 1] = null;
- if (i == B72) break;
- }
- }
- {
- register struct S206 *W73 = &keytab.A[(unsigned)(s)];
-
- W73->wrd = w;
- W73->sym = s;
- }
- }
-
- void
- fixinit(i)
- strindx i;
- {
- toknbuf t;
-
- gettokn(i, &t);
- t.A[1 - 1] = 'i';
- puttokn(i, &t);
- }
-
-