Class StringManager

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Integer>, SequencedMap<String,Integer>

public class StringManager extends LinkedHashMap<String,Integer>
Handle all the constant strings. The constant strings will be write into the data section. At runtime the strings will be instantiate on the fly and hold in a table.
See Also:
  • Field Details

    • stringConstantFunction

      private FunctionName stringConstantFunction
    • functions

      private FunctionManager functions
    • stringMemoryOffset

      private int stringMemoryOffset
  • Constructor Details

    • StringManager

      StringManager(WasmOptions options)
      Create a new instance.
      Parameters:
      options - compiler properties and shared managers
  • Method Details

    • get

      public Integer get(@Nonnull Object str)
      Get the positive id for the string.
      Specified by:
      get in interface Map<String,Integer>
      Overrides:
      get in class LinkedHashMap<String,Integer>
      Parameters:
      str - the string
      Returns:
      the id
    • getStringConstantFunction

      @Nonnull FunctionName getStringConstantFunction()
      Get the function name object for the
      invalid reference
      #stringConstant(int)
      .
      Returns:
      the name
      See Also:
      • invalid reference
        #stringConstant(int)
    • prepareFinish

      void prepareFinish(ModuleWriter writer) throws IOException
      Finish the prepare. Now no new strings should be added.
      Parameters:
      writer - the targets for the strings
      Throws:
      IOException - if any I/O error occur
    • writeVaruint32

      private static void writeVaruint32(@Nonnegative int value, OutputStream out) throws IOException
      Write an unsigned integer.
      Parameters:
      value - the value
      out - target stream
      Throws:
      IOException - if an I/O error occurs.