1 /* bcdefs.h: The single file to include all constants and type definitions. */
3 /* This file is part of GNU bc.
4 Copyright (C) 1991, 1992, 1993, 1994, 1997 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. */
32 /* Standard includes for all files. */
34 #include <sys/types.h>
45 /* Include the other definitions. */
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
;
67 /* Argument list. Recorded in the function so arguments can
68 be checked at call time. */
70 typedef struct arg_list
73 int arg_is_var
; /* Extension ... variable parameters. */
74 struct arg_list
*next
;
77 /* Each function has its own code segments and labels. There can be
78 no jumps between functions so labels are unique to a function. */
82 char f_defined
; /* Is this function defined yet. */
83 char *f_body
[BC_MAX_SEGS
];
85 bc_label_group
*f_label
;
97 /* Variables are "pushable" (auto) and thus we need a stack mechanism.
98 This is built into the variable record. */
100 typedef struct bc_var
103 struct bc_var
*v_next
;
107 /* bc arrays can also be "auto" variables and thus need the same
108 kind of stacking mechanisms. */
110 typedef struct bc_array_node
114 bc_num n_num
[NODE_SIZE
];
115 struct bc_array_node
*n_down
[NODE_SIZE
];
119 typedef struct bc_array
121 bc_array_node
*a_tree
;
125 typedef struct bc_var_array
129 struct bc_var_array
*a_next
;
133 /* For the stacks, execution and function, we need records to allow
134 for arbitrary size. */
136 typedef struct estack_rec
{
138 struct estack_rec
*s_next
;
141 typedef struct fstack_rec
{
143 struct fstack_rec
*s_next
;
147 /* The following are for the name tree. */
149 typedef struct id_rec
{
150 char *id
; /* The program name. */
151 /* A name == 0 => nothing assigned yet. */
152 int a_name
; /* The array variable name (number). */
153 int f_name
; /* The function name (number). */
154 int v_name
; /* The variable name (number). */
155 short balance
; /* For the balanced tree. */
156 struct id_rec
*left
, *right
; /* Tree pointers. */
160 /* A list of files to process. */
162 typedef struct file_node
{
164 struct file_node
*next
;