15460Slinton /* Copyright (c) 1982 Regents of the University of California */ 25460Slinton 3*5784Slinton /* static char sccsid[] = "@(#)tree.h 1.4 02/13/82"; */ 45460Slinton 55460Slinton /* 65460Slinton * This file contains the declarations of the variables and routines 75460Slinton * within the "tree" subdirectory that are accessible from outside. 85460Slinton */ 95460Slinton 105460Slinton #include "tree/opinfo.h" 115460Slinton 125460Slinton /* 135460Slinton * Evaluation stack manipulation macros. These are publically 145460Slinton * available because "eval" leaves it's result on the stack. 155460Slinton * 165460Slinton * These macros allow one to operate on stacks of arbitrary types 175460Slinton * (including a stack of different typed objects). 185460Slinton * 195460Slinton * Sadly, underflow and overflow are not checked for. 205460Slinton */ 215460Slinton 225460Slinton typedef char STACK; 235460Slinton 245460Slinton #define WMASK (sizeof(int) - 1) 255460Slinton 265460Slinton #define push(type, value) ((type *) (sp += sizeof(type)))[-1] = (value) 275460Slinton #define pop(type) (*((type *) (sp -= sizeof(type)))) 285460Slinton #define alignstack() sp = (char *) (( ((int) sp) + WMASK)&~WMASK) 295460Slinton 305563Slinton STACK stack[]; 315460Slinton STACK *sp; 325460Slinton 335460Slinton NODE *build(); /* create a node in the parse tree */ 345460Slinton prtree(); /* print a tree in source form */ 355460Slinton eval(); /* evaluate a tree, leaving value on stack */ 36*5784Slinton long popsmall(); /* pop a small item from the stack given its type */ 375460Slinton tfree(); /* release storage for a tree */ 385460Slinton BOOLEAN tr_equal(); /* test if two trees are structurally equivalent */ 395460Slinton BOOLEAN cond(); /* evaluate a node for a conditional */ 405460Slinton ADDRESS lval(); /* return the object address of a node */ 415460Slinton BOOLEAN isredirected(); /* TRUE if output is being redirected */ 42