00001 /* bcdefs.h: The single file to include all constants and type definitions. */ 00002 00003 /* This file is part of bc written for MINIX. 00004 Copyright (C) 1991, 1992 Free Software Foundation, Inc. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License , or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; see the file COPYING. If not, write to 00018 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 00019 00020 You may contact the author by: 00021 e-mail: phil@cs.wwu.edu 00022 us-mail: Philip A. Nelson 00023 Computer Science Department, 9062 00024 Western Washington University 00025 Bellingham, WA 98226-9062 00026 00027 *************************************************************************/ 00028 00029 /* Include the configuration file. */ 00030 #include "config.h" 00031 00032 /* Standard includes for all files. */ 00033 #include <stdio.h> 00034 #include <sys/types.h> 00035 #include <ctype.h> 00036 #ifdef STRINGS_H 00037 #include <strings.h> 00038 #else 00039 #include <string.h> 00040 #endif 00041 #ifndef NO_LIMITS 00042 #include <limits.h> 00043 #endif 00044 00045 /* Include the other definitions. */ 00046 #include "const.h" 00047 #include "number.h" 00048 00049 00050 /* These definitions define all the structures used in 00051 code and data storage. This includes the representation of 00052 labels. The "guiding" principle is to make structures that 00053 take a minimum of space when unused but can be built to contain 00054 the full structures. */ 00055 00056 /* Labels are first. Labels are generated sequentially in functions 00057 and full code. They just "point" to a single bye in the code. The 00058 "address" is the byte number. The byte number is used to get an 00059 actual character pointer. */ 00060 00061 typedef struct bc_label_group 00062 { 00063 long l_adrs [ BC_LABEL_GROUP ]; 00064 struct bc_label_group *l_next; 00065 } bc_label_group; 00066 00067 00068 /* Each function has its own code segments and labels. There can be 00069 no jumps between functions so labels are unique to a function. */ 00070 00071 typedef struct arg_list 00072 { 00073 int av_name; 00074 struct arg_list *next; 00075 } arg_list; 00076 00077 typedef struct 00078 { 00079 char f_defined; /* Is this function defined yet. */ 00080 char *f_body[BC_MAX_SEGS]; 00081 int f_code_size; 00082 bc_label_group *f_label; 00083 arg_list *f_params; 00084 arg_list *f_autos; 00085 } bc_function; 00086 00087 /* Code addresses. */ 00088 typedef struct { 00089 int pc_func; 00090 int pc_addr; 00091 } program_counter; 00092 00093 00094 /* Variables are "pushable" (auto) and thus we need a stack mechanism. 00095 This is built into the variable record. */ 00096 00097 typedef struct bc_var 00098 { 00099 bc_num v_value; 00100 struct bc_var *v_next; 00101 } bc_var; 00102 00103 00104 /* bc arrays can also be "auto" variables and thus need the same 00105 kind of stacking mechanisms. */ 00106 00107 typedef struct bc_array_node 00108 { 00109 union 00110 { 00111 bc_num n_num [NODE_SIZE]; 00112 struct bc_array_node *n_down [NODE_SIZE]; 00113 } n_items; 00114 } bc_array_node; 00115 00116 typedef struct bc_array 00117 { 00118 bc_array_node *a_tree; 00119 short a_depth; 00120 } bc_array; 00121 00122 typedef struct bc_var_array 00123 { 00124 bc_array *a_value; 00125 char a_param; 00126 struct bc_var_array *a_next; 00127 } bc_var_array; 00128 00129 00130 /* For the stacks, execution and function, we need records to allow 00131 for arbitrary size. */ 00132 00133 typedef struct estack_rec { 00134 bc_num s_num; 00135 struct estack_rec *s_next; 00136 } estack_rec; 00137 00138 typedef struct fstack_rec { 00139 int s_val; 00140 struct fstack_rec *s_next; 00141 } fstack_rec; 00142 00143 00144 /* The following are for the name tree. */ 00145 00146 typedef struct id_rec { 00147 char *id; /* The program name. */ 00148 /* A name == 0 => nothing assigned yet. */ 00149 int a_name; /* The array variable name (number). */ 00150 int f_name; /* The function name (number). */ 00151 int v_name; /* The variable name (number). */ 00152 short balance; /* For the balanced tree. */ 00153 struct id_rec *left, *right; /* Tree pointers. */ 00154 } id_rec;
1.4.6