Class WasmOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

class WasmOutputStream extends LittleEndianOutputStream
  • Field Details

  • Constructor Details

    • WasmOutputStream

      WasmOutputStream(WasmOptions options)
      Create a in memory stream.
      Parameters:
      options - compiler properties
    • WasmOutputStream

      WasmOutputStream(WasmOptions options, OutputStream output)
      Create a wrapped stream.
      Parameters:
      options - compiler properties
      output - the target of data
  • Method Details

    • writeOpCode

      public void writeOpCode(int op) throws IOException
      Write a binary operation code.
      Parameters:
      op - a constant from InstructionOpcodes
      Throws:
      IOException - if an I/O error occurs.
    • writeValueType

      public void writeValueType(AnyType type) throws IOException
      Write a value type.
      Parameters:
      type - a type constant
      Throws:
      IOException - if an I/O error occurs.
    • writeRefValueType

      public void writeRefValueType(AnyType type) throws IOException
      Write the value type. If it is a struct type then as reference type.
      Parameters:
      type - a type constant
      Throws:
      IOException - if an I/O error occurs.
    • writeDefaultValue

      public void writeDefaultValue(AnyType type) throws IOException
      Write the default/initial value for a type.
      Parameters:
      type - the type
      Throws:
      IOException - if an I/O error occurs.
    • writeVaruint32

      void writeVaruint32(@Nonnegative int value) throws IOException
      Write an unsigned integer.
      Parameters:
      value - the value
      Throws:
      IOException - if an I/O error occurs.
    • writeVarint

      void writeVarint(long value) throws IOException
      Write an integer value.
      Parameters:
      value - the value
      Throws:
      IOException - if an I/O error occurs.
    • writeFloat

      void writeFloat(float value) throws IOException
      Write an float value.
      Parameters:
      value - the value
      Throws:
      IOException - if an I/O error occurs.
    • writeDouble

      void writeDouble(double value) throws IOException
      Write an double value.
      Parameters:
      value - the value
      Throws:
      IOException - if an I/O error occurs.
    • writeConst

      void writeConst(Number value, ValueType valueType) throws IOException
      Write a constant number value
      Parameters:
      value - the value
      valueType - the data type of the number
      Throws:
      IOException - if any I/O error occur
    • writeString

      void writeString(@Nonnull String str) throws IOException
      Write a string as UTF8 encoded.
      Parameters:
      str - the string
      Throws:
      IOException - if any I/O error occur
    • writeSection

      void writeSection(SectionType type, WasmOutputStream data) throws IOException
      Write a section with header and data.
      Parameters:
      type - the name of the section
      data - the data of the section
      Throws:
      IOException - if any I/O error occur