Commit | Line | Data |
---|---|---|
ae45b4cd KB |
1 | /* |
2 | * Copyright (c) 1982 Regents of the University of California | |
3 | * @(#)asscan.h 4.9 6/30/83 | |
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 MAXTAHOE 32 | |
17 | #define SAFETY 16 | |
18 | ||
19 | #define AVAILTOKS TOKBUFLG -\ | |
20 | sizeof(int) -\ | |
21 | sizeof (struct tokbufdesc *) -\ | |
22 | MAXTAHOE - SAFETY | |
23 | ||
24 | struct tokbufdesc{ | |
25 | int tok_count; /*absolute byte length*/ | |
26 | struct tokbufdesc *tok_next; | |
27 | char toks[AVAILTOKS]; | |
28 | char bufovf[MAXTAHOE + 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 inttoktype; */ | |
42 | typedef char bytetoktype; | |
43 | ||
44 | typedef char *ptrall; /*all uses will be type cast*/ | |
45 | typedef u_short lgtype; /*for storing length of strings or skiping*/ | |
46 | /* | |
47 | * defintions for putting various typed values | |
48 | * into the intermediate buffers | |
49 | * ptr will ALWAYS be of type ptrall | |
50 | */ | |
51 | ||
52 | #define ptype(type, ptr, val) \ | |
53 | (ptr) = (char *)((int)((ptr) + sizeof(type)-1)&~(sizeof(type)-1)), \ | |
54 | *(type *)(ptr) = (val), (ptr) += sizeof(type) | |
55 | ||
56 | #define pchar(ptr, val) *(ptr)++ = (val) | |
57 | #define puchar(ptr, val) *(ptr)++ = (val) | |
58 | ||
59 | #define pshort(ptr, val) ptype (short, ptr, val) | |
60 | #define plgtype(ptr, val) ptype (lgtype, ptr, val) | |
61 | #define pushort(ptr, val) ptype (u_short, ptr, val) | |
62 | #define pint(ptr, val) ptype (int, ptr, val) | |
63 | #define puint(ptr, val) ptype (u_int, ptr, val) | |
64 | #define plong(ptr, val) ptype (long, ptr, val) | |
65 | #define pulong(ptr, val) ptype (u_int, ptr, val) | |
66 | #define pnumber(ptr, val) ptype (Bignum, ptr, val) | |
67 | #define pptr(ptr, val) ptype (int, ptr, val) | |
68 | #define popcode(ptr, val) *(ptr)++ = (val) | |
69 | #define ptoken(ptr, val) *(ptr)++ = (val) | |
70 | #define pskiplg(ptr, val) ptype (lgtype, ptr, val) | |
71 | ||
72 | ||
73 | #define gtype(type, ptr, val) \ | |
74 | (ptr) = (char *)((int)((ptr) + sizeof(type)-1)&~(sizeof(type)-1)), \ | |
75 | (val) = *(type *)(ptr) , (ptr) += sizeof(type) | |
76 | ||
77 | #define gchar(val, ptr) (val) = *(ptr)++ | |
78 | #define guchar(val, ptr) (val) = *(ptr)++ | |
79 | ||
80 | #define gshort(val, ptr) gtype (short, ptr, val) | |
81 | #define glgtype(ptr, val) gtype (lgtype, ptr, val) | |
82 | #define gushort(val, ptr) gtype (u_short, ptr, val) | |
83 | #define gint(val, ptr) gtype (int, ptr, val) | |
84 | #define guint(val, ptr) gtype (u_int, ptr, val) | |
85 | #define glong(val, ptr) gtype (long, ptr, val) | |
86 | #define gulong(val, ptr) gtype (u_int, ptr, val) | |
87 | #define gnumber(val, ptr) gtype (Bignum, ptr, val) | |
88 | #define gptr(val, ptr) gtype (int, ptr, val) | |
89 | #define gopcode(val, ptr) (val) = *(ptr)++ | |
90 | #define gtoken(val, ptr) (val) = *(ptr)++ | |
91 | #define gskiplg(val, ptr) gtype (lgtype, ptr, val) | |
92 | ||
93 | ||
94 | extern ptrall tokptr; /*the next token to consume, call by copy*/ | |
95 | extern ptrall tokub; /*current upper bound in the current buffer*/ |