122580Sdist /* 222580Sdist * Copyright (c) 1980 Regents of the University of California. 322580Sdist * All rights reserved. The Berkeley software License Agreement 422580Sdist * specifies the terms and conditions for redistribution. 522580Sdist * 6*33243Sbostic * @(#)tree.h 5.3 (Berkeley) 01/03/88 722580Sdist */ 85460Slinton 95460Slinton /* 105460Slinton * This file contains the declarations of the variables and routines 115460Slinton * within the "tree" subdirectory that are accessible from outside. 125460Slinton */ 135460Slinton 145460Slinton #include "tree/opinfo.h" 155460Slinton 165460Slinton /* 175460Slinton * Evaluation stack manipulation macros. These are publically 185460Slinton * available because "eval" leaves it's result on the stack. 195460Slinton * 205460Slinton * These macros allow one to operate on stacks of arbitrary types 215460Slinton * (including a stack of different typed objects). 225460Slinton * 235460Slinton * Sadly, underflow and overflow are not checked for. 245460Slinton */ 255460Slinton 265460Slinton typedef char STACK; 275460Slinton 285460Slinton #define WMASK (sizeof(int) - 1) 295460Slinton 3030842Smckusick #ifdef tahoe 3130842Smckusick #define push(type, value) ((*(type *)sp) = value, sp += (sizeof(type) + WMASK) & ~WMASK, value) 3230842Smckusick #define pop(type) (sp -= (sizeof(type) + WMASK) & ~WMASK, (*((type *) sp))) 3330842Smckusick #else 345460Slinton #define push(type, value) ((type *) (sp += sizeof(type)))[-1] = (value) 355460Slinton #define pop(type) (*((type *) (sp -= sizeof(type)))) 3630842Smckusick #endif 375460Slinton #define alignstack() sp = (char *) (( ((int) sp) + WMASK)&~WMASK) 3830842Smckusick #define downalignstack() sp = (char *) (( ((int) sp))&~WMASK) 395460Slinton 405563Slinton STACK stack[]; 415460Slinton STACK *sp; 425460Slinton 435460Slinton NODE *build(); /* create a node in the parse tree */ 44*33243Sbostic int prtree(); /* print a tree in source form */ 45*33243Sbostic int eval(); /* evaluate a tree, leaving value on stack */ 465784Slinton long popsmall(); /* pop a small item from the stack given its type */ 47*33243Sbostic int tfree(); /* release storage for a tree */ 485460Slinton BOOLEAN tr_equal(); /* test if two trees are structurally equivalent */ 495460Slinton BOOLEAN cond(); /* evaluate a node for a conditional */ 505460Slinton ADDRESS lval(); /* return the object address of a node */ 515460Slinton BOOLEAN isredirected(); /* TRUE if output is being redirected */ 52