Class StaticCodeBuilder


  • class StaticCodeBuilder
    extends java.lang.Object
    Write the static class initializer code.
    • Constructor Detail

      • StaticCodeBuilder

        StaticCodeBuilder​(WasmOptions options,
                          ClassFileLoader classFileLoader,
                          JavaMethodWasmCodeBuilder javaCodeBuilder)
        Create a instance with a snapshot of all static class initializer.
        Parameters:
        options - the compiler options
        classFileLoader - for loading the class files
        javaCodeBuilder - global code builder
    • Method Detail

      • createStartFunction

        @Nonnull
        FunctionName createStartFunction​(java.util.Iterator<FunctionName> writeLaterClinit)
                                  throws java.io.IOException
        Create a start function for the static class constructors
        Parameters:
        writeLaterClinit - iterator of all needed static constructors
        Returns:
        the synthetic function name
        Throws:
        java.io.IOException - if any I/O error occur
      • scan

        private StaticCodeBuilder.ScanState scan​(FunctionName name,
                                                 java.util.LinkedHashMap<java.lang.String,​FunctionName> constructors)
        Scan for for references to other classes
        Parameters:
        name - the name of the static constructor (class initializer)
        constructors - all static constructors which have references or was not scanned
        Returns:
        the reference state
      • patch

        private void patch​(StaticCodeBuilder.ScanState scan,
                           java.util.LinkedHashMap<java.lang.String,​StaticCodeBuilder.ScanState> scans)
        Patch static constructor (class initializer)
        Parameters:
        scan - the current scan
        scans - a list with all static constructors which was not called