Annotation of researchv10no/cmd/ccom/common/catch2.c, revision 1.1

1.1     ! root        1: # include "mfile2.h"
        !             2: 
        !             3: ttype( t )
        !             4: register TWORD t; 
        !             5: {
        !             6:        /* return the coded type of t */
        !             7:        /* this is called only from the first pass */
        !             8: 
        !             9: # ifdef TWOPTRS
        !            10:        if( ISPTR(t) ) 
        !            11:        {
        !            12:                do 
        !            13:                {
        !            14:                        t = DECREF(t);
        !            15:                } while ( ISARY(t) );
        !            16:                /* arrays that are left are usually only
        !            17:                ** in structure references... 
        !            18:                */
        !            19:                if( TWOPTRS(t) ) return( TPOINT2 );
        !            20:                return( TPOINT );
        !            21:        }
        !            22: # endif
        !            23: 
        !            24:        if( t != BTYPE(t) ) return( TPOINT ); /* TPOINT means not simple! */
        !            25: 
        !            26:        switch( t )
        !            27:        {
        !            28: 
        !            29:        case CHAR:
        !            30:                return( TCHAR );
        !            31:        case SHORT:
        !            32:                return( TSHORT );
        !            33:        case STRTY:
        !            34:        case UNIONTY:
        !            35:                return( TSTRUCT );
        !            36:        case INT:
        !            37:                return( TINT );
        !            38:        case UNSIGNED:
        !            39:                return( TUNSIGNED );
        !            40:        case USHORT:
        !            41:                return( TUSHORT );
        !            42:        case UCHAR:
        !            43:                return( TUCHAR );
        !            44:        case ULONG:
        !            45:                return( TULONG );
        !            46:        case LONG:
        !            47:                return( TLONG );
        !            48:        case FLOAT:
        !            49:                return( TFLOAT );
        !            50:        case DOUBLE:
        !            51:                return( TDOUBLE );
        !            52:        case VOID:
        !            53:                return( TVOID );
        !            54:        }
        !            55:        cerror( "ttype(0%o)", t );
        !            56:        /* NOTREACHED */
        !            57: }
        !            58: 
        !            59: NODE resc[NRGS];
        !            60: 
        !            61: int busy[NRGS];
        !            62: 
        !            63: # define TBUSY 0100
        !            64: 
        !            65: allo0()
        !            66: {
        !            67:        /* free everything */
        !            68:        register i;
        !            69: 
        !            70:        for( i=0; i<NRGS; ++i )
        !            71:        {
        !            72:                busy[i] = 0;
        !            73:        }
        !            74: }
        !            75: 
        !            76: rbusy(r, t )
        !            77: register r; 
        !            78: register TWORD t; 
        !            79: {
        !            80:        /* mark register r busy */
        !            81: 
        !            82: #ifndef NODBG
        !            83:        if( rdebug )
        !            84:        {
        !            85:                printf( "rbusy( %s, ", rnames[r] );
        !            86:                t2print( t );
        !            87:                printf( " )\n" );
        !            88:        }
        !            89: #endif
        !            90:        if( istreg(r) ) 
        !            91:        {
        !            92:                ++busy[r];
        !            93:                if( szty( t ) > 1 )
        !            94:                {
        !            95:                        if( !istreg(r+1) ) cerror( "big register" );
        !            96:                        ++busy[r+1];
        !            97:                }
        !            98:        }
        !            99: }
        !           100: 
        !           101: int tmpoff;  /* offset of next temp to be allocated */
        !           102: 
        !           103: freetemp( k )
        !           104: register k;
        !           105: {
        !           106:        /* allocate k integers worth of temp space
        !           107:        ** we also make the convention that, if the number of words is more than 1,
        !           108:        ** it must be aligned for storing doubles... 
        !           109:        */
        !           110: 
        !           111: # ifndef BACKTEMP
        !           112:        int t;
        !           113: 
        !           114:        if( k>1 )
        !           115:        {
        !           116:                SETOFF( tmpoff, ALDOUBLE );
        !           117:        }
        !           118: 
        !           119:        t = tmpoff;
        !           120:        tmpoff += k*SZINT;
        !           121:        if( tmpoff > maxtemp ) maxtemp = tmpoff;
        !           122:        return(t);
        !           123: 
        !           124: # else
        !           125:        tmpoff += k*SZINT;
        !           126:        if( k>1 ) 
        !           127:        {
        !           128:                SETOFF( tmpoff, ALDOUBLE );
        !           129:        }
        !           130:        if( tmpoff > maxtemp ) maxtemp = tmpoff;
        !           131:        return( -tmpoff );
        !           132: # endif
        !           133: }
        !           134: 
        !           135: allchk()
        !           136: {
        !           137:        /* check to ensure that all register are free */
        !           138:        register i;
        !           139: 
        !           140:        for( i=0; i<NRGS; ++i )
        !           141:        {
        !           142:                if( busy[i] )
        !           143:                {
        !           144:                        cerror( "register allocation error");
        !           145:                }
        !           146:        }
        !           147: }
        !           148: 
        !           149: /* this may not be the best place for this routine... */
        !           150: argsize( p )
        !           151: register NODE *p; 
        !           152: {
        !           153:        /* size of the arguments */
        !           154:        register t;
        !           155:        t = 0;
        !           156:        if( p->tn.op == CM )
        !           157:        {
        !           158:                t = argsize( p->in.left );
        !           159:                p = p->in.right;
        !           160:        }
        !           161:        if( p->tn.type & (TDOUBLE|TFLOAT) )
        !           162:        {
        !           163:                SETOFF( t, ALDOUBLE );
        !           164:                t += SZDOUBLE;
        !           165:        }
        !           166:        else if( p->tn.type & (TLONG|TULONG) )
        !           167:        {
        !           168:                SETOFF( t, ALLONG );
        !           169:                t += SZLONG;
        !           170:        }
        !           171:        else if( p->tn.type & TPOINT )
        !           172:        {
        !           173:                SETOFF( t, ALPOINT );
        !           174:                t += SZPOINT;
        !           175:        }
        !           176:        else if( p->tn.type & TSTRUCT )
        !           177:        {
        !           178:                SETOFF( p->stn.stsize, ALSTACK);  /* alignment */
        !           179:                t += p->stn.stsize;  /* size */
        !           180:        }
        !           181:        else 
        !           182:        {
        !           183:                SETOFF( t, ALINT );
        !           184:                t += SZINT;
        !           185:        }
        !           186:        return( t );
        !           187: }

unix.superglobalmegacorp.com

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