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