Rev 2 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<!-- Crown Copyright (c) 1998 -->
<HTML>
<HEAD>
<TITLE>Diagnostic SORTs</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#400080" ALINK="#FF0000">
<H1><A NAME=S4>TDF Diagnostic Specification, Issue 3.0</A></H1>
<H3>January 1998</H3>
<A HREF="diag5.html"><IMG SRC="../images/next.gif" ALT="next section"></A>
<A HREF="diag1.html"><IMG SRC="../images/prev.gif" ALT="previous section"></A>
<A HREF="diag1.html"><IMG SRC="../images/top.gif" ALT="current document"></A>
<A HREF="../index.html"><IMG SRC="../images/home.gif" ALT="TenDRA home page">
</A>
<IMG SRC="../images/no_index.gif" ALT="document index"><P>
<HR>
<DL>
<DT><A HREF="#S5"><B>2.1</B> - DIAG_DESCRIPTOR</A><DD>
<DL>
<DT><A HREF="#S6"><B>2.1.1</B> - diag_desc_id</A><DD>
<DT><A HREF="#S7"><B>2.1.2</B> - diag_desc_struct</A><DD>
<DT><A HREF="#S8"><B>2.1.3</B> - diag_desc_typedef</A><DD>
</DL>
<DT><A HREF="#S9"><B>2.2</B> - DIAG_UNIT</A><DD>
<DL>
<DT><A HREF="#S10"><B>2.2.1</B> - build_diag_unit</A><DD>
</DL>
<DT><A HREF="#S11"><B>2.3</B> - DIAG_TAG</A><DD>
<DL>
<DT><A HREF="#S12"><B>2.3.1</B> - make_diag_tag</A><DD>
</DL>
<DT><A HREF="#S13"><B>2.4</B> - DIAG_TAGDEF</A><DD>
<DL>
<DT><A HREF="#S14"><B>2.4.1</B> - make_diag_tagdef</A><DD>
</DL>
<DT><A HREF="#S15"><B>2.5</B> - DIAG_TYPE_UNIT</A><DD>
<DL>
<DT><A HREF="#S16"><B>2.5.1</B> - build_diagtype_unit</A><DD>
</DL>
<DT><A HREF="#S17"><B>2.6</B> - DIAG_TYPE</A><DD>
<DL>
<DT><A HREF="#S18"><B>2.6.1</B> - diag_type_apply_token</A><DD>
<DT><A HREF="#S19"><B>2.6.2</B> - diag_array</A><DD>
<DT><A HREF="#S20"><B>2.6.3</B> - diag_bitfield</A><DD>
<DT><A HREF="#S21"><B>2.6.4</B> - diag_enum</A><DD>
<DT><A HREF="#S22"><B>2.6.5</B> - diag_floating_variety</A><DD>
<DT><A HREF="#S23"><B>2.6.6</B> - diag_loc</A><DD>
<DT><A HREF="#S24"><B>2.6.7</B> - diag_proc</A><DD>
<DT><A HREF="#S25"><B>2.6.8</B> - diag_ptr</A><DD>
<DT><A HREF="#S26"><B>2.6.9</B> - diag_struct</A><DD>
<DT><A HREF="#S27"><B>2.6.10</B> - diag_type_null</A><DD>
<DT><A HREF="#S28"><B>2.6.11</B> - diag_union</A><DD>
<DT><A HREF="#S29"><B>2.6.12</B> - diag_variety</A><DD>
<DT><A HREF="#S30"><B>2.6.13</B> - use_diag_tag</A><DD>
</DL>
<DT><A HREF="#S31"><B>2.7</B> - ENUM_VALUES</A><DD>
<DL>
<DT><A HREF="#S32"><B>2.7.1</B> - make_enum_values_list</A><DD>
</DL>
<DT><A HREF="#S33"><B>2.8</B> - DIAG_FIELD</A><DD>
<DL>
<DT><A HREF="#S34"><B>2.8.1</B> - make_diag_field</A><DD>
</DL>
<DT><A HREF="#S35"><B>2.9</B> - DIAG_TQ</A><DD>
<DL>
<DT><A HREF="#S36"><B>2.9.1</B> - add_diag_const</A><DD>
<DT><A HREF="#S37"><B>2.9.2</B> - add_diag_volatile</A><DD>
<DT><A HREF="#S38"><B>2.9.3</B> - diag_tq_null</A><DD>
</DL>
<DT><A HREF="#S39"><B>2.10</B> - FILENAME</A><DD>
<DL>
<DT><A HREF="#S40"><B>2.10.1</B> - filename_apply_token</A><DD>
<DT><A HREF="#S41"><B>2.10.2</B> - make_filename</A><DD>
</DL>
<DT><A HREF="#S42"><B>2.11</B> - SOURCEMARK</A><DD>
<DL>
<DT><A HREF="#S43"><B>2.11.1</B> - make_sourcemark</A><DD>
</DL>
</DL>
<HR>
<H1>2. Diagnostic SORTs</H1>
As a summary of this section<P>
<UL>
<LI><CODE>DIAG_TYPE</CODE>s describe programming language types (e.g.
arrays, structs...). <CODE>DIAG_TQ</CODE>s are qualifiers of <CODE>DIAG_TYPE
</CODE>s used for attributes like volatile and const.
<LI><CODE>FILENAME</CODE>s and<CODE> SOURCEMARK</CODE>s describe source
files and locations within them.
<LI><CODE>DIAG_TAG</CODE>s associate integers with <CODE>DIAG_TYPE</CODE>s.
They are used in a similar manner to normal TDF <CODE>TAG</CODE>s,
and are held in a (TDF) linkable unit called a <CODE>DIAG_TYPE_UNIT</CODE>.
<LI><CODE>DIAG_UNIT</CODE>s hold a collection of <CODE>DIAG_DESCRIPTOR</CODE>s,
used for information outside procedure bodies.
</UL>
<HR>
<H2><A NAME=S5>2.1. DIAG_DESCRIPTOR</A></H2>
<B>Number of encoding bits</B>: 2<BR>
<B>Is coding extendable</B>: yes<P>
<CODE>DIAG_DESCRIPTOR</CODE>s are used to associate names in the source
program with diagnostic items.<P>
<H3><A NAME=S6>2.1.1. diag_desc_id</A></H3>
<B>Encoding number</B>: 1<P>
<PRE>
<I>src_name</I>: TDFSTRING<I>(k, n)</I>
<I>whence</I>: SOURCEMARK
<I>found_at</I>: EXP POINTER(<I>al</I>)
<I>type</I>: DIAG_TYPE
-> DIAG_DESCRIPTOR
</PRE>
Generates a descriptor for an identifier (of <CODE>DIAG_TYPE</CODE>
<I>type</I>), whose source name was <I>src_name</I> from source location
<I>whence</I>. The <CODE>EXP </CODE><I>found_at</I> describes how
to access the value. Note that the <CODE>EXP</CODE> need not be unique
(e.g. FORTRAN EQUIVALENCE might be implemented this way).<P>
<H3><A NAME=S7>2.1.2. diag_desc_struct</A></H3>
<B>Encoding number</B>: 2<P>
<PRE>
<I>src_name</I>: TDFSTRING<I>(k, n)</I>
<I>whence</I>: SOURCEMARK
<I>new_type</I>: DIAG_TYPE
-> DIAG_DESCRIPTOR
</PRE>
Generates a descriptor whose source name was <I>src_name</I>. <I>new_type</I>
must be either a <CODE>DIAG_STRUCT</CODE>, <CODE>DIAG_UNION</CODE>
or <CODE>DIAG_ENUM</CODE>.<P>
This construct is obsolete.<P>
<H3><A NAME=S8>2.1.3. diag_desc_typedef</A></H3>
<B>Encoding number</B>: 3<P>
<PRE>
<I>src_name</I>: TDFSTRING<I>(k, n)</I>
<I>whence</I>: SOURCEMARK
<I>new_type</I>: DIAG_TYPE
-> DIAG_DESCRIPTOR
</PRE>
Generates a descriptor for a type <I>new_type</I> whose source name
was <I>src_name</I>. Note that <I>diag_desc_typedef</I> is used for
associating a name with a type, rather than for any name given in
the initial description of the type (e.g. in C this is used for typedef,
not for struct/union/enum tags).<P>
<HR>
<H2><A NAME=S9>2.2. DIAG_UNIT</A></H2>
<B>Number of encoding bits</B>: 0<BR>
<B>Is coding extendable</B>: no<BR>
<B>Unit identification</B>: <I>diagdef</I><P>
A <CODE>DIAG_UNIT</CODE> is a TDF unit containing <CODE>DIAG_DESCRIPTOR</CODE>s.
A <CODE>DIAG_UNIT</CODE> is used to contain descriptions of items
outside procedure bodies (e.g. global variables, global type definitions).<P>
<H3><A NAME=S10>2.2.1. build_diag_unit</A></H3>
<B>Encoding number</B>: 0<P>
<PRE>
<I>no_labels</I>: TDFINT
<I>descriptors</I>: SLIST(DIAG_DESCRIPTOR)
-> DIAG_UNIT
</PRE>
Create a <CODE>DIAG_UNIT</CODE> containing <CODE>DIAG_DESCRIPTOR</CODE>s.
<I>no_labels</I> is the number of local labels used in <I>descriptors</I>
(for conditionals).<P>
<HR>
<H2><A NAME=S11>2.3. DIAG_TAG</A></H2>
<B>Number of encoding bits</B>: 1<BR>
<B>Is coding extendable</B>: yes<BR>
<B>Linkable entity identification</B>: <I>diagtag</I><P>
<CODE>DIAG_TAG</CODE>s are used <I>inter alia</I> to break cyclic
diagnostic types. They are (TDF) linkable entities. A <CODE>DIAG_TAG</CODE>
is made from a number, and used in <I>use_diag_tag</I> to obtain the
<CODE>DIAG_TYPE</CODE> associated with that number by <I>make_diag_tagdef</I>.
<P>
<H3><A NAME=S12>2.3.1. make_diag_tag</A></H3>
<B>Encoding number</B>: 1<P>
<PRE>
<I>num</I>: TDFINT
-> DIAG_TAG
</PRE>
Create a <CODE>DIAG_TAG</CODE> from <I>num</I>.<P>
<HR>
<H2><A NAME=S13>2.4. DIAG_TAGDEF</A></H2>
<B>Number of encoding bits</B>: 1<BR>
<B>Is coding extendable</B>: yes<P>
<CODE>DIAG_TAGDEF</CODE>s associate <CODE>DIAG_TAG</CODE>s with <CODE>DIAG_TYPE
</CODE>s.<P>
<H3><A NAME=S14>2.4.1. make_diag_tagdef</A></H3>
<B>Encoding number</B>: 1<P>
<PRE>
<I>tno</I>: TDFINT
<I>dtype</I>: DIAG_TYPE
-> DIAG_TAGDEF
</PRE>
Associates tag number <I>tno</I> with <I>dtype</I>.<P>
<HR>
<H2><A NAME=S15>2.5. DIAG_TYPE_UNIT</A></H2>
<B>Number of encoding bits</B>: 0<BR>
<B>Is coding extendable</B>: no<BR>
<B>Unit identification</B>: <I>diagtype</I><P>
A <CODE>DIAG_TYPE_UNIT</CODE> is a TDF unit containing <CODE>DIAG_TAGDEF</CODE>s.
<P>
<H3><A NAME=S16>2.5.1. build_diagtype_unit</A></H3>
<B>Encoding number</B>: 0<P>
<PRE>
<I>no_labels</I>: TDFINT
<I>tagdefs</I>: SLIST(DIAG_TAGDEF)
-> DIAG_TYPEUNIT
</PRE>
Create a <CODE>DIAG_TYPEUNIT</CODE> containing <CODE>DIAG_TAGDEF</CODE>s.
<I>no_labels</I> is the number of local labels used in <I>tagdefs</I>
(for conditionals).<P>
<HR>
<H2><A NAME=S17>2.6. DIAG_TYPE</A></H2>
<B>Sortname</B>: <I>foreign_sort("diag_type")</I><BR>
<B>Number of encoding bits</B>: 4<BR>
<B>Is coding extendable</B>: yes<P>
<CODE>DIAG_TYPE</CODE>s are used to provide diagnostic information
about data types.<P>
<H3><A NAME=S18>2.6.1. diag_type_apply_token</A></H3>
<B>Encoding number</B>: 1<P>
<PRE>
<I>token_value</I>: TOKEN
<I>token_args</I>: BITSTREAM
-> DIAG_TYPE
</PRE>
The token is applied to the arguments to give a <CODE>DIAG_TYPE</CODE>.
If there is a definition for <I>token_value</I> in the <CODE>CAPSULE</CODE>
then <I>token_args</I> is a <CODE>BITSTREAM</CODE> encoding of the
<CODE>SORT</CODE>s of its parameters, in the order specified.<P>
<H3><A NAME=S19>2.6.2. diag_array</A></H3>
<B>Encoding number</B>: 2<P>
<PRE>
<I>element_type</I>: DIAG_TYPE
<I>stride</I>: EXP OFFSET(<I>p</I>,<I>p</I>)
<I>lower_bound</I>: EXP INTEGER(<I>v</I>)
<I>upper_bound</I>: EXP INTEGER(<I>v</I>)
<I>index_type</I>: DIAG_TYPE
-> DIAG_TYPE
</PRE>
An array of <I>element_type</I> objects. <I>stride</I> is the <CODE>OFFSET
</CODE>
between elements of the array (i.e. <I>p</I> is described by <I>element_type</I>).
The bounds are in general not runtime constants, hence the values
are <CODE>EXP</CODE>s (not say <CODE>SIGNED_NAT</CODE>). The <CODE>VARIETY
</CODE>
<I>v</I> is described by <I>index_type</I>. As in TDF there is no
multi-dimensional array primitive.<P>
<H3><A NAME=S20>2.6.3. diag_bitfield</A></H3>
<B>Encoding number</B>: 3<P>
<PRE>
<I>type</I>: DIAG_TYPE
<I>number_of_bits</I>: NAT
-> DIAG_TYPE
</PRE>
Describes <I>number_of_bits</I>, which when extracted will have <CODE>DIAG_TYPE
</CODE>
<I>type</I>.<P>
<H3><A NAME=S21>2.6.4. diag_enum</A></H3>
<B>Encoding number</B>: 4<P>
<PRE>
<I>base_type</I>: DIAG_TYPE
<I>enum_name</I>: TDFSTRING<I>(k, n)</I>
<I>values</I>: LIST(ENUM_VALUES)
-> DIAG_TYPE
</PRE>
An enumeration to be stored in an object of type <I>base_type</I>.
If <I>enum_name</I> is a string contining zero characters this signifies
no source tag.<P>
<H3><A NAME=S22>2.6.5. diag_floating_variety</A></H3>
<B>Encoding number</B>: 5<P>
<PRE>
<I>var</I>: FLOATING_VARIETY
-> DIAG_TYPE
</PRE>
Creates a <CODE>DIAG_TYPE</CODE> to describe an <CODE>FLOATING_VARIETY</CODE>
<I>var</I>.<P>
<H3><A NAME=S23>2.6.6. diag_loc</A></H3>
<B>Encoding number</B>: 6<P>
<PRE>
<I>object</I>: DIAG_TYPE
<I>qualifier</I>: DIAG_TQ
-> DIAG_TYPE
</PRE>
Records the existence of an item of <CODE>DIAG_TYPE</CODE> <I>object</I>,
qualified by <I>qualifier</I>. <I>diag_loc</I> is used for variables
(which may of course not actually occupy a memory location).<P>
<H3><A NAME=S24>2.6.7. diag_proc</A></H3>
<B>Encoding number</B>: 7<P>
<PRE>
<I>params</I>: LIST(DIAG_TYPE)
<I>optional_args</I>: BOOL
<I>result_type</I>: DIAG_TYPE
-> DIAG_TYPE
</PRE>
Describes a procedure taking <I>n</I> parameters. <I>optional_args</I>
is true if and only if the <I>make_proc</I> which this <I>diag_proc</I>
describes had <I>vartag</I> present.<P>
<H3><A NAME=S25>2.6.8. diag_ptr</A></H3>
<B>Encoding number</B>: 8<P>
<PRE>
<I>object</I>: DIAG_TYPE
<I>qualifier</I>: DIAG_TQ
-> DIAG_TYPE
</PRE>
Describes a pointer to an object of <CODE>DIAG_TYPE</CODE> <I>object</I>.
The <CODE>DIAG_TQ</CODE> qualifier <I>qualifier</I> qualifies the
pointer, not the object pointed to.<P>
<H3><A NAME=S26>2.6.9. diag_struct</A></H3>
<B>Encoding number</B>: 9<P>
<PRE>
<I>tdf_shape</I>: SHAPE
<I>src_name</I>: TDFSTRING<I>(k, n)</I>
<I>fields</I>: LIST(DIAG_FIELD)
-> DIAG_TYPE
</PRE>
Describes a structure. If <I>src_name</I> is a string contining zero
characters this signifies no source tag for the whole structure. <I>tdf_shape
</I>
allows the total size to be computed.<P>
<H3><A NAME=S27>2.6.10. diag_type_null</A></H3>
<B>Encoding number</B>: 10<P>
<PRE>
-> DIAG_TYPE
</PRE>
A null <CODE>DIAG_TYPE</CODE>.<P>
<H3><A NAME=S28>2.6.11. diag_union</A></H3>
<B>Encoding number</B>: 11<P>
<PRE>
<I>tdf_shape</I>: SHAPE
<I>src_name</I>: TDFSTRING<I>(k, n)</I>
<I>fields</I>: LIST(DIAG_FIELD)
-> DIAG_TYPE
</PRE>
Describes a union. If <I>src_name</I> is a string contining zero characters
this signifies no source tag for the whole union. <I>tdf_shape</I>
allows the total size to be computed.<P>
<H3><A NAME=S29>2.6.12. diag_variety</A></H3>
<B>Encoding number</B>: 12<P>
<PRE>
<I>var</I>: VARIETY
-> DIAG_TYPE
</PRE>
Creates a <CODE>DIAG_TYPE</CODE> to describe an integer <CODE>VARIETY</CODE>
<I>var</I>.<P>
<H3><A NAME=S30>2.6.13. use_diag_tag</A></H3>
<B>Encoding number</B>: 13<P>
<PRE>
<I>dtag</I>: DIAG_TAG
-> DIAG_TYPE
</PRE>
Obtains the <CODE>DIAG_TYPE</CODE> associated with <CODE>DIAG_TAG</CODE>
<I>dtag</I>.<P>
<HR>
<H2><A NAME=S31>2.7. ENUM_VALUES</A></H2>
<B>Number of encoding bits</B>: 0<BR>
<B>Is coding extendable</B>: no<P>
<H3><A NAME=S32>2.7.1. make_enum_values_list</A></H3>
<B>Encoding number</B>: 0<P>
<PRE>
<I>value</I>: EXP <I>sh</I>
<I>src_name</I>: TDFSTRING<I>(k, n)</I>
-> ENUM_VALUES
</PRE>
<CODE>ENUM_VALUES</CODE> describe elements of an enumerated type.
<I>src_name</I> is the source language name. <I>value</I> evaluates
to a value of <CODE>SHAPE</CODE> <I>sh</I>. Note that all members
of a <CODE>LIST(ENUM_VALUES</CODE>) must have the same <I>sh</I>.<P>
<HR>
<H2><A NAME=S33>2.8. DIAG_FIELD</A></H2>
<B>Number of encoding bits</B>: 0<BR>
<B>Is coding extendable</B>: no<P>
<H3><A NAME=S34>2.8.1. make_diag_field</A></H3>
<B>Encoding number</B>: 0<P>
<PRE>
<I>field_name</I>: TDFSTRING<I>(k, n)</I>
<I>found_at</I>: EXP OFFSET( ALIGNMENT <I>whole</I>, ALIGNMENT <I>this_field
</I>)
<I>field_type</I>: DIAG_TYPE
-> DIAG_FIELD
</PRE>
<CODE>DIAG_FIELD</CODE>s describe one field of a structure or union.
<I>field_name</I> is the source language name. <I>found_at</I> is
the <CODE>OFFSET</CODE> between <I>whole</I> (the enclosing structure
or union), and this field (<I>this_field</I>). <I>field_type</I> is
the <CODE>DIAG_TYPE</CODE> of the field.<P>
<HR>
<H2><A NAME=S35>2.9. DIAG_TQ</A></H2>
<B>Number of encoding bits</B>: 2<BR>
<B>Is coding extendable</B>: yes<P>
<CODE>DIAG_TQ</CODE>s are type qualifiers, used to qualify <CODE>DIAG_TYPE
</CODE>s. A <CODE>DIAG_TQ</CODE> is constructed from <I>diag_tq_null</I>
and the various <I>add_diag_XXX</I> operations.<P>
<H3><A NAME=S36>2.9.1. add_diag_const</A></H3>
<B>Encoding number</B>: 1<P>
<PRE>
<I>qual</I>: DIAG_TQ
-> DIAG_TQ
</PRE>
Marks a <CODE>DIAG_TQ</CODE> type qualifier as being <I>const</I>
in the ANSI C sense.<P>
<H3><A NAME=S37>2.9.2. add_diag_volatile</A></H3>
<B>Encoding number</B>: 2<P>
<PRE>
<I>qual</I>: DIAG_TQ
-> DIAG_TQ
</PRE>
Marks a <CODE>DIAG_TQ</CODE> type qualifier as being <I>volatile</I>
in the ANSI C sense.<P>
<H3><A NAME=S38>2.9.3. diag_tq_null</A></H3>
<B>Encoding number</B>: 3<P>
<PRE>
-> DIAG_TQ
</PRE>
Create a null <CODE>DIAG_TQ</CODE> type qualifier.<P>
<HR>
<H2><A NAME=S39>2.10. FILENAME</A></H2>
<B>Sortname</B>: <I>foreign_sort("~diag_file")</I><BR>
<B>Number of encoding bits</B>: 2<BR>
<B>Is coding extendable</B>: yes<P>
<CODE>FILENAME </CODE>record details of source files used in producing
a <CODE>CAPSULE</CODE>. They can be tokenised for abbreviation.<P>
<H3><A NAME=S40>2.10.1. filename_apply_token</A></H3>
<B>Encoding number</B>: 1<P>
<PRE>
<I>token_value</I>: TOKEN
<I>token_args</I>: BITSTREAM
-> FILENAME
</PRE>
The token is applied to the arguments to give a <CODE>FILENAME</CODE>.
If there is a definition for <I>token_value</I> in the <CODE>CAPSULE</CODE>
then <I>token_args</I> is a <CODE>BITSTREAM</CODE> encoding of the
<CODE>SORT</CODE>s of its parameters, in the order specified.<P>
<H3><A NAME=S41>2.10.2. make_filename</A></H3>
<B>Encoding number</B>: 2<P>
<PRE>
<I>date</I>: NAT
<I>machine</I>: TDFSTRING<I>(k1, n1)</I>
<I>file</I>: TDFSTRING<I>(k2, n2)</I>
-> FILENAME
</PRE>
Create a <CODE>FILENAME</CODE> for file <I>file</I>, dated <I>date</I>
(a UNIX timestamp; seconds since 1 Jan 1970) on machine <I>machine</I>.<P>
<HR>
<H2><A NAME=S42>2.11. SOURCEMARK</A></H2>
<B>Number of encoding bits</B>: 1<BR>
<B>Is coding extendable</B>: yes<P>
A <CODE>SOURCEMARK</CODE> records a location in the source program.
Present <CODE>SOURCEMARK</CODE>s assume that a location can be described
by one or two numbers within a <CODE>FILENAME</CODE>.<P>
<H3><A NAME=S43>2.11.1. make_sourcemark</A></H3>
<B>Encoding number</B>: 1<P>
<PRE>
<I>file</I>: FILENAME
<I>line_no</I>: NAT
<I>char_offset</I>: NAT
-> SOURCEMARK
</PRE>
Create a <CODE>SOURCEMARK</CODE> referencing the <I>char_offset</I>'th
character on line <I>line_no</I> in file <I>file</I>.<P>
<I>char_offset</I> is counted from 1, 0 meaning that no character
offset is available.<P>
<HR>
<P><I>Part of the <A HREF="../index.html">TenDRA Web</A>.<BR>Crown
Copyright © 1998.</I></P>
</BODY>
</HTML>