#pragma
directive
syntaxThis document is designed as a technical overview of the TenDRA C++ to TDF/ANDF producer. It is divided into two broad areas; descriptions of the public interfaces of the producer, and an overview of the producer source code.
Whereas the interface description contains most of the information which would be required in a users' guide, it is not necessarily in a readily digestible form. The C++ producer is designed to complement the existing TenDRA C to TDF producer; although they are completely distinct programs, the same design philosophy underlies both and they share a number of common interfaces. There are no radical differences between the two producers, besides the fact that the C++ producer covers a vastly larger and more complex language. This means that much of the existing documentation on the C producer can be taken as also applying to the C++ producer. This document tries to make clear where the C++ producer extends the C producer's interfaces, and those portions of these interfaces which are not directly applicable to C++.
A familiarity with both C++ and TDF is assumed. The version of C++ implemented is that given by the draft ISO C++ standard. All references to "ISO C++" within the document should strictly be qualified using the word "draft", but for convenience this has been left implicit. The C++ producer has a number of switches which allow it to be configured for older dialects of C++. In particular, the version of C++ described in the ARM (Annotated Reference Manual) is fully supported.
The TDF specification (version 4.0) may be consulted for a description of the compiler intermediate language used. The paper TDF and Portability provides a useful (if slightly old) introduction to some of the ideas relating to static program analysis and interface checking which underlie the whole TenDRA compilation system.The warning sign:
Since this document was originally written, the old C producer, tdfc, has been replaced by a new C producer, tdfc2, which is just a modified version of the C++ producer, tcpplus. All C producer documentation continues to apply to the new C producer, but the new C producer also has many of the features described in this document as only applying to the C++ producer.
The most important public interfaces of the C++ producer are the ISO C++ standard and the TDF 4.0 specification; however there are other interfaces, mostly common to both the C and C++ producers, which are described in this section.
An important design criterion of the C++ producer was that it should
be strictly ISO conformant by default, but have a method whereby dialect
features and extra static program analysis can be enabled. This compiler
configuration is controlled by the
#pragma TenDRA
directives
described in the first section.
The requirement that the C and C++ producers should be able to translate
portable C or C++ programs into target independent TDF requires a
mechanism whereby the target dependent implementations of APIs can
be represented. This mechanism, the #pragma
token
syntax, is described in the following section. Note
that at present this mechanism only contains support for C APIs; it
is considered that the C++ language itself contains sufficient interface
mechanisms for C++ APIs to be described.
The C and C++ producers provide two mechanisms whereby type and declaration information derived from a translation unit can be stored to a file for post-processing by other tools. The first is the symbol table dump, which is a public interface designed for use by third party tools. The second is the C/C++ spec file, which is designed for ease of reading and writing by the producers themselves, and is used for intermodule analysis.
The mapping from C++ to TDF implemented by the C++ producer is largely straightforward. There are however target dependencies arising within the language itself which require special handling. These are represented by certain standard tokens which the producer requires to be defined on the target machine. These tokens are also used to describe the interface between the producer and the run-time system. Note that the C++ producer is primarily concerned with the C++ language, not with the standard C++ library. An example implementation of those library components which are required as an integral part of the language (memory allocation, exception handling, run-time type information etc.) is provided. Otherwise, libraries should be obtained from third parties. A number of hints on integrating such libraries with the C++ producer are given.
The C++ producer is a large program (over 200000 lines, including automatically generated code) written in C. A description of the coding conventions used, the API observed and the basic organisation of the source code are described in the first section.
One of the design methods used in the C++ producer is the extensive
use of automatic code generation tools. The type system is based
around the calculus
tool, which allows complex type systems
to be described in a simple format. The interface generated by calculus
allows for rigorous static type checking, generic type constructors
for lists, stacks etc., encapsulation of the operations on the types
within the system, and optional run-time checking for null pointers
and discriminated union tags. An overview is given of the type
system used as the basis of the C++ producer design. Also see
the
calculus
users' guide.
The other general purpose code generation tool used in the C++ producer
is the parser generator, sid
. A brief description of
the problems in writing a C++ parser is given.
Also see the sid
users'
guide.
The other code generation tools used were written specifically for the C++ producer. The error reporting routines within the producer are based on an error catalogue, from which code for constructing and printing errors is generated. The TDF output routines are based on primitives automatically generated from a standard database describing the TDF specification.
The program itself is well commented, so no lower level program documentation
has been provided. When performing development work the producer
should be compiled with the DEBUG
macro defined. This
enables the calculus
run-time checks, along with other
assertions, and makes available the debugging routines,
DEBUG_
type, which can be used to print an object
from the internal type system.
http://www.cygnus.com/misc/wp/dec96pub/
or
http://www.maths.warwick.ac.uk/c++/pub/wp/html/cd2/
.
http://heg-school.aw.com/cseng/authors/ellis/annocpp/annocpp.html
Part of the TenDRA Web.
Crown
Copyright © 1998.