Class WasmOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    class WasmOutputStream
    extends LittleEndianOutputStream
    • Constructor Detail

      • WasmOutputStream

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

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

      • writeOpCode

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

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

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

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

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

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

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

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

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

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

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