1*22580Sdist /* 2*22580Sdist * Copyright (c) 1980 Regents of the University of California. 3*22580Sdist * All rights reserved. The Berkeley software License Agreement 4*22580Sdist * specifies the terms and conditions for redistribution. 5*22580Sdist * 6*22580Sdist * @(#)tree.h 5.1 (Berkeley) 06/06/85 7*22580Sdist */ 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 305460Slinton #define push(type, value) ((type *) (sp += sizeof(type)))[-1] = (value) 315460Slinton #define pop(type) (*((type *) (sp -= sizeof(type)))) 325460Slinton #define alignstack() sp = (char *) (( ((int) sp) + WMASK)&~WMASK) 335460Slinton 345563Slinton STACK stack[]; 355460Slinton STACK *sp; 365460Slinton 375460Slinton NODE *build(); /* create a node in the parse tree */ 385460Slinton prtree(); /* print a tree in source form */ 395460Slinton eval(); /* evaluate a tree, leaving value on stack */ 405784Slinton long popsmall(); /* pop a small item from the stack given its type */ 415460Slinton tfree(); /* release storage for a tree */ 425460Slinton BOOLEAN tr_equal(); /* test if two trees are structurally equivalent */ 435460Slinton BOOLEAN cond(); /* evaluate a node for a conditional */ 445460Slinton ADDRESS lval(); /* return the object address of a node */ 455460Slinton BOOLEAN isredirected(); /* TRUE if output is being redirected */ 46