Subversion Repositories tendra.SVN

Rev

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