make empty fields work, get rid of pw_class keywords
[unix-history] / usr / src / usr.bin / pascal / px / vars.h
CommitLineData
1259848a
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 *
24ba2374 6 * @(#)vars.h 5.3 (Berkeley) %G%
1259848a 7 */
1e2b51bb
KM
8
9#include <stdio.h>
10
11/*
12 * px - Berkeley Pascal interpreter
13 *
14 * Version 4.0, January 1981
15 *
16 * Original version by Ken Thompson
17 *
18 * Substantial revisions by Bill Joy and Chuck Haley
19 * November-December 1976
20 *
21 * Rewritten for VAX 11/780 by Kirk McKusick
22 * Fall 1978
23 *
24 * Rewritten in ``C'' using libpc by Kirk McKusick
25 * Winter 1981
26 *
27 * Px is described in detail in the "PX 4.0 Implementation Notes"
28 * The source code for px is in several major pieces:
29 *
30 * int.c C main program which reads in interpreter code
31 * interp.c Driver including main interpreter loop and
32 * the interpreter instructions grouped by their
33 * positions in the interpreter table.
1e2b51bb
KM
34 * utilities.c Interpreter exit, backtrace, and runtime statistics.
35 *
36 * In addition there are several headers defining mappings for panic
37 * names into codes, and a definition of the interpreter transfer
38 * table. These are made by the script make.ed1 in this directory and
39 * the routine opc.c from ${PASCALDIR}. (see the makefile for details)
40 */
41#define PXPFILE "pmon.out"
42#define BITSPERBYTE 8
43#define BITSPERLONG (BITSPERBYTE * sizeof(long))
980cb17c 44#define HZ 100
1e2b51bb
KM
45#define NAMSIZ 76
46#define MAXFILES 32
47#define PREDEF 2
a7012926 48#ifdef ADDR32
f568a707 49#ifndef tahoe
1e2b51bb
KM
50#define STDLVL ((struct iorec *)(0x7ffffff1))
51#define GLVL ((struct iorec *)(0x7ffffff0))
f568a707
KM
52#else tahoe
53#define STDLVL ((struct iorec *)(0xbffffff1))
54#define GLVL ((struct iorec *)(0xbffffff0))
55#endif tahoe
a7012926
KM
56#endif ADDR32
57#ifdef ADDR16
9a92014d
KM
58#define STDLVL ((struct iorec *)(0xfff1))
59#define GLVL ((struct iorec *)(0xfff0))
a7012926 60#endif ADDR16
1e2b51bb
KM
61#define FILNIL ((struct iorec *)(0))
62#define INPUT ((struct iorec *)(&input))
63#define OUTPUT ((struct iorec *)(&output))
64#define ERR ((struct iorec *)(&_err))
65#define PX 0 /* normal run of px */
66#define PIX 1 /* load and go */
67#define PIPE 2 /* bootstrap via a pipe */
79029c32 68#define PDX 3 /* invoked by the debugger "pdx" */
1e2b51bb 69#define releq 0
15834a19
KM
70#define relne 2
71#define rellt 4
72#define relgt 6
73#define relle 8
74#define relge 10
9a92014d 75typedef enum {FALSE, TRUE} bool;
1e2b51bb
KM
76
77/*
78 * interrupt and allocation routines
79 */
80extern long createtime;
81extern char *PALLOC();
82extern char *malloc();
9a92014d 83extern long time();
1e2b51bb
KM
84extern intr();
85extern memsize();
1e2b51bb
KM
86extern syserr();
87extern liberr();
88
89/*
796c7f60 90 * stack routines and structures
1e2b51bb 91 */
796c7f60
KM
92struct sze8 {
93 char element[8];
94};
1e2b51bb
KM
95
96/*
97 * emulated pc types
98 */
99union progcntr {
100 char *cp;
101 unsigned char *ucp;
102 short *sp;
103 unsigned short *usp;
104 long *lp;
9a92014d 105 double *dbp;
1e2b51bb 106 struct hdr *hdrp;
24ba2374 107 struct sze8 *s8p;
1e2b51bb
KM
108};
109\f
110/*
111 * THE RUNTIME DISPLAY
112 *
113 * The entries in the display point to the active static block marks.
114 * The first entry in the display is for the global variables,
115 * then the procedure or function at level one, etc.
116 * Each display entry points to a stack frame as shown:
117 *
118 * base of stack frame
119 * ---------------
120 * | |
121 * | block mark |
122 * | |
15834a19
KM
123 * --------------- <-- display entry "stp" points here
124 * | | <-- display entry "locvars" points here
1e2b51bb
KM
125 * | local |
126 * | variables |
127 * | |
128 * ---------------
129 * | |
130 * | expression |
131 * | temporary |
132 * | storage |
133 * | |
134 * - - - - - - - -
135 *
136 * The information in the block mark is thus at positive offsets from
15834a19
KM
137 * the display.stp pointer entries while the local variables are at negative
138 * offsets from display.locvars. The block mark actually consists of
139 * two parts. The first part is created at CALL and the second at entry,
140 * i.e. BEGIN. Thus:
1e2b51bb
KM
141 *
142 * -------------------------
143 * | |
144 * | Saved lino |
145 * | Saved lc |
146 * | Saved dp |
147 * | |
148 * -------------------------
149 * | |
150 * | Saved (dp) |
151 * | |
15834a19
KM
152 * | Pointer to current |
153 * | routine header info |
1e2b51bb 154 * | |
15834a19
KM
155 * | Saved value of |
156 * | "curfile" |
1e2b51bb
KM
157 * | |
158 * | Empty tos value |
159 * | |
160 * -------------------------
161 */
162\f
1e2b51bb
KM
163/*
164 * program variables
165 */
831541c9
KM
166extern union display _display; /* runtime display */
167extern struct dispsave *_dp; /* ptr to active frame */
15834a19
KM
168extern long _lino; /* current line number */
169extern int _argc; /* number of passed args */
170extern char **_argv; /* values of passed args */
9a92014d 171extern bool _nodump; /* TRUE => no post mortum dump */
831541c9 172extern long _runtst; /* TRUE => runtime tests */
15834a19
KM
173extern long _mode; /* execl by PX, PIPE, or PIX */
174extern long _stlim; /* statement limit */
175extern long _stcnt; /* statement count */
50d6e33c 176extern long _seed; /* random number seed */
15834a19
KM
177extern char *_maxptr; /* maximum valid pointer */
178extern char *_minptr; /* minimum valid pointer */
179extern long *_pcpcount; /* pointer to pxp buffer */
180extern long _cntrs; /* number of counters */
181extern long _rtns; /* number of routine cntrs */
182\f
1e2b51bb
KM
183/*
184 * The file i/o routines maintain a notion of a "current file".
185 * A pointer to this file structure is kept in "curfile".
186 *
187 * file structures
188 */
189struct iorechd {
190 char *fileptr; /* ptr to file window */
191 long lcount; /* number of lines printed */
192 long llimit; /* maximum number of text lines */
193 FILE *fbuf; /* FILE ptr */
194 struct iorec *fchain; /* chain to next file */
195 struct iorec *flev; /* ptr to associated file variable */
196 char *pfname; /* ptr to name of file */
197 short funit; /* file status flags */
198 short fblk; /* index into active file table */
199 long fsize; /* size of elements in the file */
200 char fname[NAMSIZ]; /* name of associated UNIX file */
201};
202
203struct iorec {
204 char *fileptr; /* ptr to file window */
205 long lcount; /* number of lines printed */
206 long llimit; /* maximum number of text lines */
207 FILE *fbuf; /* FILE ptr */
208 struct iorec *fchain; /* chain to next file */
209 struct iorec *flev; /* ptr to associated file variable */
210 char *pfname; /* ptr to name of file */
211 short funit; /* file status flags */
212 short fblk; /* index into active file table */
213 long fsize; /* size of elements in the file */
214 char fname[NAMSIZ]; /* name of associated UNIX file */
215 char buf[BUFSIZ]; /* I/O buffer */
216 char window[1]; /* file window element */
217};
15834a19 218\f
1e2b51bb
KM
219/*
220 * unit flags
221 */
222#define FDEF 0x80 /* 1 => reserved file name */
223#define FTEXT 0x40 /* 1 => text file, process EOLN */
224#define FWRITE 0x20 /* 1 => open for writing */
225#define FREAD 0x10 /* 1 => open for reading */
226#define TEMP 0x08 /* 1 => temporary file */
227#define SYNC 0x04 /* 1 => window is out of sync */
228#define EOLN 0x02 /* 1 => at end of line */
229#define EOFF 0x01 /* 1 => at end of file */
230
231/*
232 * file routines
233 */
234extern struct iorec *GETNAME();
235extern char *MKTEMP();
236
237/*
238 * file record variables
239 */
240extern struct iorechd _fchain; /* head of active file chain */
241extern struct iorec *_actfile[]; /* table of active files */
242extern long _filefre; /* last used entry in _actfile */
243
244/*
245 * standard files
246 */
247extern struct iorechd input;
248extern struct iorechd output;
249extern struct iorechd _err;
15834a19 250
1e2b51bb 251/*
15834a19 252 * Px execution profile array
1e2b51bb 253 */
15834a19
KM
254#ifdef PROFILE
255#define NUMOPS 256
256extern long _profcnts[NUMOPS];
257#endif PROFILE