Import of original zoneinfo code and database - tzcode
[minix3.git] / commands / bc / bcdefs.h
bloba9d217657086e31fa9cd3f23d6249ed02643a899
1 /* bcdefs.h: The single file to include all constants and type definitions. */
3 /* This file is part of bc written for MINIX.
4 Copyright (C) 1991, 1992 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License , or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 You may contact the author by:
21 e-mail: phil@cs.wwu.edu
22 us-mail: Philip A. Nelson
23 Computer Science Department, 9062
24 Western Washington University
25 Bellingham, WA 98226-9062
27 *************************************************************************/
29 /* Include the configuration file. */
30 #include "config.h"
32 /* Standard includes for all files. */
33 #include <stdio.h>
34 #include <sys/types.h>
35 #include <ctype.h>
36 #ifdef STRINGS_H
37 #include <strings.h>
38 #else
39 #include <string.h>
40 #endif
41 #ifndef NO_LIMITS
42 #include <limits.h>
43 #endif
45 /* Include the other definitions. */
46 #include "const.h"
47 #include "number.h"
50 /* These definitions define all the structures used in
51 code and data storage. This includes the representation of
52 labels. The "guiding" principle is to make structures that
53 take a minimum of space when unused but can be built to contain
54 the full structures. */
56 /* Labels are first. Labels are generated sequentially in functions
57 and full code. They just "point" to a single bye in the code. The
58 "address" is the byte number. The byte number is used to get an
59 actual character pointer. */
61 typedef struct bc_label_group
63 long l_adrs [ BC_LABEL_GROUP ];
64 struct bc_label_group *l_next;
65 } bc_label_group;
68 /* Each function has its own code segments and labels. There can be
69 no jumps between functions so labels are unique to a function. */
71 typedef struct arg_list
73 int av_name;
74 struct arg_list *next;
75 } arg_list;
77 typedef struct
79 char f_defined; /* Is this function defined yet. */
80 char *f_body[BC_MAX_SEGS];
81 int f_code_size;
82 bc_label_group *f_label;
83 arg_list *f_params;
84 arg_list *f_autos;
85 } bc_function;
87 /* Code addresses. */
88 typedef struct {
89 int pc_func;
90 int pc_addr;
91 } program_counter;
94 /* Variables are "pushable" (auto) and thus we need a stack mechanism.
95 This is built into the variable record. */
97 typedef struct bc_var
99 bc_num v_value;
100 struct bc_var *v_next;
101 } bc_var;
104 /* bc arrays can also be "auto" variables and thus need the same
105 kind of stacking mechanisms. */
107 typedef struct bc_array_node
109 union
111 bc_num n_num [NODE_SIZE];
112 struct bc_array_node *n_down [NODE_SIZE];
113 } n_items;
114 } bc_array_node;
116 typedef struct bc_array
118 bc_array_node *a_tree;
119 short a_depth;
120 } bc_array;
122 typedef struct bc_var_array
124 bc_array *a_value;
125 char a_param;
126 struct bc_var_array *a_next;
127 } bc_var_array;
130 /* For the stacks, execution and function, we need records to allow
131 for arbitrary size. */
133 typedef struct estack_rec {
134 bc_num s_num;
135 struct estack_rec *s_next;
136 } estack_rec;
138 typedef struct fstack_rec {
139 int s_val;
140 struct fstack_rec *s_next;
141 } fstack_rec;
144 /* The following are for the name tree. */
146 typedef struct id_rec {
147 char *id; /* The program name. */
148 /* A name == 0 => nothing assigned yet. */
149 int a_name; /* The array variable name (number). */
150 int f_name; /* The function name (number). */
151 int v_name; /* The variable name (number). */
152 short balance; /* For the balanced tree. */
153 struct id_rec *left, *right; /* Tree pointers. */
154 } id_rec;