Java Reference
In-Depth Information
variableAttributes
variableType : a type reference
typeAttributes
thisType : a type reference
Figure 8.9: Attribute Descriptor Structures
To represent a variable declaration, we will need to store the type of
the variable. Figure 8.9 illustrates the necessary Attributes structure. The
variableType field will get a reference to a type descriptor as its value, but the
reference may not be available yet. A second version is shown in Figure 8.9
that represents an identifier used as the name of a type rather than as a variable.
Adi
erent
use, although the information stored about it, a type reference, is the same as
that for a variable name.
Arbitrarily complex structures, determined by the complexity of the in-
formation to be stored, may be used for attributes. Even the simple examples
used here include references to other structures that represent type informa-
tion. As we outline the declaration processing for other language features, we
will define similar attribute structures for each.
ff
erent tag value, typeAttributes , must be supplied to indicate this di
ff
8.5.2 Type Descriptor Structures
Among the attributes of almost any identifier is a type, which is represented
by a type reference, as indicated in the previous examples. We will interpret a
type reference as a reference to a struct of type TypeDescriptor.Representing
types presents a compiler writer with much the same problem as representing
attributes: there are many di
erent
information, so our solution will be similar, with typeKind as the name of the
tag member of a TypeDescriptorstruct.
Figure 8.10 shows several variants of TypeDescriptor; the first assumes
that integer is a built-in type in the language being compiled. The first exam-
ple type descriptor is unusual in that it includes no information other than
the fact that it represents the built-in integer type. The other examples show
that we may include any information required to describe the type, including
ff
erent types whose descriptions require di
ff
 
 
Search WWH ::




Custom Search