Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.22
 
1.23
 
MAIN:ragge:20030604193605
 
trees.c
_>9595         int opty;
 9696         struct symtab *sp;
 9797         NODE *lr, *ll;
<> 98+        char *name;
9899         int i;
 99100 
 100101 # ifndef BUG1
     
 !
127128                                 l->n_lval = l->n_fcon == 0.0;
 128129                         else
 129130                                 l->n_lval = l->n_dcon == 0.0;
<>130 -                        l->n_rval = NONAME;
  131+                        l->n_sp = NULL;
131132                         l->n_op = ICON;
 132133                         l->n_csiz = l->n_type = INT;
 133134                         l->n_cdim = 0;
     
 !
305306                 switch(o){
 306307 
 307308                 case NAME:
<>308 -                        sp = &stab[idname];
 309 -                        if( sp->stype == UNDEF ){
 310 -                                uerror( "%s undefined", sp->sname );
  309+                        sp = spname;
  310+                        if (sp->stype == UNDEF) {
  311+                                uerror("%s undefined", sp->sname);
311312                                 /* make p look reasonable */
 312313                                 p->n_type = p->n_csiz = INT;
 313314                                 p->n_cdim = 0;
<>314 -                                p->n_rval = idname;
  315+                                p->n_sp = sp;
315316                                 p->n_lval = 0;
<>316 -                                defid( p, SNULL );
  317+                                defid(p, SNULL);
317318                                 break;
<>318 -                                }
  319+                        }
319320                         p->n_type = sp->stype;
 320321                         p->n_cdim = sp->dimoff;
 321322                         p->n_csiz = sp->sizoff;
 322323                         p->n_lval = 0;
<>323 -                        p->n_rval = idname;
  324+                        p->n_sp = sp;
324325                         /* special case: MOETY is really an ICON... */
<>325 -                        if( p->n_type == MOETY ){
 326 -                                p->n_rval = NONAME;
 327 -                                p->n_lval = sp->offset;
  326+                        if (p->n_type == MOETY) {
  327+                                p->n_sp = NULL;
  328+                                p->n_lval = sp->soffset;
328329                                 p->n_cdim = 0;
 329330                                 p->n_type = ENUMTY;
 330331                                 p->n_op = ICON;
<>331 -                                }
  332+                        }
332333                         break;
 333334 
 334335                 case ICON:
     
 !
347348                         p->n_csiz = CHAR;
 348349 #endif
 349350                         p->n_lval = 0;
<>350 -                        p->n_rval = NOLAB;
  351+                        p->n_sp = NULL;
351352                         p->n_cdim = curdim;
 352353                         break;
 353354 
     
 !
371372                         /* p->x turned into *(p+offset) */
 372373                         /* rhs must be a name; check correctness */
 373374 
<> 375+                        /* Find member symbol struct */
  376+                        if (l->n_type != PTR+STRTY && l->n_type != PTR+UNIONTY){
  377+                                uerror("struct or union required");
  378+                                break;
  379+                        }
  380+
  381+                        if ((i = dimtab[l->n_csiz + 1]) < 0)
  382+                                uerror("undefined struct or union");
  383+
  384+                        name = r->n_name;
  385+                        for (; dimtab[i] >= 0; i++) {
  386+                                sp = (struct symtab *)dimtab[i];
  387+                                if (sp->sname == name)
  388+                                        break;
  389+                        }
  390+                        if (dimtab[i] < 0)
  391+                                uerror("member '%s' not declared", name);
  392+
  393+                        r->n_sp = sp;
  394+                        p = stref(p);
  395+                        break;
  396+
  397+#if 0
374398                         i = r->n_rval;
 375399                         if( i<0 || ((sp= &stab[i])->sclass != MOS && sp->sclass != MOU && !(sp->sclass&FIELD)) ){
 376400                                 uerror( "member of structure or union required" );
     
 !
422446                         p = stref( p );
 423447                         break;
 424448 
<> 449+#endif
425450                 case UNARY MUL:
 426451                         if( l->n_op == UNARY AND ){
 427452                                 p->n_op = l->n_op = FREE;
     
 !
531556                         break;
 532557 
 533558                 case CALL:
<>534 -                        p->n_right = r = fixargs( p->n_right );
  559+                        p->n_right = r = fixargs(p->n_right);
535560                 case UNARY CALL:
<>536 -                        if( !ISPTR(l->n_type)) uerror("illegal function");
  561+                        if (!ISPTR(l->n_type))
  562+                                uerror("illegal function");
537563                         p->n_type = DECREF(l->n_type);
<>538 -                        if( !ISFTN(p->n_type)) uerror("illegal function");
 539 -                        p->n_type = DECREF( p->n_type );
  564+                        if (!ISFTN(p->n_type))
  565+                                uerror("illegal function");
  566+                        p->n_type = DECREF(p->n_type);
540567                         p->n_cdim = l->n_cdim;
 541568                         p->n_csiz = l->n_csiz;
<>542 -                        if( l->n_op == UNARY AND && l->n_left->n_op == NAME &&
 543 -                                l->n_left->n_rval >= 0 && l->n_left->n_rval != NONAME &&
 544 -                                ( (i=stab[l->n_left->n_rval].sclass) == FORTRAN || i==UFORTRAN ) ){
  569+                        if (l->n_op == UNARY AND && l->n_left->n_op == NAME &&
  570+                            l->n_left->n_sp != NULL && l->n_left->n_sp != NULL &&
  571+                            (l->n_left->n_sp->sclass == FORTRAN ||
  572+                            l->n_left->n_sp->sclass == UFORTRAN)) {
545573                                 p->n_op += (FORTCALL-CALL);
<>546 -                                }
 547 -                        if( p->n_type == STRTY || p->n_type == UNIONTY ){
  574+                        }
  575+                        if (p->n_type == STRTY || p->n_type == UNIONTY) {
548576                                 /* function returning structure */
 549577                                 /*  make function really return ptr to str., with * */
 550578 
 551579                                 p->n_op += STCALL-CALL;
<>552 -                                p->n_type = INCREF( p->n_type );
 553 -                                p = buildtree( UNARY MUL, p, NIL );
  580+                                p->n_type = INCREF(p->n_type);
  581+                                p = buildtree(UNARY MUL, p, NIL);
554582 
 555583                                 }
 556584                         break;
     
 !
620648         return( p );
 621649 }
 622650 
<> 651+#if 0
623652 /*
 624653  * is the MOS or MOU at stab[i] OK for strict reference by a ptr
 625654  * i has been checked to contain a MOS or MOU
     
 !
657686         }
 658687         return(0);
 659688 }
<> 689+#endif
660690 
 661691 /*
 662692  * apply the op o to the lval part of p; if binary, rhs is val
     
 !
673703         u = ISUNSIGNED(p->n_type) || ISUNSIGNED(q->n_type);
 674704         if( u && (o==LE||o==LT||o==GE||o==GT)) o += (UGE-GE);
 675705 
<>676 -        if( p->n_rval != NONAME && q->n_rval != NONAME ) return(0);
 677 -        if( q->n_rval != NONAME && o!=PLUS ) return(0);
 678 -        if( p->n_rval != NONAME && o!=PLUS && o!=MINUS ) return(0);
  706+        if (p->n_sp != NULL && q->n_sp != NULL)
  707+                return(0);
  708+        if (q->n_sp != NULL && o != PLUS)
  709+                return(0);
  710+        if (p->n_sp != NULL && o != PLUS && o != MINUS)
  711+                return(0);
679712 
 680713         /* usual type conversions -- handle casts of constants */
 681714 #define ISLONG(t)       ((t) == LONG || (t) == ULONG)
     
 !
695728 
 696729         case PLUS:
 697730                 p->n_lval += val;
<>698 -                if( p->n_rval == NONAME ){
  731+                if (p->n_sp == NULL) {
699732                         p->n_rval = q->n_rval;
 700733                         p->n_type = q->n_type;
<>701 -                        }
  734+                }
702735                 break;
 703736         case MINUS:
 704737                 p->n_lval -= val;
     
 !
857890 stref(NODE *p)
 858891 {
 859892         TWORD t;
<>860 -        int d, s, dsc, align, snum;
  893+        int d, s, dsc, align;
861894         OFFSZ off;
 862895         register struct symtab *q;
 863896 
 864897         /* make p->x */
 865898         /* this is also used to reference automatic variables */
 866899 
<>867 -        snum = p->n_right->n_rval;
 868 -        q = &stab[snum];
  900+        q = p->n_right->n_sp;
869901         p->n_right->n_op = FREE;
 870902         p->n_op = FREE;
 871903         p = pconvert(p->n_left);
     
 !
883915 
 884916         /* compute the offset to be added */
 885917 
<>886 -        off = q->offset;
  918+        off = q->soffset;
887919         dsc = q->sclass;
 888920 
 889921         if (dsc & FIELD) {  /* normalize offset */
     
 !
900932 
 901933         if (dsc & FIELD) {
 902934                 p = block(FLD, p, NIL, q->stype, 0, q->sizoff);
<>903 -                p->n_rval = PKFIELD(dsc&FLDSIZ, q->offset%align);
  935+                p->n_rval = PKFIELD(dsc&FLDSIZ, q->soffset%align);
904936         }
 905937 
 906938         p = clocal(p);
<>907 -        p->n_su = snum/* Needed if this is a function */
  939+        p->n_su = (int)q; /* XXX cast */ /* Needed if this is a function */
908940         return p;
 909941 }
 910942 
     
 !
939971                 }
 940972 
 941973         }
<>942 -
  974+/* make a constant node with value i */
943975 NODE *
<>944 -bcon( i ){ /* make a constant node with value i */
  976+bcon(int i)
  977+{
945978         register NODE *p;
 946979 
<>947 -        p = block( ICON, NIL, NIL, INT, 0, INT );
  980+        p = block(ICON, NIL, NIL, INT, 0, INT);
948981         p->n_lval = i;
<>949 -        p->n_rval = NONAME;
 950 -        return( clocal(p) );
 951 -        }
  982+        p->n_sp = NULL;
  983+        return(clocal(p));
  984+}
952985 
 953986 NODE *
 954987 bpsize(NODE *p)
     
 !
13191352         p = talloc();
 13201353         p->n_rval = 0;
 13211354         p->n_op = o;
<> 1355+        p->n_lval = 0; /* Protect against large lval */
13221356         p->n_left = l;
 13231357         p->n_right = r;
 13241358         p->n_type = t;
     
 !
16431677         if( o == DCON || o == FCON ){
 16441678                 (void) locctr( DATA );
 16451679                 defalign( o == DCON ? ALDOUBLE : ALFLOAT );
<>1646 -                deflab( i = getlab() );
  1680+                deflab(i = getlab());
16471681                 if( o == FCON )
 16481682                         fincode( p->n_fcon, SZFLOAT );
 16491683                 else
 16501684                         fincode( p->n_dcon, SZDOUBLE );
<>1651 -                p->n_lval = 0;
 1652 -                p->n_rval = -i;
 1653 -                p->n_type = (o == DCON ? DOUBLE : FLOAT);
16541685                 p->n_op = NAME;
<> 1686+                p->n_type = (o == DCON ? DOUBLE : FLOAT);
  1687+                p->n_lval = 0;
  1688+                p->n_sp = tmpalloc(sizeof(struct symtab_hdr));
  1689+                p->n_sp->sclass = ILABEL;
  1690+                p->n_sp->soffset = i;
16551691         }
 16561692 }
 16571693 #endif PRTDCON
     
 !
16911727 
 16921728         case NAME:
 16931729         case ICON:
<>1694 -                if( p->n_rval == NONAME ) p->n_name = "";
 1695 -                else if( p->n_rval >= 0 ){ /* copy name from exname */
 1696 -                        register char *cp;
 1697 -                        cp = exname( stab[p->n_rval].sname );
 1698 -                        if (isinlining)
 1699 -                                p->n_name = strdup(cp);
 1700 -                        else
 1701 -                                p->n_name = tstr(cp);
  1730+                if (p->n_sp != NULL) {
  1731+                        if (p->n_sp->sflags & SLABEL ||
  1732+                            p->n_sp->sclass == ILABEL) {
  1733+                                char *cp = tmpalloc(32);
  1734+                                sprintf(cp, LABFMT, p->n_sp->soffset);
  1735+                                p->n_name = cp;
  1736+                        } else {
  1737+                                p->n_name = exname(p->n_sp->sname);
17021738                         }
<>1703 -                else {
 1704 -                        char temp[32];
 1705 -                        sprintf( temp, LABFMT, -p->n_rval );
 1706 -                        if (isinlining)
 1707 -                                p->n_name = strdup(temp);
 1708 -                        else
 1709 -                                p->n_name = tstr(temp);
 1710 -                }
  1739+                } else
  1740+                        p->n_name = "";
  1741+if (p->n_name[0] == -1) cerror("minus1");
<_17111742                 break;
 17121743 
 17131744         case STARG:
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-08-20 18:34 +0200