Module de.carne.mcd

Class InstructionOpcode

  • All Implemented Interfaces:
    java.lang.Comparable<InstructionOpcode>

    public class InstructionOpcode
    extends java.lang.Object
    implements java.lang.Comparable<InstructionOpcode>
    Immutable byte sequence representing an opcode.
    • Method Detail

      • wrap

        public static InstructionOpcode wrap​(byte[] bytes,
                                             int offset,
                                             int length)
        Wraps a byte array into a InstructionOpcode instance (without copying it).
        Parameters:
        bytes - the byte array backing up the created InstructionOpcode instance.
        offset - the offset of the first byte to wrap in the byte array.
        length - the number of bytes to wrap in the byte array.
        Returns:
        the InstructionOpcode instance representing the wrapped bytes.
      • length

        public int length()
        Gets the number of bytes represented by this InstructionOpcode instance.
        Returns:
        the number of bytes represented by this InstructionOpcode instance.
      • byteAt

        public byte byteAt​(int n)
        Gets the nth opcode byte.
        Parameters:
        n - the offset of the byte to get.
        Returns:
        the nth opcode byte.
      • bytes

        public byte[] bytes()
        Gets the byte array represented by this opcode.
        Returns:
        the byte array represented by this opcode.
      • compareTo

        public static int compareTo​(byte[] bytes1,
                                    int offset1,
                                    int length1,
                                    byte[] bytes2,
                                    int offset2,
                                    int length2)
        Parameters:
        bytes1 - left hands opcode's bytes.
        offset1 - left hands opcode's offset.
        length1 - left hands opcode's length.
        bytes2 - right hands opcode's bytes.
        offset2 - right hands opcode's offset.
        length2 - right hands opcode's length.
        Returns:
        See compareTo(InstructionOpcode)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(@Nullable java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public static java.lang.String toString​(byte[] bytes)
        Returns the string representation of the given byte array.
        Parameters:
        bytes - the bytes to format.
        Returns:
        the string representation of the given byte array.
      • toString

        public static java.lang.String toString​(byte[] bytes,
                                                int offset,
                                                int length)
        Returns the string representation of the given byte range.
        Parameters:
        bytes - the bytes to format.
        offset - the offset of the first byte to format.
        length - the number of bytes to format.
        Returns:
        the string representation of the given byte range.
      • parse

        public static byte[] parse​(java.lang.String s)
        Parses a byte array's string representation as returned by toString() and it's derivates.
        Parameters:
        s - the string to parse.
        Returns:
        the parsed byte array.
        Throws:
        java.lang.NumberFormatException - if the string cannot be parsed.