next up previous
Next: Format Execution Up: Internal Design Previous: Internal Design

Format Compilation

The process of compilation of the format string involves two steps.

First, all the loops in the format are exploded into a linked list. Each node of the linked list represents an element and is a structure of the following type:

                 typedef struct StructSymbType {
                   char Name[NAMELEN];
                   char Fmt[FMTLEN];
                   unsigned int abc[3];
                   unsigned int Type;
                   float (*func)(char *,float **,int);
                   float *fargv[NARGV];
                   int fargc;
                   float *ptr;
                   struct StructSymbType *next;
                 } SymbType;

Apart from the name of the element and the C styled format in which it would be written out as an ASCII string, this structure also has information on how to get the numeric value associated with the element. This information is in the field Type. All elements need to be one of the following types:

Type Meaning
CHARType Represents a character to output
FTYPE Function type: the value will be
returned by a call to the function func
PTYPE Pointer type: the value will be in the buffer
at the location pointed to by ptr

The abc field carries the current values of the three operators (ant,base, and chan).

All valid elements are tabulated in a table, which is a list of structure of the following type:

                 typedef struct TT {
                   char *Name;
                   unsigned int Class,Type;
                 } TypeTable;

Before putting each element of the body on the list, check is made to ensure that all the required operators (as listed in the table above) are active. To generate this information about the required operators, elements are further categorized into one of the following classes:

Class Operators Needed
IV None
AV ant
BV base
CV chan
BCV base,chan
ABCV ant,base,chan

Once the element is validated for the required active operators, a new link is created on the list of elements and the structure on the list is filled with the Name, Type. This is done for every value of the active operators and the current values of these operators are put in the abc array (passive operators have a value of -1).

Having exploded the loops, the second step in the process of compilation is to fill in the information about how to get the numeric values of the elements on the list. By this time, if no error has occurred, it is assured that the syntax of the format was correct and all the elements in the format were recognized.

For filling in the above mentioned information, one uses the Type of the element and, if required, the values in the array abc.

For PTYPE elements, the ptr field is made to point to the location in the memory where the required value is to be found. These type of elements generally refer to particular values in the buffer in the memory and need the offsets in the buffer which can be calculated using the abc array.

For FTYPE elements, the func field is filled with a pointer to a function which will be called when the value of the element is required. If the calculation of the value requires some data, the pointers to such data should be put in the fargv field and the total number of such pointer be filled in the field fargc. These will be passed as arguments to function when the value of the element is required. The first argument passed to the function will be the name of the element. Examples of this kind of element is HA or real/imaginary value of the visibility.

For CHARType elements, nothing needs to be done. The name of such elements is the character that is to be copied on the output during execution.


next up previous
Next: Format Execution Up: Internal Design Previous: Internal Design

Sanjay Bhatnagar
Thu Jan 23 23:40:05 MST 1997