| 1 | /* |
| 2 | * Copyright (c) 1982 Regents of the University of California |
| 3 | * @(#)asscan.h 4.9 %G% |
| 4 | */ |
| 5 | /* |
| 6 | * The character scanner is called to fill up one token buffer |
| 7 | * |
| 8 | * 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 are replaced |
| 11 | * with 'skip' tokens that direct the second pass to ignore the |
| 12 | * following tokens. |
| 13 | */ |
| 14 | |
| 15 | #define TOKBUFLG 4096 |
| 16 | #define MAXVAX 32 |
| 17 | #define SAFETY 16 |
| 18 | |
| 19 | #define AVAILTOKS TOKBUFLG -\ |
| 20 | sizeof(int) -\ |
| 21 | sizeof (struct tokbufdesc *) -\ |
| 22 | MAXVAX - SAFETY |
| 23 | |
| 24 | struct tokbufdesc{ |
| 25 | int tok_count; /*absolute byte length*/ |
| 26 | struct tokbufdesc *tok_next; |
| 27 | char toks[AVAILTOKS]; |
| 28 | char bufovf[MAXVAX + SAFETY]; |
| 29 | }; |
| 30 | /* |
| 31 | * Definitions for handling tokens in the intermediate file |
| 32 | * buffers. |
| 33 | * |
| 34 | * We want to have the compiler produce the efficient auto increment |
| 35 | * instruction for stepping through the buffer of tokens. We must |
| 36 | * fool the type checker into thinking that a pointer can point |
| 37 | * to various size things. |
| 38 | */ |
| 39 | |
| 40 | typedef int inttoktype; |
| 41 | typedef char bytetoktype; |
| 42 | |
| 43 | typedef char *ptrall; /*all uses will be type cast*/ |
| 44 | typedef u_short lgtype; /*for storing length of strings or skiping*/ |
| 45 | /* |
| 46 | * defintions for putting various typed values |
| 47 | * into the intermediate buffers |
| 48 | * ptr will ALWAYS be of type ptrall |
| 49 | */ |
| 50 | |
| 51 | #define pchar(ptr,val) *ptr++ = val |
| 52 | #define puchar(ptr,val) *ptr++ = val |
| 53 | |
| 54 | #define pshort(ptr,val) *(short *)ptr=val, ptr += sizeof(short) |
| 55 | #define plgtype(ptr,val) *(lgtype *)ptr=val, ptr += sizeof(lgtype) |
| 56 | #define pushort(ptr,val) *(u_short *)ptr=val, ptr += sizeof(short) |
| 57 | #define pint(ptr,val) *(int *)ptr = val, ptr += sizeof(int) |
| 58 | #define puint(ptr,val) *(u_int int *)ptr=val, ptr += sizeof(int) |
| 59 | #define plong(ptr,val) *(long *)ptr = val, ptr += sizeof(long) |
| 60 | #define pulong(ptr,val) *(u_int long *)ptr=val, ptr += sizeof(long) |
| 61 | #define pnumber(ptr,val) *(Bignum*)ptr=val, ptr += sizeof(Bignum) |
| 62 | #define popcode(ptr,val) *(struct Opcode*)ptr=val, ptr += sizeof(struct Opcode) |
| 63 | |
| 64 | #define pptr(ptr,val) *(int *)ptr = (val), ptr += sizeof(ptrall) |
| 65 | #define ptoken(ptr,val) *ptr++ = val |
| 66 | #define pskiplg(ptr,val) *(lgtype *)ptr = val, ptr += sizeof(short) |
| 67 | |
| 68 | #define gchar(val, ptr) val = *ptr++ |
| 69 | #define guchar(val, ptr) val = *ptr++ |
| 70 | |
| 71 | #define gshort(val, ptr) val = *(short *)ptr , ptr += sizeof (short) |
| 72 | #define glgtype(val, ptr) val = *(lgtype *)ptr , ptr += sizeof (lgtype) |
| 73 | #define gushort(val, ptr) val = *(u_short *)ptr , ptr += sizeof (short) |
| 74 | #define gint(val, ptr) val = *(int *)ptr, ptr += sizeof (int) |
| 75 | #define guint(val, ptr) val = *(u_int *)ptr, ptr += sizeof (int) |
| 76 | #define glong(val, ptr) val = *(long *)ptr, ptr += sizeof (long) |
| 77 | #define gulong(val, ptr) val = *(u_int *)ptr, ptr += sizeof (long) |
| 78 | #define gnumber(val, ptr) val = *(Bignum *)ptr, ptr += sizeof(Bignum) |
| 79 | #define gopcode(val, ptr) val = *(struct Opcode *)ptr, ptr += sizeof(struct Opcode) |
| 80 | |
| 81 | #define gptr(val, ptr) val = *(int *)ptr, ptr += sizeof (ptrall) |
| 82 | #define gtoken(val, ptr) val = *ptr++ |
| 83 | #define gskiplg(val, ptr) val = *(lgtype *)ptr, ptr += sizeof (short) |
| 84 | |
| 85 | extern ptrall tokptr; /*the next token to consume, call by copy*/ |
| 86 | extern ptrall tokub; /*current upper bound in the current buffer*/ |