Class WasmConstInstruction


  • class WasmConstInstruction
    extends WasmInstruction
    WasmInstruction for constant values.
    • Field Detail

      • value

        private final java.lang.Number value
      • valueType

        private final ValueType valueType
    • Constructor Detail

      • WasmConstInstruction

        WasmConstInstruction​(java.lang.Number value,
                             ValueType valueType,
                             int javaCodePos,
                             int lineNumber)
        Create an instance of a constant instruction
        Parameters:
        value - the constant value
        valueType - the data type of the number
        javaCodePos - the code position/offset in the Java method
        lineNumber - the line number in the Java source code
      • WasmConstInstruction

        WasmConstInstruction​(java.lang.Number value,
                             int javaCodePos,
                             int lineNumber)
        Create an instance of a constant instruction
        Parameters:
        value - the constant value
        javaCodePos - the code position/offset in the Java method
        lineNumber - the line number in the Java source code
    • Method Detail

      • getValueType

        @Nonnull
        private static ValueType getValueType​(java.lang.Number value)
        Find the matching ValueType for the given value.
        Parameters:
        value - the constant value
        Returns:
        the ValueType
      • writeTo

        public void writeTo​(@Nonnull
                            ModuleWriter writer)
                     throws java.io.IOException
        Write this instruction to the WASM module.
        Specified by:
        writeTo in class WasmInstruction
        Parameters:
        writer - the target writer
        Throws:
        java.io.IOException - if any I/O error occur
      • getPushValueType

        AnyType getPushValueType()
        Get the ValueType if this instruction push a value on the stack.
        Specified by:
        getPushValueType in class WasmInstruction
        Returns:
        the ValueType or null if no value is push
      • getPopCount

        int getPopCount()
        Get the count of values that are removed from the stack.
        Specified by:
        getPopCount in class WasmInstruction
        Returns:
        the count