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