xref: /original-bsd/usr.bin/pascal/pdx/tree.h (revision 7211505a)
1 /*
2  * Copyright (c) 1980 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  *	@(#)tree.h	5.3 (Berkeley) 01/03/88
7  */
8 
9 /*
10  * This file contains the declarations of the variables and routines
11  * within the "tree" subdirectory that are accessible from outside.
12  */
13 
14 #include "tree/opinfo.h"
15 
16 /*
17  * Evaluation stack manipulation macros.  These are publically
18  * available because "eval" leaves it's result on the stack.
19  *
20  * These macros allow one to operate on stacks of arbitrary types
21  * (including a stack of different typed objects).
22  *
23  * Sadly, underflow and overflow are not checked for.
24  */
25 
26 typedef char STACK;
27 
28 #define WMASK			(sizeof(int) - 1)
29 
30 #ifdef tahoe
31 #define push(type, value)	((*(type *)sp) = value, sp += (sizeof(type) + WMASK) & ~WMASK, value)
32 #define	pop(type)		(sp -= (sizeof(type) + WMASK) & ~WMASK, (*((type *) sp)))
33 #else
34 #define push(type, value)	((type *) (sp += sizeof(type)))[-1] = (value)
35 #define pop(type)		(*((type *) (sp -= sizeof(type))))
36 #endif
37 #define alignstack()		sp = (char *) (( ((int) sp) + WMASK)&~WMASK)
38 #define downalignstack()	sp = (char *) (( ((int) sp))&~WMASK)
39 
40 STACK stack[];
41 STACK *sp;
42 
43 NODE *build();		/* create a node in the parse tree */
44 int prtree();		/* print a tree in source form */
45 int eval();		/* evaluate a tree, leaving value on stack */
46 long popsmall();	/* pop a small item from the stack given its type */
47 int tfree();		/* release storage for a tree */
48 BOOLEAN tr_equal();	/* test if two trees are structurally equivalent */
49 BOOLEAN cond();		/* evaluate a node for a conditional */
50 ADDRESS lval();		/* return the object address of a node */
51 BOOLEAN isredirected();	/* TRUE if output is being redirected */
52