Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.25
 
1.26
 
MAIN:ragge:20030609155556
 
trees.c
_>9696         struct symtab *sp;
 9797         NODE *lr, *ll;
 9898         char *name;
<>99 -        int i;
  99+        struct symtab **elem;
100100 
 101101 # ifndef BUG1
 102102         if (bdebug)
     
 !
130130                                 l->n_lval = l->n_dcon == 0.0;
 131131                         l->n_sp = NULL;
 132132                         l->n_op = ICON;
<>133 -                        l->n_csiz = l->n_type = INT;
  133+                        l->n_type = INT;
  134+                        l->n_sue = MKSUE(INT);
134135                         l->n_cdim = 0;
 135136                         return(l);
 136137                 case UNARY MINUS:
     
 !
172173                 case EQ:
 173174                 case NE:
 174175                         if( l->n_type == ENUMTY && r->n_type == ENUMTY ){
<>175 -                                p = block( o, l, r, INT, 0, INT );
  176+                                p = block(o, l, r, INT, 0, MKSUE(INT));
176177                                 chkpun( p );
 177178                                 p->n_op = FREE;
 178179                                 }
     
 !
246247                                         }
 247248                                 fpe_count = -1;
 248249                                 l->n_op = DCON;
<>249 -                                l->n_type = l->n_csiz = DOUBLE;
  250+                                l->n_type = DOUBLE;
  251+                                l->n_sue = MKSUE(DOUBLE);
250252                                 r->n_op = FREE;
 251253                                 return (l);
 252254                         }
 253255                 }
 254256 
 255257         /* it's real; we must make a new node */
 256258 
<>257 -        p = block( o, l, r, INT, 0, INT );
  259+        p = block(o, l, r, INT, 0, MKSUE(INT));
258260 
 259261         actions = opact(p);
 260262 #ifndef BUG1
     
 !
291293 
 292294                 p->n_type = q->n_type;
 293295                 p->n_cdim = q->n_cdim;
<>294 -                p->n_csiz = q->n_csiz;
  296+                p->n_sue = q->n_sue;
295297                 }
 296298 
 297299         if( actions & CVTL ) p = convert( p, CVTL );
     
 !
310312                         if (sp->stype == UNDEF) {
 311313                                 uerror("%s undefined", sp->sname);
 312314                                 /* make p look reasonable */
<>313 -                                p->n_type = p->n_csiz = INT;
  315+                                p->n_type = INT;
  316+                                p->n_sue = MKSUE(INT);
314317                                 p->n_cdim = 0;
 315318                                 p->n_sp = sp;
 316319                                 p->n_lval = 0;
     
 !
319322                         }
 320323                         p->n_type = sp->stype;
 321324                         p->n_cdim = sp->dimoff;
<>322 -                        p->n_csiz = sp->sizoff;
  325+                        p->n_sue = sp->ssue;
323326                         p->n_lval = 0;
 324327                         p->n_sp = sp;
 325328                         /* special case: MOETY is really an ICON... */
     
 !
335338                 case ICON:
 336339                         p->n_type = INT;
 337340                         p->n_cdim = 0;
<>338 -                        p->n_csiz = INT;
  341+                        p->n_sue = MKSUE(INT);
339342                         break;
 340343 
 341344                 case STRING:
 342345                         p->n_op = NAME;
 343346 #ifdef CHAR_UNSIGNED
 344347                         p->n_type = UCHAR+ARY;
<>345 -                        p->n_csiz = UCHAR;
  348+                        p->n_sue = MKSUE(UCHAR);
346349 #else
 347350                         p->n_type = CHAR+ARY;
<>348 -                        p->n_csiz = CHAR;
  351+                        p->n_sue = MKSUE(CHAR);
349352 #endif
 350353                         p->n_lval = 0;
 351354                         p->n_sp = NULL;
     
 !
357360                         p->n_rval = 0;
 358361                         p->n_type = FLOAT;
 359362                         p->n_cdim = 0;
<>360 -                        p->n_csiz = FLOAT;
  363+                        p->n_sue = MKSUE(FLOAT);
361364                         break;
 362365 
 363366                 case DCON:
 364367                         p->n_lval = 0;
 365368                         p->n_rval = 0;
 366369                         p->n_type = DOUBLE;
 367370                         p->n_cdim = 0;
<>368 -                        p->n_csiz = DOUBLE;
  371+                        p->n_sue = MKSUE(DOUBLE);
369372                         break;
 370373 
 371374                 case STREF:
     
 !
378381                                 break;
 379382                         }
 380383 
<>381 -                        if ((i = dimtab[l->n_csiz + 1]) < 0)
  384+                        if ((elem = l->n_sue->suelem) == NULL)
382385                                 uerror("undefined struct or union");
 383386 
 384387                         name = r->n_name;
<>385 -                        for (; dimtab[i] >= 0; i++) {
 386 -                                sp = (struct symtab *)dimtab[i];
  388+                        for (; *elem != NULL; elem++) {
  389+                                sp = *elem;
387390                                 if (sp->sname == name)
 388391                                         break;
 389392                         }
<>390 -                        if (dimtab[i] < 0)
  393+                        if (*elem == NULL)
391394                                 uerror("member '%s' not declared", name);
 392395 
 393396                         r->n_sp = sp;
     
 !
402405                         if( !ISPTR(l->n_type))uerror("illegal indirection");
 403406                         p->n_type = DECREF(l->n_type);
 404407                         p->n_cdim = l->n_cdim;
<>405 -                        p->n_csiz = l->n_csiz;
  408+                        p->n_sue = l->n_sue;
406409                         break;
 407410 
 408411                 case UNARY AND:
     
 !
414417                         case NAME:
 415418                                 p->n_type = INCREF( l->n_type );
 416419                                 p->n_cdim = l->n_cdim;
<>417 -                                p->n_csiz = l->n_csiz;
  420+                                p->n_sue = l->n_sue;
418421                                 break;
 419422 
 420423                         case COMOP:
     
 !
461464                 case ASG LS:
 462465                 case ASG RS:
 463466                         if( r->n_type != INT )
<>464 -                                p->n_right = r = makety(r, INT, 0, INT );
  467+                                p->n_right = r = makety(r, INT, 0, MKSUE(INT));
465468                         break;
 466469 
 467470                 case RETURN:
     
 !
473476                          * the addresses of left and right */
 474477 
 475478                         {
<> 479+                                struct suedef *sue;
476480                                 TWORD t;
<>477 -                                int d, s;
  481+                                int d;
478482 
<>479 -                                if( l->n_csiz != r->n_csiz ) uerror( "assignment of different structures" );
  483+                                if (l->n_sue != r->n_sue)
  484+                                        uerror("assignment of different structures");
480485 
<>481 -                                r = buildtree( UNARY AND, r, NIL );
  486+                                r = buildtree(UNARY AND, r, NIL);
482487                                 t = r->n_type;
 483488                                 d = r->n_cdim;
<>484 -                                s = r->n_csiz;
  489+                                sue = r->n_sue;
485490 
<>486 -                                l = block( STASG, l, r, t, d, s );
  491+                                l = block( STASG, l, r, t, d, sue);
487492 
 488493                                 if( o == RETURN ){
 489494                                         p->n_op = FREE;
     
 !
499504                 case COLON:
 500505                         /* structure colon */
 501506 
<>502 -                        if( l->n_csiz != r->n_csiz ) uerror( "type clash in conditional" );
  507+                        if (l->n_sue != r->n_sue)
  508+                                uerror( "type clash in conditional" );
503509                         break;
 504510 
 505511                 case CALL:
     
 !
512518                                 uerror("illegal function");
 513519                         p->n_type = DECREF(p->n_type);
 514520                         p->n_cdim = l->n_cdim;
<>515 -                        p->n_csiz = l->n_csiz;
  521+                        p->n_sue = l->n_sue;
516522                         if (l->n_op == UNARY AND && l->n_left->n_op == NAME &&
 517523                             l->n_left->n_sp != NULL && l->n_left->n_sp != NULL &&
 518524                             (l->n_left->n_sp->sclass == FORTRAN ||
     
 !
586592                 }
 587593 
 588594         if( p->n_type == STRTY || p->n_type == UNIONTY ){
<>589 -                p = block( STARG, p, NIL, p->n_type, p->n_cdim, p->n_csiz );
  595+                p = block(STARG, p, NIL, p->n_type, p->n_cdim, p->n_sue);
590596                 p->n_left = buildtree( UNARY AND, p->n_left, NIL );
 591597                 p = clocal(p);
 592598                 }
     
 !
667673         else
 668674                 utype = u ? UNSIGNED : INT;
 669675         if( !ISPTR(p->n_type) && p->n_type != utype )
<>670 -                p = makety(p, utype, 0, (int)utype);
  676+                p = makety(p, utype, 0, MKSUE(utype));
671677         if( q->n_type != utype )
<>672 -                q = makety(q, utype, 0, (int)utype);
  678+                q = makety(q, utype, 0, MKSUE(utype));
673679 
 674680         switch( o ){
 675681 
     
 !
784790                 if( logop( p->n_op ) && p->n_op != EQ && p->n_op != NE )
 785791                         werror( "comparison of enums" ); */
 786792                 if (t1==ENUMTY && t2==ENUMTY) {
<>787 -                        if (p->n_left->n_csiz!=p->n_right->n_csiz)
  793+                        if (p->n_left->n_sue!=p->n_right->n_sue)
788794                                 werror("enumeration type clash, "
 789795                                     "operator %s", opst[p->n_op]);
 790796                         return;
     
 !
808814                             "and integer, op %s", opst[p->n_op]);
 809815         } else if (ref1) {
 810816                 if (t1 == t2) {
<>811 -                        if (p->n_left->n_csiz != p->n_right->n_csiz) {
  817+                        if (p->n_left->n_sue != p->n_right->n_sue) {
812818                                 werror("illegal structure pointer combination");
 813819                                 return;
 814820                         }
     
 !
836842 NODE *
 837843 stref(NODE *p)
 838844 {
<> 845+        struct suedef *sue;
839846         TWORD t;
<>840 -        int d, s, dsc, align;
  847+        int d, dsc, align;
841848         OFFSZ off;
 842849         register struct symtab *q;
 843850 
     
 !
856863 
 857864         t = INCREF(q->stype);
 858865         d = q->dimoff;
<>859 -        s = q->sizoff;
  866+        sue = q->ssue;
860867 
<>861 -        p = makety(p, t, d, s);
  868+        p = makety(p, t, d, sue);
862869 
 863870         /* compute the offset to be added */
 864871 
     
 !
867874 
 868875         if (dsc & FIELD) {  /* normalize offset */
 869876                 align = ALINT;
<>870 -                s = INT;
  877+                sue = MKSUE(INT);
871878                 off = (off/align)*align;
 872879         }
 873880         if (off != 0)
<>874 -                p = clocal(block(PLUS, p, offcon(off, t, d, s), t, d, s));
  881+                p = clocal(block(PLUS, p, offcon(off, t, d, sue), t, d, sue));
875882 
 876883         p = buildtree(UNARY MUL, p, NIL);
 877884 
 878885         /* if field, build field info */
 879886 
 880887         if (dsc & FIELD) {
<>881 -                p = block(FLD, p, NIL, q->stype, 0, q->sizoff);
  888+                p = block(FLD, p, NIL, q->stype, 0, q->ssue);
882889                 p->n_rval = PKFIELD(dsc&FLDSIZ, q->soffset%align);
 883890         }
 884891 
     
 !
924931 {
 925932         register NODE *p;
 926933 
<>927 -        p = block(ICON, NIL, NIL, INT, 0, INT);
  934+        p = block(ICON, NIL, NIL, INT, 0, MKSUE(INT));
928935         p->n_lval = i;
 929936         p->n_sp = NULL;
 930937         return(clocal(p));
     
 !
933940 NODE *
 934941 bpsize(NODE *p)
 935942 {
<>936 -        return(offcon(psize(p), p->n_type, p->n_cdim, p->n_csiz));
  943+        return(offcon(psize(p), p->n_type, p->n_cdim, p->n_sue));
937944 }
 938945 
 939946 /*
     
 !
949956                 return(SZINT);
 950957         }
 951958         /* note: no pointers to fields */
<>952 -        return(tsize(DECREF(p->n_type), p->n_cdim, p->n_csiz));
  959+        return(tsize(DECREF(p->n_type), p->n_cdim, p->n_sue));
953960 }
 954961 
 955962 /*
     
 !
965972         q = (f == CVTL) ? p->n_left : p->n_right;
 966973 
 967974         s = bpsize(f == CVTL ? p->n_right : p->n_left);
<>968 -        r = block(PMCONV, q, s, INT, 0, INT);
  975+        r = block(PMCONV, q, s, INT, 0, MKSUE(INT));
969976         r = clocal(r);
 970977         /*
 971978          * Indexing is only allowed with integer arguments, so insert
 972979          * SCONV here if arg is not an integer.
 973980          * XXX - complain?
 974981          */
 975982         if (r->n_type != INT)
<>976 -                r = clocal(block(SCONV, r, NIL, INT, 0, INT));
  983+                r = clocal(block(SCONV, r, NIL, INT, 0, MKSUE(INT)));
977984         if (f == CVTL)
 978985                 p->n_left = r;
 979986         else
     
 !
990997         register TWORD ty;
 991998 
 992999         if( (ty=BTYPE(p->n_type)) == ENUMTY || ty == MOETY ) {
<>993 -                if (dimtab[p->n_csiz] == SZCHAR)
  1000+                if (p->n_sue->suesize == SZCHAR)
9941001                         ty = CHAR;
<>995 -                else if (dimtab[p->n_csiz] == SZINT)
  1002+                else if (p->n_sue->suesize == SZINT)
9961003                         ty = INT;
<>997 -                else if (dimtab[p->n_csiz] == SZSHORT)
  1004+                else if (p->n_sue->suesize == SZSHORT)
9981005                         ty = SHORT;
<>999 -                else if (dimtab[p->n_csiz] == SZLONGLONG)
  1006+                else if (p->n_sue->suesize == SZLONGLONG)
10001007                         ty = LONGLONG;
 10011008                 else
 10021009                         ty = LONG;
 10031010                 ty = ctype(ty);
<>1004 -                p->n_csiz = ty;
  1011+                p->n_sue = MKSUE(ty);
10051012                 MODTYPE(p->n_type,ty);
 10061013                 if (p->n_op == ICON && ty != LONG && ty != LONGLONG)
<>1007 -                        p->n_type = p->n_csiz = INT;
 1008 -                }
  1014+                        p->n_type = INT, p->n_sue = MKSUE(INT);
10091015         }
<> 1016+}
10101017 #endif
 10111018 
 10121019 NODE *
     
 !
10421049 
 10431050         case MINUS:
 10441051                 returnclocal( block( PVCONV,
<>1045 -                        p, bpsize(p->n_left), INT, 0, INT ) ) );
  1052+                        p, bpsize(p->n_left), INT, 0, MKSUE(INT))));
10461053                 }
 10471054 
 10481055         cerror( "illegal oconvert: %d", p->n_op );
     
 !
10581065         /* with MINUS, the sizes must be the same */
 10591066         /* with COLON, the types must be the same */
 10601067 
<> 1068+        struct suedef *sue, *sue2;
10611069         TWORD t1, t2, t;
<>1062 -        int o, d2, d, s2, s;
  1070+        int o, d2, d;
10631071 
 10641072         o = p->n_op;
 10651073         t = t1 = p->n_left->n_type;
 10661074         t2 = p->n_right->n_type;
 10671075         d = p->n_left->n_cdim;
 10681076         d2 = p->n_right->n_cdim;
<>1069 -        s = p->n_left->n_csiz;
 1070 -        s2 = p->n_right->n_csiz;
  1077+        sue = p->n_left->n_sue;
  1078+        sue2 = p->n_right->n_sue;
10711079 
 10721080         switch( o ){
 10731081 
     
 !
11001108                 if( !ISPTR(t1) ){
 11011109                         t = t2;
 11021110                         d = d2;
<>1103 -                        s = s2;
  1111+                        sue = sue2;
11041112                         break;
 11051113                         }
 11061114                 if( !ISPTR(t2) ){
 11071115                         break;
 11081116                         }
 11091117 
 11101118                 /* both are pointers */
<>1111 -                if( talign(t2,s2) < talign(t,s) ){
  1119+                if( talign(t2,sue2) < talign(t,sue) ){
11121120                         t = t2;
<>1113 -                        s = s2;
  1121+                        sue = sue2;
11141122                         }
 11151123                 break;
 11161124                 }
 11171125 
<>1118 -        p->n_left = makety( p->n_left, t, d, s );
 1119 -        p->n_right = makety( p->n_right, t, d, s );
  1126+        p->n_left = makety( p->n_left, t, d, 0 );
  1127+        p->n_left->n_sue = sue;
  1128+        p->n_right = makety( p->n_right, t, d, 0 );
  1129+        p->n_right->n_sue = sue;
11201130         if( o!=MINUS && !logop(o) ){
 11211131 
 11221132                 p->n_type = t;
 11231133                 p->n_cdim = d;
<>1124 -                p->n_csiz = s;
  1134+                p->n_sue = sue;
11251135                 }
 11261136 
 11271137         return(clocal(p));
     
 !
11941204            from LONG to INT and ULONG to UNSIGNED */
 11951205 
 11961206         if( (t != t1 || (u && !ISUNSIGNED(p->n_left->n_type))) && ! asgop(o) )
<>1197 -                p->n_left = makety( p->n_left, tu, 0, (int)tu );
  1207+                p->n_left = makety( p->n_left, tu, 0, MKSUE(tu));
11981208 
 11991209         if( t != t2 || (u && !ISUNSIGNED(p->n_right->n_type)) || o==CAST) {
 12001210                 if ( tu == ENUMTY ) {/* always asgop */
<>1201 -                        p->n_right = makety( p->n_right, INT, 0, INT );
  1211+                        p->n_right = makety( p->n_right, INT, 0, MKSUE(INT));
12021212                         p->n_right->n_type = tu;
 12031213                         p->n_right->n_cdim = p->n_left->n_cdim;
<>1204 -                        p->n_right->n_csiz = p->n_left->n_csiz;
  1214+                        p->n_right->n_sue = p->n_left->n_sue;
12051215                         }
 12061216                 else
<>1207 -                        p->n_right = makety( p->n_right, tu, 0, (int)tu );
  1217+                        p->n_right = makety( p->n_right, tu, 0, MKSUE(tu));
12081218         }
 12091219 
 12101220         if( asgop(o) ){
 12111221                 p->n_type = p->n_left->n_type;
 12121222                 p->n_cdim = p->n_left->n_cdim;
<>1213 -                p->n_csiz = p->n_left->n_csiz;
  1223+                p->n_sue = p->n_left->n_sue;
12141224                 }
 12151225         else if( !logop(o) ){
 12161226                 p->n_type = tu;
 12171227                 p->n_cdim = 0;
<>1218 -                p->n_csiz = t;
  1228+                p->n_sue = MKSUE(t);
12191229                 }
 12201230 
 12211231 # ifndef BUG1
     
 !
12271237         }
 12281238 
 12291239 NODE *
<>1230 -makety( p, t, d, s ) register NODE *p; TWORD t; {
  1240+makety(NODE *p, TWORD t, int d, struct suedef *sue)
  1241+{
12311242         /* make p into type t by inserting a conversion */
 12321243 
 12331244         if( p->n_type == ENUMTY && p->n_op == ICON ) econvert(p);
 12341245         if( t == p->n_type ){
 12351246                 p->n_cdim = d;
<>1236 -                p->n_csiz = s;
 1237 -                return( p );
 1238 -                }
  1247+                p->n_sue = sue;
  1248+                return(p);
  1249+        }
12391250 
 12401251         if( t & TMASK ){
 12411252                 /* non-simple type */
<>1242 -                return( block( PCONV, p, NIL, t, d, s ) );
  1253+                return( block( PCONV, p, NIL, t, d, sue));
12431254                 }
 12441255 
 12451256         if( p->n_op == ICON ){
     
 !
12491260                                 p->n_dcon = (U_CONSZ) p->n_lval;
 12501261                         else
 12511262                                 p->n_dcon = p->n_lval;
<>1252 -                        p->n_type = p->n_csiz = t;
  1263+                        p->n_type = t;
  1264+                        p->n_sue = MKSUE(t);
12531265                         return (clocal(p));
 12541266                 }
 12551267                 if (t == FLOAT) {
     
 !
12611273                                 p->n_fcon = p->n_lval;
 12621274                                 }
 12631275 
<>1264 -                        p->n_type = p->n_csiz = t;
  1276+                        p->n_type = t;
  1277+                        p->n_sue = MKSUE(t);
12651278                         return( clocal(p) );
 12661279                         }
 12671280                 }
     
 !
12711284                 p->n_op = DCON;
 12721285                 db = p->n_fcon;
 12731286                 p->n_dcon = db;
<>1274 -                p->n_type = p->n_csiz = t;
  1287+                p->n_type = t;
  1288+                p->n_sue = MKSUE(t);
12751289                 return (clocal(p));
 12761290         } else if (p->n_op == DCON && t == FLOAT) {
 12771291                 float fl;
     
 !
12831297                         werror("float conversion loses precision");
 12841298 #endif
 12851299                 p->n_fcon = fl;
<>1286 -                p->n_type = p->n_csiz = t;
  1300+                p->n_type = t;
  1301+                p->n_sue = MKSUE(t);
12871302                 return (clocal(p));
 12881303         }
 12891304 
<>1290 -        return( clocal( block( SCONV, p, NIL, t, d, s ) ) );
  1305+        return( clocal( block( SCONV, p, NIL, t, d, sue)));
12911306 
 12921307         }
 12931308 
 12941309 NODE *
<>1295 -block( o, l, r, t, d, s ) register NODE *l, *r; TWORD t; {
 1296 -
  1310+block(int o, NODE *l, NODE *r, TWORD t, int d, struct suedef *sue)
  1311+{
12971312         register NODE *p;
 12981313 
 12991314         p = talloc();
     
 !
13051320         p->n_type = t;
 13061321         p->n_su = 0;
 13071322         p->n_cdim = d;
<>1308 -        p->n_csiz = s;
  1323+        p->n_sue = sue;
13091324         return(p);
 13101325         }
 13111326 
     
 !
15831598         int i;
 15841599 
 15851600         /* whatever is the meaning of this if it is a bitfield? */
<>1586 -        i = tsize( p->n_type, p->n_cdim, p->n_csiz )/SZCHAR;
  1601+        i = tsize( p->n_type, p->n_cdim, p->n_sue )/SZCHAR;
15871602 
 15881603         tfree(p);
 15891604         if( i <= 0 ) werror( "sizeof returns 0" );
     
 !
16101625                 printf( ", %d, ", p->n_rval );
 16111626                 }
 16121627         tprint( p->n_type );
<>1613 -        printf( ", %d, %d\n", p->n_cdim, p->n_csiz );
  1628+        printf( ", %d, %p\n", p->n_cdim, p->n_sue );
16141629         return 0;
 16151630 }
 16161631 # endif
     
 !
16931708         case STCALL:
 16941709         case UNARY STCALL:
 16951710                 /* set up size parameters */
<>1696 -                p->n_stsize = (tsize(STRTY,p->n_left->n_cdim,p->n_left->n_csiz)+SZCHAR-1)/SZCHAR;
 1697 -                p->n_stalign = talign(STRTY,p->n_left->n_csiz)/SZCHAR;
  1711+                p->n_stsize = (tsize(STRTY,p->n_left->n_cdim,p->n_left->n_sue)+SZCHAR-1)/SZCHAR;
  1712+                p->n_stalign = talign(STRTY,p->n_left->n_sue)/SZCHAR;
<_16981713                 break;
 16991714 
 17001715         case REG:
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-09-02 13:40 +0200