source: trunk/minix/commands/bc/bcdefs.h@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 4.1 KB
Line 
1/* bcdefs.h: The single file to include all constants and type definitions. */
2
3/* This file is part of bc written for MINIX.
4 Copyright (C) 1991, 1992 Free Software Foundation, Inc.
5
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.
10
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.
15
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.
19
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
26
27*************************************************************************/
28
29/* Include the configuration file. */
30#include "config.h"
31
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
44
45/* Include the other definitions. */
46#include "const.h"
47#include "number.h"
48
49
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. */
55
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. */
60
61typedef struct bc_label_group
62 {
63 long l_adrs [ BC_LABEL_GROUP ];
64 struct bc_label_group *l_next;
65 } bc_label_group;
66
67
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. */
70
71typedef struct arg_list
72 {
73 int av_name;
74 struct arg_list *next;
75 } arg_list;
76
77typedef struct
78 {
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;
86
87/* Code addresses. */
88typedef struct {
89 int pc_func;
90 int pc_addr;
91 } program_counter;
92
93
94/* Variables are "pushable" (auto) and thus we need a stack mechanism.
95 This is built into the variable record. */
96
97typedef struct bc_var
98 {
99 bc_num v_value;
100 struct bc_var *v_next;
101 } bc_var;
102
103
104/* bc arrays can also be "auto" variables and thus need the same
105 kind of stacking mechanisms. */
106
107typedef struct bc_array_node
108 {
109 union
110 {
111 bc_num n_num [NODE_SIZE];
112 struct bc_array_node *n_down [NODE_SIZE];
113 } n_items;
114 } bc_array_node;
115
116typedef struct bc_array
117 {
118 bc_array_node *a_tree;
119 short a_depth;
120 } bc_array;
121
122typedef struct bc_var_array
123 {
124 bc_array *a_value;
125 char a_param;
126 struct bc_var_array *a_next;
127 } bc_var_array;
128
129
130/* For the stacks, execution and function, we need records to allow
131 for arbitrary size. */
132
133typedef struct estack_rec {
134 bc_num s_num;
135 struct estack_rec *s_next;
136} estack_rec;
137
138typedef struct fstack_rec {
139 int s_val;
140 struct fstack_rec *s_next;
141} fstack_rec;
142
143
144/* The following are for the name tree. */
145
146typedef 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;
Note: See TracBrowser for help on using the repository browser.