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 |
#ifndef CONSTANT_INCLUDED
|
|
|
32 |
#define CONSTANT_INCLUDED
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
/*
|
|
|
36 |
CONSTANT EVALUATION MACROS
|
|
|
37 |
|
|
|
38 |
All the calculation routines are based on lists of unsigned int's
|
|
|
39 |
holding values in the range [0,0xffff]. The type unsigned long is
|
|
|
40 |
guaranteed to contain at least the range [0,0xffffffff]. All
|
|
|
41 |
calculations are performed in this double precision type to allow for
|
|
|
42 |
overflows. The macros LO_HALF, HI_HALF, EXTEND_VALUE and COMBINE_VALUES
|
|
|
43 |
are used for converting to and from the extended type.
|
|
|
44 |
*/
|
|
|
45 |
|
|
|
46 |
#define NAT_DIGITS 16
|
|
|
47 |
#define NAT_MASK ( ( unsigned ) 0xffff )
|
|
|
48 |
|
|
|
49 |
#define LO_HALF( A ) ( ( unsigned ) ( ( A ) & NAT_MASK ) )
|
|
|
50 |
#define HI_HALF( A ) ( LO_HALF ( ( A ) >> NAT_DIGITS ) )
|
|
|
51 |
|
|
|
52 |
#define EXTEND_VALUE( A ) ( ( unsigned long ) ( A ) )
|
|
|
53 |
#define COMBINE_VALUES( A, B ) ( EXTEND_VALUE ( A ) +\
|
|
|
54 |
( EXTEND_VALUE ( B ) << NAT_DIGITS ) )
|
|
|
55 |
#define EXTENDED_MAX COMBINE_VALUES ( NAT_MASK, NAT_MASK )
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
/*
|
|
|
59 |
CONSTANT EVALUATION DECLARATIONS
|
|
|
60 |
|
|
|
61 |
The routines in this module are concerned with constructing and
|
|
|
62 |
performing calculations with integer constant expressions.
|
|
|
63 |
*/
|
|
|
64 |
|
|
|
65 |
extern void init_constant PROTO_S ( ( void ) ) ;
|
|
|
66 |
extern void init_float PROTO_S ( ( FLOAT_TYPE ) ) ;
|
|
|
67 |
extern FLOAT get_float PROTO_S ( ( TYPE, int ) ) ;
|
|
|
68 |
|
|
|
69 |
extern NAT make_nat_literal PROTO_S ( ( NAT, unsigned, unsigned ) ) ;
|
|
|
70 |
extern NAT make_large_nat PROTO_S ( ( LIST ( unsigned ) ) ) ;
|
|
|
71 |
extern NAT make_nat_value PROTO_S ( ( unsigned long ) ) ;
|
|
|
72 |
extern NAT make_small_nat PROTO_S ( ( int ) ) ;
|
|
|
73 |
extern unsigned long get_nat_value PROTO_S ( ( NAT ) ) ;
|
|
|
74 |
extern NAT negate_nat PROTO_S ( ( NAT ) ) ;
|
|
|
75 |
extern NAT binary_nat_op PROTO_S ( ( unsigned, NAT, NAT ) ) ;
|
|
|
76 |
extern int compare_nat PROTO_S ( ( NAT, NAT ) ) ;
|
|
|
77 |
extern int eq_nat PROTO_S ( ( NAT, NAT ) ) ;
|
|
|
78 |
|
|
|
79 |
extern int check_nat_range PROTO_S ( ( TYPE, NAT ) ) ;
|
|
|
80 |
extern int check_type_size PROTO_S ( ( TYPE, NAT ) ) ;
|
|
|
81 |
extern NAT max_type_value PROTO_S ( ( TYPE, int ) ) ;
|
|
|
82 |
extern void check_bounds PROTO_S ( ( int, TYPE, EXP ) ) ;
|
|
|
83 |
extern unsigned eval_const_cond PROTO_S ( ( EXP ) ) ;
|
|
|
84 |
extern unsigned no_bits PROTO_S ( ( unsigned ) ) ;
|
|
|
85 |
extern int divides_nat PROTO_S ( ( EXP, EXP ) ) ;
|
|
|
86 |
extern int is_zero_nat PROTO_S ( ( NAT ) ) ;
|
|
|
87 |
extern int is_negative_nat PROTO_S ( ( NAT ) ) ;
|
|
|
88 |
extern int is_error_nat PROTO_S ( ( NAT ) ) ;
|
|
|
89 |
extern int is_calc_nat PROTO_S ( ( NAT ) ) ;
|
|
|
90 |
extern int is_zero_exp PROTO_S ( ( EXP ) ) ;
|
|
|
91 |
extern int is_literal PROTO_S ( ( EXP ) ) ;
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
/*
|
|
|
95 |
CONSTANT EVALUATION ROUTINES
|
|
|
96 |
|
|
|
97 |
These routines are concerned with the evaluation of integer constant
|
|
|
98 |
expressions. They are so designed that the int_lit expressions are
|
|
|
99 |
precisely the constant-expressions from the grammar.
|
|
|
100 |
*/
|
|
|
101 |
|
|
|
102 |
extern EXP make_test_nat PROTO_S ( ( EXP ) ) ;
|
|
|
103 |
extern EXP make_unary_nat PROTO_S ( ( unsigned, EXP ) ) ;
|
|
|
104 |
extern EXP make_binary_nat PROTO_S ( ( unsigned, EXP, EXP ) ) ;
|
|
|
105 |
extern EXP make_compare_nat PROTO_S ( ( NTEST, EXP, EXP ) ) ;
|
|
|
106 |
extern EXP make_cond_nat PROTO_S ( ( EXP, EXP, EXP ) ) ;
|
|
|
107 |
extern EXP make_cast_nat PROTO_S ( ( TYPE, EXP, ERROR *, unsigned ) ) ;
|
|
|
108 |
extern EXP make_int_exp PROTO_S ( ( TYPE, unsigned, NAT ) ) ;
|
|
|
109 |
extern NAT make_nat_exp PROTO_S ( ( EXP, ERROR * ) ) ;
|
|
|
110 |
extern EXP calc_nat_value PROTO_S ( ( NAT, TYPE ) ) ;
|
|
|
111 |
|
|
|
112 |
#define SMALL_NAT_SIZE 257
|
|
|
113 |
#define SMALL_NAT_ALLOC 17
|
|
|
114 |
#define SMALL_FLT_SIZE 2
|
|
|
115 |
|
|
|
116 |
extern NAT small_neg_nat [ SMALL_NAT_SIZE ] ;
|
|
|
117 |
extern NAT small_nat [ SMALL_NAT_SIZE ] ;
|
|
|
118 |
extern string small_number [ SMALL_FLT_SIZE ] ;
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
#endif
|