xref: /csrg-svn/usr.bin/pascal/pdx/tree.h (revision 62131)
148104Sbostic /*-
2*62131Sbostic  * Copyright (c) 1980, 1993
3*62131Sbostic  *	The Regents of the University of California.  All rights reserved.
422580Sdist  *
548104Sbostic  * %sccs.include.redist.c%
648104Sbostic  *
7*62131Sbostic  *	@(#)tree.h	8.1 (Berkeley) 06/06/93
822580Sdist  */
95460Slinton 
105460Slinton /*
115460Slinton  * This file contains the declarations of the variables and routines
125460Slinton  * within the "tree" subdirectory that are accessible from outside.
135460Slinton  */
145460Slinton 
155460Slinton #include "tree/opinfo.h"
165460Slinton 
175460Slinton /*
185460Slinton  * Evaluation stack manipulation macros.  These are publically
195460Slinton  * available because "eval" leaves it's result on the stack.
205460Slinton  *
215460Slinton  * These macros allow one to operate on stacks of arbitrary types
225460Slinton  * (including a stack of different typed objects).
235460Slinton  *
245460Slinton  * Sadly, underflow and overflow are not checked for.
255460Slinton  */
265460Slinton 
275460Slinton typedef char STACK;
285460Slinton 
295460Slinton #define WMASK			(sizeof(int) - 1)
305460Slinton 
3130842Smckusick #ifdef tahoe
3230842Smckusick #define push(type, value)	((*(type *)sp) = value, sp += (sizeof(type) + WMASK) & ~WMASK, value)
3330842Smckusick #define	pop(type)		(sp -= (sizeof(type) + WMASK) & ~WMASK, (*((type *) sp)))
3430842Smckusick #else
355460Slinton #define push(type, value)	((type *) (sp += sizeof(type)))[-1] = (value)
365460Slinton #define pop(type)		(*((type *) (sp -= sizeof(type))))
3730842Smckusick #endif
385460Slinton #define alignstack()		sp = (char *) (( ((int) sp) + WMASK)&~WMASK)
3930842Smckusick #define downalignstack()	sp = (char *) (( ((int) sp))&~WMASK)
405460Slinton 
415563Slinton STACK stack[];
425460Slinton STACK *sp;
435460Slinton 
445460Slinton NODE *build();		/* create a node in the parse tree */
4533243Sbostic int prtree();		/* print a tree in source form */
4633243Sbostic int eval();		/* evaluate a tree, leaving value on stack */
475784Slinton long popsmall();	/* pop a small item from the stack given its type */
4833243Sbostic int tfree();		/* release storage for a tree */
495460Slinton BOOLEAN tr_equal();	/* test if two trees are structurally equivalent */
505460Slinton BOOLEAN cond();		/* evaluate a node for a conditional */
515460Slinton ADDRESS lval();		/* return the object address of a node */
525460Slinton BOOLEAN isredirected();	/* TRUE if output is being redirected */
53