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:48 $
64
$Revision: 1.1.1.1 $
65
$Log: li_fns.c,v $
66
 * Revision 1.1.1.1  1998/01/17  15:55:48  release
67
 * First version to be checked into rolling release.
68
 *
69
 * Revision 1.1  1995/04/06  10:43:17  currie
70
 * Initial revision
71
 *
72
***********************************************************************/
73
 
74
 
75
 
76
 
77
 
78
#include "config.h"
79
#include "common_types.h"
80
#include "flags.h"
81
#include "messages_li.h"
82
#include "natmacs.h"
83
#include "main_reads.h"
84
#include "externs.h"
85
 
86
#if is80x86
87
#include "assembler.h"
88
#include "localflags.h"
89
#define use_link_stuff 1
90
#endif
91
 
92
#if use_link_stuff
93
extern weak_cell *weak_list;
94
#include "out.h"
95
#endif
96
 
97
#include "xalloc.h"
98
#include "readglob.h"
99
#include "basicread.h"
100
#include "exp.h"
101
#include "expmacs.h"
102
#include "tags.h"
103
#include "machine.h"
104
 
105
 
106
/* PROCEDURES */
107
 
7 7u83 108
extern void out_rename(char *, char *);
2 7u83 109
 
7 7u83 110
static char *
111
id_prefix(char *s)
2 7u83 112
{
7 7u83 113
	char *r;
114
	int l1, l2;
115
	l1 = (int)strlen(name_prefix);
116
	if (l1==0) {
117
		return s;
118
	}
119
	l2 = (int)strlen(s);
120
	r = (char *)xcalloc(l1 + l2 + 1, sizeof(char));
121
	IGNORE strcpy(r, name_prefix);
122
	IGNORE strcpy(&r[l1], s);
123
	return r;
2 7u83 124
}
125
 
7 7u83 126
 
127
linkinfo
128
f_make_weak_defn(exp e1, exp e2)
2 7u83 129
{
130
#if use_link_stuff
7 7u83 131
	weak_cell *wc = (weak_cell *)xmalloc(sizeof(weak_cell));
2 7u83 132
 
7 7u83 133
	wc->weak_id = brog(son(e1))->dec_u.dec_val.dec_id;
134
	wc->val_id = brog(son(e2))->dec_u.dec_val.dec_id;
135
	brog(son(e2))->dec_u.dec_val.isweak = 1;
136
	wc->next = weak_list;
137
	weak_list = wc;
2 7u83 138
 
139
#endif
7 7u83 140
	kill_exp(e1, e1);
141
	kill_exp(e2, e2);
142
	return 0;
2 7u83 143
}
144
 
145
 
7 7u83 146
linkinfo
147
f_make_weak_symbol(tdfstring id, exp e)
2 7u83 148
{
149
#if use_link_stuff
7 7u83 150
	char **lid = &brog(son(e))->dec_u.dec_val.dec_id;
151
	char *nid = id_prefix(id.ints.chars);
152
	brog(son(e))->dec_u.dec_val.isweak = 1;
153
	brog(son(e))->dec_u.dec_val.extnamed = 1;
154
	outs(".weak ");
155
	outs(nid);
156
	outnl();
157
	out_rename(*lid, nid);
158
	*lid = nid;
2 7u83 159
#endif
7 7u83 160
	kill_exp(e, e);
161
	return 0;
2 7u83 162
}
163
 
7 7u83 164
 
165
linkinfo
166
f_make_comment(tdfstring id)
2 7u83 167
{
168
#if use_link_stuff
7 7u83 169
	outs(".ident \"");
170
	outs(id_prefix(id.ints.chars));
171
	outs("\"");
172
	outnl();
2 7u83 173
#endif
7 7u83 174
	return 0;
2 7u83 175
}
176
 
7 7u83 177
 
178
linkinfo
179
f_static_name_def(exp e, tdfstring id)
2 7u83 180
{
7 7u83 181
	char **oldid = &brog(son(e))->dec_u.dec_val.dec_id;
182
	char *newid = id_prefix(id.ints.chars);
2 7u83 183
 
7 7u83 184
	if (name(e) != name_tag || !isglob(son(e))) {
185
		failer(ILLEGAL_STATIC);
186
		kill_exp(e, e);
187
		return 0;
188
	}
2 7u83 189
 
7 7u83 190
	if (separate_units) {
191
		failer(INCOMPATIBLE_U);
192
	} else {
193
		out_rename(*oldid, newid);
194
	}
2 7u83 195
 
7 7u83 196
	*oldid = newid;
197
	kill_exp(e, e);
198
	return 0;
2 7u83 199
}
200
 
7 7u83 201
 
202
void
203
init_linkinfo(void)
2 7u83 204
{
7 7u83 205
	return;
2 7u83 206
}
207
 
7 7u83 208
 
2 7u83 209
linkinfo f_dummy_linkinfo;
210
 
7 7u83 211
linkinfo_list
212
new_linkinfo_list(int n)
2 7u83 213
{
7 7u83 214
	UNUSED(n);
215
	return 0;
2 7u83 216
}
217
 
7 7u83 218
 
219
linkinfo_list
220
add_linkinfo_list(linkinfo_list list, linkinfo elem, int index)
2 7u83 221
{
7 7u83 222
	UNUSED(list);
223
	UNUSED(elem);
224
	UNUSED(index);
225
	return 0;
2 7u83 226
}
227
 
228
 
7 7u83 229
void
230
start_make_linkinfo_unit(int no_of_tokens, int no_of_tags, int no_of_als,
231
			 int no_of_diagtypes)
2 7u83 232
{
7 7u83 233
	int i;
234
	UNUSED(no_of_diagtypes);
2 7u83 235
 
7 7u83 236
	unit_no_of_tokens = no_of_tokens;
237
	unit_ind_tokens = (tok_define **)xcalloc(unit_no_of_tokens,
238
						 sizeof(tok_define *));
239
	for (i = 0; i < unit_no_of_tokens; ++i) {
240
		unit_ind_tokens[i] = (tok_define *)0;
241
	}
2 7u83 242
 
7 7u83 243
	unit_no_of_tags = no_of_tags;
244
	unit_ind_tags = (dec **)xcalloc(unit_no_of_tags, sizeof(dec *));
245
	for (i = 0; i < unit_no_of_tags; ++i) {
246
		unit_ind_tags[i] = (dec *)0;
247
	}
2 7u83 248
 
7 7u83 249
	unit_no_of_als = no_of_als;
250
	unit_ind_als = (aldef **)xcalloc(unit_no_of_als, sizeof(aldef *));
251
	for (i = 0; i < unit_no_of_als; ++i) {
252
		unit_ind_als[i] = (aldef *)0;
253
	}
2 7u83 254
 
7 7u83 255
	return;
2 7u83 256
}
257
 
7 7u83 258
 
259
int
260
f_make_linkinfo_unit(void)
2 7u83 261
{
7 7u83 262
	int i;
263
	int j = 0;
264
	int no_of_labels;
265
	for (i = 0; i < unit_no_of_tokens; ++i) {
266
		if (unit_ind_tokens[i] == (tok_define *)0)
267
			unit_ind_tokens[i] = &unit_toktab[j++];
268
	}
269
	j = 0;
270
	for (i = 0; i < unit_no_of_tags; ++i) {
271
		if (unit_ind_tags[i] == (dec *)0)
272
			unit_ind_tags[i] = &unit_tagtab[j++];
273
	}
274
	j = 0;
275
	for (i = 0; i < unit_no_of_als; ++i) {
276
		if (unit_ind_als[i] == (aldef *)0)
277
			unit_ind_als[i] = &unit_altab[j++];
278
	}
279
	start_bytestream();
280
	no_of_labels = small_dtdfint();
281
	unit_no_of_labels = no_of_labels;
282
	unit_labtab = (exp *)xcalloc(unit_no_of_labels, sizeof(exp));
283
	IGNORE d_linkinfo_list();
284
	end_bytestream();
2 7u83 285
 
7 7u83 286
	xfree((void *)unit_ind_tokens);
287
	xfree((void *)unit_ind_tags);
288
	xfree((void *)unit_ind_als);
289
	xfree((void *)unit_labtab);
290
	xfree((void *)unit_toktab);
291
	xfree((void *)unit_tagtab);
2 7u83 292
 
7 7u83 293
	return 0;
2 7u83 294
}
295
 
7 7u83 296
 
297
linkinfo_props
298
f_make_linkinfos(tdfint nl, linkinfo_list tds)
2 7u83 299
{
7 7u83 300
	UNUSED(nl);
301
	UNUSED(tds);
302
	return 0;
2 7u83 303
}