9 date 2007.07.22.13.35.20; author khansen; state Exp;
14 date 2004.12.16.13.21.07; author kenth; state Exp;
19 date 2004.06.30.07.56.49; author kenth; state Exp;
30 @convert tabs to whitespaces
34 * $Id: unit.h,v 1.2 2004/12/16 13:21:07 kenth Exp khansen $
36 * Revision 1.2 2004/12/16 13:21:07 kenth
37 * added unit parent pointer to some structs
39 * Revision 1.1 2004/06/30 07:56:49 kenth
45 * (C) 2004 Kent Hansen
47 * The XORcyst is free software; you can redistribute it and/or modify
48 * it under the terms of the GNU General Public License as published by
49 * the Free Software Foundation; either version 2 of the License, or
50 * (at your option) any later version.
52 * The XORcyst is distributed in the hope that it will be useful,
53 * but WITHOUT ANY WARRANTY; without even the implied warranty of
54 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55 * GNU General Public License for more details.
57 * You should have received a copy of the GNU General Public License
58 * along with The XORcyst; if not, write to the Free Software
59 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
65 /*---------------------------------------------------------------------------*/
66 /* Data structures. */
68 enum tag_constant_type {
73 typedef enum tag_constant_type constant_type;
76 * Describes a constant exported from unit.
79 constant_type type; /* *_CONSTANT */
82 long integer; /* type == INTEGER_CONSTANT */
83 char *string; /* type == STRING_CONSTANT */
85 struct tag_unit *unit; /* Owner unit */
88 typedef struct tag_constant constant;
91 * Describes a symbol located in another unit that this unit references.
97 struct tag_unit *from; /* Unit exported from */
100 typedef struct tag_external external;
102 /* The possible kinds of expression */
105 OPERATOR_EXPRESSION=0,
113 typedef enum tag_expr_type expr_type;
115 /* Attributes of operator expression */
116 struct tag_operator_expr
118 int operator; /* See bytecode header for valid values */
119 struct tag_expression *lhs;
120 struct tag_expression *rhs;
123 typedef struct tag_operator_expr operator_expr;
125 /** Describes an expression. */
126 struct tag_expression
130 operator_expr op_expr; /* type == OPERATOR_EXPRESSION */
131 unsigned long integer; /* type == INTEGER_EXPRESSION */
132 char *string; /* type == STRING_EXPRESSION */
133 int local_id; /* type == LOCAL_EXPRESSION */
134 int extrn_id; /* type == EXTERNAL_EXPRESSION */
136 struct tag_unit *unit; /* Owner unit */
139 typedef struct tag_expression expression;
141 /** The possible kinds of segment. */
142 enum tag_segment_type {
147 typedef enum tag_segment_type segment_type;
150 * A segment of a unit.
153 int size; /* Size in bytes */
154 unsigned char *bytes;
157 typedef struct tag_segment segment;
163 char *name; /* Name of unit */
164 constant *constants; /* Array of exported constants */
165 int const_count; /* Number of exported constants */
166 external *externals; /* Array of imported symbols */
167 int ext_count; /* Number of imported symbols */
168 expression **expressions; /* Array of expressions */
169 int expr_count; /* Number of expressions */
170 segment dataseg; /* The data segment */
171 segment codeseg; /* The code segment */
174 typedef struct tag_unit unit;
176 /*---------------------------------------------------------------------------*/
177 /* Function prototypes. */
179 int unit_read(char *, unit *);
180 void unit_finalize(unit *);
188 @added unit parent pointer to some structs
193 * $Id: unit.h,v 1.1 2004/06/30 07:56:49 kenth Exp kenth $
201 constant_type type; /* *_CONSTANT */
204 long integer; /* type == INTEGER_CONSTANT */
205 char *string; /* type == STRING_CONSTANT */
207 struct tag_unit *unit; /* Owner unit */
212 struct tag_unit *from; /* Unit exported from */
215 OPERATOR_EXPRESSION=0,
223 int operator; /* See bytecode header for valid values */
224 struct tag_expression *lhs;
225 struct tag_expression *rhs;
230 operator_expr op_expr; /* type == OPERATOR_EXPRESSION */
231 unsigned long integer; /* type == INTEGER_EXPRESSION */
232 char *string; /* type == STRING_EXPRESSION */
233 int local_id; /* type == LOCAL_EXPRESSION */
234 int extrn_id; /* type == EXTERNAL_EXPRESSION */
236 struct tag_unit *unit; /* Owner unit */
243 int size; /* Size in bytes */
244 unsigned char *bytes;
247 char *name; /* Name of unit */
248 constant *constants; /* Array of exported constants */
249 int const_count; /* Number of exported constants */
250 external *externals; /* Array of imported symbols */
251 int ext_count; /* Number of imported symbols */
252 expression **expressions; /* Array of expressions */
253 int expr_count; /* Number of expressions */
254 segment dataseg; /* The data segment */
255 segment codeseg; /* The code segment */