Subversion Repositories tendra.SVN

Rev

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

Rev Author Line No. Line
2 7u83 1
/*
7 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
33
 
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:-
42
 
43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
45
 
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;
49
 
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;
53
 
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
/**********************************************************************
62
$Author: release $
63
$Date: 1998/01/17 15:55:46 $
64
$Revision: 1.1.1.1 $
65
$Log: diag_info.c,v $
66
 * Revision 1.1.1.1  1998/01/17  15:55:46  release
67
 * First version to be checked into rolling release.
68
 *
69
 * Revision 1.9  1998/01/11  18:45:07  pwe
70
 * consistent new/old diags
71
 *
72
 * Revision 1.8  1998/01/09  09:30:04  pwe
73
 * prep restructure
74
 *
75
 * Revision 1.7  1997/12/04  19:36:41  pwe
76
 * ANDF-DE V1.9
77
 *
78
 * Revision 1.6  1997/11/06  09:17:56  pwe
79
 * ANDF-DE V1.8
80
 *
81
 * Revision 1.5  1997/10/23  09:21:23  pwe
82
 * ANDF-DE V1.7 and extra diags
83
 *
84
 * Revision 1.4  1997/08/23  13:27:06  pwe
85
 * initial ANDF-DE
86
 *
87
 * Revision 1.3  1997/03/20  17:04:52  currie
88
 * Dwarf2 diags
89
 *
90
Revision 1.2  1997/02/18 12:55:51  currie
91
NEW DIAG STRUCTURE
92
 
93
 * Revision 1.1  1995/04/06  10:42:55  currie
94
 * Initial revision
95
 *
96
***********************************************************************/
97
 
98
 
99
#include "config.h"
100
#include "common_types.h"
101
#include "readglob.h"
102
#include "table_fns.h"
103
#include "basicread.h"
104
#include "sortmacs.h"
105
#include "xalloc.h"
106
#ifdef NEWDIAGS
107
#include "exp.h"
108
#include "expmacs.h"
109
#include "tags.h"
110
#include "externs.h"
111
#include "dg_aux.h"
112
#include "mark_scope.h"
113
#endif
114
 
115
#include "main_reads.h"
116
#include "check.h"
117
#include "dg_fns.h"
118
#include "diag_fns.h"
119
 
120
 
121
/* PROCEDURES */
122
 
123
 
124
#ifdef NEWDIAGS
125
 
126
 
7 7u83 127
exp
128
diag_locate(exp e)
2 7u83 129
{
7 7u83 130
	/* need contents for var locations, old diags */
131
	exp id = son(e);
132
	if (isglob(id)) {
133
		if (brog(id)->dec_u.dec_val.dec_var) {
134
			e = f_contents(brog(id)->dec_u.dec_val.dec_shape, e);
135
		}
136
	} else {
137
		if (isvar(id)) {
138
			e = f_contents(sh(son(id)), e);
139
		}
140
	}
141
	return e;
2 7u83 142
}
143
 
144
 
7 7u83 145
exp
146
read_exp_to_source(exp body)
2 7u83 147
{
7 7u83 148
	dg_sourcepos s1, s2;
149
	int was_within_diags = within_diags;
150
	within_diags = 1;
151
	s1 = d_sourcemark();
152
	s2 = d_sourcemark();
153
	within_diags = was_within_diags;
154
	if (s1.file == s2.file) {
155
		s2.sp_key = SP_SPAN;
156
		s2.to_file = s2.file;
157
		s2.to_line = s2.from_line;
158
		s2.to_column = s2.from_column;
159
		s2.from_line = s1.from_line;
160
		s2.from_column = s1.from_column;
161
	}
162
	if (name(body) == proc_tag || name(body) == general_proc_tag) {
163
		return body;
164
	}
165
	body = f_dg_exp(body, f_singlestep_dg(s1));
166
	body = f_dg_exp(body, f_sourcepos_dg(s2));
167
	return body;
2 7u83 168
}
169
 
170
 
7 7u83 171
exp
172
read_diag_id_scope(exp body)
2 7u83 173
{
7 7u83 174
	dg_idname nam;
175
	exp acc;
176
	dg_type typ;
177
	dg_name dgn;
178
	int was_within_diags = within_diags;
179
	within_diags = 1;
180
	nam = f_dg_sourcestring_idname(d_tdfstring());
181
	acc = hold_check(d_exp());
182
	typ = d_diag_type();
183
	within_diags = was_within_diags;
184
	dgn = f_dg_object_name(nam, f_dg_null_sourcepos, typ,
185
			       yes_exp_option(diag_locate(acc)),
186
			       no_dg_accessibility_option);
2 7u83 187
 
7 7u83 188
	if (isparam(son(acc)) ||
189
	    (son(son(acc)) != nilexp && name(son(son(acc))) == chvar_tag &&
190
	     shape_size(sh(son(son(acc)))) < 32 &&
191
	     name(son(son(son(acc)))) == cont_tag &&
192
	     name(son(son(son(son(acc))))) == name_tag &&
193
	     isparam(son(son(son(son(son(acc)))))))) {
194
		dg_info x = dgf(body);
195
		if (x && x->key == DGA_PARAMS) {
196
			dgn->next = x->data.i_param.args;
197
			x->data.i_param.args = dgn;
198
		} else {
199
			body = f_dg_exp(body, f_params_dg(dgn, no_exp_option));
200
		}
201
	} else {
202
		body = f_dg_exp(body, f_name_decl_dg(dgn));
203
		mark_scope(body);
204
	}
205
	return(body);
2 7u83 206
}
207
 
208
 
7 7u83 209
exp
210
read_diag_type_scope(exp body)
2 7u83 211
{
7 7u83 212
	dg_idname nam;
213
	dg_type typ;
214
	dg_name dgn;
215
	int was_within_diags = within_diags;
216
	within_diags = 1;
217
	nam = f_dg_sourcestring_idname(d_tdfstring());
218
	typ = d_diag_type();
219
	within_diags = was_within_diags;
220
	dgn = f_dg_type_name(nam, f_dg_null_sourcepos,
221
			     no_dg_accessibility_option, typ, f_false,
222
			     no_bool_option, no_dg_constraint_list_option);
223
	body = f_dg_exp(body, f_name_decl_dg(dgn));
224
	mark_scope2(body);
225
	return body;
2 7u83 226
}
227
 
228
 
229
#else
230
 
7 7u83 231
diag_info *
232
read_exp_to_source(void)
2 7u83 233
{
7 7u83 234
	diag_info *new = (diag_info *)xcalloc(1, sizeof(diag_info));
2 7u83 235
 
7 7u83 236
	new->key = DIAG_INFO_SOURCE;
237
	new->data.source.beg = d_sourcemark();
238
	new->data.source.end = d_sourcemark();
2 7u83 239
 
7 7u83 240
	return new;
2 7u83 241
}
242
 
7 7u83 243
 
244
diag_info *
245
read_diag_id_scope(void)
2 7u83 246
{
7 7u83 247
	diag_info *new = (diag_info *)xcalloc(1, sizeof(diag_info));
2 7u83 248
 
7 7u83 249
	new->key = DIAG_INFO_ID;
250
	new->data.id_scope.nme = d_tdfstring();
251
	new->data.id_scope.access = hold_check(d_exp());
252
	IGNORE hold(hold(new->data.id_scope.access));
253
	new->data.id_scope.typ = d_diag_type();
254
	return(new);
2 7u83 255
}
256
 
7 7u83 257
 
258
diag_info *
259
read_diag_type_scope(void)
2 7u83 260
{
7 7u83 261
	diag_info *new = (diag_info *)xcalloc(1, sizeof(diag_info));
2 7u83 262
 
7 7u83 263
	new->key = DIAG_INFO_TYPE;
264
	new->data.type_scope.nme = d_tdfstring();
265
	new->data.type_scope.typ = d_diag_type();
266
	return(new);
2 7u83 267
}
268
 
7 7u83 269
 
270
diag_info *
271
read_diag_tag_scope(void)
2 7u83 272
{
7 7u83 273
	diag_info *new = (diag_info *)xcalloc(2, sizeof(diag_info));
2 7u83 274
 
7 7u83 275
	new->key = DIAG_INFO_TAG;
276
	new->data.tag_scope.nme = d_tdfstring();
277
	new->data.tag_scope.typ = d_diag_type();
278
	return(new);
2 7u83 279
}
280
 
281
#endif