Annotation of researchv10no/cmd/trace/assert.c, revision 1.1

1.1     ! root        1: #include "trace.h"
        !             2: #include "trace.d"
        !             3: 
        !             4:  extern struct TBL *tbl;
        !             5:  extern int *globvars, nrvars;
        !             6:  extern int assertbl, abase, errortbl, ebase;
        !             7: 
        !             8: require(TT, stuff, by)
        !             9: {
        !            10:        if (assertbl != NONE)
        !            11:                assert(TT, stuff, by);
        !            12:        if (errortbl != NONE)
        !            13:                errort(TT, stuff, by);
        !            14: }
        !            15: 
        !            16: inscope(TT, stuff, by)
        !            17: { register int i;
        !            18: 
        !            19:        for (i = 0; i < tbl[assertbl].nrcols; i++)
        !            20:                if (TT == tbl[assertbl].coltyp[i]
        !            21:                &&  stuff == tbl[assertbl].colmap[i]
        !            22:                &&  by == tbl[assertbl].colorg[i])
        !            23:                        return 1;
        !            24: 
        !            25:        return 0;
        !            26: }
        !            27: 
        !            28: assert(TT, stuff, by)
        !            29: { int h, i, j, x, frst;
        !            30: 
        !            31:        for (frst = 0; frst < tbl[assertbl].nrcols; frst++)
        !            32:                if (tbl[assertbl].coltyp[frst] == TT
        !            33:                &&  stuff == tbl[assertbl].colmap[frst]
        !            34:                &&  by == tbl[assertbl].colorg[frst])
        !            35:                        break;
        !            36: 
        !            37:        if (frst == tbl[assertbl].nrcols)
        !            38:                return;         /* not within assertion's scope */
        !            39: 
        !            40:        for (i = 0; i < tbl[assertbl].nrrows; i++)
        !            41:        {
        !            42:                if (globvars[i+abase] != 1)
        !            43:                        continue;
        !            44: 
        !            45:                for (j = frst; j < tbl[assertbl].nrcols; j++)
        !            46:                {
        !            47:                        if (TT == tbl[assertbl].coltyp[j]
        !            48:                        &&  stuff == tbl[assertbl].colmap[j]
        !            49:                        &&  by == tbl[assertbl].colorg[j])
        !            50:                        {
        !            51:                         if (tbl[assertbl].ptr[i][j].nrpils == 0)
        !            52:                                output("assertion violated: ", 1);
        !            53:                         else
        !            54:                         for (h = 0; h < tbl[assertbl].ptr[i][j].nrpils; h++)
        !            55:                         {      x = tbl[assertbl].ptr[i][j].one[h].transf;
        !            56:                                globvars[x+abase] = 2;
        !            57:                                globvars[i+abase] = 0;
        !            58:        }       }       }}
        !            59:        for (i = abase; i < nrvars; i++)
        !            60:                if (globvars[i] == 2)
        !            61:                        globvars[i] = 1;
        !            62: }
        !            63: 
        !            64: assertholds()
        !            65: { int i;
        !            66:        if (assertbl == NONE)
        !            67:                return 1;
        !            68: 
        !            69:        for (i = abase; i < nrvars; i++)
        !            70:                if (globvars[i] && tbl[assertbl].endrow[i-abase])
        !            71:                        return 1;
        !            72:        return 0;
        !            73: }
        !            74: 
        !            75: errort(TT, stuff, by)
        !            76: { int h, i, j, x, frst;
        !            77: 
        !            78:        for (frst = 0; frst < tbl[errortbl].nrcols; frst++)
        !            79:                if (tbl[errortbl].coltyp[frst] == TT
        !            80:                &&  stuff == tbl[errortbl].colmap[frst]
        !            81:                &&  by == tbl[errortbl].colorg[frst])
        !            82:                        break;
        !            83: 
        !            84:        if (frst == tbl[errortbl].nrcols)
        !            85:                return;         /* not within assertion's scope */
        !            86: 
        !            87:        for (i = 0; i < tbl[errortbl].nrrows; i++)
        !            88:        {
        !            89:                if (globvars[i+ebase] != 1)
        !            90:                        continue;
        !            91: 
        !            92:                for (j = frst; j < tbl[errortbl].nrcols; j++)
        !            93:                {
        !            94:                        if (TT == tbl[errortbl].coltyp[j]
        !            95:                        &&  stuff == tbl[errortbl].colmap[j]
        !            96:                        &&  by == tbl[errortbl].colorg[j])
        !            97:                        {
        !            98:                         if (tbl[errortbl].ptr[i][j].nrpils == 0)
        !            99:                                globvars[i+ebase] = 0;
        !           100:                         else
        !           101:                         for (h = 0; h < tbl[errortbl].ptr[i][j].nrpils; h++)
        !           102:                         {      x = tbl[errortbl].ptr[i][j].one[h].transf;
        !           103:                                globvars[x+ebase] = 2;
        !           104:                                globvars[i+ebase] = 0;
        !           105:                         }
        !           106:                        }
        !           107:                }
        !           108:        }
        !           109:        for (i = ebase; i < nrvars; i++)
        !           110:                if (globvars[i] == 2)
        !           111:                {       globvars[i] = 1;
        !           112:                        if (tbl[errortbl].endrow[i-ebase])
        !           113:                                output("error matched: ", 2);
        !           114:                }
        !           115:        globvars[ebase] = 1;
        !           116: }
        !           117: 
        !           118: peekassert(ice)
        !           119:        struct FREEZE *ice;
        !           120: { register int i;
        !           121:   if (assertbl != NONE)
        !           122:        for (i = abase; i < nrvars; i++)
        !           123:                globvars[i] = ice->varsaved[i];
        !           124:   else if (errortbl != NONE)
        !           125:        for (i = ebase; i < nrvars; i++)
        !           126:                globvars[i] = ice->varsaved[i];
        !           127: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.