Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.99
 
1.100
 
MAIN:ragge:20030904204644
 
pftn.c
_>10251025         return((unsigned int)sue->suesize * mult);
 10261026 }
 10271027 
<> 1028+/* compute the size associated with type ty,
  1029+ *  dimoff d, and sizoff s */
  1030+/* BETTER NOT BE CALLED WHEN t, d, and s REFER TO A BIT FIELD... */
  1031+NODE *
  1032+btsize(TWORD ty, union dimfun *d, struct suedef *sue)
  1033+{
  1034+        NODE *rv;
  1035+        int i;
  1036+
  1037+        rv = bcon(1);
  1038+
  1039+        for( i=0; i<=(SZINT-BTSHIFT-1); i+=TSHIFT ){
  1040+                switch( (ty>>i)&TMASK ){
  1041+
  1042+                case FTN:
  1043+                        cerror( "compiler takes size of function");
  1044+                case PTR:
  1045+                        return optim(buildtree(MUL, bcon(SZPOINT/SZCHAR), rv));
  1046+                case ARY:
  1047+                        rv = buildtree(MUL, rv, d->ddim >= 0 ? bcon(d->ddim) :
  1048+                            tempnode(-d->ddim, INT, 0, MKSUE(INT)));
  1049+                        d++;
  1050+                        continue;
  1051+                case 0:
  1052+                        break;
  1053+
  1054+                        }
  1055+                }
  1056+
  1057+        if (sue == NULL)
  1058+                cerror("bad tsize sue");
  1059+        if (ty != STRTY && ty != UNIONTY) {
  1060+                if (sue->suesize == 0) {
  1061+                        uerror("unknown size");
  1062+                        return(bcon(SZINT/SZCHAR));
  1063+                }
  1064+        } else {
  1065+                if (sue->suelem == NULL)
  1066+                        uerror("unknown structure/union/enum");
  1067+        }
  1068+
  1069+        return optim(buildtree(MUL, bcon(sue->suesize/SZCHAR), rv));
  1070+}
  1071+
10281072 /*
 10291073  * force inoff to have the value n
 10301074  */
     
 !
16721716 static void
 16731717 dynalloc(struct symtab *p, int *poff)
 16741718 {
<>1675 -        struct suedef sue;
 1676 -//      struct symtab *q;
 1677 -        NODE *n, *nn;
 1678 -        OFFSZ ptroff, argoff;
  1719+        union dimfun *df;
  1720+        NODE *n, *nn, *tn, *pol;
16791721         TWORD t;
<>1680 -//      int al, off, tsz;
 1681 -        int i;
  1722+        int i, no;
16821723 
 16831724         bccode(); /* Init code generation */
 16841725         send_passt(IP_NEWBLK, regvar, autooff);
<>1685 -        /*
 1686 -         * Setup space on the stack, one pointer to the array space
 1687 -         * and n-1 integers for the array sizes.
 1688 -         */
 1689 -        ptroff = upoff(tsize(PTR, 0, &sue), talign(PTR, &sue), poff);
 1690 -        if (arrstkp > 1) {
 1691 -                union dimfun tab[2];
 1692 -                tab[0].ddim = arrstkp-1;
 1693 -                tab[1].ddim = INT;
 1694 -                argoff = upoff(tsize(ARY+INT, tab, NULL),
 1695 -                    talign(ARY+INT, 0), poff);
 1696 -        }
16971726 
 16981727         /*
<>1699 -         * Set the initial pointer the same as the stack pointer.
 1700 -         * Assume that the stack pointer is correctly aligned already.
  1728+         * The pointer to the array is stored in a TEMP node, which number
  1729+         * is in the soffset field;
17011730          */
<>1702 -        p->soffset = ptroff;
 1703 -        p->stype = INCREF(p->stype);
 1704 -        spname = p;
 1705 -        nn = buildtree(NAME, NIL, NIL);
  1731+        t = p->stype;
  1732+        p->sflags |= (STNODE|SDYNARRAY);
  1733+        p->stype = INCREF(p->stype);    /* Make this an indirect pointer */
  1734+        tn = tempnode(0, p->stype, p->sdf, p->ssue);
  1735+        p->soffset = tn->n_lval;
17061736 
<>1707 -        /*
 1708 -         * Calculate the size of the array to be allocated on stack.
 1709 -         * Save the sizes on the stack while doing this.
 1710 -         */
 1711 -        n = arrstk[0];
 1712 -        i = 0;
  1737+        df = p->sdf;
17131738 
<>1714 -        if (arrstkp != 1)
 1715 -                cerror("dynalloc: no multidim arrays");
 1716 -#if 0
 1717 -        while (++i < arrstkp) {
 1718 -                
 1719 -                sp = clocal(block(PLUS, stknode(INCREF(STRTY), 0, 0),
 1720 -                    offcon(argoff + (i-1) * ALINT, INT, 0, INT), INT, 0, INT);
 1721 -                sp = buildtree(UNARY MUL, sp, NIL);
  1739+        pol = NIL;
  1740+        for (i = 0; ISARY(t); t = DECREF(t), df++) {
  1741+                if (df->ddim >= 0)
  1742+                        continue;
  1743+                n = arrstk[i++];
  1744+                nn = tempnode(0, INT, 0, MKSUE(INT));
  1745+                no = nn->n_lval;
  1746+                ecomp(buildtree(ASSIGN, nn, n)); /* Save size */
17221747 
<>1723 -                n = buildtree(ASSIGN, sp, arrstk[i]);
  1748+                df->ddim = -no;
  1749+                n = tempnode(no, INT, 0, MKSUE(INT));
  1750+                if (pol == NIL)
  1751+                        pol = n;
  1752+                else
  1753+                        pol = buildtree(MUL, pol, n);
17241754         }
<>1725 -
 1726 -        sp = block(PCONV, stknode(INCREF(STRTY), 0, 0), NIL,
 1727 -            INCREF(BTYPE(p->stype)), p->dimoff, p->sizoff);
 1728 -        n = buildtree(PLUS, sp, n);
 1729 -
 1730 -#endif
 1731 -
 1732 -        /* get the underlying size without ARYs */
 1733 -        t = p->stype;
 1734 -        while (ISARY(t))
 1735 -                t = DECREF(t);
 1736 -
 1737 -        /* Write it onto the stack */
 1738 -        spalloc(nn, n, tsize(t, 0, p->ssue));
 1739 -        p->sflags |= SDYNARRAY;
  1755+        /* Create stack gap */
  1756+        spalloc(tn, pol, tsize(t, 0, p->ssue));
<_17401757         arrstkp = 0;
 17411758 }
 17421759 
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-11-01 07:57 +0100