Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.51
 
1.52
 
MAIN:ragge:20030611144225
 
pftn.c
_>4444         struct  symtab **in_xp/* member in structure initializations */
 4545         int     in_n;           /* number of initializations seen */
 4646         struct  suedef *in_sue;
<>47 -        int     *in_d;          /* dimoff */
  47+        union   dimfun *in_df;  /* dimoff/protos */
4848         TWORD   in_t;           /* type */
 4949         struct  symtab *in_sym; /* stab index */
 5050         int     in_fl;  /* flag which says if this level is controlled by {} */
     
 !
6363 static void dynalloc(struct symtab *p, int *poff);
 6464 void inforce(OFFSZ n);
 6565 void vfdalign(int n);
<>66 -static void instk(struct symtab *p, TWORD t, int *d, struct suedef *, OFFSZ off);
  66+static void instk(struct symtab *p, TWORD t, union dimfun *d,
  67+    struct suedef *, OFFSZ off);
6768 void gotscal(void);
 6869 static void ssave(struct symtab *);
 6970 
     
 !
7677         TWORD type;
 7778         TWORD stp;
 7879         int scl;
<>79 -        int *dsym, *ddef;
  80+        union dimfun *dsym, *ddef;
8081         int slev, temp;
 8182         int changed;
 8283 
     
 !
9394                 printf("defid(%s (%p), ", p->sname, p);
 9495                 tprint(q->n_type);
 9596                 printf(", %s, (%p,%p)), level %d\n", scnames(class),
<>96 -                    q->n_dim, q->n_sue, blevel);
  97+                    q->n_df, q->n_sue, blevel);
9798         }
 9899 # endif
 99100 
     
 !
113114                 printf("        previous def'n: ");
 114115                 tprint(stp);
 115116                 printf(", %s, (%p,%p)), level %d\n",
<>116 -                    scnames(p->sclass), p->sdim, p->ssue, slev);
  117+                    scnames(p->sclass), p->sdf, p->ssue, slev);
117118         }
 118119 # endif
 119120 
     
 !
146147                 goto mismatch;
 147148 
 148149         /* test (and possibly adjust) dimensions */
<>149 -        dsym = p->sdim;
 150 -        ddef = q->n_dim;
  150+        dsym = p->sdf;
  151+        ddef = q->n_df;
151152         changed = 0;
 152153         for( temp=type; temp&TMASK; temp = DECREF(temp) ){
 153154                 if( ISARY(temp) ){
<>154 -                        if (*dsym == 0) {
 155 -                                *dsym = *ddef;
  155+                        if (dsym->ddim == 0) {
  156+                                dsym->ddim = ddef->ddim;
156157                                 changed = 1;
<>157 -                        } else if (*ddef != 0 && *dsym != *ddef) {
  158+                        } else if (ddef->ddim != 0 && dsym->ddim!=ddef->ddim) {
158159                                 goto mismatch;
 159160                         }
 160161                         ++dsym;
     
 !
327328 
 328329         /* copy dimensions */
 329330 
<>330 -        p->sdim = q->n_dim;
  331+        p->sdf = q->n_df;
331332 
 332333         /* allocate offsets */
 333334         if (class&FIELD) {
     
 !
384385 
 385386 # ifndef BUG1
 386387         if (ddebug)
<>387 -                printf( "       sdim, ssue, offset: %p, %p, %d\n",
 388 -                    p->sdim, p->ssue, p->soffset);
  388+                printf( "       sdf, ssue, offset: %p, %p, %d\n",
  389+                    p->sdf, p->ssue, p->soffset);
389390 # endif
 390391 
 391392 }
     
 !
648649                 if (p->sclass & FIELD) {
 649650                         sz = p->sclass&FLDSIZ;
 650651                 } else {
<>651 -                        sz = tsize(p->stype, p->sdim, p->ssue);
  652+                        sz = tsize(p->stype, p->sdf, p->ssue);
652653                 }
 653654                 if (sz > strucoff)
 654655                         strucoff = sz/* for use with unions */
     
 !
809810  *  dimoff d, and sizoff s */
 810811 /* BETTER NOT BE CALLED WHEN t, d, and s REFER TO A BIT FIELD... */
 811812 OFFSZ
<>812 -tsize(TWORD ty, int *d, struct suedef *sue)
  813+tsize(TWORD ty, union dimfun *d, struct suedef *sue)
813814 {
 814815 
 815816         int i;
     
 !
827828                 case PTR:
 828829                         return( SZPOINT * mult );
 829830                 case ARY:
<>830 -                        mult *= (unsigned int) *d++;
  831+                        mult *= (unsigned int) d->ddim;
  832+                        d++;
831833                         continue;
 832834                 case 0:
 833835                         break;
     
 !
957959 
 958960         pstk = 0;
 959961 
<>960 -        instk(p, p->stype, p->sdim, p->ssue, inoff);
  962+        instk(p, p->stype, p->sdf, p->ssue, inoff);
961963 
 962964 }
 963965 
 964966 /*
 965967  * make a new entry on the parameter stack to initialize p
 966968  */
 967969 void
<>968 -instk(struct symtab *p, TWORD t, int *d, struct suedef *sue, OFFSZ off)
  970+instk(struct symtab *p, TWORD t, union dimfun *d, struct suedef *sue, OFFSZ off)
969971 {
 970972         struct instk *sp;
 971973 
     
 !
984986                 pstk->in_fl = 0;        /* { flag */
 985987                 pstk->in_sym = p;
 986988                 pstk->in_t = t;
<>987 -                pstk->in_d = d;
  989+                pstk->in_df = d;
988990                 pstk->in_sue = sue;
 989991                 pstk->in_n = 0/* number seen */
 990992                 pstk->in_xp = (t == STRTY || t == UNIONTY) ? sue->suelem : NULL;
     
 !
10241026                                 cerror("insane %s member list",
 10251027                                     t == STRTY ? "structure" : "union");
 10261028                         t = p->stype;
<>1027 -                        d = p->sdim;
  1029+                        d = p->sdf;
10281030                         sue = p->ssue;
 10291031                         off += p->soffset;
 10301032                         continue;
     
 !
10581060                  */
 10591061 
 10601062                 lxarg = pstk->in_prev->in_prev != NULL ?
<>1061 -                    *pstk->in_prev->in_d : 0;
  1063+                    pstk->in_prev->in_df->ddim : 0;
10621064                 while (*wr != 0) {
 10631065                         if (*wr++ == '\\')
 10641066                                 val = esccon(&wr);
     
 !
11171119         }
 11181120 
 11191121         p = buildtree(STRING, NIL, NIL);
<>1120 -        p->n_dim = tmpalloc(sizeof(int));
 1121 -        *p->n_dim = i;
  1122+        p->n_df = tmpalloc(sizeof(union dimfun));
  1123+        p->n_df->ddim = i;
11221124         if (isinlining) {
 11231125                 p->n_sp = permalloc(sizeof(struct symtab_hdr));
 11241126                 p->n_sp->sclass = ILABEL;
     
 !
11471149 {
 11481150         struct suedef *sue;
 11491151         TWORD t;
<>1150 -        int *d, n, *d1;
  1152+        union dimfun *d, *d1;
  1153+        int n;
11511154 
 11521155 # ifndef BUG1
 11531156         if (idebug)
     
 !
11671170                 pstk = pstk->in_prev;
 11681171 
 11691172         t = pstk->in_t;
<>1170 -        d = pstk->in_d;
  1173+        d = pstk->in_df;
11711174         sue = pstk->in_sue;
 11721175         n = pstk->in_n;
 11731176 
     
 !
11761179 
 11771180                 vfdalign(pstk->in_sz);  /* fill out part of the last element, if needed */
 11781181                 n = inoff/pstk->in_sz/* real number of initializers */
<>1179 -                if (*d1 >= n) {
  1182+                if (d1->ddim >= n) {
11801183                         /* once again, t is an array, so no fields */
 11811184                         inforce(tsize(t, d, sue));
<>1182 -                        n = *d1;
  1185+                        n = d1->ddim;
11831186                 }
<>1184 -                if (*d1 != 0 && *d1 != n)
  1187+                if (d1->ddim != 0 && d1->ddim != n)
11851188                         uerror("too many initializers");
 11861189                 if (n == 0)
 11871190                         werror("empty array declaration");
<>1188 -                *d = n;
 1189 -                if (*d1 == 0) {
  1191+                d->ddim = n;
  1192+                if (d1->ddim == 0) {
11901193                         FIXDEF(pstk->in_sym);
 11911194                 }
 11921195         }
     
 !
12301233 void
 12311234 doinit(NODE *p)
 12321235 {
<> 1236+        union dimfun *d;
12331237         NODE *u;
 12341238         struct suedef *sue;
<>1235 -        int sz, *d;
  1239+        int sz;
12361240         TWORD t;
 12371241         int o;
 12381242 
     
 !
12731277 # endif
 12741278 
 12751279         t = pstk->in_t/* type required */
<>1276 -        d = pstk->in_d;
  1280+        d = pstk->in_df;
12771281         sue = pstk->in_sue;
 12781282         if (pstk->in_sz < 0) {  /* bit field */
 12791283                 sz = -pstk->in_sz;
     
 !
13401344                                 continue;
 13411345 
 13421346                         /* otherwise, put next element on the stack */
<>1343 -                        instk(p, p->stype, p->sdim, p->ssue,
  1347+                        instk(p, p->stype, p->sdf, p->ssue,
13441348                             p->soffset + pstk->in_off);
 13451349                         return;
 13461350                 } else if( ISARY(t) ){
 13471351                         n = ++pstk->in_n;
<>1348 -                        if (n >= *pstk->in_d && pstk->in_prev != NULL)
  1352+                        if (n >= pstk->in_df->ddim && pstk->in_prev != NULL)
13491353                                 continue;
 13501354 
 13511355                         /* put the new element onto the stack */
 13521356 
 13531357                         temp = pstk->in_sz;
 13541358                         instk(pstk->in_sym, (TWORD)DECREF(pstk->in_t),
<>1355 -                            pstk->in_d+1, pstk->in_sue, pstk->in_off+n*temp);
  1359+                            pstk->in_df+1, pstk->in_sue, pstk->in_off+n*temp);
13561360                         return;
<>1357 -                }
  1361+                } else if (ISFTN(t))
  1362+                        cerror("gotscal");
13581363 
 13591364         }
 13601365         ifull = 1;
     
 !
14571462 
 14581463         al = talign(p->stype, p->ssue);
 14591464         noff = off = *poff;
<>1460 -        tsz = tsize(p->stype, p->sdim, p->ssue);
  1465+        tsz = tsize(p->stype, p->sdf, p->ssue);
14611466 #ifdef BACKAUTO
 14621467         if (p->sclass == AUTO) {
 14631468                 if ((offsz-off) < tsz)
     
 !
15281533          */
 15291534         ptroff = upoff(tsize(PTR, 0, &sue), talign(PTR, &sue), poff);
 15301535         if (arrstkp > 1) {
<>1531 -                int tab[2];
 1532 -                tab[0] = arrstkp-1;
 1533 -                tab[1] = INT;
  1536+                union dimfun tab[2];
  1537+                tab[0].ddim = arrstkp-1;
  1538+                tab[1].ddim = INT;
15341539                 argoff = upoff(tsize(ARY+INT, tab, NULL),
 15351540                     talign(ARY+INT, 0), poff);
 15361541         }
     
 !
16981703 
 16991704         /* if an array is not initialized, no empty dimension */
 17001705         if (class != EXTERN && class != TYPEDEF &&
<>1701 -            ISARY(p->n_type) && *p->n_dim == 0)
  1706+            ISARY(p->n_type) && p->n_df->ddim == 0)
17021707                 uerror("null storage definition");
 17031708 
 17041709 #ifndef LCOMM
     
 !
18431848 
 18441849 static struct tylnk {
 18451850         struct tylnk *next;
<>1846 -        int dim;
  1851+        union dimfun df;
18471852 } tylnk, *tylkp;
 18481853 static int ntdim;
 18491854 
 18501855 static void
<>1851 -tylkadd(int dim)
  1856+tylkadd(union dimfun dim)
18521857 {
 18531858         tylkp->next = tmpalloc(sizeof(struct tylnk));
 18541859         tylkp = tylkp->next;
 18551860         tylkp->next = NULL;
<>1856 -        tylkp->dim = dim;
  1861+        tylkp->df = dim;
18571862         ntdim++;
 18581863 }
 18591864 
 18601865 /* merge type typ with identifier idp  */
 18611866 NODE *
 18621867 tymerge(NODE *typ, NODE *idp)
 18631868 {
<> 1869+        union dimfun *j;
18641870         struct tylnk *base;
 18651871         unsigned int t;
<>1866 -        int i, *j;
  1872+        int i;
18671873 
 18681874         if (typ->n_op != TYPE)
<>1869 -                cerror( "tymerge: arg 1" );
  1875+                cerror("tymerge: arg 1");
18701876         if (idp == NIL)
<>1871 -                return( NIL );
  1877+                return(NIL);
18721878 
 18731879 # ifndef BUG1
<>1874 -        if( ddebug > 2 ) fwalk( idp, eprint, 0 );
  1880+        if (ddebug > 2)
  1881+                fwalk(idp, eprint, 0);
18751882 # endif
 18761883 
 18771884         idp->n_type = typ->n_type;
     
 !
18831890         tyreduce(idp);
 18841891         idp->n_sue = typ->n_sue;
 18851892 
<>1886 -        for (t = typ->n_type, j = typ->n_dim; t&TMASK; t = DECREF(t))
 1887 -                if (ISARY(t))
  1893+        for (t = typ->n_type, j = typ->n_df; t&TMASK; t = DECREF(t))
  1894+                if (ISARY(t) || ISFTN(t))
18881895                         tylkadd(*j++);
 18891896 
 18901897         if (ntdim) {
<>1891 -                int *a = permalloc(sizeof(int) * ntdim);
  1898+                union dimfun *a = permalloc(sizeof(union dimfun) * ntdim);
18921899                 for (i = 0, base = tylnk.next; base; base = base->next, i++)
<>1893 -                        a[i] = base->dim;
 1894 -                idp->n_dim = a;
  1900+                        a[i] = base->df;
  1901+                idp->n_df = a;
18951902         } else
<>1896 -                idp->n_dim = NULL;
  1903+                idp->n_df = NULL;
18971904 
 18981905         /* now idp is a single node: fix up type */
 18991906 
     
 !
19141921 void
 19151922 tyreduce(NODE *p)
 19161923 {
<> 1924+        union dimfun dim;
19171925         NODE *q;
<>1918 -        int o, temp;
  1926+        int o;
19191927         unsigned int t;
 19201928 
 19211929         o = p->n_op;
     
 !
19281936         switch (o) {
 19291937         case UNARY CALL:
 19301938                 t += (FTN-PTR);
<> 1939+                dim.dfun = NULL; /* XXX */
19311940                 break;
 19321941         case LB:
 19331942                 t += (ARY-PTR);
 19341943                 if (p->n_right->n_op != ICON) {
 19351944                         q = p->n_right;
 19361945                         o = RB;
 19371946                 } else {
<>1938 -                        temp = p->n_right->n_lval;
  1947+                        dim.ddim = p->n_right->n_lval;
19391948                         p->n_right->n_op = FREE;
<>1940 -                        if (temp == 0 && p->n_left->n_op == LB)
  1949+                        if (dim.ddim == 0 && p->n_left->n_op == LB)
19411950                                 uerror("null dimension");
 19421951                 }
 19431952                 break;
     
 !
19461955         p->n_left->n_type = t;
 19471956         tyreduce(p->n_left);
 19481957 
<>1949 -        if (o == LB)
 1950 -                tylkadd(temp);
  1958+        if (o == LB || o == (UNARY CALL))
  1959+                tylkadd(dim);
19511960         if (o == RB) {
<>1952 -                tylkadd(-1);
  1961+                dim.ddim = -1;
  1962+                tylkadd(dim);
19531963                 arrstk[arrstkp++] = q;
 19541964         }
 19551965 
     
 !
19902000                 if (type == FLOAT)
 19912001                         type = DOUBLE;
 19922002                 else if (ISARY(type)) {
<>1993 -                        ++p->n_dim;
  2003+                        ++p->n_df;
<_19942004                         type += (PTR-ARY);
 19952005                 } else if (ISFTN(type)) {
 19962006                         werror("a function is declared as an argument");
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-10-01 22:20 +0200