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, Inc.
19
59 Temple Place, Suite 330
22
You may contact the author by:
23
e-mail: philnelson@acm.org
24
us-mail: Philip A. Nelson
25
Computer Science Department, 9062
26
Western Washington University
27
Bellingham, WA 98226-9062
29
*************************************************************************/
31
/* Include the configuration file. */
34
/* Standard includes for all files. */
36
#include <sys/types.h>
52
#include <readline/readline.h>
53
#include <readline/history.h>
56
/* Include the other definitions. */
60
/* These definitions define all the structures used in
61
code and data storage. This includes the representation of
62
labels. The "guiding" principle is to make structures that
63
take a minimum of space when unused but can be built to contain
64
the full structures. */
66
/* Labels are first. Labels are generated sequentially in functions
67
and full code. They just "point" to a single bye in the code. The
68
"address" is the byte number. The byte number is used to get an
69
actual character pointer. */
71
typedef struct bc_label_group
73
long l_adrs [ BC_LABEL_GROUP ];
74
struct bc_label_group *l_next;
77
/* Argument list. Recorded in the function so arguments can
78
be checked at call time. */
80
typedef struct arg_list
83
int arg_is_var; /* Extension ... variable parameters. */
84
struct arg_list *next;
87
/* Each function has its own code segments and labels. There can be
88
no jumps between functions so labels are unique to a function. */
92
char f_defined; /* Is this function defined yet. */
94
int f_body_size; /* Size of body. Power of 2. */
96
bc_label_group *f_label;
101
/* Code addresses. */
108
/* Variables are "pushable" (auto) and thus we need a stack mechanism.
109
This is built into the variable record. */
111
typedef struct bc_var
114
struct bc_var *v_next;
118
/* bc arrays can also be "auto" variables and thus need the same
119
kind of stacking mechanisms. */
121
typedef struct bc_array_node
125
bc_num n_num [NODE_SIZE];
126
struct bc_array_node *n_down [NODE_SIZE];
130
typedef struct bc_array
132
bc_array_node *a_tree;
136
typedef struct bc_var_array
140
struct bc_var_array *a_next;
144
/* For the stacks, execution and function, we need records to allow
145
for arbitrary size. */
147
typedef struct estack_rec {
149
struct estack_rec *s_next;
152
typedef struct fstack_rec {
154
struct fstack_rec *s_next;
158
/* The following are for the name tree. */
160
typedef struct id_rec {
161
char *id; /* The program name. */
162
/* A name == 0 => nothing assigned yet. */
163
int a_name; /* The array variable name (number). */
164
int f_name; /* The function name (number). */
165
int v_name; /* The variable name (number). */
166
short balance; /* For the balanced tree. */
167
struct id_rec *left, *right; /* Tree pointers. */
171
/* A list of files to process. */
173
typedef struct file_node {
175
struct file_node *next;
178
/* Macro Definitions */
181
#define HISTORY_SIZE(n) history(hist, &histev, H_SETSIZE, n)
182
#define UNLIMIT_HISTORY history(hist, &histev, H_SETSIZE, INT_MAX)
185
#if defined(READLINE)
186
#define HISTORY_SIZE(n) stifle_history(n)
187
#define UNLIMIT_HISTORY unstifle_history()