Symbol records

The declaration for the symbol record is in the member ibmwxin in the samples data set SIBMZSAM. Each symbol record assigns a number that is called a symbol index. The index is used by later records to refer to the symbol described by this record.

For example, the index can be used as the name of a user variable or constant. The name of the identifier is indicated by a literal index. Each symbol record contains the file index and source line number for the file and line in which the symbol was declared.

If the identifier is part of a structure or union, the symbol record contains a symbol index for each of the following:

  • The first sibling, if any
  • The parent, if any
  • The first child, if any

Consider the following structure:

       dcl
         1 a
           , 3 b     fixed bin
           , 3 c     fixed bin
           , 3 d
             , 5 e   fixed bin
             , 5 f   fixed bin
       ;

The symbol indices assigned to the elements of the preceding structure would be as follows:

Table 1. Symbol indices assigned to the elements of a structure
 symbol  index     sibling      parent    child
 -----   -----     -------      ------    -----
   a       1          0           0         2
   b       2          3           1         0
   c       3          4           1         0
   d       4          0           1         5
   e       5          6           4         0
   f       6          0           4         0

Each symbol record also contains a series of bit(1) fields that indicate if various attributes apply to this variable.

Each symbol record also contains the following elements:

User-given structure level
This is a user-given structure level for the identifier. For the element c of the structure above, the value is 3. For non-structure members, the value is set to 1.
Logican structure level
The logical structure level for the identifier For the element c of the structure above, the value is 2. For non-structure members, the value is set to 1.
Dimensions

The number of dimensions declared for the variable not counting any inherited dimensions.

The number of dimensions for the variable including all inherited dimensions.

Offset
The offset into the outermost parent structure.
Elemental size
Elemental size is in bytes unless the variable is bit aligned, in which case it is in bits. In either case, this does not factor any in dimensions.
Size
Size in bytes with its dimensions factored in.
Alignment
Identified by the following:
  • 0 for bit-aligned
  • 7 for byte-aligned
  • 15 for halfword-aligned
  • 31 for fullword-aligned
  • 63 for quadword-aligned

A union within the record is dedicated to describing information that is dependent on the variable's storage class:

Static variables
If the variable is declared as external with a separate external name (dcl x ext('y')), the literal index of that name is specified.
Based variables
If the variable is declared as based on another mapped variable that is not an element of an array, the symbol index of that variable is specified.
Defined variables
If the variable is declared as defined on another mapped variable that is not an element of an array, the symbol index of that variable is specified here. If its position attribute is constant, it is also specified.

The variable's data type is specified by the ordinal shown in Table 2.

Table 2. Data type of a variable
define
  ordinal
    xin_Data_Kind
      (  xin_Data_Kind_Unset
        ,xin_Data_Kind_Character
        ,xin_Data_Kind_Bit
        ,xin_Data_Kind_Graphic
        ,xin_Data_Kind_Fixed
        ,xin_Data_Kind_Float
        ,xin_Data_Kind_Picture
        ,xin_Data_Kind_Pointer
        ,xin_Data_Kind_Offset
        ,xin_Data_Kind_Entry
        ,xin_Data_Kind_File
        ,xin_Data_Kind_Label
        ,xin_Data_Kind_Format
        ,xin_Data_Kind_Area
        ,xin_Data_Kind_Task
        ,xin_Data_Kind_Event
        ,xin_Data_Kind_Condition
        ,xin_Data_Kind_Structure
        ,xin_Data_Kind_Union
        ,xin_Data_Kind_Descriptor
        ,xin_Data_Kind_Ordinal
        ,xin_Data_Kind_Handle
        ,xin_Data_Kind_Type
        ,xin_Data_Kind_Builtin
        ,xin_Data_Kind_Generic
        ,xin_Data_Kind_Widechar
                                   )  prec(8) unsigned;

A union within the record is dedicated to describing information that is dependent on the variable's data type. Most of this information is self-explanatory (for example, the precision for an arithmetic type) except perhaps for the following variables:

Picture variables
The literal index of the picture specification is specified.
Entry variables
If the variable has the returns attribute, the symbol index of the returns description is specified.
Ordinal variables
The ordinal type index is specified.
Typed variables and handles
The symbol index of the underlying type is specified.
String and area variables
The type and value of the extent is specified in addition to the symbol index of the returns description. The type of the extent is encoded by the values:
declare
  (  xin_Extent_Constant     value(01)
    ,xin_Extent_Star         value(02)
    ,xin_Extent_Nonconstant  value(04)
    ,xin_Extent_Refer        value(08)
    ,xin_Extent_In_Error     value(16)
  )
  fixed bin;

If the element has any dimensions, the type and values for its lower and upper bounds are specified at the very end of the record. These fields are not present if the element has no dimensions.

Note that the attributes flags reflect the attributes after the compiler has applied all defaults. So, for example, every numeric variable (including numeric PICTURE variables) has either the REAL or COMPLEX attribute flag set.