Class: JvmBytecode::Instructions::Instruction
- Inherits:
-
Object
- Object
- JvmBytecode::Instructions::Instruction
show all
- Defined in:
- lib/jvm_bytecode/instructions/instruction.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Instruction.
30
31
32
33
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 30
def initialize(cp)
@cp = cp
@args = nil
end
|
Class Attribute Details
.mnemonic ⇒ Object
Returns the value of attribute mnemonic.
7
8
9
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 7
def mnemonic
@mnemonic
end
|
.opcode ⇒ Object
Returns the value of attribute opcode.
7
8
9
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 7
def opcode
@opcode
end
|
.size ⇒ Object
Returns the value of attribute size.
7
8
9
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 7
def size
@size
end
|
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
28
29
30
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 28
def args
@args
end
|
#cp ⇒ Object
Returns the value of attribute cp.
27
28
29
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 27
def cp
@cp
end
|
Class Method Details
.all ⇒ Object
18
19
20
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 18
def all
@@instructions.values
end
|
.fetch(opcode) ⇒ Object
22
23
24
|
# 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
|
9
10
11
12
13
14
15
16
|
# 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
|
Instance Method Details
#additional_bytecode ⇒ Object
39
40
41
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 39
def additional_bytecode
''
end
|
#bytecode ⇒ Object
35
36
37
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 35
def bytecode
[self.class.opcode].pack('C') + additional_bytecode
end
|
#decode(io) ⇒ Object
43
44
45
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 43
def decode(io)
end
|
#to_hash ⇒ Object
47
48
49
50
51
52
|
# File 'lib/jvm_bytecode/instructions/instruction.rb', line 47
def to_hash
{
mnemonic: self.class.mnemonic,
opcode: self.class.opcode
}
end
|