1 /********************************************************************
3 identifier.h - structures used to hold identifier descriptions
5 Niksa Orlic, 2004-04-28
7 ********************************************************************/
9 /*
10 When an unit compiles, it exports public symbols into
12 unit_name.bsf (binary symbol file)
14 The bsf file contains an array of symbol entries.
16 Symbols are divided into the following categories:
18 Constant
19 ---------
20 1 byte identifier: set to 1 to indicate that it is an constant
21 STRING - symbol name
22 1 byte to indicate the constant type, (1-integer, 2-real, 3-boolean, 4-char, 5-string)
23 value: if a constant is integer or float, this is 4-byte field
24 if a constant is string, then a STRING entry follows
25 if a constant is a boolean or a char, 1 byte follows
27 Variable
28 --------
29 1 byte indentifier: set to 2 for variable
30 STRING - symbol name
31 TYPE - variable type
33 Type
34 ----
35 1 byte identifier: set to 3 for type definition
36 STRING - symbol name
37 TYPE - the type description
39 Procedure
40 ---------
41 1 byte identifier: set to 4 for procedures
42 STRING - name
43 1 byte - the number of parameters (n)
44 TYPE[n] - parameters type
46 Function
47 --------
48 1 byte identifier: set to 5 for functions
49 STRING - name
50 TYPE - return type
51 1 byte - number of parameters
52 TYPE[n] - parameter types
55 Special fields used are:
57 STRING
58 ------
59 1 byte containing the string length (n)
60 n bytes with the string data (NOT zero terminated)
62 TYPE
63 ----
64 1 byte : type class, a value from en_type_class enumeration
66 if a type is an array: TYPE element_type
67 1 byte dimensions num
68 TYPE[n] dimension interval types
70 if a type is a record: 1 byte number of elements
71 {STRING, TYPE} [n] for each element there is a pair name/type describing the member
72 4 bytes record ID
74 if a type is an interval: 1 byte interval base type (from the en_type_class)
75 4 bytes: starting value
76 4 bytes: ending value
78 */
80 #include <stdio.h>
82 /*
83 The possible identifier classes
84 */
85 enum en_identifier_class
86 {
87 none,
88 program_name,
89 constant_name,
90 variable_name,
91 type_name,
92 procedure_name,
93 function_name,
94 parameter_name,
95 unit_name
96 };
99 /*
100 The structure used to hold the description of
101 a single identifier
102 */
103 struct identifier_descriptor_struct
104 {
107 /* for constants */
113 /* for variables */
117 /* for types */
120 /* for procedures and functions */
122 type_list *parameters; /* the list of formal parameters to the function, each one is identifier_descriptor */
127 int unit_function; /* used by all items that are defined inside an unit , 1 says that the item is inside a unit */
130 /* for parameters */
135 /* for units */
138 /* this field is set in get_identifier function and is true
139 if this struct describes identifier directly located inside
140 the program block*/
142 };