show PC of labels
[xorcyst.git] / RCS / unit.h,v
blobf551f212e0e566740fe164d8bb6e17df2d8612d6
1 head    1.3;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
8 1.3
9 date    2007.07.22.13.35.20;    author khansen; state Exp;
10 branches;
11 next    1.2;
13 1.2
14 date    2004.12.16.13.21.07;    author kenth;   state Exp;
15 branches;
16 next    1.1;
18 1.1
19 date    2004.06.30.07.56.49;    author kenth;   state Exp;
20 branches;
21 next    ;
24 desc
28 1.3
29 log
30 @convert tabs to whitespaces
32 text
33 @/*
34  * $Id: unit.h,v 1.2 2004/12/16 13:21:07 kenth Exp khansen $
35  * $Log: unit.h,v $
36  * Revision 1.2  2004/12/16 13:21:07  kenth
37  * added unit parent pointer to some structs
38  *
39  * Revision 1.1  2004/06/30 07:56:49  kenth
40  * Initial revision
41  *
42  */
44 /**
45  *    (C) 2004 Kent Hansen
46  *
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.
51  *
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.
56  *
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
60  */
62 #ifndef UNIT_H
63 #define UNIT_H
65 /*---------------------------------------------------------------------------*/
66 /* Data structures. */
68 enum tag_constant_type {
69     INTEGER_CONSTANT=0,
70     STRING_CONSTANT
73 typedef enum tag_constant_type constant_type;
75 /**
76  * Describes a constant exported from unit.
77  */
78 struct tag_constant {
79     constant_type type; /* *_CONSTANT */
80     char *name;
81     union {
82         long integer;   /* type == INTEGER_CONSTANT */
83         char *string;   /* type == STRING_CONSTANT */
84     };
85     struct tag_unit *unit;  /* Owner unit */
88 typedef struct tag_constant constant;
90 /**
91  * Describes a symbol located in another unit that this unit references.
92  */
93 struct tag_external
95     unsigned char unit;
96     char *name;
97     struct tag_unit *from;  /* Unit exported from */
100 typedef struct tag_external external;
102 /* The possible kinds of expression */
103 enum tag_expr_type
105     OPERATOR_EXPRESSION=0,
106     INTEGER_EXPRESSION,
107     STRING_EXPRESSION,
108     LOCAL_EXPRESSION,
109     EXTERNAL_EXPRESSION,
110     PC_EXPRESSION
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
128     expr_type type;
129     union {
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 */
135     };
136     struct tag_unit *unit;  /* Owner unit */
139 typedef struct tag_expression expression;
141 /** The possible kinds of segment. */
142 enum tag_segment_type {
143     DATA_SEGMENT=0,
144     CODE_SEGMENT
147 typedef enum tag_segment_type segment_type;
150  * A segment of a unit.
151  */
152 struct tag_segment {
153     int size;   /* Size in bytes */
154     unsigned char *bytes;
157 typedef struct tag_segment segment;
160  * Describes a unit.
161  */
162 struct tag_unit {
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 *);
182 #endif  /* !UNIT_H */
188 @added unit parent pointer to some structs
190 text
191 @d2 1
192 a2 1
193  * $Id: unit.h,v 1.1 2004/06/30 07:56:49 kenth Exp kenth $
194 d4 3
195 d37 2
196 a38 2
197         INTEGER_CONSTANT=0,
198         STRING_CONSTANT
199 d47 7
200 a53 7
201         constant_type type;     /* *_CONSTANT */
202         char *name;
203         union {
204                 long integer;   /* type == INTEGER_CONSTANT */
205                 char *string;   /* type == STRING_CONSTANT */
206         };
207         struct tag_unit *unit;  /* Owner unit */
208 d63 3
209 a65 3
210         unsigned char unit;
211         char *name;
212         struct tag_unit *from;  /* Unit exported from */
213 d73 6
214 a78 6
215         OPERATOR_EXPRESSION=0,
216         INTEGER_EXPRESSION,
217         STRING_EXPRESSION,
218         LOCAL_EXPRESSION,
219         EXTERNAL_EXPRESSION,
220         PC_EXPRESSION
221 d86 3
222 a88 3
223         int operator;   /* See bytecode header for valid values */
224         struct tag_expression *lhs;
225         struct tag_expression *rhs;
226 d96 9
227 a104 9
228         expr_type type;
229         union {
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 */
235         };
236         struct tag_unit *unit;  /* Owner unit */
237 d111 2
238 a112 2
239         DATA_SEGMENT=0,
240         CODE_SEGMENT
241 d121 2
242 a122 2
243         int size;       /* Size in bytes */
244         unsigned char *bytes;
245 d131 9
246 a139 9
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 */
256 d150 1
257 a150 1
258 #endif  /* !UNIT_H */
264 @Initial revision
266 text
267 @d2 5
268 a6 2
269  * $Id$
270  * $Log$
271 d50 1
272 d62 1
273 d101 1