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:20030729092515
 
reader.c
_>55 # include "pass2.h"
 66 
 77 /*      some storage declarations */
<> 8+/*
  9+ * TODO: re-invent autoincr()/deltest()
  10+ */
811 
 912 int nrecur;
 1013 int lflag;
     
 !
3033 } *templst;
 3134 
 3235 int e2print(NODE *p, int down, int *a, int *b);
<>33 -static void splitline(NODE *);
3436 
<> 37+#ifdef PCC_DEBUG
3538 static void
<> 39+cktree(NODE *p)
  40+{
  41+        if (p->n_op > MAXOP)
  42+                cerror("op %d slipped through", p->n_op);
  43+}
  44+#endif
  45+
  46+static void
3647 opchk(NODE *p)
 3748 {
 3849         int o = p->n_op;
     
 !
5364                 lineid(lineno, ftitle);
 5465 
 5566         /* generate code for the tree p */
<>56 -# ifndef BUG4
 57 -        if (e2debug) fwalk( p, e2print, 0 );
 58 -# endif
  67+#ifdef PCC_DEBUG
  68+        walkf(p, cktree);
  69+        if (e2debug)
  70+                fwalk(p, e2print, 0);
  71+#endif
5972 
 6073 walkf(p, opchk);
 6174 
     
 !
131144         eoftn(regs, autos, retlab);
 132145 }
 133146 
<>134 -#if 0
 135 -NODE *deltrees[DELAYS];
 136 -int deli;
 137 -
 138 -void xtrcomop(NODE *p);
 139 -NODE *saveq[100];
 140 -int nsaveq = 0;
 141 -
 142 -void
 143 -splitline(NODE *p)
 144 -{
 145 -        int i;
 146 -
 147 -        nsaveq = 0;
 148 -
 149 -        for (i = 0; i < nsaveq; i++)
 150 -                codgen(saveq[i], FOREFF);
 151 -        codgen(p, FOREFF);
 152 -}
 153 -
154147 /*
<>155 - * look in all legal places for COMOP's and ++ and -- ops to delay
 156 - * note; don't delay ++ and -- within calls or things like
 157 - * getchar (in their macro forms) will start behaving strangely
 158 - */
 159 -void
 160 -delay(NODE *p)
 161 -{
 162 -        int i;
 163 -
 164 -        /* look for visible COMOPS, and rewrite repeatedly */
 165 -
 166 -        while (delay1(p))
 167 -                ;
 168 -
 169 -        /* look for visible, delayable ++ and -- */
 170 -
 171 -        deli = 0;
 172 -        delay2( p );
 173 -        codgen( p, FOREFF );  /* do what is left */
 174 -        for( i = 0; i<deli; ++i )
 175 -                codgen( deltrees[i], FOREFF );  /* do the rest */
 176 -}
 177 -
 178 -/*
 179 - * look for COMOPS
 180 - */
 181 -int
 182 -delay1(NODE *p)
 183 -{
 184 -        int o, ty;
 185 -
 186 -        o = p->n_op;
 187 -        ty = optype( o );
 188 -        if( ty == LTYPE ) return( 0 );
 189 -        else if( ty == UTYPE ) return( delay1( p->n_left ) );
 190 -
 191 -        switch( o ){
 192 -
 193 -        case QUEST:
 194 -        case ANDAND:
 195 -        case OROR:
 196 -                /* don't look on RHS */
 197 -                return( delay1(p->n_left ) );
 198 -
 199 -        case COMOP/* the meat of the routine */
 200 -                delay( p->n_left );  /* completely evaluate the LHS */
 201 -                /* rewrite the COMOP */
 202 -                { register NODE *q;
 203 -                        q = p->n_right;
 204 -                        ncopy( p, p->n_right );
 205 -                        nfree(q);
 206 -                }
 207 -                return( 1 );
 208 -        }
 209 -
 210 -        return( delay1(p->n_left) || delay1(p->n_right ) );
 211 -}
 212 -
 213 -void
 214 -delay2(NODE *p)
 215 -{
 216 -
 217 -        /* look for delayable ++ and -- operators */
 218 -
 219 -        int o, ty;
 220 -        o = p->n_op;
 221 -        ty = optype( o );
 222 -
 223 -        switch( o ){
 224 -
 225 -        case NOT:
 226 -        case QUEST:
 227 -        case ANDAND:
 228 -        case OROR:
 229 -        case CALL:
 230 -        case UNARY CALL:
 231 -        case STCALL:
 232 -        case UNARY STCALL:
 233 -        case FORTCALL:
 234 -        case UNARY FORTCALL:
 235 -        case COMOP:
 236 -        case CBRANCH:
 237 -                /* for the moment, don't delay past a conditional context, or
 238 -                 * inside of a call */
 239 -                return;
 240 -
 241 -        case UNARY MUL:
 242 -                /* if *p++, do not rewrite */
 243 -                if( autoincr( p ) ) return;
 244 -                break;
 245 -
 246 -        case INCR:
 247 -        case DECR:
 248 -                if( deltest( p ) ){
 249 -                        if( deli < DELAYS ){
 250 -                                register NODE *q;
 251 -                                deltrees[deli++] = tcopy(p);
 252 -                                q = p->n_left;
 253 -                                nfree(p->n_right);  /* zap constant */
 254 -                                ncopy( p, q );
 255 -                                nfree(q);
 256 -                                return;
 257 -                                }
 258 -                        }
 259 -
 260 -                }
 261 -
 262 -        if( ty == BITYPE ) delay2( p->n_right );
 263 -        if( ty != LTYPE ) delay2( p->n_left );
 264 -}
 265 -#endif
 266 -
 267 -/*
268148  * generate the code for p;
 269149  * order may call codgen recursively
 270150  * cookie is used to describe the context
     
 !
424304                 }
 425305                 break;
 426306 
<>427 -        case COMOP:
428307         case FORCE:
 429308         case CBRANCH:
<>430 -        case QUEST:
 431 -        case ANDAND:
 432 -        case OROR:
 433 -        case NOT:
434309         case UNARY CALL:
 435310         case CALL:
 436311         case UNARY STCALL:
     
 !
466341                 nomat:
 467342                 cerror( "no table entry for op %s", opst[p->n_op] );
 468343 
<>469 -        case COMOP:
 470 -                codgen( p1, FOREFF );
 471 -                p2->n_rall = p->n_rall;
 472 -                codgen( p2, cookie );
 473 -                ncopy( p, p2 );
 474 -                nfree(p2);
 475 -                goto cleanup;
 476 -
477344         case FORCE:
 478345                 /* recurse, letting the work be done by rallo */
 479346                 cook = INTAREG|INTBREG;
     
 !
488355                 nfree(p);
 489356                 return;
 490357 
<>491 -        case QUEST:
 492 -                cbranch( p1, -1, m=getlab() );
 493 -                p2->n_left->n_rall = p->n_rall;
 494 -                codgen( p2->n_left, INTAREG|INTBREG );
 495 -                /* force right to compute result into same reg used by left */
 496 -                p2->n_right->n_rall = p2->n_left->n_rval|MUSTDO;
 497 -                reclaim( p2->n_left, RNULL, 0 );
 498 -                cbgen( 0, m1 = getlab(), 'I' );
 499 -                deflab( m );
 500 -                codgen( p2->n_right, INTAREG|INTBREG );
 501 -                deflab( m1 );
 502 -                p->n_op = REG/* set up node describing result */
 503 -                p->n_lval = 0;
 504 -                p->n_rval = p2->n_right->n_rval;
 505 -                p->n_type = p2->n_right->n_type;
 506 -                tfree( p2->n_right );
 507 -                nfree(p2);
 508 -                goto cleanup;
 509 -
 510 -        case ANDAND:
 511 -        case OROR:
 512 -        case NOT/* logical operators */
 513 -                /* if here, must be a logical operator for 0-1 value */
 514 -                p1 = talloc();
 515 -                *p1 = *p;       /* hack to avoid clobber in reclaim() */
 516 -                cbranch( p1, -1, m=getlab() );
 517 -                p->n_op = CCODES;
 518 -                p->n_label = m;
 519 -                order( p, INTAREG );
 520 -                goto cleanup;
 521 -
522358         case FLD:       /* fields of funny type */
 523359                 if ( p1->n_op == UNARY MUL ){
 524360                         offstar( p1->n_left );
     
 !
717553                 ++callflag;
 718554                 return;
 719555 
<>720 -        case COMOP:
 721 -                markcall( p->n_right );
 722 -                if( p->n_right->n_su > fregs ) SETSTO( p, INTEMP );
 723 -                store( p->n_left );
 724 -                return;
 725 -
 726 -        case ANDAND:
 727 -        case OROR:
 728 -        case QUEST:
 729 -                markcall( p->n_right );
 730 -                if( p->n_right->n_su > fregs ) SETSTO( p, INTEMP );
731556         case CBRANCH:   /* to prevent complicated expressions on the LHS from being stored */
<>732 -        case NOT:
733557                 constore( p->n_left );
 734558                 return;
 735559 
     
 !
760584 void
 761585 constore(NODE *p)
 762586 {
<>763 -        switch( p->n_op ) {
 764 -
 765 -        case ANDAND:
 766 -        case OROR:
 767 -        case QUEST:
 768 -                markcall( p->n_right );
 769 -        case NOT:
 770 -                constore( p->n_left );
 771 -                return;
 772 -
 773 -                }
 774 -
775587         store( p );
 776588 }
 777589 
     
 !
907719                 reclaim( p, RNULL, 0 );
 908720                 return;
 909721 
<>910 -        case ANDAND:
 911 -                lab = false<0 ? getlab() : false ;
 912 -                cbranch( p->n_left, -1, lab );
 913 -                cbranch( p->n_right, true, false );
 914 -                if( false < 0 ) deflab( lab );
 915 -                nfree(p);
 916 -                return;
 917 -
 918 -        case OROR:
 919 -                lab = true<0 ? getlab() : true;
 920 -                cbranch( p->n_left, lab, -1 );
 921 -                cbranch( p->n_right, true, false );
 922 -                if( true < 0 ) deflab( lab );
 923 -                nfree(p);
 924 -                return;
 925 -
 926 -        case NOT:
 927 -                cbranch( p->n_left, false, true );
 928 -                nfree(p);
 929 -                break;
 930 -
 931 -        case COMOP:
 932 -                codgen( p->n_left, FOREFF );
 933 -                nfree(p);
 934 -                cbranch( p->n_right, true, false );
 935 -                return;
 936 -
 937 -        case QUEST:
 938 -                flab = false<0 ? getlab() : false;
 939 -                tlab = true<0 ? getlab() : true;
 940 -                cbranch( p->n_left, -1, lab = getlab() );
 941 -                cbranch( p->n_right->n_left, tlab, flab );
 942 -                deflab( lab );
 943 -                cbranch( p->n_right->n_right, true, false );
 944 -                if( true < 0 ) deflab( tlab);
 945 -                if( false < 0 ) deflab( flab );
 946 -                nfree(p->n_right);
 947 -                nfree(p);
 948 -                return;
 949 -
<_950722         case ICON:
 951723                 if( p->n_type != FLOAT && p->n_type != DOUBLE ){
 952724 
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 12:17 +0200