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