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