Class: JvmBytecode::Field
- Inherits:
-
Object
- Object
- JvmBytecode::Field
show all
- Includes:
- AccessFlag
- Defined in:
- lib/jvm_bytecode/field.rb
Constant Summary
collapse
- ACCESS_FLAGS =
{
public: 0x0001,
private: 0x0002,
protected: 0x0004,
static: 0x0008,
final: 0x0010,
volatile: 0x0040,
transient: 0x0080,
synthetic: 0x1000,
enum: 0x4000
}.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from AccessFlag
#access_flag, #all_access_flag, #readable_access_flag, #set_access_flag
Constructor Details
#initialize(cp) ⇒ Field
Returns a new instance of Field.
24
25
26
27
28
29
|
# File 'lib/jvm_bytecode/field.rb', line 24
def initialize(cp)
@cp = cp
@name = 0
@descriptor = 0
@attributes = []
end
|
Class Method Details
.decode_serial(cp, io) ⇒ Object
18
19
20
21
22
|
# File 'lib/jvm_bytecode/field.rb', line 18
def self.decode_serial(cp, io)
Array.new(io.read(2).unpack('S>').first) do
new(cp).tap { |f| f.decode(io) }
end
end
|
Instance Method Details
#bytecode ⇒ Object
39
40
41
42
|
# File 'lib/jvm_bytecode/field.rb', line 39
def bytecode
[access_flag, @name, @descriptor].pack('S>3') +
@attributes.join_bytecodes
end
|
#decode(io) ⇒ Object
44
45
46
47
48
49
|
# File 'lib/jvm_bytecode/field.rb', line 44
def decode(io)
acc_flag, @name, @descriptor = io.read(6).unpack('S>3')
set_access_flag(acc_flag)
@attributes = Attributes::Attribute.decode_serial(@cp, io)
end
|
#descriptor(d) ⇒ Object
35
36
37
|
# File 'lib/jvm_bytecode/field.rb', line 35
def descriptor(d)
@descriptor = @cp.index_or_utf8(d)
end
|
#name(n) ⇒ Object
31
32
33
|
# File 'lib/jvm_bytecode/field.rb', line 31
def name(n)
@name = @cp.index_or_utf8(n)
end
|
#to_hash ⇒ Object
51
52
53
|
# File 'lib/jvm_bytecode/field.rb', line 51
def to_hash
{}
end
|