2 |
7u83 |
1 |
# Crown Copyright (c) 1997
|
|
|
2 |
#
|
|
|
3 |
# This TenDRA(r) Computer Program is subject to Copyright
|
|
|
4 |
# owned by the United Kingdom Secretary of State for Defence
|
|
|
5 |
# acting through the Defence Evaluation and Research Agency
|
|
|
6 |
# (DERA). It is made available to Recipients with a
|
|
|
7 |
# royalty-free licence for its use, reproduction, transfer
|
|
|
8 |
# to other parties and amendment for any purpose not excluding
|
|
|
9 |
# product development provided that any such use et cetera
|
|
|
10 |
# shall be deemed to be acceptance of the following conditions:-
|
|
|
11 |
#
|
|
|
12 |
# (1) Its Recipients shall ensure that this Notice is
|
|
|
13 |
# reproduced upon any copies or amended versions of it;
|
|
|
14 |
#
|
|
|
15 |
# (2) Any amended version of it shall be clearly marked to
|
|
|
16 |
# show both the nature of and the organisation responsible
|
|
|
17 |
# for the relevant amendment or amendments;
|
|
|
18 |
#
|
|
|
19 |
# (3) Its onward transfer from a recipient to another
|
|
|
20 |
# party shall be deemed to be that party's acceptance of
|
|
|
21 |
# these conditions;
|
|
|
22 |
#
|
|
|
23 |
# (4) DERA gives no warranty or assurance as to its
|
|
|
24 |
# quality or suitability for any purpose and DERA accepts
|
|
|
25 |
# no liability whatsoever in relation to any use to which
|
|
|
26 |
# it may be put.
|
|
|
27 |
#
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
#
|
|
|
31 |
# TOKEN DECLARATIONS
|
|
|
32 |
#
|
|
|
33 |
# The following standard C tokens are declared.
|
|
|
34 |
#
|
|
|
35 |
|
|
|
36 |
( make_tokdec ~char variety )
|
|
|
37 |
( make_tokdec ~signed_int variety )
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
#
|
|
|
41 |
# OFFSET TO INTEGER CONVERSIONS
|
|
|
42 |
#
|
|
|
43 |
# These tokens are used to convert offsets to and from integers. The
|
|
|
44 |
# latter uses an offset cast to prevent the rounding which would occur
|
|
|
45 |
# from a more natural offset_pad expression - the C++ type rules ensure
|
|
|
46 |
# correctness.
|
|
|
47 |
#
|
|
|
48 |
|
|
|
49 |
( make_tokdef ~cpp.offset.div
|
|
|
50 |
( exp a ) exp
|
|
|
51 |
( offset_div ~signed_int
|
|
|
52 |
( offset_subtract
|
|
|
53 |
( offset_pad ( alignment ( integer ~char ) ) a )
|
|
|
54 |
( offset_zero ( alignment ( integer ~char ) ) ) )
|
|
|
55 |
( offset_pad
|
|
|
56 |
( alignment ( integer ~char ) )
|
|
|
57 |
( shape_offset ( integer ~char ) ) ) ) )
|
|
|
58 |
|
|
|
59 |
( make_tokdef ~cpp.offset.cast
|
|
|
60 |
( alignment s exp a ) exp
|
|
|
61 |
( component
|
|
|
62 |
( offset s s )
|
|
|
63 |
( make_compound
|
|
|
64 |
( offset_max
|
|
|
65 |
( shape_offset
|
|
|
66 |
( offset
|
|
|
67 |
( alignment ( integer ~char ) )
|
|
|
68 |
( alignment ( integer ~char ) ) ) )
|
|
|
69 |
( shape_offset
|
|
|
70 |
( offset s s ) ) )
|
|
|
71 |
( offset_zero
|
|
|
72 |
( alignment
|
|
|
73 |
( offset
|
|
|
74 |
( alignment ( integer ~char ) )
|
|
|
75 |
( alignment ( integer ~char ) ) ) ) )
|
|
|
76 |
a )
|
|
|
77 |
( offset_zero ( alignment ( offset s s ) ) ) ) )
|
|
|
78 |
|
|
|
79 |
( make_tokdef ~cpp.offset.mult
|
|
|
80 |
( alignment s exp a ) exp
|
|
|
81 |
( ~cpp.offset.cast
|
|
|
82 |
s
|
|
|
83 |
( offset_mult
|
|
|
84 |
( offset_pad
|
|
|
85 |
( alignment ( integer ~char ) )
|
|
|
86 |
( shape_offset ( integer ~char ) ) )
|
|
|
87 |
a ) ) )
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
#
|
|
|
91 |
# NULL POINTER TO DATA MEMBER
|
|
|
92 |
#
|
|
|
93 |
# This token gives the null pointer to data member.
|
|
|
94 |
#
|
|
|
95 |
|
|
|
96 |
( make_tokdef ~cpp.pm.null
|
|
|
97 |
exp
|
|
|
98 |
( make_int ~signed_int 0 ) )
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
#
|
|
|
102 |
# CONSTRUCT A POINTER TO DATA MEMBER
|
|
|
103 |
#
|
|
|
104 |
# This token constructs a pointer to data member from the offset
|
|
|
105 |
# expression a. Note that 1 is added to allow for null pointers to
|
|
|
106 |
# members.
|
|
|
107 |
#
|
|
|
108 |
|
|
|
109 |
( make_tokdef ~cpp.pm.make
|
|
|
110 |
( exp a ) exp
|
|
|
111 |
( plus wrap
|
|
|
112 |
( ~cpp.offset.div a )
|
|
|
113 |
( make_int ~signed_int 1 ) ) )
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
#
|
|
|
117 |
# DECONSTRUCT A POINTER TO DATA MEMBER
|
|
|
118 |
#
|
|
|
119 |
# This token turns the pointer to data member expression a into an offset
|
|
|
120 |
# for a shape of alignment s. The result is undefined if a is the null
|
|
|
121 |
# pointer to member, otherwise 1 needs to be subtracted from a.
|
|
|
122 |
#
|
|
|
123 |
|
|
|
124 |
( make_tokdef ~cpp.pm.offset
|
|
|
125 |
( exp a alignment s ) exp
|
|
|
126 |
( ~cpp.offset.mult
|
|
|
127 |
s
|
|
|
128 |
( minus wrap a ( make_int ~signed_int 1 ) ) ) )
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
#
|
|
|
132 |
# POINTER TO DATA MEMBER TEST
|
|
|
133 |
#
|
|
|
134 |
# These tokens are used to compare the pointer to data member expressions
|
|
|
135 |
# a and b and to compare a against the null pointer to member.
|
|
|
136 |
#
|
|
|
137 |
|
|
|
138 |
( make_tokdef ~cpp.pm.compare
|
|
|
139 |
( exp a exp b label lab ntest n ) exp
|
|
|
140 |
( integer_test n lab a b ) )
|
|
|
141 |
|
|
|
142 |
( make_tokdef ~cpp.pm.test
|
|
|
143 |
( exp a label lab ntest n ) exp
|
|
|
144 |
( integer_test n lab a ( make_int ~signed_int 0 ) ) )
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
#
|
|
|
148 |
# POINTER TO DATA MEMBER CAST
|
|
|
149 |
#
|
|
|
150 |
# These tokens cast a non-null pointer to data member a by adding or
|
|
|
151 |
# subtracting the base class offset b.
|
|
|
152 |
#
|
|
|
153 |
|
|
|
154 |
( make_tokdef ~cpp.pm.cast
|
|
|
155 |
( exp a exp b ) exp
|
|
|
156 |
( plus wrap a ( ~cpp.offset.div b ) ) )
|
|
|
157 |
|
|
|
158 |
( make_tokdef ~cpp.pm.uncast
|
|
|
159 |
( exp a exp b ) exp
|
|
|
160 |
( minus wrap a ( ~cpp.offset.div b ) ) )
|