home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / ptoc / part07 / ptc.c.5
Encoding:
Text File  |  1987-07-27  |  38.7 KB  |  1,501 lines

  1.  void
  2. eexpr(tp)
  3.     treeptr    tp;
  4. {
  5.     treeptr    tq;
  6.     boolean    flag;
  7.  
  8.     (*G200_donearr) = false;
  9.     if (Member((unsigned)(tp->tt), Conset[144])) {
  10.         tq = typeof(tp->U.V41.texpl);
  11.         if ((Member((unsigned)(tq->tt), Conset[145])) || (tq == typnods.A[(int)(tset)])) {
  12.             switch (tp->tt) {
  13.               case nplus:
  14.                 (*G196_setused) = true;
  15.                 useunion = true;
  16.                 (void)fprintf(output.fp, "Union"), Putl(output, 0);
  17.                 break ;
  18.               case nminus:
  19.                 (*G196_setused) = true;
  20.                 usediff = true;
  21.                 (void)fprintf(output.fp, "Diff"), Putl(output, 0);
  22.                 break ;
  23.               case nmul:
  24.                 (*G196_setused) = true;
  25.                 useintr = true;
  26.                 (void)fprintf(output.fp, "Inter"), Putl(output, 0);
  27.                 break ;
  28.               case neq:
  29.                 useseq = true;
  30.                 (void)fprintf(output.fp, "Eq"), Putl(output, 0);
  31.                 break ;
  32.               case nne:
  33.                 usesne = true;
  34.                 (void)fprintf(output.fp, "Ne"), Putl(output, 0);
  35.                 break ;
  36.               case nge:
  37.                 usesge = true;
  38.                 (void)fprintf(output.fp, "Ge"), Putl(output, 0);
  39.                 break ;
  40.               case nle:
  41.                 usesle = true;
  42.                 (void)fprintf(output.fp, "Le"), Putl(output, 0);
  43.                 break ;
  44.               default:
  45.                 Caseerror(Line);
  46.             }
  47.             if (Member((unsigned)(tp->tt), Conset[146]))
  48.                 (*G198_dropset) = false;
  49.             Putchr('(', output);
  50.             eexpr(tp->U.V41.texpl);
  51.             if (tq->tt == nsetof)
  52.                 (void)fprintf(output.fp, ".S"), Putl(output, 0);
  53.             (void)fprintf(output.fp, ", "), Putl(output, 0);
  54.             eexpr(tp->U.V41.texpr);
  55.             tq = typeof(tp->U.V41.texpr);
  56.             if (tq->tt == nsetof)
  57.                 (void)fprintf(output.fp, ".S"), Putl(output, 0);
  58.             Putchr(')', output);
  59.             goto L999;
  60.         }
  61.     }
  62.     if (Member((unsigned)(tp->tt), Conset[147])) {
  63.         tq = typeof(tp->U.V41.texpl);
  64.         if (tq->tt == nconfarr)
  65.             fatal(ecmpconf);
  66.         if ((Member((unsigned)(tq->tt), Conset[148])) || (tq == typnods.A[(int)(tstring)])) {
  67.             (void)fprintf(output.fp, "Cmpstr("), Putl(output, 0);
  68.             eexpr(tp->U.V41.texpl);
  69.             if (tq->tt == narray)
  70.                 (void)fprintf(output.fp, ".A"), Putl(output, 0);
  71.             (void)fprintf(output.fp, ", "), Putl(output, 0);
  72.             tq = typeof(tp->U.V41.texpr);
  73.             if (tq->tt == nconfarr)
  74.                 fatal(ecmpconf);
  75.             eexpr(tp->U.V41.texpr);
  76.             if (tq->tt == narray)
  77.                 (void)fprintf(output.fp, ".A"), Putl(output, 0);
  78.             Putchr(')', output);
  79.             switch (tp->tt) {
  80.               case neq:
  81.                 (void)fprintf(output.fp, " == "), Putl(output, 0);
  82.                 break ;
  83.               case nne:
  84.                 (void)fprintf(output.fp, " != "), Putl(output, 0);
  85.                 break ;
  86.               case ngt:
  87.                 (void)fprintf(output.fp, " > "), Putl(output, 0);
  88.                 break ;
  89.               case nlt:
  90.                 (void)fprintf(output.fp, " < "), Putl(output, 0);
  91.                 break ;
  92.               case nge:
  93.                 (void)fprintf(output.fp, " >= "), Putl(output, 0);
  94.                 break ;
  95.               case nle:
  96.                 (void)fprintf(output.fp, " <= "), Putl(output, 0);
  97.                 break ;
  98.               default:
  99.                 Caseerror(Line);
  100.             }
  101.             Putchr('0', output);
  102.             goto L999;
  103.         }
  104.     }
  105.     switch (tp->tt) {
  106.       case neq:  case nne:  case nlt:  case nle:
  107.       case ngt:  case nge:  case nor:  case nand:
  108.       case nplus:  case nminus:  case nmul:  case ndiv:
  109.       case nmod:  case nquot:
  110.         flag = (boolean)(cprio.A[(int)(tp->tt) - (int)(nassign)] > cprio.A[(int)(tp->U.V41.texpl->tt) - (int)(nassign)]);
  111.         if ((Member((unsigned)(tp->tt), Conset[149])) && !arithexpr(tp->U.V41.texpl)) {
  112.             (void)fprintf(output.fp, "(int)"), Putl(output, 0);
  113.             flag = true;
  114.         }
  115.         if (flag)
  116.             Putchr('(', output);
  117.         eexpr(tp->U.V41.texpl);
  118.         if (flag)
  119.             Putchr(')', output);
  120.         switch (tp->tt) {
  121.           case neq:
  122.             (void)fprintf(output.fp, " == "), Putl(output, 0);
  123.             break ;
  124.           case nne:
  125.             (void)fprintf(output.fp, " != "), Putl(output, 0);
  126.             break ;
  127.           case nlt:
  128.             (void)fprintf(output.fp, " < "), Putl(output, 0);
  129.             break ;
  130.           case nle:
  131.             (void)fprintf(output.fp, " <= "), Putl(output, 0);
  132.             break ;
  133.           case ngt:
  134.             (void)fprintf(output.fp, " > "), Putl(output, 0);
  135.             break ;
  136.           case nge:
  137.             (void)fprintf(output.fp, " >= "), Putl(output, 0);
  138.             break ;
  139.           case nor:
  140.             (void)fprintf(output.fp, " || "), Putl(output, 0);
  141.             break ;
  142.           case nand:
  143.             (void)fprintf(output.fp, " && "), Putl(output, 0);
  144.             break ;
  145.           case nplus:
  146.             (void)fprintf(output.fp, " + "), Putl(output, 0);
  147.             break ;
  148.           case nminus:
  149.             (void)fprintf(output.fp, " - "), Putl(output, 0);
  150.             break ;
  151.           case nmul:
  152.             (void)fprintf(output.fp, " * "), Putl(output, 0);
  153.             break ;
  154.           case ndiv:
  155.             (void)fprintf(output.fp, " / "), Putl(output, 0);
  156.             break ;
  157.           case nmod:
  158.             (void)fprintf(output.fp, " %% "), Putl(output, 0);
  159.             break ;
  160.           case nquot:
  161.             (void)fprintf(output.fp, " / (("), Putl(output, 0);
  162.             printid(defnams.A[(int)(dreal)]->U.V6.lid);
  163.             Putchr(')', output);
  164.             break ;
  165.           default:
  166.             Caseerror(Line);
  167.         }
  168.         flag = (boolean)(cprio.A[(int)(tp->tt) - (int)(nassign)] > cprio.A[(int)(tp->U.V41.texpr->tt) - (int)(nassign)]);
  169.         if ((Member((unsigned)(tp->tt), Conset[150])) && !arithexpr(tp->U.V41.texpr)) {
  170.             (void)fprintf(output.fp, "(int)"), Putl(output, 0);
  171.             flag = true;
  172.         }
  173.         if (flag)
  174.             Putchr('(', output);
  175.         eexpr(tp->U.V41.texpr);
  176.         if (flag)
  177.             Putchr(')', output);
  178.         if (tp->tt == nquot)
  179.             Putchr(')', output);
  180.         break ;
  181.       case nuplus:  case numinus:  case nnot:
  182.         switch (tp->tt) {
  183.           case numinus:
  184.             Putchr('-', output);
  185.             break ;
  186.           case nnot:
  187.             Putchr('!', output);
  188.             break ;
  189.           case nuplus:
  190.             break ;
  191.           default:
  192.             Caseerror(Line);
  193.         }
  194.         flag = (boolean)(cprio.A[(int)(tp->tt) - (int)(nassign)] >= cprio.A[(int)(tp->U.V42.texps->tt) - (int)(nassign)]);
  195.         if (flag)
  196.             Putchr('(', output);
  197.         eexpr(tp->U.V42.texps);
  198.         if (flag)
  199.             Putchr(')', output);
  200.         break ;
  201.       case nin:
  202.         usememb = true;
  203.         (void)fprintf(output.fp, "Member((unsigned)("), Putl(output, 0);
  204.         eexpr(tp->U.V41.texpl);
  205.         (void)fprintf(output.fp, "), "), Putl(output, 0);
  206.         (*G198_dropset) = true;
  207.         eexpr(tp->U.V41.texpr);
  208.         (*G198_dropset) = false;
  209.         tq = typeof(tp->U.V41.texpr);
  210.         if (tq->tt == nsetof)
  211.             (void)fprintf(output.fp, ".S"), Putl(output, 0);
  212.         Putchr(')', output);
  213.         break ;
  214.       case nassign:
  215.         tq = typeof(tp->U.V27.trhs);
  216.         if (tq == typnods.A[(int)(tstring)]) {
  217.             (void)fprintf(output.fp, "%sstrncpy(", voidcast), Putl(output, 0);
  218.             eexpr(tp->U.V27.tlhs);
  219.             (void)fprintf(output.fp, ".A, "), Putl(output, 0);
  220.             eexpr(tp->U.V27.trhs);
  221.             (void)fprintf(output.fp, ", sizeof("), Putl(output, 0);
  222.             eexpr(tp->U.V27.tlhs);
  223.             (void)fprintf(output.fp, ".A))"), Putl(output, 0);
  224.         } else
  225.             if (tq == typnods.A[(int)(tboolean)]) {
  226.                 eexpr(tp->U.V27.tlhs);
  227.                 (void)fprintf(output.fp, " = "), Putl(output, 0);
  228.                 tq = tp->U.V27.trhs;
  229.                 while (tq->tt == nuplus)
  230.                     tq = tq->U.V42.texps;
  231.                 if (Member((unsigned)(tq->tt), Conset[151])) {
  232.                     Putchr('(', output);
  233.                     printid(defnams.A[(int)(dboolean)]->U.V6.lid);
  234.                     (void)fprintf(output.fp, ")("), Putl(output, 0);
  235.                     eexpr(tq);
  236.                     Putchr(')', output);
  237.                 } else
  238.                     eexpr(tq);
  239.             } else
  240.                 if (tq == typnods.A[(int)(tnil)]) {
  241.                     eexpr(tp->U.V27.tlhs);
  242.                     (void)fprintf(output.fp, " = ("), Putl(output, 0);
  243.                     etypedef(typeof(tp->U.V27.tlhs));
  244.                     (void)fprintf(output.fp, ")NIL"), Putl(output, 0);
  245.                 } else {
  246.                     tq = typeof(tp->U.V27.tlhs);
  247.                     if (tq->tt == nsetof) {
  248.                         usescpy = true;
  249.                         (void)fprintf(output.fp, "Setncpy("), Putl(output, 0);
  250.                         eselect(tp->U.V27.tlhs);
  251.                         (void)fprintf(output.fp, "S, "), Putl(output, 0);
  252.                         (*G198_dropset) = true;
  253.                         tq = typeof(tp->U.V27.trhs);
  254.                         if (tq == typnods.A[(int)(tset)])
  255.                             eexpr(tp->U.V27.trhs);
  256.                         else {
  257.                             eselect(tp->U.V27.trhs);
  258.                             Putchr('S', output);
  259.                         }
  260.                         (*G198_dropset) = false;
  261.                         (void)fprintf(output.fp, ", sizeof("), Putl(output, 0);
  262.                         eselect(tp->U.V27.tlhs);
  263.                         (void)fprintf(output.fp, "S))"), Putl(output, 0);
  264.                     } else {
  265.                         eexpr(tp->U.V27.tlhs);
  266.                         (void)fprintf(output.fp, " = "), Putl(output, 0);
  267.                         eexpr(tp->U.V27.trhs);
  268.                     }
  269.                 }
  270.         break ;
  271.       case ncall:
  272.         tq = idup(tp->U.V30.tcall);
  273.         if ((Member((unsigned)(tq->tt), Conset[152])) && (tq->U.V13.tsubstmt != (struct S61 *)NIL))
  274.             if (tq->U.V13.tsubstmt->tt == npredef)
  275.                 epredef(tq, tp);
  276.             else
  277.                 ecall(tp);
  278.         else
  279.             ecall(tp);
  280.         break ;
  281.       case nselect:
  282.         eselect(tp->U.V40.trecord);
  283.         eexpr(tp->U.V40.tfield);
  284.         break ;
  285.       case nindex:
  286.         eselect(tp->U.V39.tvariable);
  287.         (void)fprintf(output.fp, "A["), Putl(output, 0);
  288.         tq = tp->U.V39.toffset;
  289.         if (arithexpr(tq))
  290.             eexpr(tq);
  291.         else {
  292.             (void)fprintf(output.fp, "(int)("), Putl(output, 0);
  293.             eexpr(tq);
  294.             Putchr(')', output);
  295.         }
  296.         tq = typeof(tp->U.V39.tvariable);
  297.         if (tq->tt == narray)
  298.             if (clower(tq->U.V23.taindx) != 0) {
  299.                 (void)fprintf(output.fp, " - "), Putl(output, 0);
  300.                 tq = typeof(tq->U.V23.taindx);
  301.                 if (tq->tt == nsubrange)
  302.                     if (arithexpr(tq->U.V19.tlo))
  303.                         eexpr(tq->U.V19.tlo);
  304.                     else {
  305.                         (void)fprintf(output.fp, "(int)("), Putl(output, 0);
  306.                         eexpr(tq->U.V19.tlo);
  307.                         Putchr(')', output);
  308.                     }
  309.                 else
  310.                     fatal(etree);
  311.             }
  312.         Putchr(']', output);
  313.         break ;
  314.       case nderef:
  315.         tq = typeof(tp->U.V42.texps);
  316.         if ((tq->tt == nfileof) || ((tq->tt == npredef) && (tq->U.V12.tdef == dtext))) {
  317.             eexpr(tp->U.V42.texps);
  318.             (void)fprintf(output.fp, ".buf"), Putl(output, 0);
  319.         } else
  320.             if ((*G202_doarrow) == 0) {
  321.                 Putchr('*', output);
  322.                 eexpr(tp->U.V42.texps);
  323.             } else {
  324.                 eexpr(tp->U.V42.texps);
  325.                 (void)fprintf(output.fp, "->"), Putl(output, 0);
  326.                 (*G200_donearr) = true;
  327.             }
  328.         break ;
  329.       case nid:
  330.         tq = idup(tp);
  331.         if (tq->tt == nvarpar) {
  332.             if (((*G202_doarrow) == 0) || (tq->U.V14.tattr == areference)) {
  333.                 (void)fprintf(output.fp, "(*"), Putl(output, 0);
  334.                 printid(tp->U.V43.tsym->U.V6.lid);
  335.                 Putchr(')', output);
  336.             } else {
  337.                 printid(tp->U.V43.tsym->U.V6.lid);
  338.                 (void)fprintf(output.fp, "->"), Putl(output, 0);
  339.                 (*G200_donearr) = true;
  340.             }
  341.         } else
  342.             if ((tq->tt == nconst) && (*G194_conflag))
  343.                 (void)fprintf(output.fp, "%1d", cvalof(tp)), Putl(output, 0);
  344.             else
  345.                 if (Member((unsigned)(tq->tt), Conset[153])) {
  346.                     (void)fprintf(output.fp, "(*"), Putl(output, 0);
  347.                     printid(tp->U.V43.tsym->U.V6.lid);
  348.                     Putchr(')', output);
  349.                 } else
  350.                     printid(tp->U.V43.tsym->U.V6.lid);
  351.         break ;
  352.       case nchar:
  353.         printchr(tp->U.V43.tsym->U.V11.lchar);
  354.         break ;
  355.       case ninteger:
  356.         (void)fprintf(output.fp, "%1d", tp->U.V43.tsym->U.V10.linum), Putl(output, 0);
  357.         break ;
  358.       case nreal:
  359.         printtok(tp->U.V43.tsym->U.V8.lfloat);
  360.         break ;
  361.       case nstring:
  362.         printstr(tp->U.V43.tsym->U.V7.lstr);
  363.         break ;
  364.       case nset:
  365.         if (constset(tp->U.V42.texps)) {
  366.             (void)fprintf(output.fp, "Conset[%1d]", setcnt), Putl(output, 0);
  367.             setcnt = setcnt + 1;
  368.             tq = mknode(nset);
  369.             tq->tnext = setlst;
  370.             setlst = tq;
  371.             tq->U.V42.texps = tp->U.V42.texps;
  372.         } else {
  373.             increment();
  374.             flag = (*G198_dropset);
  375.             if ((*G198_dropset))
  376.                 (*G198_dropset) = false;
  377.             else
  378.                 (void)fprintf(output.fp, "Saveset("), Putl(output, 0);
  379.             (void)fprintf(output.fp, "(Tmpset = Newset(), "), Putl(output, 0);
  380.             tq = tp->U.V42.texps;
  381.             while (tq != (struct S61 *)NIL) {
  382.                 switch (tq->tt) {
  383.                   case nrange:
  384.                     usemksub = true;
  385.                     (void)fprintf(output.fp, "%sMksubr(", voidcast), Putl(output, 0);
  386.                     (void)fprintf(output.fp, "(unsigned)("), Putl(output, 0);
  387.                     eexpr(tq->U.V41.texpl);
  388.                     (void)fprintf(output.fp, "), "), Putl(output, 0);
  389.                     (void)fprintf(output.fp, "(unsigned)("), Putl(output, 0);
  390.                     eexpr(tq->U.V41.texpr);
  391.                     (void)fprintf(output.fp, "), Tmpset)"), Putl(output, 0);
  392.                     break ;
  393.                   case nin:  case neq:  case nne:  case nlt:
  394.                   case nle:  case ngt:  case nge:  case nor:
  395.                   case nand:  case nmul:  case ndiv:  case nmod:
  396.                   case nquot:  case nplus:  case nminus:  case nnot:
  397.                   case numinus:  case nuplus:  case nindex:  case nselect:
  398.                   case nderef:  case ncall:  case ninteger:  case nchar:
  399.                   case nid:
  400.                     useins = true;
  401.                     (void)fprintf(output.fp, "%sInsmem(", voidcast), Putl(output, 0);
  402.                     (void)fprintf(output.fp, "(unsigned)("), Putl(output, 0);
  403.                     eexpr(tq);
  404.                     (void)fprintf(output.fp, "), Tmpset)"), Putl(output, 0);
  405.                     break ;
  406.                   default:
  407.                     Caseerror(Line);
  408.                 }
  409.                 tq = tq->tnext;
  410.                 if (tq != (struct S61 *)NIL) {
  411.                     Putchr(',', output),Putchr('\n', output);
  412.                     indent();
  413.                 }
  414.             }
  415.             (void)fprintf(output.fp, ", Tmpset)"), Putl(output, 0);
  416.             if (!flag) {
  417.                 Putchr(')', output);
  418.                 (*G196_setused) = true;
  419.             }
  420.             decrement();
  421.         }
  422.         break ;
  423.       case nnil:
  424.         tq = tp;
  425.         do {
  426.             tq = tq->tup;
  427.         } while (!(Member((unsigned)(tq->tt), Conset[154])));
  428.         if (Member((unsigned)(tq->tt), Conset[155])) {
  429.             if (typeof(tq->U.V41.texpl) == typnods.A[(int)(tnil)])
  430.                 tq = typeof(tq->U.V41.texpr);
  431.             else
  432.                 tq = typeof(tq->U.V41.texpl);
  433.             if (tq->tt == nptr) {
  434.                 Putchr('(', output);
  435.                 etypedef(tq);
  436.                 Putchr(')', output);
  437.             }
  438.         }
  439.         (void)fprintf(output.fp, "NIL"), Putl(output, 0);
  440.         break ;
  441.       default:
  442.         Caseerror(Line);
  443.     }
  444. L999:
  445.     ;
  446. }
  447.  
  448.  void
  449. econst(tp)
  450.     treeptr    tp;
  451. {
  452.     symptr    sp;
  453.  
  454.     while (tp != (struct S61 *)NIL) {
  455.         sp = tp->U.V14.tidl->U.V43.tsym;
  456.         if (sp->U.V6.lid->inref > 1)
  457.             sp->U.V6.lid = mkrename('X', sp->U.V6.lid);
  458.         if (tp->U.V14.tbind->tt == nstring) {
  459.             indent();
  460.             (void)fprintf(output.fp, "%s%s%c", C50_static, chartyp, tab1), Putl(output, 0);
  461.             printid(sp->U.V6.lid);
  462.             (void)fprintf(output.fp, "[]    = "), Putl(output, 0);
  463.             eexpr(tp->U.V14.tbind);
  464.             Putchr(';', output),Putchr('\n', output);
  465.         } else {
  466.             (void)fprintf(output.fp, "%s", C4_define), Putl(output, 0);
  467.             printid(sp->U.V6.lid);
  468.             Putchr(space, output);
  469.             eexpr(tp->U.V14.tbind);
  470.             Putchr('\n', output);
  471.         }
  472.         tp = tp->tnext;
  473.     }
  474. }
  475.  
  476. void etypedef();
  477.  
  478. void etdef();
  479.  
  480.  void
  481. etrange(tp)
  482.     treeptr    tp;
  483. {
  484.     integer    lo, hi;
  485.     register unsigned char    i;
  486.  
  487.     lo = clower(tp);
  488.     hi = cupper(tp);
  489.     {
  490.         unsigned char    B51 = 1,
  491.             B52 = nmachdefs;
  492.  
  493.         if (B51 <= B52)
  494.             for (i = B51; ; i++) {
  495.                 {
  496.                     register struct S193 *W53 = &machdefs.A[i - 1];
  497.  
  498.                     if ((lo >= W53->lolim) && (hi <= W53->hilim)) {
  499.                         printtok(W53->typstr);
  500.                         goto L999;
  501.                     }
  502.                 }
  503.                 if (i == B52) break;
  504.             }
  505.     }
  506.     fatal(erange);
  507. L999:
  508.     ;
  509. }
  510.  
  511.  void
  512. printsuf(ip)
  513.     idptr    ip;
  514. {
  515.     toknbuf    w;
  516.     toknidx    i, j;
  517.  
  518.     gettokn(ip->istr, &w);
  519.     i = 1;
  520.     j = i;
  521.     while (w.A[i - 1] != null) {
  522.         if (w.A[i - 1] == '.')
  523.             j = i;
  524.         i = i + 1;
  525.     }
  526.     if (w.A[j - 1] == '.')
  527.         j = j + 1;
  528.     while (w.A[j - 1] != null) {
  529.         Putchr(w.A[j - 1], output);
  530.         j = j + 1;
  531.     }
  532. }
  533.  
  534.  void
  535. etdef(uid, tp)
  536.     idptr    uid;
  537.     treeptr    tp;
  538. {
  539.     integer    i;
  540.     treeptr    tq;
  541.  
  542.     switch (tp->tt) {
  543.       case nid:
  544.         printid(tp->U.V43.tsym->U.V6.lid);
  545.         break ;
  546.       case nptr:
  547.         tq = typeof(tp->U.V16.tptrid);
  548.         if (tq->tt == nrecord) {
  549.             (void)fprintf(output.fp, "struct "), Putl(output, 0);
  550.             printid(tq->U.V21.tuid);
  551.         } else
  552.             printid(tp->U.V16.tptrid->U.V43.tsym->U.V6.lid);
  553.         (void)fprintf(output.fp, " *"), Putl(output, 0);
  554.         break ;
  555.       case nscalar:
  556.         (void)fprintf(output.fp, "enum { "), Putl(output, 0);
  557.         increment();
  558.         tp = tp->U.V17.tscalid;
  559.         if (tp->U.V43.tsym->U.V6.lid->inref > 1)
  560.             tp->U.V43.tsym->U.V6.lid = mkrename('E', tp->U.V43.tsym->U.V6.lid);
  561.         printid(tp->U.V43.tsym->U.V6.lid);
  562.         i = 1;
  563.         while (tp->tnext != (struct S61 *)NIL) {
  564.             if (i >= 4) {
  565.                 Putchr(',', output),Putchr('\n', output);
  566.                 indent();
  567.                 i = 1;
  568.             } else {
  569.                 (void)fprintf(output.fp, ", "), Putl(output, 0);
  570.                 i = i + 1;
  571.             }
  572.             tp = tp->tnext;
  573.             if (tp->U.V43.tsym->U.V6.lid->inref > 1)
  574.                 tp->U.V43.tsym->U.V6.lid = mkrename('E', tp->U.V43.tsym->U.V6.lid);
  575.             printid(tp->U.V43.tsym->U.V6.lid);
  576.         }
  577.         decrement();
  578.         (void)fprintf(output.fp, " } "), Putl(output, 0);
  579.         break ;
  580.       case nsubrange:
  581.         tq = typeof(tp->U.V19.tlo);
  582.         if (tq == typnods.A[(int)(tinteger)])
  583.             etrange(tp);
  584.         else {
  585.             if (tq->tup->tt == ntype)
  586.                 tq = tq->tup->U.V14.tidl;
  587.             etdef((idptr)NIL, tq);
  588.         }
  589.         break ;
  590.       case nfield:
  591.         etdef((idptr)NIL, tp->U.V14.tbind);
  592.         Putchr(tab1, output);
  593.         tp = tp->U.V14.tidl;
  594.         if (uid != (struct S59 *)NIL)
  595.             tp->U.V43.tsym->U.V6.lid = mkconc('.', uid, tp->U.V43.tsym->U.V6.lid);
  596.         printsuf(tp->U.V43.tsym->U.V6.lid);
  597.         i = 1;
  598.         while (tp->tnext != (struct S61 *)NIL) {
  599.             if (i >= 4) {
  600.                 Putchr(',', output),Putchr('\n', output);
  601.                 indent();
  602.                 Putchr(tab1, output);
  603.                 i = 1;
  604.             } else {
  605.                 (void)fprintf(output.fp, ", "), Putl(output, 0);
  606.                 i = i + 1;
  607.             }
  608.             tp = tp->tnext;
  609.             if (uid != (struct S59 *)NIL)
  610.                 tp->U.V43.tsym->U.V6.lid = mkconc('.', uid, tp->U.V43.tsym->U.V6.lid);
  611.             printsuf(tp->U.V43.tsym->U.V6.lid);
  612.         }
  613.         Putchr(';', output),Putchr('\n', output);
  614.         break ;
  615.       case nrecord:
  616.         (void)fprintf(output.fp, "struct "), Putl(output, 0);
  617.         if (tp->U.V21.tuid == (struct S59 *)NIL)
  618.             tp->U.V21.tuid = uid;
  619.         else
  620.             if (uid == (struct S59 *)NIL)
  621.                 printid(tp->U.V21.tuid);
  622.         (void)fprintf(output.fp, " {\n"), Putl(output, 1);
  623.         increment();
  624.         if ((tp->U.V21.tflist == (struct S61 *)NIL) && (tp->U.V21.tvlist == (struct S61 *)NIL)) {
  625.             indent();
  626.             (void)fprintf(output.fp, "%s%cdummy;\n", inttyp, tab1), Putl(output, 1);
  627.         }
  628.         tq = tp->U.V21.tflist;
  629.         while (tq != (struct S61 *)NIL) {
  630.             indent();
  631.             etdef(uid, tq);
  632.             tq = tq->tnext;
  633.         }
  634.         if (tp->U.V21.tvlist != (struct S61 *)NIL) {
  635.             indent();
  636.             (void)fprintf(output.fp, "union {\n"), Putl(output, 1);
  637.             increment();
  638.             tq = tp->U.V21.tvlist;
  639.             while (tq != (struct S61 *)NIL) {
  640.                 if ((tq->U.V20.tvrnt->U.V21.tflist != (struct S61 *)NIL) || (tq->U.V20.tvrnt->U.V21.tvlist != (struct S61 *)NIL)) {
  641.                     indent();
  642.                     if (uid == (struct S59 *)NIL)
  643.                         etdef(mkvrnt(), tq->U.V20.tvrnt);
  644.                     else
  645.                         etdef(mkconc('.', uid, mkvrnt()), tq->U.V20.tvrnt);
  646.                     Putchr(';', output),Putchr('\n', output);
  647.                 }
  648.                 tq = tq->tnext;
  649.             }
  650.             decrement();
  651.             indent();
  652.             (void)fprintf(output.fp, "} U;\n"), Putl(output, 1);
  653.         }
  654.         decrement();
  655.         indent();
  656.         if (tp->tup->tt == nvariant) {
  657.             (void)fprintf(output.fp, "} "), Putl(output, 0);
  658.             printsuf(tp->U.V21.tuid);
  659.         } else
  660.             Putchr('}', output);
  661.         break ;
  662.       case nconfarr:
  663.         (void)fprintf(output.fp, "struct "), Putl(output, 0);
  664.         printid(tp->U.V22.tcuid);
  665.         (void)fprintf(output.fp, " { "), Putl(output, 0);
  666.         etdef((idptr)NIL, tp->U.V22.tcelem);
  667.         (void)fprintf(output.fp, "%cA[]; }", tab1), Putl(output, 0);
  668.         break ;
  669.       case narray:
  670.         (void)fprintf(output.fp, "struct { "), Putl(output, 0);
  671.         etdef((idptr)NIL, tp->U.V23.taelem);
  672.         (void)fprintf(output.fp, "%cA[", tab1), Putl(output, 0);
  673.         tq = typeof(tp->U.V23.taindx);
  674.         if (tq->tt == nsubrange) {
  675.             if (arithexpr(tq->U.V19.thi)) {
  676.                 eexpr(tq->U.V19.thi);
  677.                 if (cvalof(tq->U.V19.tlo) != 0) {
  678.                     (void)fprintf(output.fp, " - "), Putl(output, 0);
  679.                     eexpr(tq->U.V19.tlo);
  680.                 }
  681.             } else {
  682.                 (void)fprintf(output.fp, "(int)("), Putl(output, 0);
  683.                 eexpr(tq->U.V19.thi);
  684.                 if (cvalof(tq->U.V19.tlo) != 0) {
  685.                     (void)fprintf(output.fp, ") - (int)("), Putl(output, 0);
  686.                     eexpr(tq->U.V19.tlo);
  687.                 }
  688.                 Putchr(')', output);
  689.             }
  690.             (void)fprintf(output.fp, " + 1"), Putl(output, 0);
  691.         } else
  692.             (void)fprintf(output.fp, "%1d", crange(tp->U.V23.taindx)), Putl(output, 0);
  693.         (void)fprintf(output.fp, "]; }"), Putl(output, 0);
  694.         break ;
  695.       case nfileof:
  696.         (void)fprintf(output.fp, "struct {\n"), Putl(output, 1);
  697.         indent();
  698.         (void)fprintf(output.fp, "%cFILE%c*fp;\n", tab1, tab1), Putl(output, 1);
  699.         indent();
  700.         (void)fprintf(output.fp, "%c%s%ceoln:1,\n", tab1, filebits, tab1), Putl(output, 1);
  701.         indent();
  702.         (void)fprintf(output.fp, "%seof:1,\n", tab3), Putl(output, 1);
  703.         indent();
  704.         (void)fprintf(output.fp, "%sout:1,\n", tab3), Putl(output, 1);
  705.         indent();
  706.         (void)fprintf(output.fp, "%sinit:1,\n", tab3), Putl(output, 1);
  707.         indent();
  708.         (void)fprintf(output.fp, "%s:%1d;\n", tab3, filefill), Putl(output, 1);
  709.         indent();
  710.         Putchr(tab1, output);
  711.         etdef((idptr)NIL, tp->U.V18.tof);
  712.         (void)fprintf(output.fp, "%cbuf;\n", tab1), Putl(output, 1);
  713.         indent();
  714.         (void)fprintf(output.fp, "} "), Putl(output, 0);
  715.         break ;
  716.       case nsetof:
  717.         (void)fprintf(output.fp, "struct { %s%cS[%1d]; }", setwtyp, tab1, csetsize(tp)), Putl(output, 0);
  718.         break ;
  719.       case npredef:
  720.         switch (tp->U.V12.tobtyp) {
  721.           case tboolean:
  722.             printid(defnams.A[(int)(dboolean)]->U.V6.lid);
  723.             break ;
  724.           case tchar:
  725.             (void)fprintf(output.fp, "%s", chartyp), Putl(output, 0);
  726.             break ;
  727.           case tinteger:
  728.             printid(defnams.A[(int)(dinteger)]->U.V6.lid);
  729.             break ;
  730.           case treal:
  731.             printid(defnams.A[(int)(dreal)]->U.V6.lid);
  732.             break ;
  733.           case tstring:
  734.             (void)fprintf(output.fp, "%s *", chartyp), Putl(output, 0);
  735.             break ;
  736.           case ttext:
  737.             (void)fprintf(output.fp, "text"), Putl(output, 0);
  738.             break ;
  739.           case tnil:  case tset:  case terror:
  740.             fatal(etree);
  741.             break ;
  742.           case tnone:
  743.             (void)fprintf(output.fp, "%s", voidtyp), Putl(output, 0);
  744.             break ;
  745.           default:
  746.             Caseerror(Line);
  747.         }
  748.         break ;
  749.       case nempty:
  750.         (void)fprintf(output.fp, "%s", voidtyp), Putl(output, 0);
  751.         break ;
  752.       default:
  753.         Caseerror(Line);
  754.     }
  755. }
  756.  
  757.  void
  758. etypedef(tp)
  759.     treeptr    tp;
  760. {
  761.     etdef((idptr)NIL, tp);
  762. }
  763.  
  764.  void
  765. etype(tp)
  766.     treeptr    tp;
  767. {
  768.     symptr    sp;
  769.  
  770.     while (tp != (struct S61 *)NIL) {
  771.         sp = tp->U.V14.tidl->U.V43.tsym;
  772.         if (sp->U.V6.lid->inref > 1)
  773.             sp->U.V6.lid = mkrename('Y', sp->U.V6.lid);
  774.         indent();
  775.         (void)fprintf(output.fp, "%s", typdef), Putl(output, 0);
  776.         etypedef(tp->U.V14.tbind);
  777.         Putchr(tab1, output);
  778.         printid(sp->U.V6.lid);
  779.         Putchr(';', output),Putchr('\n', output);
  780.         tp = tp->tnext;
  781.     }
  782. }
  783.  
  784.  void
  785. evar(tp)
  786.     treeptr    tp;
  787. {
  788.     treeptr    tq;
  789.     integer    i;
  790.  
  791.     while (tp != (struct S61 *)NIL) {
  792.         indent();
  793.         switch (tp->tt) {
  794.           case nvar:  case nvalpar:  case nvarpar:
  795.             if (tp->U.V14.tattr == aregister)
  796.                 (void)fprintf(output.fp, "%s", registr), Putl(output, 0);
  797.             etypedef(tp->U.V14.tbind);
  798.             break ;
  799.           case nparproc:  case nparfunc:
  800.             if (tp->tt == nparproc)
  801.                 (void)fprintf(output.fp, "%s", voidtyp), Putl(output, 0);
  802.             else
  803.                 etypedef(tp->U.V15.tpartyp);
  804.             tq = tp->U.V15.tparid;
  805.             (void)fprintf(output.fp, "%c(*", tab1), Putl(output, 0);
  806.             printid(tq->U.V43.tsym->U.V6.lid);
  807.             (void)fprintf(output.fp, ")()"), Putl(output, 0);
  808.             goto L555;
  809.             break ;
  810.           default:
  811.             Caseerror(Line);
  812.         }
  813.         Putchr(tab1, output);
  814.         tq = tp->U.V14.tidl;
  815.         i = 1;
  816.         do {
  817.             if (tp->tt == nvarpar)
  818.                 Putchr('*', output);
  819.             printid(tq->U.V43.tsym->U.V6.lid);
  820.             tq = tq->tnext;
  821.             if (tq != (struct S61 *)NIL) {
  822.                 if (i >= 6) {
  823.                     i = 1;
  824.                     Putchr(',', output),Putchr('\n', output);
  825.                     indent();
  826.                     Putchr(tab1, output);
  827.                 } else {
  828.                     i = i + 1;
  829.                     (void)fprintf(output.fp, ", "), Putl(output, 0);
  830.                 }
  831.             }
  832.         } while (!(tq == (struct S61 *)NIL));
  833.     L555:
  834.         Putchr(';', output),Putchr('\n', output);
  835.         if (tp->tt == nvarpar)
  836.             if (tp->U.V14.tbind->tt == nconfarr) {
  837.                 indent();
  838.                 etypedef(tp->U.V14.tbind->U.V22.tindtyp);
  839.                 Putchr(tab1, output);
  840.                 tq = tp->U.V14.tbind->U.V22.tcindx->U.V19.thi;
  841.                 printid(tq->U.V43.tsym->U.V6.lid);
  842.                 Putchr(';', output),Putchr('\n', output);
  843.             }
  844.         tp = tp->tnext;
  845.     }
  846. }
  847.  
  848.  
  849. void estmt();
  850.  
  851.  void
  852. ewithtype(tp)
  853.     treeptr    tp;
  854. {
  855.     treeptr    tq;
  856.  
  857.     tq = typeof(tp);
  858.     (void)fprintf(output.fp, "struct "), Putl(output, 0);
  859.     printid(tq->U.V21.tuid);
  860. }
  861.  
  862.  void
  863. echoise(tp)
  864.     treeptr    tp;
  865. {
  866.     treeptr    tq;
  867.     integer    i;
  868.  
  869.     while (tp != (struct S61 *)NIL) {
  870.         tq = tp->U.V36.tchocon;
  871.         i = 0;
  872.         indent();
  873.         while (tq != (struct S61 *)NIL) {
  874.             (void)fprintf(output.fp, "  case "), Putl(output, 0);
  875.             (*G194_conflag) = true;
  876.             eexpr(tq);
  877.             (*G194_conflag) = false;
  878.             Putchr(':', output);
  879.             i = i + 1;
  880.             tq = tq->tnext;
  881.             if ((tq == (struct S61 *)NIL) || (i % 4 == 0)) {
  882.                 Putchr('\n', output);
  883.                 if (tq != (struct S61 *)NIL)
  884.                     indent();
  885.                 i = 0;
  886.             }
  887.         }
  888.         increment();
  889.         if (tp->U.V36.tchostmt->tt == nbegin)
  890.             estmt(tp->U.V36.tchostmt->U.V24.tbegin);
  891.         else
  892.             estmt(tp->U.V36.tchostmt);
  893.         indent();
  894.         (void)fprintf(output.fp, "break ;\n"), Putl(output, 1);
  895.         decrement();
  896.         tp = tp->tnext;
  897.         if (tp != (struct S61 *)NIL)
  898.             if (tp->U.V36.tchocon == (struct S61 *)NIL)
  899.                 tp = (struct S61 *)NIL;
  900.     }
  901. }
  902.  
  903.  void
  904. cenv(ip, dp)
  905.     idptr    ip;
  906.     declptr    dp;
  907. {
  908.     treeptr    tp;
  909.     symptr    sp;
  910.     idptr    np;
  911.     register hashtyp    h;
  912.  
  913.     {
  914.         register struct S60 *W54 = &*dp;
  915.  
  916.         {
  917.             hashtyp    B55 = 0,
  918.                 B56 = hashmax - 1;
  919.  
  920.             if (B55 <= B56)
  921.                 for (h = B55; ; h++) {
  922.                     sp = W54->ddecl.A[h];
  923.                     while (sp != (struct S62 *)NIL) {
  924.                         if (sp->lt == lfield) {
  925.                             np = sp->U.V6.lid;
  926.                             tp = sp->lsymdecl->tup->tup;
  927.                             if ((tp->tup->tt == nvariant) && (tp->U.V21.tuid != (struct S59 *)NIL))
  928.                                 np = mkconc('.', tp->U.V21.tuid, np);
  929.                             np = mkconc('>', ip, np);
  930.                             sp->U.V6.lid = np;
  931.                         }
  932.                         sp = sp->lnext;
  933.                     }
  934.                     if (h == B56) break;
  935.                 }
  936.         }
  937.     }
  938. }
  939.  
  940.  void
  941. eglobid(tp)
  942.     treeptr    tp;
  943. {
  944.     toknidx    j;
  945.     toknbuf    w;
  946.  
  947.     gettokn(tp->U.V43.tsym->U.V6.lid->istr, &w);
  948.     j = 1;
  949.     if (w.A[1 - 1] == '*')
  950.         j = 2;
  951.     while (w.A[j - 1] != null) {
  952.         Putchr(w.A[j - 1], output);
  953.         j = j + 1;
  954.     }
  955. }
  956.  
  957.  void
  958. estmt(tp)
  959.     treeptr    tp;
  960. {
  961.     treeptr    tq;
  962.     idptr    locid1, locid2;
  963.     boolean    stusd;
  964.     char    opc1, opc2;
  965.  
  966.     while (tp != (struct S61 *)NIL) {
  967.         switch (tp->tt) {
  968.           case nbegin:
  969.             if (Member((unsigned)(tp->tup->tt), Conset[156]))
  970.                 indent();
  971.             Putchr('{', output),Putchr('\n', output);
  972.             increment();
  973.             estmt(tp->U.V24.tbegin);
  974.             decrement();
  975.             indent();
  976.             Putchr('}', output);
  977.             if (tp->tup->tt != nif)
  978.                 Putchr('\n', output);
  979.             break ;
  980.           case nrepeat:
  981.             indent();
  982.             (void)fprintf(output.fp, "do {\n"), Putl(output, 1);
  983.             increment();
  984.             estmt(tp->U.V33.treptstmt);
  985.             decrement();
  986.             indent();
  987.             (void)fprintf(output.fp, "} while (!("), Putl(output, 0);
  988.             eexpr(tp->U.V33.treptxp);
  989.             (void)fprintf(output.fp, "));\n"), Putl(output, 1);
  990.             break ;
  991.           case nwhile:
  992.             indent();
  993.             (void)fprintf(output.fp, "while ("), Putl(output, 0);
  994.             increment();
  995.             eexpr(tp->U.V32.twhixp);
  996.             stusd = (*G196_setused);
  997.             if (tp->U.V32.twhistmt->tt == nbegin) {
  998.                 decrement();
  999.                 (void)fprintf(output.fp, ") "), Putl(output, 0);
  1000.                 estmt(tp->U.V32.twhistmt);
  1001.             } else {
  1002.                 Putchr(')', output),Putchr('\n', output);
  1003.                 estmt(tp->U.V32.twhistmt);
  1004.                 decrement();
  1005.             }
  1006.             (*G196_setused) = (boolean)(stusd || (*G196_setused));
  1007.             break ;
  1008.           case nfor:
  1009.             indent();
  1010.             if (tp->U.V34.tincr) {
  1011.                 opc1 = '+';
  1012.                 opc2 = '<';
  1013.             } else {
  1014.                 opc1 = '-';
  1015.                 opc2 = '>';
  1016.             }
  1017.             if (!lazyfor) {
  1018.                 locid1 = mkvariable('B');
  1019.                 locid2 = mkvariable('B');
  1020.                 Putchr('{', output),Putchr('\n', output);
  1021.                 increment();
  1022.                 indent();
  1023.                 tq = idup(tp->U.V34.tforid);
  1024.                 etypedef(tq->U.V14.tbind);
  1025.                 tq = typeof(tq->U.V14.tbind);
  1026.                 Putchr(tab1, output);
  1027.                 printid(locid1);
  1028.                 (void)fprintf(output.fp, " = "), Putl(output, 0);
  1029.                 eexpr(tp->U.V34.tfrom);
  1030.                 Putchr(',', output),Putchr('\n', output);
  1031.                 indent();
  1032.                 Putchr(tab1, output);
  1033.                 printid(locid2);
  1034.                 (void)fprintf(output.fp, " = "), Putl(output, 0);
  1035.                 eexpr(tp->U.V34.tto);
  1036.                 Putchr(';', output),Putchr('\n', output);
  1037.                 Putchr('\n', output);
  1038.                 indent();
  1039.                 (void)fprintf(output.fp, "if ("), Putl(output, 0);
  1040.                 if (tq->tt == nscalar) {
  1041.                     (void)fprintf(output.fp, "(int)("), Putl(output, 0);
  1042.                     printid(locid1);
  1043.                     Putchr(')', output);
  1044.                 } else
  1045.                     printid(locid1);
  1046.                 (void)fprintf(output.fp, " %c= ", opc2), Putl(output, 0);
  1047.                 if (tq->tt == nscalar) {
  1048.                     (void)fprintf(output.fp, "(int)("), Putl(output, 0);
  1049.                     printid(locid2);
  1050.                     Putchr(')', output);
  1051.                 } else
  1052.                     printid(locid2);
  1053.                 Putchr(')', output),Putchr('\n', output);
  1054.                 increment();
  1055.                 indent();
  1056.                 tp->U.V34.tfrom = newid(locid1);
  1057.                 tp->U.V34.tfrom->tup = tp;
  1058.             }
  1059.             (void)fprintf(output.fp, "for ("), Putl(output, 0);
  1060.             increment();
  1061.             eexpr(tp->U.V34.tforid);
  1062.             tq = typeof(tp->U.V34.tforid);
  1063.             (void)fprintf(output.fp, " = "), Putl(output, 0);
  1064.             eexpr(tp->U.V34.tfrom);
  1065.             (void)fprintf(output.fp, "; "), Putl(output, 0);
  1066.             if (lazyfor) {
  1067.                 if (tq->tt == nscalar) {
  1068.                     (void)fprintf(output.fp, "(int)("), Putl(output, 0);
  1069.                     eexpr(tp->U.V34.tforid);
  1070.                     Putchr(')', output);
  1071.                 } else
  1072.                     eexpr(tp->U.V34.tforid);
  1073.                 (void)fprintf(output.fp, " %c= ", opc2), Putl(output, 0);
  1074.                 if (tq->tt == nscalar) {
  1075.                     (void)fprintf(output.fp, "(int)("), Putl(output, 0);
  1076.                     eexpr(tp->U.V34.tto);
  1077.                     Putchr(')', output);
  1078.                 } else
  1079.                     eexpr(tp->U.V34.tto);
  1080.             }
  1081.             (void)fprintf(output.fp, "; "), Putl(output, 0);
  1082.             eexpr(tp->U.V34.tforid);
  1083.             if (tq->tt == nscalar) {
  1084.                 (void)fprintf(output.fp, " = ("), Putl(output, 0);
  1085.                 eexpr(tq->tup->U.V14.tidl);
  1086.                 (void)fprintf(output.fp, ")((int)("), Putl(output, 0);
  1087.                 eexpr(tp->U.V34.tforid);
  1088.                 (void)fprintf(output.fp, ")%c1)", opc1), Putl(output, 0);
  1089.             } else
  1090.                 (void)fprintf(output.fp, "%c%c", opc1, opc1), Putl(output, 0);
  1091.             if (!lazyfor) {
  1092.                 if (tp->U.V34.tforstmt->tt != nbegin) {
  1093.                     tq = mknode(nbegin);
  1094.                     tq->U.V24.tbegin = tp->U.V34.tforstmt;
  1095.                     tq->U.V24.tbegin->tup = tq;
  1096.                     tp->U.V34.tforstmt = tq;
  1097.                     tq->tup = tp;
  1098.                 }
  1099.                 tq = tp->U.V34.tforstmt->U.V24.tbegin;
  1100.                 while (tq->tnext != (struct S61 *)NIL)
  1101.                     tq = tq->tnext;
  1102.                 tq->tnext = mknode(nbreak);
  1103.                 tq = tq->tnext;
  1104.                 tq->tup = tp->U.V34.tforstmt;
  1105.                 tq->U.V29.tbrkid = tp->U.V34.tforid;
  1106.                 tq->U.V29.tbrkxp = newid(locid2);
  1107.                 tq->U.V29.tbrkxp->tup = tq;
  1108.             }
  1109.             if (tp->U.V34.tforstmt->tt == nbegin) {
  1110.                 decrement();
  1111.                 (void)fprintf(output.fp, ") "), Putl(output, 0);
  1112.                 estmt(tp->U.V34.tforstmt);
  1113.             } else {
  1114.                 Putchr(')', output),Putchr('\n', output);
  1115.                 estmt(tp->U.V34.tforstmt);
  1116.                 decrement();
  1117.             }
  1118.             if (!lazyfor) {
  1119.                 decrement();
  1120.                 decrement();
  1121.                 indent();
  1122.                 Putchr('}', output),Putchr('\n', output);
  1123.             }
  1124.             break ;
  1125.           case nif:
  1126.             indent();
  1127.             (void)fprintf(output.fp, "if ("), Putl(output, 0);
  1128.             increment();
  1129.             eexpr(tp->U.V31.tifxp);
  1130.             stusd = (*G196_setused);
  1131.             (*G196_setused) = false;
  1132.             if (tp->U.V31.tthen->tt == nbegin) {
  1133.                 decrement();
  1134.                 (void)fprintf(output.fp, ") "), Putl(output, 0);
  1135.                 estmt(tp->U.V31.tthen);
  1136.                 if (tp->U.V31.telse != (struct S61 *)NIL)
  1137.                     Putchr(space, output);
  1138.                 else
  1139.                     Putchr('\n', output);
  1140.             } else {
  1141.                 Putchr(')', output),Putchr('\n', output);
  1142.                 estmt(tp->U.V31.tthen);
  1143.                 decrement();
  1144.                 if (tp->U.V31.telse != (struct S61 *)NIL)
  1145.                     indent();
  1146.             }
  1147.             if (tp->U.V31.telse != (struct S61 *)NIL) {
  1148.                 (void)fprintf(output.fp, "else"), Putl(output, 0);
  1149.                 if (tp->U.V31.telse->tt == nbegin) {
  1150.                     Putchr(space, output);
  1151.                     estmt(tp->U.V31.telse);
  1152.                     Putchr('\n', output);
  1153.                 } else {
  1154.                     increment();
  1155.                     Putchr('\n', output);
  1156.                     estmt(tp->U.V31.telse);
  1157.                     decrement();
  1158.                 }
  1159.             }
  1160.             (*G196_setused) = (boolean)(stusd || (*G196_setused));
  1161.             break ;
  1162.           case ncase:
  1163.             indent();
  1164.             (void)fprintf(output.fp, "switch ("), Putl(output, 0);
  1165.             increment();
  1166.             eexpr(tp->U.V35.tcasxp);
  1167.             (void)fprintf(output.fp, ") {\n"), Putl(output, 1);
  1168.             decrement();
  1169.             echoise(tp->U.V35.tcaslst);
  1170.             indent();
  1171.             (void)fprintf(output.fp, "  default:\n"), Putl(output, 1);
  1172.             increment();
  1173.             if (tp->U.V35.tcasother == (struct S61 *)NIL) {
  1174.                 indent();
  1175.                 (void)fprintf(output.fp, "Caseerror(Line);\n"), Putl(output, 1);
  1176.             } else
  1177.                 estmt(tp->U.V35.tcasother);
  1178.             decrement();
  1179.             indent();
  1180.             Putchr('}', output),Putchr('\n', output);
  1181.             break ;
  1182.           case nwith:
  1183.             indent();
  1184.             Putchr('{', output),Putchr('\n', output);
  1185.             increment();
  1186.             tq = tp->U.V37.twithvar;
  1187.             while (tq != (struct S61 *)NIL) {
  1188.                 indent();
  1189.                 (void)fprintf(output.fp, "%s", registr), Putl(output, 0);
  1190.                 ewithtype(tq->U.V38.texpw);
  1191.                 (void)fprintf(output.fp, " *"), Putl(output, 0);
  1192.                 locid1 = mkvariable('W');
  1193.                 printid(locid1);
  1194.                 (void)fprintf(output.fp, " = "), Putl(output, 0);
  1195.                 eaddr(tq->U.V38.texpw);
  1196.                 Putchr(';', output),Putchr('\n', output);
  1197.                 cenv(locid1, tq->U.V38.tenv);
  1198.                 tq = tq->tnext;
  1199.             }
  1200.             Putchr('\n', output);
  1201.             if (tp->U.V37.twithstmt->tt == nbegin)
  1202.                 estmt(tp->U.V37.twithstmt->U.V24.tbegin);
  1203.             else
  1204.                 estmt(tp->U.V37.twithstmt);
  1205.             decrement();
  1206.             indent();
  1207.             Putchr('}', output),Putchr('\n', output);
  1208.             break ;
  1209.           case ngoto:
  1210.             indent();
  1211.             if (islocal(tp->U.V26.tlabel))
  1212.                 (void)fprintf(output.fp, "goto L%1d;\n", tp->U.V26.tlabel->U.V43.tsym->U.V9.lno), Putl(output, 1);
  1213.             else {
  1214.                 tq = idup(tp->U.V26.tlabel);
  1215.                 (void)fprintf(output.fp, "longjmp(J[%1d].jb, %1d);\n", tq->U.V13.tstat, tp->U.V26.tlabel->U.V43.tsym->U.V9.lno), Putl(output, 1);
  1216.             }
  1217.             break ;
  1218.           case nlabstmt:
  1219.             decrement();
  1220.             indent();
  1221.             (void)fprintf(output.fp, "L%1d:\n", tp->U.V25.tlabno->U.V43.tsym->U.V9.lno), Putl(output, 1);
  1222.             increment();
  1223.             estmt(tp->U.V25.tstmt);
  1224.             break ;
  1225.           case nassign:
  1226.             indent();
  1227.             eexpr(tp);
  1228.             Putchr(';', output),Putchr('\n', output);
  1229.             break ;
  1230.           case ncall:
  1231.             indent();
  1232.             tq = idup(tp->U.V30.tcall);
  1233.             if ((Member((unsigned)(tq->tt), Conset[157])) && (tq->U.V13.tsubstmt != (struct S61 *)NIL))
  1234.                 if (tq->U.V13.tsubstmt->tt == npredef)
  1235.                     epredef(tq, tp);
  1236.                 else {
  1237.                     ecall(tp);
  1238.                     Putchr(';', output),Putchr('\n', output);
  1239.                 }
  1240.             else {
  1241.                 ecall(tp);
  1242.                 Putchr(';', output),Putchr('\n', output);
  1243.             }
  1244.             break ;
  1245.           case npush:
  1246.             indent();
  1247.             eglobid(tp->U.V28.ttmp);
  1248.             (void)fprintf(output.fp, " = "), Putl(output, 0);
  1249.             eglobid(tp->U.V28.tglob);
  1250.             Putchr(';', output),Putchr('\n', output);
  1251.             indent();
  1252.             eglobid(tp->U.V28.tglob);
  1253.             (void)fprintf(output.fp, " = "), Putl(output, 0);
  1254.             if (tp->U.V28.tloc->tt == nid) {
  1255.                 tq = idup(tp->U.V28.tloc);
  1256.                 if (Member((unsigned)(tq->tt), Conset[158]))
  1257.                     printid(tp->U.V28.tloc->U.V43.tsym->U.V6.lid);
  1258.                 else
  1259.                     eaddr(tp->U.V28.tloc);
  1260.             } else
  1261.                 eaddr(tp->U.V28.tloc);
  1262.             Putchr(';', output),Putchr('\n', output);
  1263.             break ;
  1264.           case npop:
  1265.             indent();
  1266.             eglobid(tp->U.V28.tglob);
  1267.             (void)fprintf(output.fp, " = "), Putl(output, 0);
  1268.             eglobid(tp->U.V28.ttmp);
  1269.             Putchr(';', output),Putchr('\n', output);
  1270.             break ;
  1271.           case nbreak:
  1272.             indent();
  1273.             (void)fprintf(output.fp, "if ("), Putl(output, 0);
  1274.             eexpr(tp->U.V29.tbrkid);
  1275.             (void)fprintf(output.fp, " == "), Putl(output, 0);
  1276.             eexpr(tp->U.V29.tbrkxp);
  1277.             (void)fprintf(output.fp, ") break;\n"), Putl(output, 1);
  1278.             break ;
  1279.           case nempty:
  1280.             if (!(Member((unsigned)(tp->tup->tt), Conset[159]))) {
  1281.                 indent();
  1282.                 Putchr(';', output),Putchr('\n', output);
  1283.             }
  1284.             break ;
  1285.           default:
  1286.             Caseerror(Line);
  1287.         }
  1288.         if ((*G196_setused) && (Member((unsigned)(tp->tup->tt), Conset[160]))) {
  1289.             indent();
  1290.             (void)fprintf(output.fp, "Claimset();\n"), Putl(output, 1);
  1291.             (*G196_setused) = false;
  1292.         }
  1293.         tp = tp->tnext;
  1294.     }
  1295. }
  1296.  
  1297.  void
  1298. elabel(tp)
  1299.     treeptr    tp;
  1300. {
  1301.     treeptr    tq;
  1302.     integer    i;
  1303.  
  1304.     i = 0;
  1305.     tq = tp->U.V13.tsublab;
  1306.     while (tq != (struct S61 *)NIL) {
  1307.         if (tq->U.V43.tsym->U.V9.lgo)
  1308.             i = i + 1;
  1309.         tq = tq->tnext;
  1310.     }
  1311.     if (i == 1) {
  1312.         tq = tp->U.V13.tsublab;
  1313.         while (!tq->U.V43.tsym->U.V9.lgo)
  1314.             tq = tq->tnext;
  1315.         indent();
  1316.         (void)fprintf(output.fp, "if (setjmp(J[%1d].jb))\n", tp->U.V13.tstat), Putl(output, 1);
  1317.         (void)fprintf(output.fp, "%cgoto L%1d;\n", tab1, tq->U.V43.tsym->U.V9.lno), Putl(output, 1);
  1318.     } else
  1319.         if (i > 1) {
  1320.             indent();
  1321.             (void)fprintf(output.fp, "switch (setjmp(J[%1d].jb)) {\n", tp->U.V13.tstat), Putl(output, 1);
  1322.             indent();
  1323.             (void)fprintf(output.fp, "  case 0:\n"), Putl(output, 1);
  1324.             indent();
  1325.             (void)fprintf(output.fp, "%cbreak\n", tab1), Putl(output, 1);
  1326.             tq = tp->U.V13.tsublab;
  1327.             while (tq != (struct S61 *)NIL) {
  1328.                 if (tq->U.V43.tsym->U.V9.lgo) {
  1329.                     indent();
  1330.                     (void)fprintf(output.fp, "  case %1d:\n", tq->U.V43.tsym->U.V9.lno), Putl(output, 1);
  1331.                     indent();
  1332.                     (void)fprintf(output.fp, "%cgoto L%1d;\n", tab1, tq->U.V43.tsym->U.V9.lno), Putl(output, 1);
  1333.                 }
  1334.                 tq = tq->tnext;
  1335.             }
  1336.             indent();
  1337.             (void)fprintf(output.fp, "  default:\n"), Putl(output, 1);
  1338.             indent();
  1339.             (void)fprintf(output.fp, "%cCaseerror(Line)\n", tab1), Putl(output, 1);
  1340.             indent();
  1341.             Putchr('}', output),Putchr('\n', output);
  1342.         }
  1343. }
  1344.  
  1345.  void
  1346. econf(tp)
  1347.     treeptr    tp;
  1348. {
  1349.     treeptr    tq;
  1350.  
  1351.     while (tp != (struct S61 *)NIL) {
  1352.         if (tp->tt == nvarpar)
  1353.             if (tp->U.V14.tbind->tt == nconfarr) {
  1354.                 indent();
  1355.                 etypedef(tp->U.V14.tbind->U.V22.tindtyp);
  1356.                 Putchr(tab1, output);
  1357.                 tq = tp->U.V14.tbind->U.V22.tcindx->U.V19.tlo;
  1358.                 printid(tq->U.V43.tsym->U.V6.lid);
  1359.                 (void)fprintf(output.fp, " = ("), Putl(output, 0);
  1360.                 etypedef(tp->U.V14.tbind->U.V22.tindtyp);
  1361.                 (void)fprintf(output.fp, ")0;\n"), Putl(output, 1);
  1362.             }
  1363.         tp = tp->tnext;
  1364.     }
  1365. }
  1366.  
  1367.  void
  1368. esubr(tp)
  1369.     treeptr    tp;
  1370. {
  1371.     treeptr    tq, ti;
  1372.  
  1373.     while (tp != (struct S61 *)NIL) {
  1374.         if (tp->U.V13.tsubsub != (struct S61 *)NIL) {
  1375.             etypedef(tp->U.V13.tfuntyp);
  1376.             Putchr(space, output);
  1377.             printid(tp->U.V13.tsubid->U.V43.tsym->U.V6.lid);
  1378.             (void)fprintf(output.fp, "();\n"), Putl(output, 1);
  1379.             Putchr('\n', output);
  1380.             esubr(tp->U.V13.tsubsub);
  1381.         }
  1382.         if (tp->U.V13.tsubstmt == (struct S61 *)NIL) {
  1383.             if (tp->U.V13.tsubid->U.V43.tsym->lsymdecl->tup == tp)
  1384.                 (void)fprintf(output.fp, "%s", xtern), Putl(output, 0);
  1385.             etypedef(tp->U.V13.tfuntyp);
  1386.             Putchr(space, output);
  1387.             printid(tp->U.V13.tsubid->U.V43.tsym->U.V6.lid);
  1388.             (void)fprintf(output.fp, "();\n"), Putl(output, 1);
  1389.             goto L999;
  1390.         }
  1391.         Putchr(space, output);
  1392.         etypedef(tp->U.V13.tfuntyp);
  1393.         Putchr('\n', output);
  1394.         printid(tp->U.V13.tsubid->U.V43.tsym->U.V6.lid);
  1395.         Putchr('(', output);
  1396.         tq = tp->U.V13.tsubpar;
  1397.         while (tq != (struct S61 *)NIL) {
  1398.             switch (tq->tt) {
  1399.               case nvarpar:  case nvalpar:
  1400.                 ti = tq->U.V14.tidl;
  1401.                 while (ti != (struct S61 *)NIL) {
  1402.                     printid(ti->U.V43.tsym->U.V6.lid);
  1403.                     ti = ti->tnext;
  1404.                     if (ti != (struct S61 *)NIL)
  1405.                         (void)fprintf(output.fp, ", "), Putl(output, 0);
  1406.                 }
  1407.                 if (tq->U.V14.tbind->tt == nconfarr) {
  1408.                     ti = tq->U.V14.tbind->U.V22.tcindx->U.V19.thi;
  1409.                     (void)fprintf(output.fp, ", "), Putl(output, 0);
  1410.                     printid(ti->U.V43.tsym->U.V6.lid);
  1411.                 }
  1412.                 break ;
  1413.               case nparproc:  case nparfunc:
  1414.                 ti = tq->U.V15.tparid;
  1415.                 printid(ti->U.V43.tsym->U.V6.lid);
  1416.                 break ;
  1417.               default:
  1418.                 Caseerror(Line);
  1419.             }
  1420.             tq = tq->tnext;
  1421.             if (tq != (struct S61 *)NIL)
  1422.                 (void)fprintf(output.fp, ", "), Putl(output, 0);
  1423.         }
  1424.         Putchr(')', output),Putchr('\n', output);
  1425.         increment();
  1426.         evar(tp->U.V13.tsubpar);
  1427.         Putchr('{', output),Putchr('\n', output);
  1428.         econf(tp->U.V13.tsubpar);
  1429.         econst(tp->U.V13.tsubconst);
  1430.         etype(tp->U.V13.tsubtype);
  1431.         evar(tp->U.V13.tsubvar);
  1432.         if ((tp->U.V13.tsubconst != (struct S61 *)NIL) || (tp->U.V13.tsubtype != (struct S61 *)NIL) || (tp->U.V13.tsubvar != (struct S61 *)NIL))
  1433.             Putchr('\n', output);
  1434.         elabel(tp);
  1435.         estmt(tp->U.V13.tsubstmt);
  1436.         if (tp->tt == nfunc) {
  1437.             indent();
  1438.             (void)fprintf(output.fp, "return "), Putl(output, 0);
  1439.             printid(tp->U.V13.tsubvar->U.V14.tidl->U.V43.tsym->U.V6.lid);
  1440.             Putchr(';', output),Putchr('\n', output);
  1441.         }
  1442.         decrement();
  1443.         Putchr('}', output),Putchr('\n', output);
  1444.     L999:
  1445.         Putchr('\n', output);
  1446.         tp = tp->tnext;
  1447.     }
  1448. }
  1449.  
  1450.  boolean
  1451. use(d)
  1452.     predefs    d;
  1453. {
  1454.     register boolean    R174;
  1455.  
  1456.     R174 = defnams.A[(int)(d)]->U.V6.lused;
  1457.     return R174;
  1458. }
  1459.  
  1460. void eprogram();
  1461.  
  1462.  void
  1463. capital(sp)
  1464.     symptr    sp;
  1465. {
  1466.     toknbuf    tb;
  1467.  
  1468.     if (sp->U.V6.lid->inref > 1) {
  1469.         gettokn(sp->U.V6.lid->istr, &tb);
  1470.         tb.A[1 - 1] = uppercase(tb.A[1 - 1]);
  1471.         sp->U.V6.lid = saveid(&tb);
  1472.     }
  1473. }
  1474.  
  1475.  void
  1476. etextdef()
  1477. {
  1478.     treeptr    tq;
  1479.  
  1480.     (void)fprintf(output.fp, "typedef "), Putl(output, 0);
  1481.     tq = mknode(nfileof);
  1482.     tq->U.V18.tof = typnods.A[(int)(tchar)];
  1483.     etypedef(tq);
  1484.     (void)fprintf(output.fp, "%ctext;\n", tab1), Putl(output, 1);
  1485. }
  1486.  
  1487.  void
  1488. eprogram(tp)
  1489.     treeptr    tp;
  1490. {
  1491.     if (tp->U.V13.tsubid != (struct S61 *)NIL) {
  1492.         (void)fprintf(output.fp, "/*\n"), Putl(output, 1);
  1493.         (void)fprintf(output.fp, "**    Code derived from program "), Putl(output, 0);
  1494.         printid(tp->U.V13.tsubid->U.V43.tsym->U.V6.lid);
  1495.         Putchr('\n', output);
  1496.         (void)fprintf(output.fp, "*/\n"), Putl(output, 1);
  1497.         (void)fprintf(output.fp, "%s%s%cexit();\n", xtern, voidtyp, tab1), Putl(output, 1);
  1498.     }
  1499.     if (usecase || usesets || use(dinput) || use(doutput) || use(dwrite) || use(dwriteln) || use(dmessage) || use(deof) || use(deoln) || use(dflush) || use(dpage) || use(dread) || use(dreadln) || use(dclose) || use(dreset) || use(drewrite) || use(dget) || us
  1500.  
  1501.