Class TypeManager.StructType

    • Constructor Detail

      • StructType

        protected StructType​(@Nonnull
                             java.lang.String name,
                             @Nonnull
                             TypeManager.StructTypeKind kind,
                             @Nonnull
                             TypeManager manager)
        Create a reference to type
        Parameters:
        name - the Java class name like "java/lang/String"
        kind - the type kind
        manager - the manager which hold all StructTypes
    • Method Detail

      • useFieldName

        void useFieldName​(NamedStorageType fieldName)
        Mark that the field was used in any getter or setter.
        Parameters:
        fieldName - the name of the field
      • scanTypeHierarchy

        private void scanTypeHierarchy​(FunctionManager functions,
                                       TypeManager types,
                                       ClassFileLoader classFileLoader)
                                throws java.io.IOException
        Write this struct type and initialize internal structures
        Parameters:
        functions - the used functions for the vtables of the types
        types - for types of fields
        classFileLoader - for loading the class files
        Throws:
        java.io.IOException - if any I/O error occur on loading or writing
      • writeStructType

        private void writeStructType​(ModuleWriter writer)
                              throws java.io.IOException
        Write this struct type and initialize internal structures
        Parameters:
        writer - the targets for the types
        Throws:
        java.io.IOException - if any I/O error occur on loading or writing
      • listStructFields

        private void listStructFields​(java.lang.String className,
                                      FunctionManager functions,
                                      TypeManager types,
                                      ClassFileLoader classFileLoader,
                                      java.util.HashSet<java.lang.String> allNeededFields)
                               throws java.io.IOException
        List the non static fields of the class and its super classes.
        Parameters:
        className - the className to list. because the recursion this must not the name of this class
        functions - the used functions for the vtables of the types
        types - for types of fields
        classFileLoader - for loading the class files
        allNeededFields - for recursive call list this all used fields
        Throws:
        java.io.IOException - if any I/O error occur on loading or writing
      • addOrUpdateVTable

        private void addOrUpdateVTable​(FunctionManager functions,
                                       FunctionName funcName,
                                       boolean isDefault)
        Add the function to the vtable or replace if already exists
        Parameters:
        functions - the function manager
        funcName - the function to added
        isDefault - true, if the function is a default implementation of a interface
      • listInterfaces

        private void listInterfaces​(FunctionManager functions,
                                    TypeManager types,
                                    ClassFileLoader classFileLoader)
                             throws java.io.IOException
        List all interfaces of this StructType and and mark all instance methods of used interface methods.
      • Add all used interfaces to the instanceOf set.
      • Create the itable for every interface. A list of real functions that should be called if the interface method is called for this type.
      • mark all implementations of used interface method in this type as used. For example if "java/util/List.size()I" is used anywhere and this StructType implements "java/util/List" then the "size()I" method of this StrucType must also compiled.
Parameters:
functions - the used functions for the vtables of the types
types - for types of fields
classFileLoader - for loading the class files
Throws:
java.io.IOException - if any I/O error occur on loading or writing