Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
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
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
29
 
59
 
30
 
60
 
31
/*
61
/*
32
  type_to_aux.c
62
  type_to_aux.c
33
 
63
 
34
  contains procedure 
64
  contains procedure
35
  long add_type_to_aux (diag_type s, long ind) which converts a TDF 
65
  long add_type_to_aux (diag_type s, long ind) which converts a TDF
36
  shape into an AUXU (see sym.h) and adds it to the auxillary table 
66
  shape into an AUXU (see sym.h) and adds it to the auxillary table
37
  for the file number given as parameter as required by the MIPS 
67
  for the file number given as parameter as required by the MIPS
38
  (and alpha) symbol table(s).  If the entry generated is greater 
68
  (and alpha) symbol table(s).  If the entry generated is greater
39
  than 1 AUXU in length the index corresponding to the first entry 
69
  than 1 AUXU in length the index corresponding to the first entry
40
  made is returned.
70
  made is returned.
41
*/
71
*/
42
 
72
 
43
/*
73
/*
44
$Log: type_to_aux.c,v $
74
$Log: type_to_aux.c,v $
Line 75... Line 105...
75
#else
105
#else
76
#include CROSS_INCLUDE/symconst.h>
106
#include CROSS_INCLUDE/symconst.h>
77
#endif
107
#endif
78
 
108
 
79
 
109
 
80
extern long find_aux PROTO_S ((diag_type e));
110
extern long find_aux(diag_type e);
81
extern int add_aux PROTO_S ((AUXU,int));
111
extern int add_aux(AUXU,int);
82
 
112
 
83
int field=0;
113
int field=0;
84
 
114
 
85
 
115
 
86
long set_tq
116
long set_tq
87
    PROTO_N ( ( qual,type,ind ) )
-
 
88
    PROTO_T ( int qual X TIR *type X long ind )
117
(int qual, TIR *type, long ind)
89
{
118
{
90
  AUXU retaux;
119
  AUXU retaux;
91
  long index=0;
120
  long index=0;
92
  switch (field++)
121
  switch (field++)
93
    {
122
    {
Line 111... Line 140...
111
      type->tq3=type->tq2;
140
      type->tq3=type->tq2;
112
      type->tq2=type->tq1;
141
      type->tq2=type->tq1;
113
      type->tq1=type->tq0;
142
      type->tq1=type->tq0;
114
      break;
143
      break;
115
    case 6:	type->continued=1;
144
    case 6:	type->continued=1;
116
      retaux.ti=(*type);
145
      retaux.ti= (*type);
117
      index=add_aux(retaux, ind);
146
      index=add_aux(retaux, ind);
118
      type=(TIR*)xcalloc(1,sizeof(TIR));
147
      type= (TIR*)xcalloc(1,sizeof(TIR));
119
      type->tq0=qual;
148
      type->tq0=qual;
120
      field=1;
149
      field=1;
121
      return index;
150
      return index;
122
    }
151
    }
123
  type->tq0=qual;
152
  type->tq0=qual;
124
  return -1;
153
  return -1;
125
}
154
}
126
 
155
 
127
 
156
 
128
long type_size
157
long type_size
129
    PROTO_N ( ( dt ) )
-
 
130
    PROTO_T ( diag_type dt )
158
(diag_type dt)
131
{
159
{
132
  switch(dt->key) 
160
  switch (dt->key)
133
    {
161
    {
134
    case DIAG_TYPE_VARIETY: {
162
    case DIAG_TYPE_VARIETY: {
135
      return shape_size(dt->data.var);
163
      return shape_size(dt->data.var);
136
    }
164
    }
137
    case DIAG_TYPE_STRUCT: case DIAG_TYPE_UNION: {
165
    case DIAG_TYPE_STRUCT: case DIAG_TYPE_UNION: {
138
      return shape_size(dt->data.t_struct.tdf_shape);
166
      return shape_size(dt->data.t_struct.tdf_shape);
139
    }
167
    }
140
    case DIAG_TYPE_FLOAT: {
168
    case DIAG_TYPE_FLOAT: {
141
      return ((dt->data.f_var)?64:32);
169
      return((dt->data.f_var)?64:32);
142
    }
170
    }
143
    case DIAG_TYPE_ARRAY: {
171
    case DIAG_TYPE_ARRAY: {
144
      long is = type_size(dt->data.array.element_type);
172
      long is = type_size(dt->data.array.element_type);
145
      return (is *(dt->data.array.upper_b-dt->data.array.lower_b+1));
173
      return(is *(dt->data.array.upper_b-dt->data.array.lower_b+1));
146
    }
174
    }
147
    case DIAG_TYPE_ENUM: {
175
    case DIAG_TYPE_ENUM: {
148
      return type_size(dt->data.t_enum.base_type);
176
      return type_size(dt->data.t_enum.base_type);
149
    }
177
    }
150
    default: return 32;
178
    default: return 32;
151
    }
179
    }
152
}	
180
}
153
 
181
 
154
long add_type_to_aux
182
long add_type_to_aux
155
    PROTO_N ( ( dt,ind ) )
-
 
156
    PROTO_T ( diag_type dt X long ind )
183
(diag_type dt, long ind)
157
{
184
{
158
  TIR* type=(TIR*)xcalloc(1,sizeof(TIR));
185
  TIR* type= (TIR*)xcalloc(1,sizeof(TIR));
159
  long firstind= -1;
186
  long firstind= -1;
160
  int dimension=0;
187
  int dimension=0;
161
  int elemsize=0;
188
  int elemsize=0;
162
  int scale=1;
189
  int scale=1;
163
  diag_type xdt = dt;
190
  diag_type xdt = dt;
164
  AUXU maxaux, retaux;
191
  AUXU maxaux, retaux;
165
  maxaux.isym=0xffffffff;
192
  maxaux.isym=0xffffffff;
166
  field=0;
193
  field=0;
167
 
194
 
168
  type->bt=63;
195
  type->bt=63;
169
  while (type->bt==63){
196
  while (type->bt==63) {
170
    if (dt == (diag_type)0) {
197
    if (dt == (diag_type)0) {
171
      type->bt = btNil;
198
      type->bt = btNil;
172
      retaux.ti=(*type);
199
      retaux.ti= (*type);
173
      break;
200
      break;
174
    }
201
    }
175
    switch (dt->key) 
202
    switch (dt->key)
176
      {
203
      {
177
      case DIAG_TYPE_BITFIELD: {
204
      case DIAG_TYPE_BITFIELD: {
178
	type->bt=btUInt;
205
	type->bt=btUInt;
179
	type->fBitfield=1;
206
	type->fBitfield=1;
180
	retaux.ti = *type;
207
	retaux.ti = *type;
181
	firstind = add_aux(retaux, ind);
208
	firstind = add_aux(retaux, ind);
182
	retaux.rndx.rfd = dt->data.bitfield.no_of_bits.nat_val.small_nat;
209
	retaux.rndx.rfd = dt->data.bitfield.no_of_bits.nat_val.small_nat;
183
	retaux.rndx.index=0;
210
	retaux.rndx.index=0;
184
	add_aux(retaux, ind);
211
	add_aux(retaux, ind);
185
	break;
212
	break;
186
      }                     
213
      }
187
      case DIAG_TYPE_UNINIT:  case DIAG_TYPE_NULL: case DIAG_TYPE_INITED:
214
      case DIAG_TYPE_UNINIT:  case DIAG_TYPE_NULL: case DIAG_TYPE_INITED:
188
	type->bt = btNil;
215
	type->bt = btNil;
189
	retaux.ti=(*type);
216
	retaux.ti= (*type);
190
	break;
217
	break;
191
      case DIAG_TYPE_VARIETY: {
218
      case DIAG_TYPE_VARIETY: {
192
	switch (name(dt->data.var)) 
219
	switch (name(dt->data.var))
193
	  {
220
	  {
194
	  case scharhd:
221
	  case scharhd:
195
	    type->bt = btChar; 
222
	    type->bt = btChar;
196
	    retaux.ti=(*type);
223
	    retaux.ti= (*type);
197
	    break;
224
	    break;
198
	  case ucharhd: 
225
	  case ucharhd:
199
	    type->bt = btUChar; 
226
	    type->bt = btUChar;
200
	    retaux.ti=(*type);
227
	    retaux.ti= (*type);
201
	    break;
228
	    break;
202
	  case swordhd: 
229
	  case swordhd:
203
	    type->bt = btShort; 
230
	    type->bt = btShort;
204
	    retaux.ti=(*type);
231
	    retaux.ti= (*type);
205
	    break;
232
	    break;
206
	  case uwordhd: 
233
	  case uwordhd:
207
	    type->bt = btUShort; 
234
	    type->bt = btUShort;
208
	    retaux.ti=(*type);
235
	    retaux.ti= (*type);
209
	    break;
236
	    break;
210
	  case slonghd: 
237
	  case slonghd:
211
	    type->bt = btInt32; 
238
	    type->bt = btInt32;
212
	    retaux.ti=(*type);
239
	    retaux.ti= (*type);
213
	    break;
240
	    break;
214
	  case ulonghd: 
241
	  case ulonghd:
215
	    type->bt = btUInt32; 
242
	    type->bt = btUInt32;
216
	    retaux.ti=(*type);
243
	    retaux.ti= (*type);
217
	    break;
244
	    break;
218
	  case s64hd:
245
	  case s64hd:
219
	    type->bt = btLong64;
246
	    type->bt = btLong64;
220
	    retaux.ti=(*type);
247
	    retaux.ti= (*type);
221
	    break;
248
	    break;
222
	  case u64hd:
249
	  case u64hd:
223
	    type->bt = btULong64;
250
	    type->bt = btULong64;
224
	    retaux.ti=(*type);
251
	    retaux.ti= (*type);
225
	    break;
252
	    break;
226
	  default: failer("DIAGS - not variety ");
253
	  default: failer("DIAGS - not variety ");
227
          }
254
          }
228
	break;
255
	break;
229
      }
256
      }
Line 231... Line 258...
231
	if (dt->data.f_var == 0) {
258
	if (dt->data.f_var == 0) {
232
	  type->bt = btFloat;
259
	  type->bt = btFloat;
233
	}
260
	}
234
	else {
261
	else {
235
	  type->bt = btDouble;
262
	  type->bt = btDouble;
236
	}             
263
	}
237
	retaux.ti=(*type);
264
	retaux.ti= (*type);
238
	break;
265
	break;
239
      }
266
      }
240
      case DIAG_TYPE_PROC: { 
267
      case DIAG_TYPE_PROC: {
241
   /* ???  MIPS   ???  should use result type ???  */
268
   /* ???  MIPS   ???  should use result type ???  */
242
	set_tq(tqProc, type, ind);
269
	set_tq(tqProc, type, ind);
243
	type->bt = btUInt;
270
	type->bt = btUInt;
244
	retaux.ti=(*type);
271
	retaux.ti= (*type);
245
	break;
272
	break;
246
      }
273
      }
247
      case DIAG_TYPE_PTR: {
274
      case DIAG_TYPE_PTR: {
248
	firstind= set_tq(tqPtr, type, ind);
275
	firstind= set_tq(tqPtr, type, ind);
249
	dt = dt->data.ptr.object;
276
	dt = dt->data.ptr.object;
250
	break;
277
	break;
251
      }
278
      }
252
      case DIAG_TYPE_STRUCT: case DIAG_TYPE_UNION: {
279
      case DIAG_TYPE_STRUCT: case DIAG_TYPE_UNION: {
253
	type->bt = (dt->key == DIAG_TYPE_STRUCT)? btStruct:btUnion;
280
	type->bt = (dt->key == DIAG_TYPE_STRUCT)? btStruct:btUnion;
254
	retaux.ti = *type;
281
	retaux.ti = *type;
255
	if (firstind==-1){
282
	if (firstind==-1) {
256
	  firstind=add_aux(retaux, ind);
283
	  firstind=add_aux(retaux, ind);
257
	}
284
	}
258
	else{
285
	else{
259
	  add_aux(retaux, ind);
286
	  add_aux(retaux, ind);
260
	}
287
	}
Line 270... Line 297...
270
	firstind=set_tq(tqArray, type, ind);
297
	firstind=set_tq(tqArray, type, ind);
271
	dimension=1;
298
	dimension=1;
272
	xdt = dt;
299
	xdt = dt;
273
	while (ndt->key==DIAG_TYPE_ARRAY) {
300
	while (ndt->key==DIAG_TYPE_ARRAY) {
274
	  dimension++;
301
	  dimension++;
275
	  ndt = ndt->data.array.element_type; 
302
	  ndt = ndt->data.array.element_type;
276
	}
303
	}
277
	dt = ndt;
304
	dt = ndt;
278
	elemsize = type_size(ndt)>>3;
305
	elemsize = type_size(ndt) >>3;
279
	break;
306
	break;
280
      }
307
      }
281
      case DIAG_TYPE_ENUM: case DIAG_TYPE_LOC: {
308
      case DIAG_TYPE_ENUM: case DIAG_TYPE_LOC: {
282
	dt = dt->data.t_enum.base_type;
309
	dt = dt->data.t_enum.base_type;
283
	break;
310
	break;
284
      }
311
      }
285
      default: 
312
      default:
286
	failer ("bad diagnostics type");
313
	failer("bad diagnostics type");
287
	break;
314
	break;
288
      }
315
      }
289
  }	
316
  }
290
  if (firstind==-1){
317
  if (firstind==-1) {
291
    firstind=add_aux(retaux,ind);
318
    firstind=add_aux(retaux,ind);
292
  }
319
  }
293
  else{
320
  else{
294
    add_aux(retaux,ind);
321
    add_aux(retaux,ind);
295
  }
322
  }
296
  while (dimension--) {
323
  while (dimension--) {
297
    int i;
324
    int i;
298
    diag_type ndt = xdt; 
325
    diag_type ndt = xdt;
299
    for (i=1;i<dimension;i++) {
326
    for (i=1;i<dimension;i++) {
300
      ndt = ndt->data.array.element_type;
327
      ndt = ndt->data.array.element_type;
301
    }
328
    }
302
    i = no(ndt->data.array.upper_b) - no(ndt->data.array.lower_b)-1;
329
    i = no(ndt->data.array.upper_b) - no(ndt->data.array.lower_b) -1;
303
    retaux.rndx.rfd = 4095;
330
    retaux.rndx.rfd = 4095;
304
    retaux.rndx.index=4;
331
    retaux.rndx.index=4;
305
    add_aux(retaux,ind);
332
    add_aux(retaux,ind);
306
    retaux.rndx.rfd = mainfile;
333
    retaux.rndx.rfd = mainfile;
307
    retaux.rndx.index=0;
334
    retaux.rndx.index=0;
Line 317... Line 344...
317
  return firstind;
344
  return firstind;
318
/* return index of first element added to the AUX table */
345
/* return index of first element added to the AUX table */
319
}
346
}
320
 
347
 
321
 
348
 
322
			
349
 
323
		
350
 
324
 
351
 
325
 
352
 
326
 
353
 
327
 
354
 
328
 
355