class JvmBytecode::Instructions::Instruction

Attributes

mnemonic[R]
opcode[R]
size[R]
args[RW]
cp[R]

Public Class Methods

all() click to toggle source
# File lib/jvm_bytecode/instructions/instruction.rb, line 18
def all
  @@instructions.values
end
fetch(opcode) click to toggle source
# File lib/jvm_bytecode/instructions/instruction.rb, line 22
def fetch(opcode)
  @@instructions[opcode] || raise(Errors::OpcodeError, "#{sprintf('0x%02X', opcode)} is not implemented")
end
format(opcode:, size: 1, mnemonic: nil) click to toggle source
# File lib/jvm_bytecode/instructions/instruction.rb, line 9
def format(opcode:, size: 1, mnemonic: nil)
  @@instructions ||= {}
  @@instructions[opcode] = self

  @opcode = opcode
  @size = size
  @mnemonic = mnemonic || shortname.downcase
end
new(cp) click to toggle source
# File lib/jvm_bytecode/instructions/instruction.rb, line 30
def initialize(cp)
  @cp = cp
  @args = nil
end

Public Instance Methods

additional_bytecode() click to toggle source
# File lib/jvm_bytecode/instructions/instruction.rb, line 39
def additional_bytecode
  ''
end
bytecode() click to toggle source
# File lib/jvm_bytecode/instructions/instruction.rb, line 35
def bytecode
  [self.class.opcode].pack('C') + additional_bytecode
end
decode(io) click to toggle source
# File lib/jvm_bytecode/instructions/instruction.rb, line 43
def decode(io)

end
to_hash() click to toggle source
# File lib/jvm_bytecode/instructions/instruction.rb, line 47
def to_hash
  {
    mnemonic: self.class.mnemonic,
    opcode: self.class.opcode
  }
end