Annotation of 3BSD/cmd/as/asscan.h, revision 1.1

1.1     ! root        1: /* Copyright (c) 1979 Regents of the University of California */
        !             2: 
        !             3: /*
        !             4:  *     The character scanner is called to fill up one token buffer
        !             5:  *
        !             6:  *     In the first pass, the tokens in this buffer may be overwriten
        !             7:  *     to eliminate .stabs, and to change fully assemblable instructions
        !             8:  *     into ascii strings.  However, once the tokens are filled up by the
        !             9:  *     character scanner, they are used in both the first and the second
        !            10:  *     pass.  Holes created by .stab removal and preassembly are replaced
        !            11:  *     with 'skip' tokens that direct the second pass to ignore the
        !            12:  *     following tokens.
        !            13:  *
        !            14:  *     While the first pass could write a second version of the intermediate
        !            15:  *     file and really purge the .stabs and such, the buffering required
        !            16:  *     to do this seems to be too complex and too slow.
        !            17:  */
        !            18: 
        !            19: #define TOKBUFLG               2*BUFSIZ
        !            20: #define MAXVAX                 32              
        !            21: #define SAFETY                 2*NCPS
        !            22: 
        !            23: #define AVAILTOKS              TOKBUFLG -\
        !            24:                sizeof(short) -\
        !            25:                sizeof (struct tokbufdesc *) -\
        !            26:                MAXVAX - SAFETY
        !            27: 
        !            28: struct tokbufdesc{
        !            29:        short           tok_count;              /*absolute byte length*/
        !            30:        struct          tokbufdesc *tok_next;
        !            31:        char            toks[AVAILTOKS];
        !            32:        char            bufovf[MAXVAX + SAFETY];
        !            33: };
        !            34: 
        !            35: /*
        !            36:  *     All variables handling these resources are local to astmpfil.c;
        !            37:  *     we must have the structure defnitions here so that
        !            38:  *     asscan.c can touch the stuff in a token buffer
        !            39:  */
        !            40: 
        !            41: /*
        !            42:  *     Definitions for handling tokens in the intermediate file
        !            43:  *     buffers.
        !            44:  *
        !            45:  *     We want to have the compiler produce the efficient auto increment
        !            46:  *     instruction for stepping through the buffer of tokens.  We must
        !            47:  *     fool the type checker into thinking that a pointer can point
        !            48:  *     to various size things.
        !            49:  */
        !            50: 
        !            51: typedef char toktype;
        !            52: 
        !            53: typedef char *ptrall;                  /*all uses will be type cast*/
        !            54: typedef short lgtype;                  /*for storing length of strings or skiping*/
        !            55: /*
        !            56:  *     defintions for putting various typed values
        !            57:  *     into the intermediate buffers
        !            58:  *     ptr will ALWAYS be of type ptrall
        !            59:  */
        !            60: 
        !            61: #define        pchar(ptr,val)          *ptr++  = val
        !            62: #define        puchar(ptr,val)         *ptr++  = val
        !            63: 
        !            64: #define        pshort(ptr,val)         *(short *)ptr=val,      ptr += sizeof(short)
        !            65: #define        pushort(ptr,val)        *(unsigned short *)ptr=val, ptr += sizeof(short)
        !            66: #define        pint(ptr,val)           *(int *)ptr  = val,     ptr += sizeof(int)
        !            67: #define        puint(ptr,val)          *(unsigned int *)ptr=val, ptr += sizeof(int)
        !            68: #define        plong(ptr,val)          *(long *)ptr  = val,    ptr += sizeof(long)
        !            69: #define        pulong(ptr,val)         *(unsigned long *)ptr=val,ptr += sizeof(long)
        !            70: #define        pfloat(ptr,val)         *(float *)ptr  = val,   ptr += sizeof (float)
        !            71: #define        pdouble(ptr,val)        *(double *)ptr  = val,  ptr += sizeof (double)
        !            72: #define        pptr(ptr,val)           *(int *)ptr  = (val),   ptr += sizeof(ptrall)
        !            73: #define        ptoken(ptr,val)         *ptr++  = val
        !            74: #define        pstrlg(ptr,val)         *(lgtype *)ptr  = val,  ptr += sizeof(short)
        !            75: #define        pskiplg(ptr,val)        *(lgtype *)ptr  = val,  ptr += sizeof(short)
        !            76: 
        !            77: #define        gchar(val, ptr)         val = *ptr++
        !            78: #define        guchar(val, ptr)        val = *ptr++
        !            79: 
        !            80: #define        gshort(val, ptr)        val = *(short *)ptr , ptr += sizeof (short)
        !            81: #define        gushort(val, ptr)       val = *(unsigned short *)ptr , ptr += sizeof (short)
        !            82: #define        gint(val, ptr)          val = *(int *)ptr, ptr += sizeof (int)
        !            83: #define        guint(val, ptr)         val = *(unsigend int *)ptr, ptr += sizeof (int)
        !            84: #define        glong(val, ptr)         val = *(long *)ptr, ptr += sizeof (long)
        !            85: #define        gulong(val, ptr)        val = *(unsigned long *)ptr, ptr += sizeof (long)
        !            86: #define        gfloat(val, ptr)        val = *(float *)ptr, ptr += sizeof (float)
        !            87: #define        gdouble(val, ptr)       val = *(double *)ptr, ptr += sizeof (double)
        !            88: #define        gptr(val, ptr)          val = *(int *)ptr, ptr += sizeof (ptrall)
        !            89: #define        gtoken(val, ptr)        val = *ptr++
        !            90: #define        gstrlg(val, ptr)        val = *(lgtype *)ptr, ptr += sizeof (short)
        !            91: #define        gskiplg(val, ptr)       val = *(lgtype *)ptr, ptr += sizeof (short)
        !            92: 
        !            93: 
        !            94: ptrall tokptr; /*the next token to consume, call by copy*/
        !            95: ptrall tokub;  /*current upper bound in the current buffer*/
        !            96: 
        !            97: /*
        !            98:  *     Strings are known for their characters and for their length.
        !            99:  *     We cannot use a normal zero termination byte, because strings
        !           100:  *     can contain anything.
        !           101:  *
        !           102:  *     We have two "strings", so that an input string that is too long can be
        !           103:  *     split across two string buffers, and not confuse the yacc grammar.
        !           104:  *     (This is probably superflous)
        !           105:  *
        !           106:  *     We have a third string of nulls so that the .skip can be 
        !           107:  *     handled in the same way as strings.
        !           108:  */
        !           109: #define MAXSTRLG       127
        !           110: 
        !           111: struct strdesc{
        !           112:        char            str_lg;
        !           113:        char            str[MAXSTRLG];
        !           114: };
        !           115: 
        !           116: struct         strdesc         strbuf[3];
        !           117: struct         strdesc         *strptr;        /*points to the current string*/
        !           118: int                    strno;          /*the current string being filled*/

unix.superglobalmegacorp.com

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