Subversion Repositories tendra.SVN

Rev

Rev 2 | Details | Compare with Previous | 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
# TOKEN DECLARATIONS
32
#
33
# The following standard tokens are declared.
34
#
35
 
36
( make_tokdec ~comp_off ( exp ) exp )
37
( make_tokdec ~cpp.pmf.type shape )
38
( make_tokdec ~cpp.typeid.type shape )
39
( make_tokdec ~cpp.offset.div ( exp ) exp )
40
( make_tokdec ~cpp.vtab.diag shape )
41
( make_tokdec ~signed_short variety )
42
( make_tokdec ~signed_int variety )
43
( make_id_tagdec __TCPPLUS_pure proc )
44
 
45
 
46
#
47
# VIRTUAL FUNCTION TABLE TYPE DEFINITION
48
#
49
# These tokens describe the type representing a virtual function table.
50
# This is basically the same as the type VTABLE defined in implement.h but
51
# the size of the table, n, is provided as a token argument.
52
#
53
 
54
( local make_tokdef extra.rtti
55
    exp
56
    ( offset_zero ( alignment ( pointer ( alignment top ) ) ) ) )
57
 
58
( local make_tokdef extra.off
59
    exp
60
    ( offset_pad
61
	( alignment ( integer ~signed_short ) )
62
	( offset_add
63
	    extra.rtti
64
	    ( shape_offset
65
		( pointer ( alignment ~cpp.typeid.type ) ) ) ) ) )
66
 
67
( local make_tokdef extra
68
    shape
69
    ( compound
70
	( ~comp_off
71
	    ( offset_add
72
		extra.off
73
		( shape_offset
74
		    ( integer ~signed_short ) ) ) ) ) )
75
 
76
( make_tokdef ~cpp.vtab.type
77
    ( nat n ) shape
78
    ( compound
79
	( ~comp_off
80
	    ( offset_max
81
		( shape_offset
82
		    ( nof n ~cpp.pmf.type ) )
83
		( shape_offset extra ) ) ) ) )
84
 
85
 
86
#
87
# CONSTRUCT A VIRTUAL FUNCTION TABLE
88
#
89
# This token constructs a virtual function table of size n consisting of
90
# the run-time type information r, the offset a and the pointer to member
91
# functions f.
92
#
93
 
94
( make_tokdef ~cpp.vtab.make
95
    ( exp r exp a nat n exp f ) exp
96
    ( make_compound
97
	( shape_offset ( ~cpp.vtab.type n ) )
98
	( offset_zero ( alignment extra ) )
99
	( make_compound
100
	    ( shape_offset extra )
101
	    extra.rtti
102
	    r
103
	    extra.off
104
	    ( change_variety impossible ~signed_short
105
		( negate wrap ( ~cpp.offset.div a ) ) ) )
106
	( offset_pad
107
	    ( alignment ~cpp.pmf.type )
108
	    ( shape_offset ~cpp.pmf.type ) )
109
	f ) )
110
 
111
 
112
#
113
# FIND A VIRTUAL FUNCTION TABLE ENTRY
114
#
115
# These tokens gives a pointer to the nth pointer to member function in the
116
# virtual function table t.
117
#
118
 
119
( make_tokdef ~cpp.vtab.func_exp
120
    ( exp t exp n ) exp
121
    ( add_to_ptr
122
	( contents
123
	    ( pointer ( alignment ~cpp.vtab.diag ) )
124
	    t )
125
	( offset_mult
126
	    ( offset_pad
127
		( alignment ~cpp.pmf.type )
128
		( shape_offset ~cpp.pmf.type ) )
129
		n ) ) )
130
 
131
( make_tokdef ~cpp.vtab.func
132
    ( exp t signed_nat n ) exp
133
    ( ~cpp.vtab.func_exp t ( make_int ~signed_int n ) ) )
134
 
135
( make_tokdef ~cpp.vtab.off
136
    ( signed_nat n ) exp
137
    ( offset_mult
138
	( offset_pad
139
	    ( alignment ~cpp.pmf.type )
140
	    ( shape_offset ~cpp.pmf.type ) )
141
	    ( make_int ~signed_int n ) ) )
142
 
143
 
144
#
145
# FIND RUN-TIME TYPE INFORMATION
146
#
147
# This token gives the run-time type information structure associated
148
# with the virtual function table t.
149
#
150
 
151
( make_tokdef ~cpp.typeid.ref
152
    ( exp t ) exp
153
    ( contents
154
	( pointer ( alignment ~cpp.typeid.type ) )
155
	( add_to_ptr
156
	    ( contents
157
		( pointer ( alignment ~cpp.vtab.diag ) )
158
		t )
159
	    extra.rtti ) ) )
160
 
161
 
162
#
163
# PURE VIRTUAL FUNCTION
164
#
165
# This token gives the function pointer used in the entry for a pure virtual 
166
# in a virtual function table.
167
#
168
 
169
( make_tokdef ~cpp.vtab.pure
170
    exp
171
    ( obtain_tag __TCPPLUS_pure ) )