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