Subversion Repositories tendra.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
# STANDARD TOKEN DECLARATIONS
32
#
33
# The following tokens need to be declared.
34
#
35
 
36
( make_tokdec ~comp_off ( exp ) exp )
37
( make_tokdec ~ptr_to_ptr ( alignment alignment exp ) exp )
38
( make_tokdec ~char variety )
39
( make_tokdec ~signed_int variety )
40
( make_tokdec ~signed_short variety )
41
( make_tokdec ~cpp.offset.div ( exp ) exp )
42
( make_tokdec ~cpp.offset.mult ( alignment exp ) exp )
43
( make_tokdec ~cpp.vtab.func_exp ( exp exp ) exp )
44
( make_tokdec ~cpp.vtab.diag shape )
45
 
46
 
47
#
48
# POINTER TO MEMBER FUNCTION TYPE
49
#
50
# This token gives the type of a pointer to member function.
51
#
52
 
53
( local make_tokdef union
54
    shape
55
    ( compound
56
	( ~comp_off
57
	    ( offset_max
58
		( shape_offset proc )
59
		( shape_offset ( integer ~signed_short ) ) ) ) ) )
60
 
61
( local make_tokdef delta
62
    exp
63
    ( offset_zero ( alignment ( integer ~signed_short ) ) ) )
64
 
65
( local make_tokdef index
66
    exp
67
    ( offset_pad
68
	( alignment ( integer ~signed_short ) )
69
	( offset_add
70
	    delta
71
	    ( shape_offset ( integer ~signed_short ) ) ) ) )
72
 
73
( local make_tokdef func
74
    exp
75
    ( offset_pad
76
	( alignment union )
77
	( offset_add
78
	    index
79
	    ( shape_offset ( integer ~signed_short ) ) ) ) )
80
 
81
( local make_tokdef ptr_mem_func
82
    shape
83
    ( compound
84
	( ~comp_off
85
	    ( offset_add
86
		func
87
		( shape_offset union ) ) ) ) )
88
 
89
 
90
#
91
# NULL POINTER TO MEMBER FUNCTION
92
#
93
# These tokens gives the value of the null pointer to member function.
94
# There are two of them to work round an installer bug.
95
#
96
 
97
( make_tokdef ~cpp.pmf.null
98
    exp
99
    ( make_compound
100
	( shape_offset ptr_mem_func )
101
	delta
102
	( make_int ~signed_short 0 )
103
	index
104
	( make_int ~signed_short 0 )
105
	func
106
	( make_compound
107
	    ( shape_offset union )
108
	    ( offset_zero ( alignment proc ) )
109
	    make_null_proc ) ) )
110
 
111
( make_tokdef ~cpp.pmf.null2
112
    exp
113
    ( make_compound
114
	( shape_offset ptr_mem_func )
115
	delta
116
	( make_int ~signed_short 0 )
117
	index
118
	( make_int ~signed_short 0 )
119
	func
120
	( make_compound
121
	    ( shape_offset union )
122
	    ( offset_zero ( alignment proc ) )
123
	    make_null_proc ) ) )
124
 
125
 
126
#
127
# CONSTRUCT A POINTER TO MEMBER FUNCTION
128
#
129
# These tokens construct a pointer to member function expression.
130
# There are two cases, one for non-virtual functions and one for
131
# virtual functions.
132
#
133
 
134
( make_tokdef ~cpp.pmf.make
135
    ( exp a exp b exp c ) exp
136
    ( make_compound
137
	( shape_offset ptr_mem_func )
138
	delta
139
	( change_variety impossible ~signed_short
140
	    ( minus wrap
141
		( ~cpp.offset.div b )
142
		( ~cpp.offset.div c ) ) )
143
	index
144
	( make_int ~signed_short -1 )
145
	func
146
	( make_compound
147
	    ( shape_offset union )
148
	    ( offset_zero ( alignment proc ) )
149
	    a ) ) )
150
 
151
( make_tokdef ~cpp.pmf.vmake
152
    ( signed_nat a exp b exp c exp d ) exp
153
    ( make_compound
154
	( shape_offset ptr_mem_func )
155
	delta
156
	( change_variety impossible ~signed_short
157
	    ( minus wrap
158
		( ~cpp.offset.div c )
159
		( ~cpp.offset.div d ) ) )
160
	index
161
	( make_int ~signed_short a )
162
	func
163
	( make_compound
164
	    ( shape_offset union )
165
	    ( offset_zero ( alignment ( integer ~signed_short ) ) )
166
	    ( change_variety impossible ~signed_short
167
		( ~cpp.offset.div b ) ) ) ) )
168
 
169
 
170
#
171
# DECONSTRUCT A POINTER TO MEMBER FUNCTION
172
#
173
# These tokens give the various components of the pointer to member
174
# function a.
175
#
176
 
177
( make_tokdef ~cpp.pmf.func
178
    ( exp a ) exp
179
    ( contents proc ( add_to_ptr a func ) ) )
180
 
181
( local make_tokdef ~cpp.pmf.index
182
    ( exp a ) exp
183
    ( change_variety impossible ~signed_int
184
	( contents ( integer ~signed_short )
185
	    ( add_to_ptr a index ) ) ) )
186
 
187
( make_tokdef ~cpp.pmf.delta
188
    ( alignment a exp b ) exp
189
    ( ~cpp.offset.mult a
190
	( change_variety impossible ~signed_int
191
	    ( contents ( integer ~signed_short )
192
		( add_to_ptr b delta ) ) ) ) )
193
 
194
( local make_tokdef ~cpp.pmf.voff
195
    ( exp a ) exp
196
    ( change_variety impossible ~signed_int
197
	( contents ( integer ~signed_short )
198
	    ( add_to_ptr a func ) ) ) )
199
 
200
 
201
#
202
# FIND AN ACTUAL POINTER TO MEMBER FUNCTION
203
#
204
# This token modifies the pointer to member function expression a if it
205
# represents a virtual function by indexing into the virtual function
206
# for the pointer b of alignment c.
207
#
208
 
209
( make_tokdef ~cpp.pmf.virt
210
    ( exp a exp b alignment c ) exp
211
    ( identify i
212
	( ~cpp.pmf.index a )
213
	( conditional lab
214
	    ( sequence
215
		( integer_test greater_than lab
216
		    ( obtain_tag i )
217
		    ( make_int ~signed_int 0 ) )
218
		( assign a
219
		    ( contents ptr_mem_func
220
			( ~cpp.vtab.func_exp
221
			    ( add_to_ptr
222
				( ~ptr_to_ptr
223
				    c
224
				    ( alignment ~cpp.vtab.diag )
225
				    b )
226
				    ( ~cpp.offset.mult
227
					( alignment ~cpp.vtab.diag )
228
					( ~cpp.pmf.voff a ) ) )
229
			    ( obtain_tag i ) ) ) ) )
230
	    make_top ) ) )
231
 
232
 
233
#
234
# POINTER TO MEMBER FUNCTION TEST
235
#
236
# These tokens describe how to compare two pointer to member functions a
237
# and b and how to compare a against the null pointer to member function.
238
# Note that a and b are evaluated more than once in the comparison token,
239
# therefore it may be necessary to introduce an identity before calling it.
240
#
241
 
242
( make_tokdef ~cpp.pmf.compare
243
    ( exp a exp b label lab ntest n ) exp
244
    ( identify i
245
	( ~cpp.pmf.index a )
246
	( variable flag
247
	    ( make_int ~signed_int 0 )
248
	    ( sequence
249
		( conditional lab1
250
		    ( sequence
251
			( integer_test equal lab1
252
			    ( obtain_tag i )
253
			    ( ~cpp.pmf.index b ) )
254
			( offset_test equal lab1
255
			    ( ~cpp.pmf.delta
256
				( alignment ( integer ~char ) ) a )
257
			    ( ~cpp.pmf.delta
258
				( alignment ( integer ~char ) ) b ) )
259
			( conditional lab2
260
			    ( sequence
261
				( integer_test less_than lab2
262
				    ( obtain_tag i )
263
				    ( make_int ~signed_int 0 ) )
264
				( proc_test not_equal lab2
265
				    ( ~cpp.pmf.func a )
266
				    ( ~cpp.pmf.func b ) ) )
267
			    ( assign
268
				( obtain_tag flag )
269
				( make_int ~signed_int 1 ) ) ) )
270
		    make_top )
271
		( integer_test n lab
272
		    ( contents
273
			( integer ~signed_int )
274
			( obtain_tag flag ) )
275
		    ( make_int ~signed_int 1 ) ) ) ) ) )
276
 
277
( make_tokdef ~cpp.pmf.test
278
    ( exp a label lab ntest n ) exp
279
    ( integer_test n lab
280
	( ~cpp.pmf.index a )
281
	( make_int ~signed_int 0 ) ) )
282
 
283
 
284
#
285
# POINTER TO MEMBER FUNCTION CASTS
286
#
287
# These tokens cast a pointer to member function to or from a base class.
288
# b gives the base class offset, c gives the virtual function number offset,
289
# and d gives the offset of the virtual function table.
290
#
291
 
292
( make_tokdef ~cpp.pmf.cast
293
    ( exp a exp b exp c exp d ) exp
294
    ( identify i
295
	( ~cpp.pmf.index a )
296
	( conditional lab
297
	    ( sequence
298
		( integer_test not_equal lab
299
		    ( obtain_tag i )
300
		    ( make_int ~signed_int 0 ) )
301
		( assign ( add_to_ptr a delta )
302
		    ( change_variety impossible ~signed_short
303
			( plus wrap
304
			    ( change_variety impossible ~signed_int
305
				( contents ( integer ~signed_short )
306
				( add_to_ptr a delta ) ) )
307
			    ( ~cpp.offset.div b ) ) ) )
308
		( conditional lab2
309
		    ( sequence
310
			( integer_test greater_than lab2
311
			    ( obtain_tag i )
312
			    ( make_int ~signed_int 0 ) )
313
			( assign ( add_to_ptr a index )
314
			    ( change_variety impossible ~signed_short
315
				( plus wrap ( obtain_tag i ) c ) ) )
316
			( assign ( add_to_ptr a func )
317
			    ( change_variety impossible ~signed_short
318
				( ~cpp.offset.div d ) ) ) )
319
		    make_top ) )
320
		make_top ) ) )
321
 
322
( make_tokdef ~cpp.pmf.uncast
323
    ( exp a exp b exp c exp d ) exp
324
    ( identify i
325
	( ~cpp.pmf.index a )
326
	( conditional lab
327
	    ( sequence
328
		( integer_test not_equal lab
329
		    ( obtain_tag i )
330
		    ( make_int ~signed_int 0 ) )
331
		( assign ( add_to_ptr a delta )
332
		    ( change_variety impossible ~signed_short
333
			( minus wrap
334
			    ( change_variety impossible ~signed_int
335
				( contents ( integer ~signed_short )
336
				( add_to_ptr a delta ) ) )
337
			    ( ~cpp.offset.div b ) ) ) )
338
		( conditional lab2
339
		    ( sequence
340
			( integer_test greater_than lab2
341
			    ( obtain_tag i )
342
			    ( make_int ~signed_int 0 ) )
343
			( assign ( add_to_ptr a index )
344
			    ( change_variety impossible ~signed_short
345
				( minus wrap ( obtain_tag i ) c ) ) )
346
			( assign ( add_to_ptr a func )
347
			    ( change_variety impossible ~signed_short
348
				( ~cpp.offset.div d ) ) ) )
349
		    make_top ) )
350
		make_top ) ) )