Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5/src/tools/tspec/object.c – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
#include "config.h"
32
#include "object.h"
33
#include "hash.h"
34
#include "name.h"
35
#include "type.h"
36
#include "utility.h"
37
#include "variable.h"
38
 
39
 
40
/*
41
    CREATE A NEW OBJECT
42
 
43
    This routine creates a new object, with name nm and type t.
44
*/
45
 
46
object *make_object
47
    PROTO_N ( ( nm, t ) )
48
    PROTO_T ( char *nm X int t )
49
{
50
    object *p ;
51
    alloc_variable ( p, object, 1000 ) ;
52
    p->name = nm ;
53
    p->objtype = t ;
54
    p->next = null ;
55
    p->filename = filename ;
56
    p->line_no = line_no ;
57
    return ( p ) ;
58
}
59
 
60
 
61
/*
62
    JOIN TWO LISTS OF OBJECTS
63
 
64
    This routine joins two lists of objects, returning the result.
65
*/
66
 
67
object *join_object
68
    PROTO_N ( ( p, q ) )
69
    PROTO_T ( object *p X object *q )
70
{
71
    object *r = p ;
72
    if ( p == null ) return ( q ) ;
73
    if ( q == null ) return ( p ) ;
74
    while ( r->next ) r = r->next ;
75
    r->next = q ;
76
    return ( p ) ;
77
}
78
 
79
 
80
/*
81
    FIND A SUBSET
82
 
83
    This routine looks up the subset named nm.  The operation for splitting
84
    nm into its components (which should only be called with preprocessed
85
    input) needs to be kept in step with subset_name.
86
*/
87
 
88
object *make_subset
89
    PROTO_N ( ( nm ) )
90
    PROTO_T ( char *nm )
91
{
92
    object *p = search_hash ( subsets, nm, no_version ) ;
93
    if ( p == null ) {
94
	char *api = string_copy ( nm ) ;
95
	char *file = null ;
96
	char *subset = null ;
97
	char *s = strchr ( api, ':' ) ;
98
	if ( s ) {
99
	    *s = 0 ;
100
	    file = s + 1 ;
101
	    s = strchr ( file, ':' ) ;
102
	    if ( s ) {
103
		*s = 0 ;
104
		subset = s + 1 ;
105
	    }
106
	    if ( *file == 0 ) file = null ;
107
	}
108
	p = make_object ( nm, OBJ_SUBSET ) ;
109
	p->u.u_info = make_info ( api, file, subset ) ;
110
	p->u.u_info->age = ( time_t ) 0 ;
111
	IGNORE add_hash ( subsets, p, no_version ) ;
112
    }
113
    return ( p ) ;
114
}
115
 
116
 
117
/*
118
    CREATE SUBSET INFORMATION
119
 
120
    This routine creates the subset information for the subset
121
    api:file:subset.
122
*/
123
 
124
info *make_info
125
    PROTO_N ( ( api, file, subset ) )
126
    PROTO_T ( char *api X char *file X char *subset )
127
{
128
    info *p ;
129
    alloc_variable ( p, info, 100 ) ;
130
    p->api = api ;
131
    p->file = file ;
132
    p->subset = subset ;
133
    p->age = date_stamp ( filename ) ;
134
    p->incl = include_name ( output_incl_dir, api, file, subset ) ;
135
    p->src = src_name ( output_src_dir, api, file, subset ) ;
136
    p->block = block_name ( api, file, subset ) ;
137
    p->linkage = "C" ;
138
    p->nspace = null ;
139
    p->method = null ;
140
    p->prefix = token_prefix ( api, file, subset ) ;
141
    p->protect = macro_name ( PROTECT_PREFIX, api, file, subset ) ;
142
    p->version = null ;
143
    p->tokens = 0 ;
144
    p->implemented = 0 ;
145
    p->elements = null ;
146
    return ( p ) ;
147
}
148
 
149
 
150
/*
151
    UPDATE A SUBSET DATESTAMP
152
 
153
    This routine updates the datestamp on the subset p from that on the
154
    subset q.
155
*/
156
 
157
void update_time
158
    PROTO_N ( ( p, q ) )
159
    PROTO_T ( object *p X object *q )
160
{
161
    if ( p && q ) {
162
	time_t tp = p->u.u_info->age ;
163
	time_t tq = q->u.u_info->age ;
164
	if ( tp && tq > tp ) p->u.u_info->age = tq ;
165
    }
166
    return ;
167
}
168
 
169
 
170
/*
171
    CREATE A TOKEN
172
 
173
    This routine creates a token called nm (version vers) describing the
174
    object p.  If this is a real token then the tokens field of the
175
    current subset is set.
176
*/
177
 
178
object *make_token
179
    PROTO_N ( ( nm, vers, p, objtype ) )
180
    PROTO_T ( char *nm X int vers X object *p X int objtype )
181
{
182
    object *r = make_object ( nm, OBJ_TOKEN ) ;
183
    r->u.u_obj = p ;
184
    IGNORE add_hash ( tokens, r, vers ) ;
185
    if ( crt_object ) {
186
	switch ( objtype ) {
187
	    case OBJ_EXTERN :
188
	    case OBJ_WEAK : {
189
		break ;
190
	    }
191
	    default : {
192
		crt_object->u.u_info->tokens = 1 ;
193
		break ;
194
	    }
195
	}
196
    }
197
    return ( r ) ;
198
}
199
 
200
 
201
/*
202
    CREATE AN EXPRESSION
203
 
204
    This routine creates and expression object of type t called nm (version
205
    vers).
206
*/
207
 
208
object *make_exp
209
    PROTO_N ( ( nm, vers, t ) )
210
    PROTO_T ( char *nm X int vers X int t )
211
{
212
    object *r = make_object ( nm, t ) ;
213
    IGNORE add_hash ( exps, r, vers ) ;
214
    r->u.u_type = null  ;
215
    return ( r ) ;
216
}