Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.56
 
1.57
 
MAIN:ragge:20030729092018
 
trees.c
_>6363  * Some of the changes from 32V include:
 6464  * - Understand "void" as type.
 6565  * - Handle enums as ints everywhere.
<> 66+ * - Convert some C-specific ops into branches.
6667  */
 6768 
 6869 # include "pass1.h"
     
 !
7475 static int opact(NODE *p);
 7576 static int moditype(TWORD);
 7677 static NODE *strargs(NODE *);
<> 78+static void rmcops(NODE *p);
7779 
 7880 /* corrections when in violation of lint */
 7981 
     
 !
14531455         }
 14541456 }
 14551457 
<> 1458+extern int negrel[];
  1459+
  1460+static void
  1461+andorbr(NODE *p, int true, int false)
  1462+{
  1463+        int o, lab, flab, tlab;
  1464+
  1465+        lab = -1;
  1466+        switch (o = p->n_op) {
  1467+        case ULE:
  1468+        case ULT:
  1469+        case UGE:
  1470+        case UGT:
  1471+        case EQ:
  1472+        case NE:
  1473+        case LE:
  1474+        case LT:
  1475+        case GE:
  1476+        case GT:
  1477+                if (true < 0) {
  1478+                        o = p->n_op = negrel[o - EQ];
  1479+                        true = false;
  1480+                        false = -1;
  1481+                }
  1482+                rmcops(p);
  1483+                ecode(buildtree(CBRANCH, buildtree(NOT, p, NIL), bcon(true)));
  1484+                if (false >= 0)
  1485+                        branch(false);
  1486+                break;
  1487+
  1488+        case ANDAND:
  1489+                lab = false<0 ? getlab() : false ;
  1490+                andorbr(p->n_left, -1, lab);
  1491+                andorbr(p->n_right, true, false);
  1492+                if (false < 0)
  1493+                        deflab(lab);
  1494+                nfree(p);
  1495+                break;
  1496+
  1497+        case OROR:
  1498+                lab = true<0 ? getlab() : true;
  1499+                andorbr(p->n_left, lab, -1);
  1500+                andorbr(p->n_right, true, false);
  1501+                if (true < 0)
  1502+                        deflab(lab);
  1503+                nfree(p);
  1504+                break;
  1505+
  1506+        case NOT:
  1507+                andorbr(p->n_left, false, true);
  1508+                nfree(p);
  1509+                break;
  1510+
  1511+        default:
  1512+                rmcops(p);
  1513+                if (true >= 0)
  1514+                        ecode(buildtree(CBRANCH, buildtree(NOT, p, NIL),
  1515+                            bcon(true)));
  1516+                if (false >= 0) {
  1517+                        if (true >= 0)
  1518+                                branch(false);
  1519+                        else
  1520+                                ecode(buildtree(CBRANCH, p, bcon(false)));
  1521+                }
  1522+        }
  1523+}
  1524+
14561525 int tvaloff;
 14571526 
 14581527 /*
     
 !
14611530 static void
 14621531 rmcops(NODE *p)
 14631532 {
<>1464 -#if 1
14651533         NODE *q, *r;
 14661534         int o, ty, lbl, lbl2, tval;
<>1467 -#else
 1468 -        NODE *q;
 1469 -        int o, ty;
 1470 -#endif
14711535 
 14721536 again:
 14731537         o = p->n_op;
     
 !
14811545         case BITYPE:
 14821546                 switch (o) {
 14831547                 case QUEST:
<>1484 -
  1548+                        tval = tvaloff++;
14851549                         /*
 14861550                          * Create a CBRANCH node from ?:
<> 1551+                         * || and && must be taken special care of.
14871552                          */
<>1488 -                        tval = tvaloff++;
 1489 -                        rmcops(p->n_left);
 1490 -                        q = block(CBRANCH, p->n_left, bcon(lbl = getlab()),
 1491 -                            p->n_type, NULL, p->n_sue);
 1492 -                        ecode(q); /* Done with branch! */
  1553+                        andorbr(p->n_left, -1, lbl = getlab());
14931554 
 14941555                         /* Make ASSIGN node */
 14951556                         /* Only if type is not void */
     
 !
15191580                         send_passt(IP_DEFLAB, lbl2);
 15201581 
 15211582                         nfree(p->n_right);
<>1522 -                        if (p->n_type == VOID) {
 1523 -                                p->n_op = ICON;
 1524 -                                p->n_name = "";
 1525 -                        } else
 1526 -                                p->n_op = TEMP;
  1583+                        p->n_op = p->n_type == VOID ? ICON : TEMP;
15271584                         p->n_lval = tval;
 15281585                         break;
 15291586 
 15301587                 case ANDAND:
 15311588                 case OROR:
 15321589                         rmcops(p->n_left);
<> 1590+                case NOT:
  1591+#ifdef SPECIAL_CCODES
  1592+#error fix for private CCODES handling
  1593+#else
  1594+                        tval = tvaloff++;
  1595+                        q = block(TEMP, NIL, NIL, p->n_type, p->n_df, p->n_sue);
  1596+                        q->n_lval = tval;
  1597+                        r = talloc();
  1598+                        *r = *p;
  1599+                        andorbr(r, -1, lbl = getlab());
  1600+                        r = talloc();
  1601+                        *r = *q;
  1602+                        ecode(buildtree(ASSIGN, q, bcon(1)));
  1603+                        branch(lbl2 = getlab());
  1604+                        send_passt(IP_DEFLAB, lbl);
  1605+                        ecode(buildtree(ASSIGN, r, bcon(0)));
  1606+                        send_passt(IP_DEFLAB, lbl2);
  1607+                        p->n_op = TEMP;
  1608+                        p->n_lval = tval;
  1609+#endif
15331610                         break;
<> 1611+                case CBRANCH:
  1612+                        andorbr(p->n_left, -1, p->n_right->n_lval);
  1613+                        nfree(p->n_right);
  1614+                        p->n_op = ICON; p->n_type = VOID;
  1615+                        break;
<_15341616                 case COMOP:
 15351617                         rmcops(p->n_left);
 15361618                         ecode(p->n_left);
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-07-11 10:00 +0200