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

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