Subversion Repositories tendra.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
<!-- Crown Copyright (c) 1998 -->
2
<HTML>
3
<HEAD>
4
<TITLE>
5
C++ Producer Guide 
6
</TITLE>
7
</HEAD>
8
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#400080" ALINK="#FF0000">
9
 
10
<H1><A NAME="top">C++ Producer Guide</A></H1>
11
 
12
<H3>March 1998</H3>
13
<A HREF="man.html"><IMG SRC="../images/next.gif" ALT="next section"></A>
14
<IMG SRC="../images/no_prev.gif" ALT="previous section">
15
<IMG SRC="../images/no_top.gif" ALT="current document">
16
<A HREF="../index.html"><IMG SRC="../images/home.gif" ALT="TenDRA home page">
17
</A>
18
<IMG SRC="../images/no_index.gif" ALT="document index"><P>
19
<HR>
20
 
21
<DL>
22
<DT><A HREF="#intro"><B>1</B> - Introduction</A><DD>
23
<DL>
24
<DT><A HREF="#update"><B>1.1</B> - Updated introduction</A><DD>
25
</DL>
26
<DT><A HREF="#interface"><B>2</B> - Interface descriptions</A><DD>
27
<DL>
28
<DT><A HREF="man.html"><B>2.1</B> - Invocation</A><DD>
29
<DT><A HREF="pragma.html"><B>2.2</B> - Compiler configuration</A><DD>
30
<DT><A HREF="token.html"><B>2.3</B> - Token syntax</A><DD>
31
<DT><A HREF="dump.html"><B>2.4</B> - Symbol table dump</A><DD>
32
<DT><A HREF="link.html"><B>2.5</B> - Intermodule analysis</A><DD>
33
<DT><A HREF="lib.html"><B>2.6</B> - Implementation details</A><DD>
34
<DT><A HREF="std.html"><B>2.7</B> - Standard library</A><DD>
35
</DL>
36
<DT><A HREF="#program"><B>3</B> - Program overview</A><DD>
37
<DL>
38
<DT><A HREF="style.html"><B>3.1</B> - Source code organisation</A><DD>
39
<DT><A HREF="alg.html"><B>3.2</B> - Type system</A><DD>
40
<DT><A HREF="error.html"><B>3.3</B> - Error database</A><DD>
41
<DT><A HREF="parse.html"><B>3.4</B> - Parsing C++</A><DD>
42
<DT><A HREF="tdf.html"><B>3.5</B> - TDF generation</A><DD>
43
</DL>
44
<DT><A HREF="#reference">References</A><DD>
45
<DT><A HREF="pragma1.html">Annexes</A><DD>
46
<DL>
47
<DT><A HREF="pragma1.html"><B>A</B> - <CODE>#pragma</CODE> directive
48
syntax</A><DD>
49
<DT><A HREF="dump1.html"><B>B</B> - Symbol table dump syntax</A><DD>
50
<DT><A HREF="error1.html"><B>C</B> - Error catalogue syntax</A><DD>
51
</DL>
52
</DL>
53
 
54
<HR>
55
<H1><A NAME="intro">1. Introduction</A></H1>
56
<P>
57
This document is designed as a technical overview of the TenDRA C++
58
to TDF/ANDF producer.  It is divided into two broad areas; descriptions
59
of the <A HREF="#interface">public interfaces</A> of the producer,
60
and an overview of the producer <A HREF="#program">source code</A>.
61
</P>
62
<P>
63
Whereas the interface description contains most of the information
64
which would be required in a users' guide, it is not necessarily in
65
a readily digestible form.  The C++ producer is designed to complement
66
the existing TenDRA C to TDF producer; although they are completely
67
distinct programs, the same design philosophy underlies both and they
68
share a number of common interfaces.  There are no radical differences
69
between the two producers, besides the fact that the C++ producer
70
covers a vastly larger and more complex language.  This means that
71
much of the <A HREF="#tdfc">existing documentation on the C producer</A>
72
can be taken as also applying to the C++ producer.  This document tries to
73
make clear where the C++ producer extends the C producer's interfaces,
74
and those portions of these interfaces which are not directly applicable
75
to C++. 
76
</P>
77
<P>
78
A familiarity with both C++ and TDF is assumed. The version of C++
79
implemented is that given by the <A HREF="#cplusplus">draft ISO C++
80
standard</A>.  All references to &quot;ISO C++&quot; within the document
81
should strictly be qualified using the word &quot;draft&quot;, but
82
for convenience this has been left implicit.  The C++ producer has
83
a number of switches which allow it to be configured for older dialects
84
of C++.  In particular, the version of C++ described in the <A HREF="#arm">ARM
85
(Annotated Reference Manual)</A> is fully supported. 
86
</P>
87
The <A HREF="#tdf">TDF specification</A> (version 4.0) may be consulted
88
for a description of the compiler intermediate language used.  The
89
paper 
90
<A HREF="#port"><I>TDF and Portability</I></A> provides a useful (if
91
slightly old) introduction to some of the ideas relating to static
92
program analysis and interface checking which underlie the whole TenDRA
93
compilation system. 
94
<P>
95
The warning sign: 
96
<CENTER>
97
<IMG SRC="../images/warn.gif" ALT="warning">
98
</CENTER>
99
is used within the document to indicate areas where the implementation
100
is currently incomplete or incorrect. 
101
</P>
102
<P>
103
<H2><A NAME="update">1.1. Updated introduction</A></H2>
104
<P>
105
Since this document was originally written, the old C producer,
106
<I>tdfc</I>, has been replaced by a new C producer, <I>tdfc2</I>, which
107
is just a modified version of the C++ producer, <I>tcpplus</I>.  All
108
C producer documentation continues to apply to the new C producer,
109
but the new C producer also has many of the features described in this
110
document as only applying to the C++ producer.
111
</P>
112
 
113
<HR>
114
<H1><A NAME="interface">2. Interface descriptions</A></H1>
115
<P>
116
The most important public interfaces of the C++ producer are the ISO
117
C++ standard and the TDF 4.0 specification; however there are other
118
interfaces, mostly common to both the C and C++ producers, which are
119
described in this section. 
120
</P>
121
<P>
122
An important design criterion of the C++ producer was that it should
123
be strictly ISO conformant by default, but have a method whereby dialect
124
features and extra static program analysis can be enabled. This compiler
125
configuration is controlled by the 
126
<A HREF="pragma.html"><CODE>#pragma TenDRA</CODE> directives</A>
127
described in the first section. 
128
</P>
129
<P>
130
The requirement that the C and C++ producers should be able to translate
131
portable C or C++ programs into target independent TDF requires a
132
mechanism whereby the target dependent implementations of APIs can
133
be represented.  This mechanism, the <A HREF="token.html"><CODE>#pragma
134
token</CODE> syntax</A>, is described in the following section.  Note
135
that at present this mechanism only contains support for C APIs; it
136
is considered that the C++ language itself contains sufficient interface
137
mechanisms for C++ APIs to be described. 
138
</P>
139
<P>
140
The C and C++ producers provide two mechanisms whereby type and declaration
141
information derived from a translation unit can be stored to a file
142
for post-processing by other tools.  The first is the 
143
<A HREF="dump.html">symbol table dump</A>, which is a public interface
144
designed for use by third party tools.  The second is the 
145
<A HREF="link.html">C/C++ spec file</A>, which is designed for ease
146
of reading and writing by the producers themselves, and is used for
147
intermodule analysis. 
148
</P>
149
<P>
150
The mapping from C++ to TDF implemented by the C++ producer is largely
151
straightforward.  There are however target dependencies arising within
152
the language itself which require special handling.  These are represented
153
by certain <A HREF="lib.html">standard tokens</A> which the producer
154
requires to be defined on the target machine.  These tokens are also
155
used to describe the interface between the producer and the run-time
156
system.  Note that the C++ producer is primarily concerned with the
157
C++ language, not with the standard C++ library. An example implementation
158
of those library components which are required as an integral part
159
of the language (memory allocation, exception handling, run-time type
160
information etc.) is provided. Otherwise, libraries should be obtained
161
from third parties.  A number of hints on <A HREF="std.html">integrating
162
such libraries</A> with the C++ producer are given. 
163
</P>
164
 
165
<HR>
166
<H1><A NAME="program">3. Program overview</A></H1>
167
<P>
168
The C++ producer is a large program (over 200000 lines, including
169
automatically generated code) written in C.  A description of the
170
<A HREF="style.html#language">coding conventions</A> used, the 
171
<A HREF="style.html#api">API</A> observed and the basic organisation
172
of the <A HREF="style.html#src">source code</A> are described in the
173
first section. 
174
</P>
175
<P>
176
One of the design methods used in the C++ producer is the extensive
177
use of automatic code generation tools.  The type system is based
178
around the <CODE>calculus</CODE> tool, which allows complex type systems
179
to be described in a simple format.  The interface generated by <CODE>calculus
180
</CODE> allows for rigorous static type checking, generic type constructors
181
for lists, stacks etc., encapsulation of the operations on the types
182
within the system, and optional run-time checking for null pointers
183
and discriminated union tags.  An overview is given of the <A HREF="alg.html">type
184
system</A> used as the basis of the C++ producer design.  Also see
185
the 
186
<A HREF="../utilities/calc.html"><CODE>calculus</CODE> users' guide</A>.
187
</P>
188
<P>
189
The other general purpose code generation tool used in the C++ producer
190
is the parser generator, <CODE>sid</CODE>.  A brief description of
191
the problems in writing a <A HREF="parse.html">C++ parser</A> is given.
192
Also see the <A HREF="../utilities/sid.html"><CODE>sid</CODE> users'
193
guide</A>. 
194
</P>
195
<P>
196
The other code generation tools used were written specifically for
197
the C++ producer.  The error reporting routines within the producer
198
are based on an <A HREF="error.html">error catalogue</A>, from which
199
code for constructing and printing errors is generated.  The 
200
<A HREF="tdf.html">TDF output routines</A> are based on primitives
201
automatically generated from a standard database describing the TDF
202
specification. 
203
</P>
204
<P>
205
The program itself is well commented, so no lower level program documentation
206
has been provided.  When performing development work the producer
207
should be compiled with the <CODE>DEBUG</CODE> macro defined. This
208
enables the <CODE>calculus</CODE> run-time checks, along with other
209
assertions, and makes available the debugging routines, 
210
<CODE>DEBUG_</CODE><I>type</I>, which can be used to print an object
211
from the internal type system. 
212
</P>
213
 
214
<HR>
215
<H1><A NAME="reference">References</A></H1>
216
<OL>
217
<LI><A NAME="cplusplus"><B>Working paper for Draft Proposed Internation
218
Standard for Information Systems - Programming Language C++</B></A>,
219
X3J16/96-0225, December 1996:     
220
<A HREF="http://www.cygnus.com/misc/wp/dec96pub/">
221
<CODE>http://www.cygnus.com/misc/wp/dec96pub/</CODE></A> or     
222
<A HREF="http://www.maths.warwick.ac.uk/c++/pub/wp/html/cd2/">
223
<CODE>http://www.maths.warwick.ac.uk/c++/pub/wp/html/cd2/</CODE></A>.
224
<P>
225
<LI><A NAME="arm"><B>The Annotated C++ Reference Manual</B></A>, 
226
Margaret Ellis and Bjarne Stroustrup, ISBN 0-201-51459-1,     Addison-Wesley,
227
1990:     
228
<A HREF="http://heg-school.aw.com/cseng/authors/ellis/annocpp/annocpp.html">
229
<CODE>http://heg-school.aw.com/cseng/authors/ellis/annocpp/annocpp.html</CODE>
230
</A>
231
<P>
232
<LI><A NAME="tdf"><B>TDF Specification, Issue 4.0</B></A>: 
233
<A HREF="../tdf/spec1.html">attached</A>. 
234
<P>
235
<LI><A NAME="tdfc"><B>C Checker Reference Manual</B></A>: 
236
<A HREF="../tdfc/tdfc1.html">attached</A>. 
237
<P>
238
<LI><A NAME="port"><B>TDF and Portability</B></A>: 
239
<A HREF="../port/port1.html">attached</A>. 
240
<P>
241
<LI><A NAME="cstyle"><B>C Coding Standards</B></A>,     DRA/CIS(SE2)/WI/94/57/2.0
242
(OSSG internal document). 
243
</OL>
244
<P>
245
 
246
<HR>
247
<P><I>Part of the <A HREF="../index.html">TenDRA Web</A>.<BR>Crown
248
Copyright &copy; 1998.</I></P>
249
</BODY>
250
</HTML>