Subversion Repositories tendra.SVN

Rev

Rev 5 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
6 7u83 2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific, prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 *
29
 * $Id$
30
 */
31
/*
2 7u83 32
    		 Crown Copyright (c) 1997
6 7u83 33
 
2 7u83 34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
6 7u83 42
 
2 7u83 43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
6 7u83 45
 
2 7u83 46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
6 7u83 49
 
2 7u83 50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
6 7u83 53
 
2 7u83 54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
 
60
 
61
#ifndef TYPE_INCLUDED
62
#define TYPE_INCLUDED
63
 
6 7u83 64
#ifndef OBJECT_INCLUDED
65
#include "object.h"
66
#endif
2 7u83 67
 
68
/*
69
    TYPE REPRESENTING A C TYPE
70
 
71
    A type consists of a type identifier followed by a union of different
72
    information, depending on the identifier.
73
*/
74
 
75
typedef struct type_tag {
6 7u83 76
    int id;
2 7u83 77
    union {
6 7u83 78
	object *obj;
79
	struct type_tag *subtype;
80
    } u;
2 7u83 81
    union {
6 7u83 82
	int no;
83
	char *str;
84
	object *obj2;
85
	struct type_tag *next;
86
    } v;
87
    boolean state;
88
} type;
2 7u83 89
 
90
 
91
/*
92
    TYPE REPRESENTING A STRUCTURE OR UNION FIELD
93
 
94
    A field of a structure or union consists of an object, giving the
95
    corresponding token, a field name, a field type, and the parent
96
    structure or union type.
97
*/
98
 
99
typedef struct field_tag {
6 7u83 100
    object *obj;
101
    char *fname;
102
    type *ftype;
103
    type *stype;
104
} field;
2 7u83 105
 
106
 
107
/*
108
    TYPE IDENTIFIERS
109
 
110
    These are the valid type identifiers.  The first set consists of the
111
    base types, the second of the compound type constructors.
112
*/
113
 
114
#define TYPE_VOID		0
115
#define TYPE_INT		1
116
#define TYPE_SIGNED		2
117
#define TYPE_UNSIGNED		3
118
#define TYPE_FLOAT		4
119
#define TYPE_ARITH		5
120
#define TYPE_SCALAR		6
121
#define TYPE_STRUCT		7
122
#define TYPE_STRUCT_TAG		8
123
#define TYPE_UNION		9
124
#define TYPE_UNION_TAG		10
125
#define TYPE_ENUM		11
126
#define TYPE_ENUM_TAG		12
127
#define TYPE_GENERIC		13
128
#define TYPE_DEFINED		14
129
 
130
#define TYPE_ARRAY		15
131
#define TYPE_BITFIELD		16
132
#define TYPE_LIST		17
133
#define TYPE_LVALUE		18
134
#define TYPE_PROC		19
135
#define TYPE_PROMOTE		20
136
#define TYPE_PTR		21
137
#define TYPE_QUALIFIER		22
138
#define TYPE_RVALUE		23
139
 
140
 
141
 
142
/*
143
    BASE TYPE SPECIFIERS
144
 
145
    The basic type specifiers are represented as combinations of these
146
    values.
147
*/
148
 
6 7u83 149
#define BTYPE_CHAR		((unsigned)0x0001)
150
#define BTYPE_SHORT		((unsigned)0x0002)
151
#define BTYPE_INT		((unsigned)0x0004)
152
#define BTYPE_LONG		((unsigned)0x0008)
153
#define BTYPE_LLONG		((unsigned)0x0010)
154
#define BTYPE_SIGNED		((unsigned)0x0020)
155
#define BTYPE_UNSIGNED		((unsigned)0x0040)
156
#define BTYPE_FLOAT		((unsigned)0x0080)
157
#define BTYPE_DOUBLE		((unsigned)0x0100)
158
#define BTYPE_VOID		((unsigned)0x0200)
159
#define BTYPE_ERROR		((unsigned)0x0400)
2 7u83 160
 
161
 
162
/*
163
    FUNDAMENTAL TYPES
164
 
165
    These types represent the basic C types.
166
*/
167
 
6 7u83 168
#define BUILTIN(TYPE, NAME, VERS, ID)	extern type *TYPE
2 7u83 169
#include "builtin.h"
170
 
171
 
172
/*
173
    PROCEDURE DECLARATIONS
174
 
175
    These routines are concerned with creating and manipulating types.
176
*/
177
 
6 7u83 178
extern type *basic_type(unsigned);
179
extern type *make_type(char *, int, int);
180
extern type *find_type(char *, int, int, int);
181
extern type *make_subtype(type *, int);
182
extern type *inject_type(type *, type *);
183
extern type *check_type(type *, int);
184
extern type *expand_type(type *);
185
extern field *make_field(char *, int, type *, type *);
186
extern type *special_type(char *);
187
extern void init_types(void);
2 7u83 188
 
189
 
190
#endif