Subversion Repositories tendra.SVN

Rev

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
/**********************************************************************
32
$Author: release $
33
$Date: 1998/02/04 10:43:44 $
34
$Revision: 1.2 $
35
$Log: syms.c,v $
36
 * Revision 1.2  1998/02/04  10:43:44  release
37
 * Changes during testing.
38
 *
39
 * Revision 1.1.1.1  1998/01/17  15:56:07  release
40
 * First version to be checked into rolling release.
41
 *
42
 * Revision 1.3  1995/09/12  10:59:44  currie
43
 * gcc pedanttry
44
 *
45
 * Revision 1.2  1995/05/05  08:13:07  currie
46
 * initial_value + signtures
47
 *
48
 * Revision 1.1  1995/04/13  09:08:06  currie
49
 * Initial revision
50
 *
51
***********************************************************************/
52
/*  syms.c   - produce symbol numbers for binasm (dense numbers)
53
 
54
*/
55
 
56
#include "config.h"
57
#include "cross_config.h"
58
 
59
#ifndef CROSS_INCLUDE
60
#include <symconst.h>
61
#else
62
#include CROSS_INCLUDE/symconst.h>
63
#endif
64
 
65
#include "common_types.h"
66
#include "symtab.h"
67
#include "xalloc.h"
68
#include "flags.h"
69
#include "expmacs.h"
70
#include "shapemacs.h"
71
#include "syms.h"
72
#include "tags.h"
73
#include "main.h"
74
#include "basicread.h"
75
#include "mipsdiags.h"
76
#include "new_symbol.h"
77
 
78
extern long currentfile;
79
 
80
int  *symnos;
81
int  *tempsnos = (int *) 0;
82
 
83
int   next_temps = 0;
84
int   no_temps = 0;
85
 
86
 
87
 
88
int   symnoforext
89
    PROTO_N ( (ex, filen) )
90
    PROTO_T ( dec * ex X int filen )
91
{
92
				/* produce a symbolno for global given by
93
				   ex in file filen */
94
        exp tg = ex -> dec_u.dec_val.dec_exp;
95
  shape s = ex -> dec_u.dec_val.dec_shape;
96
  diag_type dt = (diag_type)0;
97
  short   symtype;
98
  short   symclass;
99
  long  v = 0;
100
  char *id = ex -> dec_u.dec_val.dec_id;
101
  if (diagnose) {
102
    diag_descriptor * t = ex ->dec_u.dec_val.diag_info;
103
    if (t != (diag_descriptor *) 0) {
104
      id = t -> data.id.nme.ints.chars;
105
      dt = t -> data.id.new_type;
106
      filen = find_file(t ->data.id.whence.file->file.ints.chars);
107
    }
108
  }
109
 
110
 
111
  if (ex -> dec_u.dec_val.extnamed) {/* it is global */
112
    if (name (s) == prokhd && !isvar (tg)
113
		&& (son(tg) == nilexp || name(son(tg))== proc_tag
114
		|| name(son(tg)) == general_proc_tag))
115
   {/* a declared procedure */
116
      if (son (tg) != nilexp) {	/* a defined procedure will be output
117
				   later with this symbolno */
118
	return add_dense_no (0, 0);
119
      }
120
      else {
121
      	symtype = stGlobal;
122
        symclass = scNil;
123
      }
124
    }
125
    else {			/* some other global */
126
      ash a;
127
      symtype = stGlobal;
128
      symclass =
129
	(son (tg) != nilexp) ?
130
	((name (son (tg))) != clear_tag ? scData : scCommon)
131
	: scNil;
132
      a = ashof (s);
133
      v = (a.ashsize + 7) >> 3;
134
    }
135
    return new_esym_d (id, v, symtype, symclass, dt, filen);
136
  }
137
  else {			/* statics */
138
    if (name (s) == prokhd && !isvar (tg)
139
		&& (son(tg) == nilexp || name(son(tg))== proc_tag
140
		|| name(son(tg)) == general_proc_tag))
141
    {/* a procedure */
142
      symtype = stStaticProc;
143
      if (son (tg) != nilexp)
144
	return add_dense_no (0, 0);
145
      /* a defined procedure will be output later with this symbolno */
146
      failer ("Static procs should have bodies ");
147
      symclass = scNil;
148
    }
149
    else {			/* other statics */
150
      symtype = stStatic;
151
      symclass = (son(tg)== nilexp || name (son (tg)) != clear_tag)
152
                     ? scData : scCommon;
153
    }
154
    return new_lsym_d (id, v, symtype, symclass, dt, filen);
155
  }
156
}
157
 
158
int   symnoforstart
159
    PROTO_N ( (i, filen) )
160
    PROTO_T ( int i X int filen )
161
{
162
				/* output symbolno for start of proc */
163
  dec * ex = main_globals[i];
164
  short   symtype = (ex -> dec_u.dec_val.extnamed) ? stProc : stStaticProc;
165
  char *id = ex -> dec_u.dec_val.dec_id;
166
  diag_type dt = (diag_type)0;
167
  if (diagnose) {
168
    diag_descriptor * t = ex ->dec_u.dec_val.diag_info;
169
    if (t != (diag_descriptor *) 0) {
170
      id = t ->data.id.nme.ints.chars;
171
      dt = t -> data.id.new_type;
172
      filen = find_file(t ->data.id.whence.file->file.ints.chars);
173
    }
174
  }
175
 
176
  return new_lsym (id, symnos[i], symtype, scText, dt, filen);
177
}
178
 
179
int   symnoforend
180
    PROTO_N ( (ex, filen) )
181
    PROTO_T ( dec * ex X int filen )
182
{
183
				/* output symbolno for end of proc */
184
  char *id = ex -> dec_u.dec_val.dec_id;
185
  diag_type dt = (diag_type)0;
186
  if (diagnose) {
187
    diag_descriptor * t = ex ->dec_u.dec_val.diag_info;
188
    if (t != (diag_descriptor *) 0) {
189
      id = t -> data.id.nme.ints.chars;
190
      dt = t -> data.id.new_type;
191
      filen = find_file(t -> data.id.whence.file->file.ints.chars);
192
    }
193
  }
194
 
195
  return new_lsym_d (id, 0, stEnd, scText, dt, filen);
196
}
197
 
198
int   symnofordata
199
    PROTO_N ( (data_lab) )
200
    PROTO_T ( int data_lab )
201
{
202
				/* output symbol number for data_lab and
203
				   remember it in tempsnos */
204
  int   a = data_lab - 32;
205
  if (a >= no_temps) {
206
    tempsnos = (int *) xrealloc ((char *) tempsnos, (100 + a) * sizeof (int));
207
    no_temps = a + 100;
208
  }
209
 
210
  return (tempsnos[a] = add_dense_no (currentfile, 1048575 /* ???? */ ));
211
}