Java Reference
In-Depth Information
EnumTypeDescriptor
constants
SymbolList
Symbol
Red
Symbol
Symbol
Symbol
symbols
Yellow
Green
Blue
EnumAttributes
0
EnumAttributes
2
EnumAttributes
3
EnumAttributes
1
Figure 8.26: Representation of an Enumeration Type
8.7 Class and Method Declarations
Declarations of classes in Java, C
, or any other language generally require
processing that is much like the struct definitions in Section 8.6.6. Because
classes have a number of additional capabilities, the details will necessarily be
more complex. Aswith structs, classes encapsulate a collection of declarations.
Thus a symbol table will be created for each new class to provide a unique
name space for the declarations in the class. A class defines a type, just as
a struct does. However, a class declaration includes a name for that type, in
contrast to the struct definition, which may be used as the type for a variable
without there being any name for the struct type. Thus the
++
method for
a class declaration will not only construct a TypeDescriptor for the class, but
also create an entry in the current symbol table for the class name.
visit
Methods are an important part of class declarations, since they generally
define the external interface used to access an instance of the class. Methods
introduce one new concept that we have not used in our discussion of dec-
laration processing, a signature , defined by the types of the parameters and
the return type of the method. Information about the signature of a method
must be constructed as the method declaration is processed and stored in the
symbol table as part of the information associated with the method name.
 
 
Search WWH ::




Custom Search