Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javafe.reader
Class ASTClassFileParser

    java.lang.Object
      javafe.decsrc.ClassFileParser
          javafe.reader.ASTClassFileParser

All Implemented Interfaces:
  javafe.decsrc.ClassFileConstants

class ASTClassFileParser
extends javafe.decsrc.ClassFileParser

Parses the contents of a class file into an AST for the purpose of type checking. Ignores components of the class file that have no relevance to type checking (e.g. method bodies).

Field Summary
`private Identifier` | `classIdentifier` The identifier of the class being parsed.
`int` | `classLocation` A dummy location representing the class being parsed.
`(package private) TypeDeclElemVec` | `classMembers` The class members of the class being parsed.
`Name` | `classPackage` The package name of the class being parsed.
`private java.lang.Object[]` | `constants` The constant pool of the class being parsed.
`private static TypeNameVec` | `emptyTypeNameVec` An empty type name vector.
`private FieldDecl[]` | `fields` The fields of the class being parsed.
`protected boolean` | `includeBodies`
`(package private) GenericFile` | `inputFile` The input file being parsed.
`private TypeName[]` | `interfaces` The type names of the interfaces implemented by the class being parsed.
`private int` | `modifiers` The modifiers of the class being parsed.
`protected boolean` | `omitPrivateFields`
`private java.lang.Object[]` | `rawConstants` The constant pool of the class being parsed.
`private RoutineDecl[]` | `routines` The methods and constructors of the class being parsed.
`private TypeName` | `super_class` The type name of the superclass of the class being parsed.
`private boolean` | `syntheticClass` Flag indicating whether the class being parsed has the synthetic attribute.
`private java.util.Vector` | `synthetics` Vector of methods and fields with Synthetic attributes.
`private int` | `this_class_index` The contant pool index of this class.
`TypeDecl` | `typeDecl` The AST of the class parsed by this parser.

Fields inherited from class javafe.decsrc.ClassFileParser
``

Fields inherited from interface javafe.decsrc.ClassFileConstants
`ACC_ABSTRACT, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_SUPER, ACC_SYNCHRONIZED, ACC_TRANSIENT, ACC_VOLATILE, CONSTANT_Class, CONSTANT_Double, CONSTANT_Float, CONSTANT_Fref, CONSTANT_IMref, CONSTANT_Integer, CONSTANT_Long, CONSTANT_Mref, CONSTANT_NameType, CONSTANT_String, CONSTANT_Unused, CONSTANT_Utf8, MAGIC, MAJOR, MINOR`

Constructor Summary
`(package private)` | `ASTClassFileParser(GenericFile inputFile, boolean includeBodies)` Parse a class into a new class parser.

Method Summary
`protected void` | `addNonSyntheticDecls(TypeDeclElemVec v, TypeDeclElem[] elems)` Add only AST nodes that are not synthetic decls to v.
`private static Name` | `getNameQualifier(Name name)` Return the package qualifier of a given name.
`private static Identifier` | `getNameTerminal(Name name)` Return the terminal identifier of a given name.
`private FormalParaDecl[]` | `makeFormals(MethodSignature signature)` Construct a vector of formal parameters from a method signature.
`protected void` | `parse_file(java.io.DataInput stream)` Parse the file and set `typeDecl`.
`private TypeName[]` | `parseTypeNames(java.io.DataInputStream stream)` Parse a sequence of type names from a given stream.
`void` | `removeExtraArg()` Binary inner class constructors have an extra initial argument to their constructors (the enclosing class).
`protected void` | `set_class_attribute(java.lang.String aname, java.io.DataInput stream, int n)` Call back from ClassFileParser.
`protected void` | `set_const_ref(int i, int ctype, int class_index, java.lang.String field_name, java.lang.String type)` Call back from ClassFileParser.
`protected void` | `set_const(int i, int ctype, java.lang.Object value)` Call back from ClassFileParser.
`protected void` | `set_field_initializer(int i, java.lang.Object value)` Call back from ClassFileParser.
`protected void` | `set_field(int i, java.lang.String fname, java.lang.String type, int mod)` Call back from ClassFileParser.
`protected void` | `set_interface(int index, int cindex)` Call back from ClassFileParser.
`protected void` | `set_method_attribute(int i, java.lang.String aname, java.io.DataInput stream, int n)` Call back from ClassFileParser.
`protected void` | `set_method_body(int i, int max_stack, int max_local, byte[] code, int num_handlers)` Call back from ClassFileParser.
`protected void` | `set_method_handler(int i, int j, int start_pc, int end_pc, int handler_pc, int catch_index)` Call back from ClassFileParser.
`protected void` | `set_method(int i, java.lang.String mname, java.lang.String sig, int mod)` Call back from ClassFileParser.
`protected void` | `set_modifiers(int modifiers)` Call back from ClassFileParser.
`protected void` | `set_num_constants(int cnum)` Call back from ClassFileParser.
`protected void` | `set_num_fields(int n)` Call back from ClassFileParser.
`protected void` | `set_num_interfaces(int n)` Call back from ClassFileParser.
`protected void` | `set_num_methods(int n)` Call back from ClassFileParser.
`protected void` | `set_super_class(int cindex)` Call back from ClassFileParser.
`protected void` | `set_this_class(int cindex)` Call back from ClassFileParser.
`protected void` | `set_version(int major, int minor)` Call back from ClassFileParser.

Methods inherited from class javafe.decsrc.ClassFileParser
`get_class, set_field_attribute, set_method_body_attribute`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### classPackage

    public Name classPackage

  The package name of the class being parsed. Initialized by constructor (by way of set_this_class)

### typeDecl

    public TypeDecl typeDecl

  The AST of the class parsed by this parser. Initialized by constructor (by way of parse_file).

### classLocation

    public int classLocation

  A dummy location representing the class being parsed. Initialized by constructor.

### synthetics

    private java.util.Vector synthetics

  Vector of methods and fields with Synthetic attributes. Use this to weed out synthetic while constructing TypeDecl.

### syntheticClass

    private boolean syntheticClass

  Flag indicating whether the class being parsed has the synthetic attribute.

### includeBodies

    protected boolean includeBodies

### omitPrivateFields

    protected boolean omitPrivateFields

### inputFile

    GenericFile inputFile

  The input file being parsed.

### constants

    private java.lang.Object[] constants

  The constant pool of the class being parsed. Initialized by set_num_constants. Elements initialized by set_const and set_const_ref. Dynamic element types according to constant tag: UTF8 String String String Class TypeName Integer Integer Float Float Long Long Double Double FieldRef null MethodRef null InterfaceMethodRef null

### rawConstants

    private java.lang.Object[] rawConstants

  The constant pool of the class being parsed. This array contains the constants as they came out of the parser (versus translated by DescriptorParser). Initialized by set_const and set_num_constants.

### modifiers

    private int modifiers

  The modifiers of the class being parsed. Initialized by set_modifiers.

### this_class_index

    private int this_class_index

  The contant pool index of this class. Initialized by set_this_class.

### super_class

    private TypeName super_class

  The type name of the superclass of the class being parsed. Initialized by set_super_class.

### interfaces

    private TypeName[] interfaces

  The type names of the interfaces implemented by the class being parsed. Initialized by set_num_interfaces. Elements initialized by set_interface.

### classMembers

    TypeDeclElemVec classMembers

  The class members of the class being parsed. Intialized by set_field, set_method, and set_class_attributes.

### fields

    private FieldDecl[] fields

  The fields of the class being parsed. Initialized by set_num_fields. Elements initialized by set_field.

### routines

    private RoutineDecl[] routines

  The methods and constructors of the class being parsed. Initialized by set_num_methods. Elements initialized by set_method.

### classIdentifier

    private Identifier classIdentifier

  The identifier of the class being parsed. Initialized by set_this_class.

### emptyTypeNameVec

    private static final TypeNameVec emptyTypeNameVec

  An empty type name vector.

Constructor Detail

### ASTClassFileParser

    ASTClassFileParser(GenericFile inputFile,
                       boolean includeBodies)
                 throws java.io.IOException,
                        java.lang.ClassFormatError

  Parse a class into a new class parser. Resulting class file is stored in `typeDecl`; this will be a "spec only" declaration. Its package is stored in `classPackage` and a location for it is stored in `classLocation`.

Parameters:
  `inputFile` - the file to parse the class from
  `includeBodies` - if true, bodies are included, if not, only a spec is produced

Method Detail

### removeExtraArg

    public void removeExtraArg()

  Binary inner class constructors have an extra initial argument to their constructors (the enclosing class). This is not present in the source file. To make the AST generated by reading the binary correspond to that obtained from a source file, we remove that extra argument for each inner (non-static) class. Since we do this at the end of parse_file, each nested class does this for its own direct inner classes. - DRCok

### addNonSyntheticDecls

    protected void addNonSyntheticDecls(TypeDeclElemVec v,
                                        TypeDeclElem[] elems)

  Add only AST nodes that are not synthetic decls to v. nodes should be an array of TypeDeclElems. A synthetic decl is one that had the synthetic attribute, or is a static method decl for an interface.

### parse_file

    protected void parse_file(java.io.DataInput stream)
                       throws java.lang.ClassFormatError,
                              java.io.IOException

  Parse the file and set `typeDecl`.

  Throws:
    `java.lang.ClassFormatError`
    `java.io.IOException`

### set_version

    protected void set_version(int major,
                               int minor)
                        throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_num_constants

    protected void set_num_constants(int cnum)
                              throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_const

    protected void set_const(int i,
                             int ctype,
                             java.lang.Object value)
                      throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_const_ref

    protected void set_const_ref(int i,
                                 int ctype,
                                 int class_index,
                                 java.lang.String field_name,
                                 java.lang.String type)
                          throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_class_attribute

    protected void set_class_attribute(java.lang.String aname,
                                       java.io.DataInput stream,
                                       int n)
                                throws java.io.IOException,
                                       java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.io.IOException`
    `java.lang.ClassFormatError`

### set_modifiers

    protected void set_modifiers(int modifiers)
                          throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_this_class

    protected void set_this_class(int cindex)
                           throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_super_class

    protected void set_super_class(int cindex)
                            throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_num_interfaces

    protected void set_num_interfaces(int n)
                               throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_interface

    protected void set_interface(int index,
                                 int cindex)
                          throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_num_fields

    protected void set_num_fields(int n)
                           throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_field

    protected void set_field(int i,
                             java.lang.String fname,
                             java.lang.String type,
                             int mod)
                      throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_field_initializer

    protected void set_field_initializer(int i,
                                         java.lang.Object value)
                                  throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_num_methods

    protected void set_num_methods(int n)
                            throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_method

    protected void set_method(int i,
                              java.lang.String mname,
                              java.lang.String sig,
                              int mod)
                       throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_method_body

    protected void set_method_body(int i,
                                   int max_stack,
                                   int max_local,
                                   byte[] code,
                                   int num_handlers)
                            throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_method_handler

    protected void set_method_handler(int i,
                                      int j,
                                      int start_pc,
                                      int end_pc,
                                      int handler_pc,
                                      int catch_index)
                               throws java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.lang.ClassFormatError`

### set_method_attribute

    protected void set_method_attribute(int i,
                                        java.lang.String aname,
                                        java.io.DataInput stream,
                                        int n)
                                 throws java.io.IOException,
                                        java.lang.ClassFormatError

  Call back from ClassFileParser.

  Throws:
    `java.io.IOException`
    `java.lang.ClassFormatError`

### parseTypeNames

    private TypeName[] parseTypeNames(java.io.DataInputStream stream)
                               throws java.io.IOException,
                                      java.lang.ClassFormatError

  Parse a sequence of type names from a given stream.

  Parameters:
    `stream` - the stream to parse the type names from
  Returns:
    an array of type names
  Throws:
    `java.lang.ClassFormatError` - if the type names are not class constants
    `java.io.IOException`

### makeFormals

    private FormalParaDecl[] makeFormals(MethodSignature signature)

  Construct a vector of formal parameters from a method signature.

  Parameters:
    `signature` - the method signature to make the formal parameters from
  Returns:
    the formal parameters

### getNameQualifier

    private static Name getNameQualifier(Name name)

  Return the package qualifier of a given name.

  Parameters:
    `name` - the name to return the package qualifier of
  Returns:
    the package qualifier of name

### getNameTerminal

    private static Identifier getNameTerminal(Name name)

  Return the terminal identifier of a given name.

  Parameters:
    `name` - the name to return the terminal identifier of
  Returns:
    the terminal identifier of name

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

The ESC/Java2 Project Homepage