2 * $Id: unit.h,v 1.3 2007/07/22 13:35:20 khansen Exp $
4 * Revision 1.3 2007/07/22 13:35:20 khansen
5 * convert tabs to whitespaces
7 * Revision 1.2 2004/12/16 13:21:07 kenth
8 * added unit parent pointer to some structs
10 * Revision 1.1 2004/06/30 07:56:49 kenth
16 * (C) 2004 Kent Hansen
18 * The XORcyst is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * The XORcyst is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with The XORcyst; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 /*---------------------------------------------------------------------------*/
37 /* Data structures. */
39 enum tag_constant_type
{
44 typedef enum tag_constant_type constant_type
;
47 * Describes a constant exported from unit.
50 constant_type type
; /* *_CONSTANT */
53 long integer
; /* type == INTEGER_CONSTANT */
54 char *string
; /* type == STRING_CONSTANT */
56 struct tag_unit
*unit
; /* Owner unit */
59 typedef struct tag_constant constant
;
62 * Describes a symbol located in another unit that this unit references.
68 struct tag_unit
*from
; /* Unit exported from */
71 typedef struct tag_external external
;
73 /* The possible kinds of expression */
76 OPERATOR_EXPRESSION
=0,
84 typedef enum tag_expr_type expr_type
;
86 /* Attributes of operator expression */
87 struct tag_operator_expr
89 int operator; /* See bytecode header for valid values */
90 struct tag_expression
*lhs
;
91 struct tag_expression
*rhs
;
94 typedef struct tag_operator_expr operator_expr
;
96 /** Describes an expression. */
101 operator_expr op_expr
; /* type == OPERATOR_EXPRESSION */
102 unsigned long integer
; /* type == INTEGER_EXPRESSION */
103 char *string
; /* type == STRING_EXPRESSION */
104 int local_id
; /* type == LOCAL_EXPRESSION */
105 int extrn_id
; /* type == EXTERNAL_EXPRESSION */
107 struct tag_unit
*unit
; /* Owner unit */
110 typedef struct tag_expression expression
;
112 /** The possible kinds of segment. */
113 enum tag_segment_type
{
118 typedef enum tag_segment_type segment_type
;
121 * A segment of a unit.
124 int size
; /* Size in bytes */
125 unsigned char *bytes
;
128 typedef struct tag_segment segment
;
134 char *name
; /* Name of unit */
135 constant
*constants
; /* Array of exported constants */
136 int const_count
; /* Number of exported constants */
137 external
*externals
; /* Array of imported symbols */
138 int ext_count
; /* Number of imported symbols */
139 expression
**expressions
; /* Array of expressions */
140 int expr_count
; /* Number of expressions */
141 segment dataseg
; /* The data segment */
142 segment codeseg
; /* The code segment */
145 typedef struct tag_unit unit
;
147 /*---------------------------------------------------------------------------*/
148 /* Function prototypes. */
150 int unit_read(char *, unit
*);
151 void unit_finalize(unit
*);