Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra4/src/tools/disp/unit.c – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | 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
#include "config.h"
32
#include "types.h"
33
#include "basic.h"
34
#include "binding.h"
35
#include "capsule.h"
36
#include "file.h"
37
#include "sort.h"
38
#include "tdf.h"
39
#include "tree.h"
40
#include "utility.h"
41
 
42
 
43
/*
44
    CURRENT MAXIMUM LABEL NUMBER
45
 
46
    This gives the number of labels in the current unit.
47
*/
48
 
49
long max_lab_no = 0 ;
50
 
51
 
52
/*
53
    READ NUMBER OF LABELS
54
 
55
    This routine reads the number of labels in a unit.
56
*/
57
 
58
void read_no_labs
59
    PROTO_Z ()
60
{
61
    long n = tdf_int () ;
62
    if ( show_stuff ) {
63
	word *w = new_word ( HORIZ_NONE ) ;
64
	out_string ( "label x " ) ;
65
	out_int ( n ) ;
66
	end_word ( w ) ;
67
	blank_line () ;
68
    }
69
    max_lab_no = n ;
70
    return ;
71
}
72
 
73
 
74
/*
75
    SET TOKEN SORTS, CHECKING FOR COMPATIBILITY
76
 
77
    The token t (with number n) is set to have result sort rs and
78
    argument sorts args.  If t has already been initialized these values
79
    are checked against the existing values.  This routine also sets
80
    the foreign field of t.
81
*/
82
 
83
void token_sort
84
    PROTO_N ( ( t, rs, args, n ) )
85
    PROTO_T ( object *t X sortname rs X char *args X long n )
86
{
87
    sortid s ;
88
    s = find_sort ( rs ) ;
89
    if ( s.decode == 'F' ) is_foreign ( t ) = 1 ;
90
    if ( args ) {
91
	char *p ;
92
	for ( p = args ; *p ; p++ ) {
93
	    if ( *p == 'F' ) is_foreign ( t ) = 1 ;
94
	}
95
    }
96
    if ( res_sort ( t ) == sort_unknown ) {
97
	sortname is = implicit_sort ( t ) ;
98
	if ( is != sort_unknown && is != rs ) {
99
	    input_error ( "Token %s inconsistent with previous use",
100
			  object_name ( var_token, n ) ) ;
101
	}
102
    } else {
103
	int good = 1 ;
104
	if ( res_sort ( t ) != rs ) good = 0 ;
105
	if ( args ) {
106
	    if ( arg_sorts ( t ) ) {
107
		good = streq ( args, arg_sorts ( t ) ) ;
108
	    } else {
109
		good = 0 ;
110
	    }
111
	} else {
112
	    if ( arg_sorts ( t ) ) good = 0 ;
113
	}
114
	if ( !good ) {
115
	    input_error ( "Token %s declared inconsistently",
116
			  object_name ( var_token, n ) ) ;
117
	}
118
    }
119
    res_sort ( t ) = rs ;
120
    arg_sorts ( t ) = args ;
121
    return ;
122
}
123
 
124
 
125
/*
126
    DECODE A TOKEN DECLARATION
127
 
128
    A single token declaration is decoded.
129
*/
130
 
131
static void de_tokdec_aux
132
    PROTO_Z ()
133
{
134
    long t ;
135
    sortid s ;
136
    object *obj ;
137
    char *args = null ;
138
    word *w = new_word ( HORIZ_NONE ) ;
139
 
140
    /* Find declaration type */
141
    IGNORE de_tokdec () ;
142
 
143
    /* Find token number */
144
    t = tdf_int () ;
145
    obj = find_binding ( crt_binding, var_token, t ) ;
146
    if ( obj == null ) {
147
	obj = new_object ( var_token ) ;
148
	set_binding ( crt_binding, var_token, t, obj ) ;
149
    }
150
    out_object ( t, obj, var_token ) ;
151
    out ( ":" ) ;
152
 
153
    /* Deal with signature */
154
    out ( "[" ) ;
155
    decode ( "?[X]" ) ;
156
    out ( "] :" ) ;
157
 
158
    /* Decode token sort */
159
    s = de_sort_name ( 0 ) ;
160
    if ( s.res == sort_token ) {
161
	long i, m ;
162
	s = de_sort_name ( 1 ) ;
163
	check_list () ;
164
	m = tdf_int () ;
165
	if ( m == 0 ) {
166
	    out ( "()" ) ;
167
	    args = "" ;
168
	} else {
169
	    word *wp = new_word ( HORIZ_BRACKETS ) ;
170
	    args = alloc_nof ( char, m + 1 ) ;
171
	    for ( i = 0 ; i < m ; i++ ) {
172
		sortid p ;
173
		p = de_sort_name ( 1 ) ;
174
		args [i] = p.decode ;
175
		out ( p.name ) ;
176
	    }
177
	    args [m] = 0 ;
178
	    end_word ( wp ) ;
179
	}
180
	out_string ( "-> " ) ;
181
    }
182
    out ( s.name ) ;
183
    end_word ( w ) ;
184
    if ( obj ) token_sort ( obj, s.res, args, t ) ;
185
    return ;
186
}
187
 
188
 
189
/*
190
    DECODE A TOKEN DEFINITION
191
 
192
    A single token definition is decoded.  If skipping is true then only
193
    the declaration information will be extracted.
194
*/
195
 
196
static void de_tokdef_aux
197
    PROTO_Z ()
198
{
199
    long t ;
200
    sortid s ;
201
    char *args ;
202
    object *obj ;
203
    long end, m ;
204
    word *w = new_word ( HORIZ_NONE ) ;
205
 
206
    /* Find definition type */
207
    IGNORE de_tokdef () ;
208
 
209
    /* Find token number */
210
    t = tdf_int () ;
211
    obj = find_binding ( crt_binding, var_token, t ) ;
212
    if ( obj == null ) {
213
	obj = new_object ( var_token ) ;
214
	set_binding ( crt_binding, var_token, t, obj ) ;
215
    }
216
    out_object ( t, obj, var_token ) ;
217
    out ( ":" ) ;
218
 
219
    /* Deal with signature */
220
    out ( "[" ) ;
221
    decode ( "?[X]" ) ;
222
    out ( "] :" ) ;
223
 
224
    /* Read definition length and work out end */
225
    end = tdf_int () ;
226
    end += posn ( here ) ;
227
 
228
    /* Find definition type */
229
    IGNORE de_token_defn () ;
230
 
231
    /* Decode token sort */
232
    s = de_sort_name ( 1 ) ;
233
    check_list () ;
234
    m = tdf_int () ;
235
    if ( m == 0 ) {
236
	out ( "()" ) ;
237
	args = "" ;
238
    } else {
239
	long i ;
240
	word *wp = new_word ( HORIZ_BRACKETS ) ;
241
	args = alloc_nof ( char, m + 1 ) ;
242
	for ( i = 0 ; i < m ; i++ ) {
243
	    long pn ;
244
	    sortid p ;
245
	    object *tp ;
246
	    p = de_sort_name ( 1 ) ;
247
	    pn = tdf_int () ;
248
	    tp = find_binding ( crt_binding, var_token, pn ) ;
249
	    if ( tp == null ) {
250
		tp = new_object ( var_token ) ;
251
		set_binding ( crt_binding, var_token, pn, tp ) ;
252
	    }
253
	    res_sort ( tp ) = p.res ;
254
	    arg_sorts ( tp ) = null ;
255
	    if ( p.res == sort_token ) {
256
		object *tpa = alloc_nof ( object, 1 ) ;
257
		*tpa = *tp ;
258
		res_sort ( tpa ) = p.res ;
259
		arg_sorts ( tpa ) = p.args ;
260
		tp->aux = tpa ;
261
	    }
262
	    args [i] = p.decode ;
263
	    if ( !dumb_mode && !( tp->named ) ) {
264
		tp->named = 1 ;
265
		tp->name.simple = 1 ;
266
		tp->name.val.str = alloc_nof ( char, 10 ) ;
267
		IGNORE sprintf ( tp->name.val.str, "~par_%ld", i ) ;
268
	    }
269
	    out_string ( p.name ) ;
270
	    out_string ( " " ) ;
271
	    out_object ( pn, tp, var_token ) ;
272
	}
273
	args [m] = 0 ;
274
	end_word ( wp ) ;
275
    }
276
    out_string ( "-> " ) ;
277
 
278
    /* Set result sort */
279
    out ( s.name ) ;
280
    end_word ( w ) ;
281
    token_sort ( obj, s.res, args, t ) ;
282
 
283
    /* Main definition body */
284
    out ( "Definition :" ) ;
285
    if ( skipping || is_foreign ( obj ) ) {
286
	long bits = end - posn ( here ) ;
287
	out ( "...." ) ;
288
	if ( bits < 0 ) {
289
	    input_error ( "Token definition size wrong" ) ;
290
	} else {
291
	    skip_bits ( bits ) ;
292
	}
293
    } else {
294
	char buff [2] ;
295
	buff [0] = s.decode ;
296
	buff [1] = 0 ;
297
	decode ( buff ) ;
298
	if ( posn ( here ) != end ) {
299
	    input_error ( "Token definition size wrong" ) ;
300
	}
301
    }
302
    return ;
303
}
304
 
305
 
306
/*
307
    DECODE A TAG DECLARATION
308
 
309
    A single tag declaration is decoded.
310
*/
311
 
312
static void de_tagdec_aux
313
    PROTO_Z ()
314
{
315
    long t ;
316
    char m ;
317
    word *wa ;
318
    object *obj ;
319
    word *w = new_word ( HORIZ_NONE ) ;
320
 
321
    /* Find declaration type */
322
    long n = de_tagdec () ;
323
 
324
    /* Get tag number */
325
    t = tdf_int () ;
326
    obj = find_binding ( crt_binding, var_tag, t ) ;
327
    if ( obj == null ) {
328
	obj = new_object ( var_tag ) ;
329
	set_binding ( crt_binding, var_tag, t, obj ) ;
330
    }
331
    out_object ( t, obj, var_tag ) ;
332
 
333
    /* Check consistency */
334
    switch ( n ) {
335
	case tagdec_make_var_tagdec : out ( "(variable)" ) ; m = 0 ; break ;
336
	case tagdec_make_id_tagdec : out ( "(identity)" ) ; m = 1 ; break ;
337
	default : out ( "(common)" ) ; m = 2 ; break ;
338
    }
339
    if ( obj ) {
340
	if ( var ( obj ) != m && var ( obj ) != 3 ) {
341
	    string s = object_name ( var_tag, t ) ;
342
	    input_error ( "Tag %s declared inconsistently", s ) ;
343
	}
344
	var ( obj ) = m ;
345
    }
346
 
347
    /* Decode declaration body */
348
    wa = new_word ( VERT_NONE ) ;
349
    format ( HORIZ_NONE, "has access : ", "?[u]" ) ;
350
    format ( HORIZ_NONE, " and signature : ", "?[X]" ) ;
351
    format ( HORIZ_NONE, " and shape : ", "S" ) ;
352
    end_word ( wa ) ;
353
    end_word ( w ) ;
354
    return ;
355
}
356
 
357
 
358
/*
359
    DECODE A TAG DEFINITION
360
 
361
    A single tag definition is decoded.
362
*/
363
 
364
static void de_tagdef_aux
365
    PROTO_Z ()
366
{
367
    long t ;
368
    char m ;
369
    object *obj ;
370
    word *w = new_word ( HORIZ_NONE ) ;
371
 
372
    /* Find definition type */
373
    long n = de_tagdef () ;
374
 
375
    /* Get tag number */
376
    t = tdf_int () ;
377
    obj = find_binding ( crt_binding, var_tag, t ) ;
378
    if ( obj == null ) {
379
	input_error ( "Tag %s defined but not declared",
380
		      object_name ( var_tag, t ) ) ;
381
	obj = new_object ( var_tag ) ;
382
	set_binding ( crt_binding, var_tag, t, obj ) ;
383
    }
384
    out_object ( t, obj, var_tag ) ;
385
 
386
    /* Check consistency */
387
    switch ( n ) {
388
	case tagdef_make_var_tagdef : out ( "(variable)" ) ; m = 0 ; break ;
389
	case tagdef_make_id_tagdef : out ( "(identity)" ) ; m = 1 ; break ;
390
	default : out ( "(common)" ) ; m = 2 ; break ;
391
    }
392
    if ( obj ) {
393
	if ( var ( obj ) != m && var ( obj ) != 3 ) {
394
	    input_error ( "Tag %s declared inconsistently",
395
			  object_name ( var_tag, t ) ) ;
396
	}
397
	var ( obj ) = m ;
398
    }
399
 
400
    /* Decode definition body */
401
    out ( "is :" ) ;
402
    end_word ( w ) ;
403
    if ( m != 1 ) format ( HORIZ_NONE, "access : ", "?[u]" ) ;
404
    format ( HORIZ_NONE, "signature : ", "?[X]" ) ;
405
    IGNORE de_exp () ;
406
    return ;
407
}
408
 
409
 
410
/*
411
    DECODE AN ALIGNMENT TAG DEFINITION
412
 
413
    A single alignment tag definition is decoded.
414
*/
415
 
416
static void de_al_tagdef_aux
417
    PROTO_Z ()
418
{
419
    long t ;
420
    object *obj ;
421
    word *w = new_word ( HORIZ_NONE ) ;
422
 
423
    /* Find definition type */
424
    IGNORE de_al_tagdef () ;
425
 
426
    /* Get alignment tag number */
427
    t = tdf_int () ;
428
    obj = find_binding ( crt_binding, var_al_tag, t ) ;
429
    if ( obj == null ) {
430
	obj = new_object ( var_al_tag ) ;
431
	set_binding ( crt_binding, var_al_tag, t, obj ) ;
432
    }
433
    out_object ( t, obj, var_al_tag ) ;
434
 
435
    /* Decode alignment body */
436
    out ( "is :" ) ;
437
    end_word ( w ) ;
438
    IGNORE de_alignment () ;
439
    return ;
440
}
441
 
442
 
443
/*
444
    DECODE A TOKEN DECLARATION UNIT
445
 
446
    This routine decodes a list of token declarations.
447
*/
448
 
449
void de_tokdec_props
450
    PROTO_Z ()
451
{
452
    long i ;
453
    long n = tdf_int () ;
454
    for ( i = 0 ; i < n ; i++ ) {
455
	de_tokdec_aux () ;
456
	blank_lines = 0 ;
457
    }
458
    total += n ;
459
    return ;
460
}
461
 
462
 
463
/*
464
    DECODE A TOKEN DEFINITION UNIT
465
 
466
    This routine decodes a list of token definitions.
467
*/
468
 
469
void de_tokdef_props
470
    PROTO_Z ()
471
{
472
    long i, n ;
473
    read_no_labs () ;
474
    n = tdf_int () ;
475
    for ( i = 0 ; i < n ; i++ ) {
476
	de_tokdef_aux () ;
477
	blank_line () ;
478
	blank_lines = 1 ;
479
    }
480
    total += n ;
481
    return ;
482
}
483
 
484
 
485
/*
486
    DECODE A TAG DECLARATION UNIT
487
 
488
    This routine decodes a list of tag declarations.
489
*/
490
 
491
void de_tagdec_props
492
    PROTO_Z ()
493
{
494
    long i, n ;
495
    read_no_labs () ;
496
    n = tdf_int () ;
497
    for ( i = 0 ; i < n ; i++ ) {
498
	de_tagdec_aux () ;
499
	blank_line () ;
500
	blank_lines = 1 ;
501
    }
502
    total += n ;
503
    return ;
504
}
505
 
506
 
507
/*
508
    DECODE A TAG DEFINITION UNIT
509
 
510
    This routine decodes a list of tag definitions.
511
*/
512
 
513
void de_tagdef_props
514
    PROTO_Z ()
515
{
516
    long i, n ;
517
    read_no_labs () ;
518
    n = tdf_int () ;
519
    for ( i = 0 ; i < n ; i++ ) {
520
	de_tagdef_aux () ;
521
	blank_line () ;
522
	blank_lines = 1 ;
523
    }
524
    total += n ;
525
    return ;
526
}
527
 
528
 
529
/*
530
    DECODE AN ALIGNMENT TAG DEFINITION UNIT
531
 
532
    This routine decodes a list of alignment tag definitions.
533
*/
534
 
535
void de_al_tagdef_props
536
    PROTO_Z ()
537
{
538
    long i, n ;
539
    read_no_labs () ;
540
    n = tdf_int () ;
541
    for ( i = 0 ; i < n ; i++ ) {
542
	de_al_tagdef_aux () ;
543
	blank_line () ;
544
	blank_lines = 1 ;
545
    }
546
    total += n ;
547
    return ;
548
}
549
 
550
 
551
/*
552
    FLAGS FOR LINKER INFORMATION AND DIAGNOSTICS
553
 
554
    These flags control the output of the various non-core units.
555
*/
556
 
557
int show_usage = 0 ;
558
int diagnostics = 0 ;
559
int versions = 1 ;
560
 
561
 
562
/*
563
    OUTPUT USAGE INFORMATION
564
 
565
    Given a usage n this routine outputs the corresponding usage
566
    information.
567
*/
568
 
569
static void out_usage
570
    PROTO_N ( ( n ) )
571
    PROTO_T ( long n )
572
{
573
    static char *usage_info [] = {
574
	"used", "declared", "defined", "multiply-defined"
575
    } ;
576
    int i ;
577
    int used = 0 ;
578
    word *w = new_word ( HORIZ_BRACKETS ) ;
579
    for ( i = 0 ; i < 4 ; i++ ) {
580
	if ( n & ( 1 << i ) ) {
581
	    out ( usage_info [i] ) ;
582
	    used = 1 ;
583
	}
584
    }
585
    if ( !used ) out ( "unused" ) ;
586
    end_word ( w ) ;
587
    return ;
588
}
589
 
590
 
591
/*
592
    DECODE USAGE INFORMATION
593
 
594
    This routine decodes the usage information for the external variables
595
    of type v.  This consists of a set of usage values in 1-1 correspondence
596
    with the externally named objects of this type.
597
*/
598
 
599
static void de_usage
600
    PROTO_N ( ( v ) )
601
    PROTO_T ( long v )
602
{
603
    object **p ;
604
    long i, n ;
605
    binding *b ;
606
    long total_ext = 0, max_ext = -1 ;
607
    if ( v < 0 || v >= no_variables ) return ;
608
    b = crt_binding + v ;
609
    n = b->sz ;
610
    if ( n == 0 ) return ;
611
    p = alloc_nof ( object *, n ) ;
612
    for ( i = 0 ; i < n ; i++ ) {
613
	object *q = b->table [i] ;
614
	long rank = ( q ? q->order : -1 ) ;
615
	if ( rank != -1 && b->table [i]->named ) {
616
	    p [ rank ] = b->table [i] ;
617
	    if ( rank >= max_ext ) max_ext = rank ;
618
	    total_ext++ ;
619
	}
620
    }
621
    if ( total_ext != max_ext + 1 ) {
622
	input_error ( "Usage information wrong" ) ;
623
	return ;
624
    }
625
    if ( total_ext ) {
626
	out_string ( var_types [v] ) ;
627
	out ( " Usage Information" ) ;
628
	blank_line () ;
629
	for ( i = 0 ; i < total_ext ; i++ ) {
630
	    long use = tdf_int () ;
631
	    word *w = new_word ( HORIZ_NONE ) ;
632
	    if ( p [i]->name.simple ) {
633
		out ( p [i]->name.val.str ) ;
634
	    } else {
635
		out_unique ( p [i]->name.val.uniq ) ;
636
	    }
637
	    out_usage ( use ) ;
638
	    end_word ( w ) ;
639
	}
640
	blank_line () ;
641
	blank_line () ;
642
	blank_lines = 2 ;
643
	total += total_ext ;
644
    }
645
    free ( p ) ;
646
    return ;
647
}
648
 
649
 
650
/*
651
    DECODE LINKER INFORMATION
652
 
653
    This routine decodes the linker information (tld2) units.  These are
654
    used to give the linker information on the usage of tokens and tags.
655
*/
656
 
657
void de_tld2_unit
658
    PROTO_Z ()
659
{
660
    de_usage ( var_token ) ;
661
    de_usage ( var_tag ) ;
662
    return ;
663
}
664
 
665
 
666
/*
667
    DECODE LINKER INFORMATION - NEW VERSION
668
 
669
    This routine decodes the linker information (tld) units.  These are
670
    used to give the linker information on the usage of the externally
671
    named objects.
672
*/
673
 
674
void de_tld_unit
675
    PROTO_Z ()
676
{
677
    long n = tdf_int () ;
678
    switch ( n ) {
679
	case 0 : {
680
	    de_tld2_unit () ;
681
	    break ;
682
	}
683
	case 1 : {
684
	    long v ;
685
	    for ( v = 0 ; v < no_variables ; v++ ) de_usage ( v ) ;
686
	    break ;
687
	}
688
	default : {
689
	    input_error ( "Illegal TLD version number %ld", n ) ;
690
	    break ;
691
	}
692
    }
693
    return ;
694
}
695
 
696
 
697
/*
698
    DECODE A DIAGNOSTIC TAG DEFINITION
699
 
700
    This routine decodes a single diagnostic tag definition.
701
*/
702
 
703
#ifdef HAVE_diag_type_unit
704
 
705
static void de_diag_tagdef_aux
706
    PROTO_Z ()
707
{
708
    long t ;
709
    object *obj ;
710
    word *w = new_word ( HORIZ_NONE ) ;
711
    IGNORE de_diag_tagdef () ;
712
 
713
    /* Get alignment tag number */
714
    t = tdf_int () ;
715
    obj = find_binding ( crt_binding, var_diag_tag, t ) ;
716
    if ( obj == null ) {
717
	obj = new_object ( var_diag_tag ) ;
718
	set_binding ( crt_binding, var_diag_tag, t, obj ) ;
719
    }
720
    out_object ( t, obj, var_diag_tag ) ;
721
 
722
    /* Decode body */
723
    out ( "is :" ) ;
724
    end_word ( w ) ;
725
    IGNORE de_diag_type () ;
726
    return ;
727
}
728
 
729
#endif
730
 
731
 
732
/*
733
    DECODE DIAGNOSTIC TYPE INFORMATION
734
 
735
    This routine decodes a diagnostic type unit.
736
*/
737
 
738
#ifdef HAVE_diag_type_unit
739
 
740
void de_diag_type_unit
741
    PROTO_Z ()
742
{
743
    long i, n ;
744
    read_no_labs () ;
745
    n = tdf_int () ;
746
    for ( i = 0 ; i < n ; i++ ) {
747
	de_diag_tagdef_aux () ;
748
	blank_line () ;
749
	blank_lines = 1 ;
750
    }
751
    total += n ;
752
    return ;
753
}
754
 
755
#endif
756
 
757
 
758
/*
759
    DECODE DIAGNOSTIC INFORMATION
760
 
761
    This routine decodes a diagnostic unit.
762
*/
763
 
764
#ifdef HAVE_diag_unit
765
 
766
void de_diag_unit
767
    PROTO_Z ()
768
{
769
    long i, n ;
770
    read_no_labs () ;
771
    n = tdf_int () ;
772
    for ( i = 0 ; i < n ; i++ ) {
773
	IGNORE de_diag_descriptor () ;
774
	blank_line () ;
775
	blank_lines = 1 ;
776
    }
777
    total += n ;
778
    return ;
779
}
780
 
781
#endif
782
 
783
 
784
/*
785
    DECODE NEW DIAGNOSTIC INFORMATION
786
 
787
    This routine decodes a new diagnostic unit.
788
*/
789
 
790
#ifdef HAVE_dg_comp_props
791
 
792
void de_dg_comp_props
793
    PROTO_Z ()
794
{
795
    long i, n ;
796
    read_no_labs () ;
797
    IGNORE de_dg_compilation () ;
798
    blank_line () ;
799
    blank_lines = 1 ;
800
    n = tdf_int () ;
801
    for ( i = 0 ; i < n ; i++ ) {
802
	IGNORE de_dg_append () ;
803
	blank_line () ;
804
	blank_lines = 1 ;
805
    }
806
    total += ( n + 1 ) ;
807
    return ;
808
}
809
 
810
#endif
811
 
812
 
813
/*
814
    DECODE LINKING INFORMATION
815
 
816
    This routine decode a linkage information unit.
817
*/
818
 
819
#ifdef HAVE_linkinfo_props
820
 
821
void de_linkinfo_props
822
    PROTO_Z ()
823
{
824
    long i, n ;
825
    read_no_labs () ;
826
    n = tdf_int () ;
827
    for ( i = 0 ; i < n ; i++ ) {
828
	IGNORE de_linkinfo () ;
829
	blank_line () ;
830
	blank_lines = 1 ;
831
    }
832
    total += n ;
833
    return ;
834
}
835
 
836
#endif
837
 
838
 
839
/*
840
    PREVIOUS VERSION NUMBER
841
 
842
    These variables are used to store the last version number read so
843
    that duplicate version numbers can be suppressed.
844
*/
845
 
846
static long last_major = -1 ;
847
static long last_minor = -1 ;
848
 
849
 
850
/*
851
    DECODE A VERSION NUMBER
852
 
853
    This routine decodes a version number for an s construct.
854
*/
855
 
856
void de_make_version
857
    PROTO_N ( ( s ) )
858
    PROTO_T ( char *s )
859
{
860
    long v1 = tdf_int () ;
861
    long v2 = tdf_int () ;
862
    if ( v1 != last_major || v2 != last_minor || dumb_mode ) {
863
	word *w ;
864
	out_string ( s ) ;
865
	w = new_word ( HORIZ_BRACKETS ) ;
866
	out_int ( v1 ) ;
867
	out_int ( v2 ) ;
868
	end_word ( w ) ;
869
	last_major = v1 ;
870
	last_minor = v2 ;
871
    }
872
    if ( v1 != version_major || v2 > version_minor ) {
873
	input_error (
874
	    "Illegal version number, %ld.%ld (supported version is %d.%d)",
875
	    v1, v2, version_major, version_minor ) ;
876
    }
877
    return ;
878
}
879
 
880
 
881
/*
882
    DECODE A VERSION UNIT
883
 
884
    This routine decodes a list of version numbers.
885
*/
886
 
887
#ifdef HAVE_version_props
888
 
889
void de_version_props
890
    PROTO_Z ()
891
{
892
    long i, n ;
893
    n = tdf_int () ;
894
    for ( i = 0 ; i < n ; i++ ) {
895
	IGNORE de_version () ;
896
	blank_lines = 0 ;
897
    }
898
    total += n ;
899
    return ;
900
}
901
 
902
#endif
903
 
904
 
905
/*
906
    DECODE A MAGIC NUMBER
907
 
908
    This routine reads the magic number s.
909
*/
910
 
911
void de_magic
912
    PROTO_N ( ( s ) )
913
    PROTO_T ( char *s )
914
{
915
    int i, n = ( int ) strlen ( s ) ;
916
    for ( i = 0 ; i < n ; i++ ) {
917
	long c = fetch ( 8 ) ;
918
	if ( c != ( long ) s [i] ) {
919
	    input_error ( "Bad magic number, %s expected", s ) ;
920
	    exit ( EXIT_FAILURE ) ;
921
	}
922
    }
923
    de_make_version ( s ) ;
924
    last_major = -1 ;
925
    last_minor = -1 ;
926
    byte_align () ;
927
    return ;
928
}